[Piglit] [PATCH 4/5] generators/gen_vs_in_fp64: Adds support to specify the GL type in the VBO

Andres Gomez agomez at igalia.com
Tue Jun 14 21:37:00 UTC 2016


Signed-off-by: Andres Gomez <agomez at igalia.com>
---
 generated_tests/gen_vs_in_fp64.py                  | 266 +++++++++++++++++----
 .../gen_vs_in_fp64/regular.shader_test.mako        |  21 +-
 2 files changed, 222 insertions(+), 65 deletions(-)

diff --git a/generated_tests/gen_vs_in_fp64.py b/generated_tests/gen_vs_in_fp64.py
index 88c4952..af7e81b 100644
--- a/generated_tests/gen_vs_in_fp64.py
+++ b/generated_tests/gen_vs_in_fp64.py
@@ -72,47 +72,165 @@ DOUBLE_NORMAL_VALUES   = ['0xffefffffffffffff', # Negative maximum normalized
                           '0x4b1e35ed24eb6496', # +7.23401345e+53
                           '0x7fefffffffffffff'] # Positive maximum normalized
 
-DSCALAR_TYPES          = [glsltypes.DOUBLE]
-
-DVEC_TYPES             = [glsltypes.DVEC2, glsltypes.DVEC3, glsltypes.DVEC4]
-
-DMAT_TYPES             = [glsltypes.DMAT2, glsltypes.DMAT2X3, glsltypes.DMAT2X4,
+FLOAT_POS_ZERO         = ['0x00000000'] #  0.0
+
+FLOAT_NORMAL_VALUES    = ['0xc21620c5', # -3.7532
+                          '0x75bc289b', #  4.7703e32
+                          '0x54c1c081', #  6.6572e12
+                          '0x878218f8', # -1.9575e-34
+                          '0x7e0857ed', #  4.5307886e37
+                          '0x2bb561bf', #  1.2887954e-12
+                          '0xff7fffff', # Negative maximum normalized
+                          '0xcb800000', # -16777216.0
+                          '0xc0a00000', # -5.0
+                          '0xbff92e73', # -1.9467300
+                          '0x80800000', # Negative minimum normalized
+                          '0x00800000', # Positive minimum normalized
+                          '0x3ff92e73', #  1.9467300
+                          '0x40a00000', #  5.0
+                          '0x4b800000', #  16777216.0
+                          '0x7f7fffff'] # Positive maximum normalized
+
+UBYTE_VALUES           = ['0', # Minimum
+                          '127', # Signed byte low frontier
+                          '128', # Signed byte up frontier
+                          '255', # Maximum
+                          '1',
+                          '5',
+                          '14',
+                          '23',
+                          '58',
+                          '91',
+                          '113',
+                          '135',
+                          '179',
+                          '185',
+                          '205',
+                          '207',
+                          '212']
+
+BYTE_VALUES            = ['-128', # Minimum
+                          '-5',
+                          '-1',
+                          '0',
+                          '1',
+                          '5',
+                          '127', # Maximum
+                          '-125',
+                          '-120',
+                          '-117',
+                          '-69',
+                          '-24',
+                          '-20',
+                          '21',
+                          '89',
+                          '106',
+                          '119']
+
+USHORT_VALUES          = ['0', # Minimum
+                          '32767', # Signed short low frontier
+                          '32768', # Signed short up frontier
+                          '65535', # Maximum
+                          '1',
+                          '5',
+                          '12610',
+                          '17110',
+                          '19962',
+                          '23589',
+                          '37265',
+                          '41792',
+                          '45699',
+                          '47934',
+                          '55916',
+                          '56412',
+                          '65142']
+
+SHORT_VALUES           = ['-32768', # Minimum
+                          '-5',
+                          '-1',
+                          '0',
+                          '1',
+                          '5',
+                          '32767', # Maximum
+                          '-16255',
+                          '-12480',
+                          '-12360',
+                          '1706',
+                          '5386',
+                          '7315',
+                          '18137',
+                          '25871',
+                          '26255',
+                          '26472']
+
+UINT_VALUES            = ['0', # Minimum
+                          '2147483647', # Signed int low frontier
+                          '2147483648', # Signed int up frontier
+                          '4294967295', # Maximum
+                          '1',
+                          '5',
+                          '1073294963',
+                          '1084227584',
+                          '1266679808',
+                          '1421983873',
+                          '2114476013',
+                          '2273450232',
+                          '3220778611',
+                          '3231711232',
+                          '3256230085',
+                          '3414163456',
+                          '4294967294']
+
+INT_VALUES             = ['-2147483648', # Minimum
+                          '-5',
+                          '-1',
+                          '0',
+                          '1',
+                          '5',
+                          '2147483647', # Maximum
+                          '-1038737211',
+                          '-1063256064',
+                          '-1074188685',
+                          '-880803840',
+                          '1073294963',
+                          '1084227584',
+                          '1266679808',
+                          '1421983873',
+                          '1975265435',
+                          '2114476013']
+
+GL_TYPES_VALUES        = {'double': DOUBLE_NORMAL_VALUES + DOUBLE_POS_ZERO,
+                          'float': FLOAT_NORMAL_VALUES + FLOAT_POS_ZERO,
+                          'ubyte': UBYTE_VALUES,
+                          'byte': BYTE_VALUES,
+                          'ushort': USHORT_VALUES,
+                          'short': SHORT_VALUES,
+                          'uint': UINT_VALUES,
+                          'int': INT_VALUES}
+
+GLSL_DSCALAR_TYPES     = [glsltypes.DOUBLE]
+
+GLSL_DVEC_TYPES        = [glsltypes.DVEC2, glsltypes.DVEC3, glsltypes.DVEC4]
+
+GLSL_DMAT_TYPES        = [glsltypes.DMAT2, glsltypes.DMAT2X3, glsltypes.DMAT2X4,
                           glsltypes.DMAT3X2, glsltypes.DMAT3, glsltypes.DMAT3X4,
                           glsltypes.DMAT4X2, glsltypes.DMAT4X3, glsltypes.DMAT4]
 
-FSCALAR_TYPES          = [glsltypes.FLOAT]
+GLSL_FSCALAR_TYPES     = [glsltypes.FLOAT]
 
-FVEC_TYPES             = [glsltypes.VEC2, glsltypes.VEC3, glsltypes.VEC4]
+GLSL_FVEC_TYPES        = [glsltypes.VEC2, glsltypes.VEC3, glsltypes.VEC4]
 
-FMAT_TYPES             = [glsltypes.MAT2, glsltypes.MAT2X3, glsltypes.MAT2X4,
+GLSL_FMAT_TYPES        = [glsltypes.MAT2, glsltypes.MAT2X3, glsltypes.MAT2X4,
                           glsltypes.MAT3X2, glsltypes.MAT3, glsltypes.MAT3X4,
                           glsltypes.MAT4X2, glsltypes.MAT4X3, glsltypes.MAT4]
 
-ISCALAR_TYPES          = [glsltypes.INT]
-
-IVEC_TYPES             = [glsltypes.IVEC2, glsltypes.IVEC3, glsltypes.IVEC4]
+GLSL_ISCALAR_TYPES     = [glsltypes.INT]
 
-USCALAR_TYPES          = [glsltypes.UINT]
+GLSL_IVEC_TYPES        = [glsltypes.IVEC2, glsltypes.IVEC3, glsltypes.IVEC4]
 
-UVEC_TYPES             = [glsltypes.UVEC2, glsltypes.UVEC3, glsltypes.UVEC4]
+GLSL_USCALAR_TYPES     = [glsltypes.UINT]
 
-HEX_VALUES_32BIT       = ['0xc21620c5', # -3.7532        float, -1038737211 int, 3256230085 uint
-                          '0x75bc289b', #  4.7703e32     float,  1975265435 int, 1975265435 uint
-                          '0x54c1c081', #  6.6572e12     float,  1421983873 int, 1421983873 uint
-                          '0x878218f8', # -1.9575e-34    float, -1038737211 int, 2273450232 uint
-                          '0x7e0857ed', #  4.5307886e+37 float,  2114476013 int, 2114476013 uint
-                          '0x2bb561bf', #  1.2887954e-12 float,   733307327 int,  733307327 uint
-                          '0xff7fffff', # -3.4028235e+38 float,    -8388609 int, 4286578687 uint
-                          '0xcb800000', # -16777216.0    float,  -880803840 int, 3414163456 uint
-                          '0xc0a00000', # -5.0           float, -1063256064 int, 3231711232 uint
-                          '0xbff92e73', # -1.9467300     float, -1074188685 int, 3220778611 uint
-                          '0x80800000', # -1.1754944e-38 float, -2139095040 int, 2155872256 uint
-                          '0x00000000', #  0.0           float,           0 int,          0 uint
-                          '0x00800000', #  1.1754944e-38 float,     8388608 int,    8388608 uint
-                          '0x3ff92e73', #  1.9467300     float,  1073294963 int, 1073294963 uint
-                          '0x40a00000', #  5.0           float,  1084227584 int, 1084227584 uint
-                          '0x4b800000', #  16777216.0    float,  1266679808 int, 1266679808 uint
-                          '0x7f7fffff'] #  3.4028235e+38 float,  2139095039 int, 2139095039 uint
+GLSL_UVEC_TYPES        = [glsltypes.UVEC2, glsltypes.UVEC3, glsltypes.UVEC4]
 
 
 # pylint: enable=bad-whitespace,line-too-long
@@ -155,15 +273,18 @@ class RegularTestTuple(TestTuple):
     @staticmethod
     def create_in_types_array(*types_arrays):
         """Creates vertex input combinations."""
+
         for product_item in itertools.product(*types_arrays):
             yield product_item
 
     @staticmethod
-    def create_tests(glsl_vers, in_types_array, position_orders, arrays_array, names_only):
+    def create_tests(glsl_vers, in_types_array, gl_types,
+                     position_orders, arrays_array, names_only):
         """Creates combinations for flat qualifier tests."""
 
         assert isinstance(glsl_vers, list)
         assert isinstance(in_types_array, types.GeneratorType)
+        assert isinstance(gl_types, list)
         assert isinstance(position_orders, list)
         assert isinstance(arrays_array, list)
         assert isinstance(names_only, bool)
@@ -188,7 +309,7 @@ class RegularTestTuple(TestTuple):
             if num_vs_in > MAX_VERTEX_ATTRIBS:
                 continue
 
-            yield ver, in_types, position_order, arrays, num_vs_in, names_only
+            yield ver, in_types, gl_types, position_order, arrays, num_vs_in, names_only
 
     @staticmethod
     def all_tests(names_only):
@@ -202,10 +323,29 @@ class RegularTestTuple(TestTuple):
         for test_args in RegularTestTuple.create_tests(
                 ['GL_ARB_vertex_attrib_64bit', '410'],
                 RegularTestTuple.create_in_types_array(
-                    itertools.chain(DSCALAR_TYPES, DVEC_TYPES, DMAT_TYPES),
-                    itertools.chain(FSCALAR_TYPES, FVEC_TYPES, FMAT_TYPES,
-                                    ISCALAR_TYPES, IVEC_TYPES,
-                                    USCALAR_TYPES, UVEC_TYPES)),
+                    itertools.chain(GLSL_DSCALAR_TYPES, GLSL_DVEC_TYPES, GLSL_DMAT_TYPES),
+                    itertools.chain(GLSL_FSCALAR_TYPES, GLSL_FVEC_TYPES, GLSL_FMAT_TYPES)),
+                ['double', 'float'],
+                [1, 2, 3],
+                [[1, 1], [1, 3], [5, 1], [5, 3]],
+                names_only):
+            yield RegularTestTuple(*test_args)
+        for test_args in RegularTestTuple.create_tests(
+                ['GL_ARB_vertex_attrib_64bit', '410'],
+                RegularTestTuple.create_in_types_array(
+                    itertools.chain(GLSL_DSCALAR_TYPES, GLSL_DVEC_TYPES, GLSL_DMAT_TYPES),
+                    itertools.chain(GLSL_ISCALAR_TYPES, GLSL_IVEC_TYPES)),
+                ['double', 'int'],
+                [1, 2, 3],
+                [[1, 1], [1, 3], [5, 1], [5, 3]],
+                names_only):
+            yield RegularTestTuple(*test_args)
+        for test_args in RegularTestTuple.create_tests(
+                ['GL_ARB_vertex_attrib_64bit', '410'],
+                RegularTestTuple.create_in_types_array(
+                    itertools.chain(GLSL_DSCALAR_TYPES, GLSL_DVEC_TYPES, GLSL_DMAT_TYPES),
+                    itertools.chain(GLSL_USCALAR_TYPES, GLSL_UVEC_TYPES)),
+                ['double', 'uint'],
                 [1, 2, 3],
                 [[1, 1], [1, 3], [5, 1], [5, 3]],
                 names_only):
@@ -213,10 +353,9 @@ class RegularTestTuple(TestTuple):
         for test_args in RegularTestTuple.create_tests(
                 ['GL_ARB_vertex_attrib_64bit', '410'],
                 RegularTestTuple.create_in_types_array(
-                    itertools.chain(FSCALAR_TYPES, FVEC_TYPES, FMAT_TYPES,
-                                    ISCALAR_TYPES, IVEC_TYPES,
-                                    USCALAR_TYPES, UVEC_TYPES),
-                    itertools.chain(DSCALAR_TYPES, DVEC_TYPES, DMAT_TYPES)),
+                    itertools.chain(GLSL_FSCALAR_TYPES, GLSL_FVEC_TYPES, GLSL_FMAT_TYPES),
+                    itertools.chain(GLSL_DSCALAR_TYPES, GLSL_DVEC_TYPES, GLSL_DMAT_TYPES)),
+                ['float', 'double'],
                 [1, 2, 3],
                 [[1, 1], [1, 2], [3, 1], [3, 2]],
                 names_only):
