65c919bc64d72ad4ca8e8f88b0b2c3fa3613ce56
2 ##########################################################################
4 # Copyright 2009 VMware, Inc.
5 # Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
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:
16 # The above copyright notice and this permission notice (including the
17 # next paragraph) shall be included in all copies or substantial portions
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.
28 ##########################################################################
47 class TextureTest(TestCase
):
70 last_level
= self
.last_level
75 bind
= PIPE_BIND_SAMPLER_VIEW
78 if not dev
.is_format_supported(format
, target
, sample_count
, bind
, geom_flags
):
82 texture
= dev
.resource_create(
88 last_level
= last_level
,
92 surface
= texture
.get_surface(face
, level
, zslice
)
94 stride
= util_format_get_stride(format
, surface
.width
)
95 size
= util_format_get_nblocksy(format
, surface
.height
) * stride
97 in_raw
= os
.urandom(size
)
99 ctx
.surface_write_raw(surface
, 0, 0, surface
.width
, surface
.height
, in_raw
, stride
)
101 out_raw
= ctx
.surface_read_raw(surface
, 0, 0, surface
.width
, surface
.height
)
103 if in_raw
!= out_raw
:
109 ctx
= dev
.context_create()
118 sizes
= [64, 32, 16, 8, 4, 2, 1]
119 #sizes = [1020, 508, 252, 62, 30, 14, 6, 3]
138 format
= random
.choice(formats
.keys())
139 if not util_format_is_depth_or_stencil(format
):
140 is_depth_or_stencil
= util_format_is_depth_or_stencil(format
)
142 if is_depth_or_stencil
:
143 target
= PIPE_TEXTURE_2D
145 target
= random
.choice(targets
)
147 size
= random
.choice(sizes
)
149 if target
== PIPE_TEXTURE_3D
:
154 if target
== PIPE_TEXTURE_CUBE
:
155 face
= random
.choice(faces
)
157 face
= PIPE_TEX_FACE_POS_X
160 last_level
= random
.randint(0, levels
- 1)
161 level
= random
.randint(0, last_level
)
162 zslice
= random
.randint(0, max(depth
>> level
, 1) - 1)
172 last_level
= last_level
,
181 if __name__
== '__main__':