r600: don't enable depth test if there is no depth buffer
[mesa.git] / progs / gallium / python / tests / texture_transfer.py
1 #!/usr/bin/env python
2 ##########################################################################
3 #
4 # Copyright 2009 VMware, Inc.
5 # Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
6 # All Rights Reserved.
7 #
8 # Permission is hereby granted, free of charge, to any person obtaining a
9 # copy of this software and associated documentation files (the
10 # "Software"), to deal in the Software without restriction, including
11 # without limitation the rights to use, copy, modify, merge, publish,
12 # distribute, sub license, and/or sell copies of the Software, and to
13 # permit persons to whom the Software is furnished to do so, subject to
14 # the following conditions:
15 #
16 # The above copyright notice and this permission notice (including the
17 # next paragraph) shall be included in all copies or substantial portions
18 # of the Software.
19 #
20 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
23 # IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
24 # ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 #
28 ##########################################################################
29
30
31 import os
32
33 from gallium import *
34 from base import *
35
36
37 def lods(*dims):
38 size = max(dims)
39 lods = 0
40 while size:
41 lods += 1
42 size >>= 1
43 return lods
44
45
46 class TextureTest(TestCase):
47
48 tags = (
49 'target',
50 'format',
51 'width',
52 'height',
53 'depth',
54 'last_level',
55 'face',
56 'level',
57 'zslice',
58 )
59
60 def test(self):
61 dev = self.dev
62
63 target = self.target
64 format = self.format
65 width = self.width
66 height = self.height
67 depth = self.depth
68 last_level = self.last_level
69 face = self.face
70 level = self.level
71 zslice = self.zslice
72
73 tex_usage = 0
74
75 texture = dev.texture_create(
76 target = target,
77 format = format,
78 width = width,
79 height = height,
80 depth = depth,
81 last_level = last_level,
82 tex_usage = tex_usage,
83 )
84 if texture is None:
85 raise TestSkip
86
87 surface = texture.get_surface(face, level, zslice)
88
89 # ???
90 stride = pf_get_stride(texture->format, w)
91 size = pf_get_nblocksy(texture->format) * stride
92
93 in_raw = os.urandom(size)
94
95 surface.put_tile_raw(0, 0, surface.width, surface.height, in_raw, stride)
96
97 out_raw = surface.get_tile_raw(0, 0, surface.width, surface.height)
98
99 if in_raw != out_raw:
100 raise TestFailure
101
102
103 def main():
104 dev = Device()
105 suite = TestSuite()
106
107 targets = [
108 PIPE_TEXTURE_2D,
109 PIPE_TEXTURE_CUBE,
110 PIPE_TEXTURE_3D,
111 ]
112
113 formats = [
114 PIPE_FORMAT_B8G8R8A8_UNORM,
115 PIPE_FORMAT_B8G8R8X8_UNORM,
116 PIPE_FORMAT_B8G8R8A8_SRGB,
117 PIPE_FORMAT_B5G6R5_UNORM,
118 PIPE_FORMAT_B5G5R5A1_UNORM,
119 PIPE_FORMAT_B4G4R4A4_UNORM,
120 PIPE_FORMAT_Z32_UNORM,
121 PIPE_FORMAT_S8Z24_UNORM,
122 PIPE_FORMAT_X8Z24_UNORM,
123 PIPE_FORMAT_Z16_UNORM,
124 PIPE_FORMAT_S8_UNORM,
125 PIPE_FORMAT_A8_UNORM,
126 PIPE_FORMAT_L8_UNORM,
127 PIPE_FORMAT_DXT1_RGB,
128 PIPE_FORMAT_DXT1_RGBA,
129 PIPE_FORMAT_DXT3_RGBA,
130 PIPE_FORMAT_DXT5_RGBA,
131 ]
132
133 sizes = [64, 32, 16, 8, 4, 2, 1]
134 #sizes = [1020, 508, 252, 62, 30, 14, 6, 3]
135 #sizes = [64]
136 #sizes = [63]
137
138 faces = [
139 PIPE_TEX_FACE_POS_X,
140 PIPE_TEX_FACE_NEG_X,
141 PIPE_TEX_FACE_POS_Y,
142 PIPE_TEX_FACE_NEG_Y,
143 PIPE_TEX_FACE_POS_Z,
144 PIPE_TEX_FACE_NEG_Z,
145 ]
146
147 for target in targets:
148 for format in formats:
149 for size in sizes:
150 if target == PIPE_TEXTURE_3D:
151 depth = size
152 else:
153 depth = 1
154 for face in faces:
155 if target != PIPE_TEXTURE_CUBE and face:
156 continue
157 levels = lods(size)
158 for last_level in range(levels):
159 for level in range(0, last_level + 1):
160 zslice = 0
161 while zslice < depth >> level:
162 test = TextureTest(
163 dev = dev,
164 target = target,
165 format = format,
166 width = size,
167 height = size,
168 depth = depth,
169 last_level = last_level,
170 face = face,
171 level = level,
172 zslice = zslice,
173 )
174 suite.add_test(test)
175 zslice = (zslice + 1)*2 - 1
176 suite.run()
177
178
179 if __name__ == '__main__':
180 main()