2 ##########################################################################
4 # Copyright 2009 VMware, Inc.
7 # Permission is hereby granted, free of charge, to any person obtaining a
8 # copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sub license, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
15 # The above copyright notice and this permission notice (including the
16 # next paragraph) shall be included in all copies or substantial portions
19 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22 # IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
23 # ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 ##########################################################################
43 class TextureTest(TestCase
):
65 last_level
= self
.last_level
71 dst_texture
= dev
.texture_create(
77 last_level
= last_level
,
78 tex_usage
= PIPE_TEXTURE_USAGE_RENDER_TARGET
,
80 if dst_texture
is None:
83 dst_surface
= dst_texture
.get_surface(face
= face
, level
= level
, zslice
= zslice
)
85 src_texture
= dev
.texture_create(
88 width
= dst_surface
.width
,
89 height
= dst_surface
.height
,
92 tex_usage
= PIPE_TEXTURE_USAGE_SAMPLER
,
95 src_surface
= src_texture
.get_surface()
100 h
= dst_surface
.height
103 stride
= pf_get_stride(texture
->format
, w
)
104 size
= pf_get_nblocksy(texture
->format
) * stride
105 src_raw
= os
.urandom(size
)
107 src_surface
.put_tile_raw(0, 0, w
, h
, src_raw
, stride
)
109 ctx
= self
.dev
.context_create()
111 ctx
.surface_copy(dst_surface
, 0, 0,
112 src_surface
, 0, 0, w
, h
)
116 dst_raw
= dst_surface
.get_tile_raw(0, 0, w
, h
)
118 if dst_raw
!= src_raw
:
134 PIPE_FORMAT_B8G8R8A8_UNORM
,
135 PIPE_FORMAT_B8G8R8X8_UNORM
,
136 PIPE_FORMAT_B8G8R8A8_SRGB
,
137 PIPE_FORMAT_B5G6R5_UNORM
,
138 PIPE_FORMAT_B5G5R5A1_UNORM
,
139 PIPE_FORMAT_B4G4R4A4_UNORM
,
140 PIPE_FORMAT_Z32_UNORM
,
141 PIPE_FORMAT_S8Z24_UNORM
,
142 PIPE_FORMAT_X8Z24_UNORM
,
143 PIPE_FORMAT_Z16_UNORM
,
144 PIPE_FORMAT_S8_UNORM
,
145 PIPE_FORMAT_A8_UNORM
,
146 PIPE_FORMAT_L8_UNORM
,
147 PIPE_FORMAT_DXT1_RGB
,
148 PIPE_FORMAT_DXT1_RGBA
,
149 PIPE_FORMAT_DXT3_RGBA
,
150 PIPE_FORMAT_DXT5_RGBA
,
153 sizes
= [64, 32, 16, 8, 4, 2, 1]
154 #sizes = [1020, 508, 252, 62, 30, 14, 6, 3]
167 for target
in targets
:
168 for format
in formats
:
170 if target
== PIPE_TEXTURE_3D
:
175 if target
!= PIPE_TEXTURE_CUBE
and face
:
178 for last_level
in range(levels
):
179 for level
in range(0, last_level
+ 1):
181 while zslice
< depth
>> level
:
189 last_level
= last_level
,
195 zslice
= (zslice
+ 1)*2 - 1
199 if __name__
== '__main__':