@@ -224,8 +363,9 @@ class RegularTestTuple(TestTuple):
         for test_args in RegularTestTuple.create_tests(
                 ['GL_ARB_vertex_attrib_64bit', '410'],
                 RegularTestTuple.create_in_types_array(
-                    itertools.chain(DSCALAR_TYPES, DVEC_TYPES, DMAT_TYPES),
-                    itertools.chain(DSCALAR_TYPES, DVEC_TYPES, DMAT_TYPES)),
+                    itertools.chain(GLSL_ISCALAR_TYPES, GLSL_IVEC_TYPES),
+                    itertools.chain(GLSL_DSCALAR_TYPES, GLSL_DVEC_TYPES, GLSL_DMAT_TYPES)),
+                ['int', 'double'],
                 [1, 2, 3],
                 [[1, 1], [1, 2], [3, 1], [3, 2]],
                 names_only):
@@ -233,15 +373,38 @@ class RegularTestTuple(TestTuple):
         for test_args in RegularTestTuple.create_tests(
                 ['GL_ARB_vertex_attrib_64bit', '410'],
                 RegularTestTuple.create_in_types_array(
-                    itertools.chain(DSCALAR_TYPES, DVEC_TYPES, DMAT_TYPES)),
+                    itertools.chain(GLSL_USCALAR_TYPES, GLSL_UVEC_TYPES),
+                    itertools.chain(GLSL_DSCALAR_TYPES, GLSL_DVEC_TYPES, GLSL_DMAT_TYPES)),
+                ['uint', 'double'],
+                [1, 2, 3],
+                [[1, 1], [1, 2], [3, 1], [3, 2]],
+                names_only):
+            yield RegularTestTuple(*test_args)
+        for test_args in RegularTestTuple.create_tests(
+                ['GL_ARB_vertex_attrib_64bit', '410'],
+                RegularTestTuple.create_in_types_array(
+                    itertools.chain(GLSL_DSCALAR_TYPES, GLSL_DVEC_TYPES, GLSL_DMAT_TYPES),
+                    itertools.chain(GLSL_DSCALAR_TYPES, GLSL_DVEC_TYPES, GLSL_DMAT_TYPES)),
+                ['double', 'double'],
+                [1, 2, 3],
+                [[1, 1], [1, 2], [3, 1], [3, 2]],
+                names_only):
+            yield RegularTestTuple(*test_args)
+        for test_args in RegularTestTuple.create_tests(
+                ['GL_ARB_vertex_attrib_64bit', '410'],
+                RegularTestTuple.create_in_types_array(
+                    itertools.chain(GLSL_DSCALAR_TYPES, GLSL_DVEC_TYPES, GLSL_DMAT_TYPES)),
+                ['double'],
                 [1, 2],
                 [[1], [5]],
                 names_only):
             yield RegularTestTuple(*test_args)
 
