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
##########################################################################
46
class TextureTest(TestCase):
69
last_level = self.last_level
74
bind = PIPE_BIND_SAMPLER_VIEW
77
if not dev.is_format_supported(format, target, sample_count, bind, geom_flags):
80
if not dev.is_format_supported(format, target, sample_count, bind, geom_flags):
84
dst_texture = dev.resource_create(
90
last_level = last_level,
94
dst_surface = dst_texture.get_surface(face = face, level = level, zslice = zslice)
96
src_texture = dev.resource_create(
99
width = dst_surface.width,
100
height = dst_surface.height,
103
bind = PIPE_BIND_SAMPLER_VIEW,
106
src_surface = src_texture.get_surface()
108
w = dst_surface.width
109
h = dst_surface.height
111
stride = util_format_get_stride(format, w)
112
size = util_format_get_nblocksy(format, h) * stride
113
src_raw = os.urandom(size)
115
ctx.surface_write_raw(src_surface, 0, 0, w, h, src_raw, stride)
117
ctx.surface_copy(dst_surface, 0, 0,
118
src_surface, 0, 0, w, h)
120
dst_raw = ctx.surface_read_raw(dst_surface, 0, 0, w, h)
122
if dst_raw != src_raw:
128
ctx = dev.context_create()
137
sizes = [64, 32, 16, 8, 4, 2, 1]
138
#sizes = [1020, 508, 252, 62, 30, 14, 6, 3]
157
format = random.choice(formats.keys())
158
if not util_format_is_depth_or_stencil(format):
159
is_depth_or_stencil = util_format_is_depth_or_stencil(format)
161
if is_depth_or_stencil:
162
target = PIPE_TEXTURE_2D
164
target = random.choice(targets)
166
size = random.choice(sizes)
168
if target == PIPE_TEXTURE_3D:
173
if target == PIPE_TEXTURE_CUBE:
174
face = random.choice(faces)
176
face = PIPE_TEX_FACE_POS_X
179
last_level = random.randint(0, levels - 1)
180
level = random.randint(0, last_level)
181
zslice = random.randint(0, max(depth >> level, 1) - 1)
191
last_level = last_level,
200
if __name__ == '__main__':