python/tests: Test all existing gallium formats.
authorJosé Fonseca <jfonseca@vmware.com>
Wed, 31 Mar 2010 12:27:08 +0000 (13:27 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Wed, 31 Mar 2010 12:27:08 +0000 (13:27 +0100)
progs/gallium/python/tests/base.py
progs/gallium/python/tests/texture_sample.py

index 3699af81451a2f272ad8bc21ddba736af3133920..6296eb5850494ecb53e77513323132d8e4f3cfe6 100755 (executable)
@@ -43,18 +43,9 @@ from gallium import *
 # Enumerate all pixel formats
 formats = {}
 for name, value in globals().items():
-    if name.startswith("PIPE_FORMAT_") and isinstance(value, int):
+    if name.startswith("PIPE_FORMAT_") and isinstance(value, int) and name != "PIPE_FORMAT_COUNT":
         formats[value] = name
 
-def is_depth_stencil_format(format):
-    # FIXME: make and use binding to util_format_is_depth_or_stencil
-    return format in (
-        PIPE_FORMAT_Z32_UNORM,
-        PIPE_FORMAT_S8Z24_UNORM,
-        PIPE_FORMAT_X8Z24_UNORM,
-        PIPE_FORMAT_Z16_UNORM,
-    )
-
 def make_image(width, height, rgba):
     import Image
     outimage = Image.new(
index 9b5c15ad1da678f8d5d4faa428cc6671d6f024fe..63686463fa5ad1361575265d3a0ae8232baa6713 100755 (executable)
@@ -559,32 +559,9 @@ def main():
         PIPE_TEXTURE_3D,
     ]
     
-    color_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_A8_UNORM,
-        PIPE_FORMAT_L8_UNORM,
-        PIPE_FORMAT_UYVY,
-        PIPE_FORMAT_DXT1_RGB,
-        #PIPE_FORMAT_DXT1_RGBA,
-        #PIPE_FORMAT_DXT3_RGBA,
-        #PIPE_FORMAT_DXT5_RGBA,
-    ]
-    
-    depth_formats = [
-        PIPE_FORMAT_Z32_UNORM,
-        PIPE_FORMAT_S8Z24_UNORM,
-        PIPE_FORMAT_X8Z24_UNORM,
-        PIPE_FORMAT_Z16_UNORM,
-    ]
-    
-    sizes = [64, 32, 16, 8, 4, 2, 1]
+    #sizes = [64, 32, 16, 8, 4, 2, 1]
     #sizes = [1020, 508, 252, 62, 30, 14, 6, 3]
-    #sizes = [64]
+    sizes = [64]
     #sizes = [63]
     
     faces = [
@@ -598,58 +575,61 @@ def main():
 
     ctx = dev.context_create()
     
-    for format in color_formats:
-        for target in targets:
+    for format in formats.iterkeys():
+        if format == PIPE_FORMAT_NONE:
+            continue
+        if not util_format_is_depth_or_stencil(format):
+            for target in targets:
+                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 = TextureColorSampleTest(
+                                        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
+        else:
+            target = PIPE_TEXTURE_2D
+            depth = 1
+            face = 0
+            last_level = 0
+            level = 0
+            zslice = 0
             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 = TextureColorSampleTest(
-                                    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
-    for format in depth_formats:
-        target = PIPE_TEXTURE_2D
-        depth = 1
-        face = 0
-        last_level = 0
-        level = 0
-        zslice = 0
-        for size in sizes:
-            test = TextureDepthSampleTest(
-                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)
+                test = TextureDepthSampleTest(
+                    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()