-    def __init__(self, ver, in_types, position_order, arrays, num_vs_in, names_only):
+    def __init__(self, ver, in_types, gl_types, position_order, arrays, num_vs_in, names_only):
         assert ver in ('GL_ARB_vertex_attrib_64bit', '410', '420')
         assert isinstance(in_types, tuple)
+        assert isinstance(gl_types, list)
+        assert len(gl_types) == len(in_types)
         assert isinstance(position_order, int)
         assert (position_order > 0) and (position_order - 1 <= len(in_types))
         assert isinstance(arrays, list)
@@ -249,6 +412,7 @@ class RegularTestTuple(TestTuple):
         super(RegularTestTuple, self).__init__(ver, names_only)
 
         self._in_types = in_types
+        self._gl_types = gl_types
         self._position_order = position_order
         self._arrays = arrays
         self._num_vs_in = num_vs_in
@@ -259,8 +423,8 @@ class RegularTestTuple(TestTuple):
         for idx, in_type in enumerate(self._in_types):
             if idx == self._position_order - 1:
                 filename += '-position'
-            filename += '-{}{}'.format(
-                in_type.name, '-array{}'.format(
+            filename += '-{}_{}{}'.format(
+                self._gl_types[idx], in_type.name, '_array{}'.format(
                     self._arrays[idx]) if self._arrays[idx] - 1 else '')
         if self._position_order > len(self._in_types):
             filename += '-position'
@@ -272,11 +436,12 @@ class RegularTestTuple(TestTuple):
                     'regular.shader_test.mako').render_unicode(
                         ver=self._ver,
                         in_types=self._in_types,
+                        gl_types=self._gl_types,
                         position_order=self._position_order,
                         arrays=self._arrays,
                         num_vs_in=self._num_vs_in,
-                        dvalues=DOUBLE_NORMAL_VALUES + DOUBLE_POS_ZERO,
-                        hvalues=HEX_VALUES_32BIT))
+                        gl_types_values=GL_TYPES_VALUES))
+
         print(filename)
 
 
