##########################################################################
+import os
+import random
+
from gallium import *
from base import *
level = self.level
zslice = self.zslice
+ tex_usage = PIPE_TEXTURE_USAGE_SAMPLER
+ geom_flags = 0
+ if not dev.is_format_supported(format, target, tex_usage, geom_flags):
+ raise TestSkip
+
+ if not dev.is_format_supported(format, target, tex_usage, geom_flags):
+ raise TestSkip
+
# textures
dst_texture = dev.texture_create(
target = target,
height = height,
depth = depth,
last_level = last_level,
- tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET,
+ tex_usage = tex_usage,
)
- if dst_texture is None:
- raise TestSkip
dst_surface = dst_texture.get_surface(face = face, level = level, zslice = zslice)
src_surface = src_texture.get_surface()
- x = 0
- y = 0
w = dst_surface.width
h = dst_surface.height
if dst_raw != src_raw:
raise TestFailure
-
def main():
targets = [
PIPE_TEXTURE_2D,
PIPE_TEXTURE_CUBE,
- #PIPE_TEXTURE_3D,
- ]
-
- formats = [
- PIPE_FORMAT_B8G8R8A8_UNORM,
- PIPE_FORMAT_B8G8R8X8_UNORM,
- PIPE_FORMAT_B8G8R8A8_SRGB,
- PIPE_FORMAT_B5G6R5_UNORM,
- PIPE_FORMAT_B5G5R5A1_UNORM,
- PIPE_FORMAT_B4G4R4A4_UNORM,
- PIPE_FORMAT_Z32_UNORM,
- PIPE_FORMAT_S8Z24_UNORM,
- PIPE_FORMAT_X8Z24_UNORM,
- PIPE_FORMAT_Z16_UNORM,
- PIPE_FORMAT_S8_UNORM,
- PIPE_FORMAT_A8_UNORM,
- PIPE_FORMAT_L8_UNORM,
- PIPE_FORMAT_DXT1_RGB,
- PIPE_FORMAT_DXT1_RGBA,
- PIPE_FORMAT_DXT3_RGBA,
- PIPE_FORMAT_DXT5_RGBA,
+ PIPE_TEXTURE_3D,
]
sizes = [64, 32, 16, 8, 4, 2, 1]
PIPE_TEX_FACE_NEG_Z,
]
- for target in targets:
- for format in formats:
- for size in sizes:
- if target == PIPE_TEXTURE_3D:
- depth = size
- else:
- depth = 1
- for face in faces:
- if target != PIPE_TEXTURE_CUBE and face:
- continue
- levels = lods(size)
- for last_level in range(levels):
- for level in range(0, last_level + 1):
- zslice = 0
- while zslice < depth >> level:
- test = TextureTest(
- dev = dev,
- ctx = ctx,
- target = target,
- format = format,
- width = size,
- height = size,
- depth = depth,
- last_level = last_level,
- face = face,
- level = level,
- zslice = zslice,
- )
- suite.add_test(test)
- zslice = (zslice + 1)*2 - 1
+ try:
+ n = int(sys.argv[1])
+ except:
+ n = 10000
+
+ for i in range(n):
+ format = random.choice(formats.keys())
+ if not util_format_is_depth_or_stencil(format):
+ is_depth_or_stencil = util_format_is_depth_or_stencil(format)
+
+ if is_depth_or_stencil:
+ target = PIPE_TEXTURE_2D
+ else:
+ target = random.choice(targets)
+
+ size = random.choice(sizes)
+
+ if target == PIPE_TEXTURE_3D:
+ depth = size
+ else:
+ depth = 1
+
+ if target == PIPE_TEXTURE_CUBE:
+ face = random.choice(faces)
+ else:
+ face = PIPE_TEX_FACE_POS_X
+
+ levels = lods(size)
+ last_level = random.randint(0, levels - 1)
+ level = random.randint(0, last_level)
+ zslice = random.randint(0, max(depth >> level, 1) - 1)
+
+ test = TextureTest(
+ dev = dev,
+ ctx = ctx,
+ target = target,
+ format = format,
+ width = size,
+ height = size,
+ depth = depth,
+ last_level = last_level,
+ face = face,
+ level = level,
+ zslice = zslice,
+ )
+ suite.add_test(test)
suite.run()
random.seed(0xdead3eef)
dev = Device()
+ ctx = dev.context_create()
suite = TestSuite()
targets = [
PIPE_TEX_FACE_NEG_Z,
]
- ctx = dev.context_create()
-
try:
n = int(sys.argv[1])
except:
depth = 1
if target == PIPE_TEXTURE_CUBE:
- face =random.choice(faces)
+ face = random.choice(faces)
else:
face = PIPE_TEX_FACE_POS_X
PIPE_FORMAT_B5G5R5A1_UNORM,
PIPE_FORMAT_B4G4R4A4_UNORM,
#PIPE_FORMAT_Z32_UNORM,
- #PIPE_FORMAT_S8Z24_UNORM,
+ #PIPE_FORMAT_S8_USCALED_Z24_UNORM,
#PIPE_FORMAT_X8Z24_UNORM,
#PIPE_FORMAT_Z16_UNORM,
- #PIPE_FORMAT_S8_UNORM,
+ #PIPE_FORMAT_S8_USCALED,
PIPE_FORMAT_A8_UNORM,
PIPE_FORMAT_L8_UNORM,
#PIPE_FORMAT_DXT1_RGB,
import os
+import random
from gallium import *
from base import *
level = self.level
zslice = self.zslice
- tex_usage = 0
+ tex_usage = PIPE_TEXTURE_USAGE_SAMPLER
+ geom_flags = 0
+ if not dev.is_format_supported(format, target, tex_usage, geom_flags):
+ raise TestSkip
+ # textures
texture = dev.texture_create(
target = target,
format = format,
last_level = last_level,
tex_usage = tex_usage,
)
- if texture is None:
- raise TestSkip
surface = texture.get_surface(face, level, zslice)
- stride = util_format_get_stride(format, width)
- size = util_format_get_nblocksy(format, height) * stride
+ stride = util_format_get_stride(format, surface.width)
+ size = util_format_get_nblocksy(format, surface.height) * stride
in_raw = os.urandom(size)
PIPE_TEXTURE_3D,
]
- formats = [
- PIPE_FORMAT_B8G8R8A8_UNORM,
- PIPE_FORMAT_B8G8R8X8_UNORM,
- PIPE_FORMAT_B8G8R8A8_SRGB,
- PIPE_FORMAT_B5G6R5_UNORM,
- PIPE_FORMAT_B5G5R5A1_UNORM,
- PIPE_FORMAT_B4G4R4A4_UNORM,
- PIPE_FORMAT_Z32_UNORM,
- PIPE_FORMAT_S8Z24_UNORM,
- PIPE_FORMAT_X8Z24_UNORM,
- PIPE_FORMAT_Z16_UNORM,
- PIPE_FORMAT_S8_UNORM,
- PIPE_FORMAT_A8_UNORM,
- PIPE_FORMAT_L8_UNORM,
- PIPE_FORMAT_DXT1_RGB,
- PIPE_FORMAT_DXT1_RGBA,
- PIPE_FORMAT_DXT3_RGBA,
- PIPE_FORMAT_DXT5_RGBA,
- ]
-
sizes = [64, 32, 16, 8, 4, 2, 1]
#sizes = [1020, 508, 252, 62, 30, 14, 6, 3]
#sizes = [64]
PIPE_TEX_FACE_NEG_Z,
]
- for target in targets:
- for format in formats:
- for size in sizes:
- if target == PIPE_TEXTURE_3D:
- depth = size
- else:
- depth = 1
- for face in faces:
- if target != PIPE_TEXTURE_CUBE and face:
- continue
- levels = lods(size)
- for last_level in range(levels):
- for level in range(0, last_level + 1):
- zslice = 0
- while zslice < depth >> level:
- test = TextureTest(
- dev = dev,
- ctx = ctx,
- target = target,
- format = format,
- width = size,
- height = size,
- depth = depth,
- last_level = last_level,
- face = face,
- level = level,
- zslice = zslice,
- )
- suite.add_test(test)
- zslice = (zslice + 1)*2 - 1
+ try:
+ n = int(sys.argv[1])
+ except:
+ n = 10000
+
+ for i in range(n):
+ format = random.choice(formats.keys())
+ if not util_format_is_depth_or_stencil(format):
+ is_depth_or_stencil = util_format_is_depth_or_stencil(format)
+
+ if is_depth_or_stencil:
+ target = PIPE_TEXTURE_2D
+ else:
+ target = random.choice(targets)
+
+ size = random.choice(sizes)
+
+ if target == PIPE_TEXTURE_3D:
+ depth = size
+ else:
+ depth = 1
+
+ if target == PIPE_TEXTURE_CUBE:
+ face = random.choice(faces)
+ else:
+ face = PIPE_TEX_FACE_POS_X
+
+ levels = lods(size)
+ last_level = random.randint(0, levels - 1)
+ level = random.randint(0, last_level)
+ zslice = random.randint(0, max(depth >> level, 1) - 1)
+
+ test = TextureTest(
+ dev = dev,
+ ctx = ctx,
+ target = target,
+ format = format,
+ width = size,
+ height = size,
+ depth = depth,
+ last_level = last_level,
+ face = face,
+ level = level,
+ zslice = zslice,
+ )
+ suite.add_test(test)
suite.run()