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
77 if not dev
.is_format_supported(format
, target
, bind
, geom_flags
):
81 texture
= dev
.resource_create(
87 last_level
= last_level
,
91 surface
= texture
.get_surface(face
, level
, zslice
)
93 stride
= util_format_get_stride(format
, surface
.width
)
94 size
= util_format_get_nblocksy(format
, surface
.height
) * stride
96 in_raw
= os
.urandom(size
)
98 ctx
.surface_write_raw(surface
, 0, 0, surface
.width
, surface
.height
, in_raw
, stride
)
100 out_raw
= ctx
.surface_read_raw(surface
, 0, 0, surface
.width
, surface
.height
)
102 if in_raw
!= out_raw
:
108 ctx
= dev
.context_create()
117 sizes
= [64, 32, 16, 8, 4, 2, 1]
118 #sizes = [1020, 508, 252, 62, 30, 14, 6, 3]
137 format
= random
.choice(formats
.keys())
138 if not util_format_is_depth_or_stencil(format
):
139 is_depth_or_stencil
= util_format_is_depth_or_stencil(format
)
141 if is_depth_or_stencil
:
142 target
= PIPE_TEXTURE_2D
144 target
= random
.choice(targets
)
146 size
= random
.choice(sizes
)
148 if target
== PIPE_TEXTURE_3D
:
153 if target
== PIPE_TEXTURE_CUBE
:
154 face
= random
.choice(faces
)
156 face
= PIPE_TEX_FACE_POS_X
159 last_level
= random
.randint(0, levels
- 1)
160 level
= random
.randint(0, last_level
)
161 zslice
= random
.randint(0, max(depth
>> level
, 1) - 1)
171 last_level
= last_level
,
180 if __name__
== '__main__':