@@ -296,7 +461,7 @@ class ColumnsTestTuple(TestTuple):
             for ver in glsl_vers:
                 utils.safe_makedirs(TestTuple.get_dir_name(ver))
 
-        for mat in DMAT_TYPES:
+        for mat in GLSL_DMAT_TYPES:
             for columns in itertools.product(range(2), repeat=mat.columns):
                 if (0 not in columns) or (1 not in columns):
                     continue
@@ -327,7 +492,8 @@ class ColumnsTestTuple(TestTuple):
                         ver=self._ver,
                         mat=self._mat,
                         columns=self._columns,
-                        dvalues=DOUBLE_NORMAL_VALUES + DOUBLE_POS_ZERO))
+                        dvalues=GL_TYPES_VALUES['double']))
+
         print(filename)
 
 
diff --git a/generated_tests/templates/gen_vs_in_fp64/regular.shader_test.mako b/generated_tests/templates/gen_vs_in_fp64/regular.shader_test.mako
index fa54932..b6fab62 100644
--- a/generated_tests/templates/gen_vs_in_fp64/regular.shader_test.mako
+++ b/generated_tests/templates/gen_vs_in_fp64/regular.shader_test.mako
@@ -31,16 +31,6 @@
       glsl_version = '{}.{}'.format(glsl_version_int[0], glsl_version_int[1:3])
 
       return (glsl_version, glsl_version_int)
-
-  def _glsl_to_gl(glsl_type):
-      if glsl_type.startswith("d"):
-          return "double"
-      elif glsl_type.startswith("u"):
-          return "uint"
-      elif glsl_type.startswith("i"):
-          return "int"
-      else:
-          return "float"
 %>
 <% glsl, glsl_int = _version(ver) %>
 
@@ -102,7 +92,7 @@ void main()
   % endif
   % for i in range(arrays[idx]):
     % for j in range(in_type.columns):
-    value${idx}${'[{}]'.format(i) if arrays[idx] > 1 else ''}/${_glsl_to_gl(in_type.name)}/${in_type.name}${'/{}'.format(j) if (in_type.columns or 0) > 1 else ''} \
+    value${idx}${'[{}]'.format(i) if arrays[idx] > 1 else ''}/${gl_types[idx]}/${in_type.name}${'/{}'.format(j) if in_type.columns > 1 else ''} \
     % endfor
   % endfor
 % endfor
@@ -110,7 +100,7 @@ void main()
   piglit_vertex/float/vec3\
 % endif
 
-% for d in range(len(dvalues)):
+% for d in range(len(gl_types_values['double'])):
   % for vertex in ('-1.0 -1.0  0.0', ' 1.0 -1.0  0.0', ' 1.0  1.0  0.0', '-1.0  1.0  0.0'):
     % for idx, in_type in enumerate(in_types):
       % if idx == position_order - 1:
@@ -119,7 +109,7 @@ void main()
       % for i in range(arrays[idx]):
         % for j in range(in_type.columns):
           % for k in range(in_type.rows):
-            ${dvalues[(d + (i * (in_type.columns) + j) * (in_type.rows) + k) % len(dvalues)] if in_type.type.name == 'double' else hvalues[(d + (i * (in_type.columns) + j) * (in_type.rows) + k) % len(hvalues)]}  \
+            ${gl_types_values[gl_types[idx]][(d + (i * in_type.columns + j) * in_type.rows + k) % len(gl_types_values[gl_types[idx]])]}  \
           % endfor
          \
         % endfor
@@ -133,14 +123,15 @@ void main()
 % endfor
 
 [test]
-% for d in range(len(dvalues)):
+% for d in range(len(gl_types_values['double'])):
 
   % for idx, in_type in enumerate(in_types):
     % for i in range(arrays[idx]):
       uniform ${in_type.name} expected${idx}${'[{}]'.format(i) if arrays[idx] > 1 else ''}\
       % for j in range(in_type.columns):
         % for k in range(in_type.rows):
-         ${dvalues[(d + (i * (in_type.columns) + j) * (in_type.rows) + k) % len(dvalues)] if in_type.type.name == 'double' else hvalues[(d + (i * (in_type.columns) + j) * (in_type.rows) + k) % len(hvalues)]}\
+	  ## Careful: these are the values for the VBO type, not the uniform type. If we use the hex format they should match or the run will fail.
+          ${gl_types_values[gl_types[idx]][(d + (i * in_type.columns + j) * in_type.rows + k) % len(gl_types_values[gl_types[idx]])]}\
         % endfor
       % endfor
 
-- 
2.8.1



More information about the Piglit mailing list