[Piglit] [PATCH 4/5] gen_conversion: refactor templates to allow multiple extensions

Nicolai Hähnle nhaehnle at gmail.com
Thu Jan 26 18:59:25 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

This will be needed for the interaction of GL_ARB_gpu_shader_fp64 with
GL_ARB_gpu_shader_int64.
---
 generated_tests/gen_conversion.py                            | 8 ++++++++
 generated_tests/templates/gen_conversion/compiler_base.mako  | 8 ++++++--
 generated_tests/templates/gen_conversion/execution_base.mako | 6 +++---
 generated_tests/templates/gen_conversion/shader_base.mako    | 6 +++---
 4 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/generated_tests/gen_conversion.py b/generated_tests/gen_conversion.py
index aa76d48..e261eac 100644
--- a/generated_tests/gen_conversion.py
+++ b/generated_tests/gen_conversion.py
@@ -274,20 +274,25 @@ class TestTuple(object):
         self._ver = ver
         self._stage = stage
         self._basic_type = basic_type
         self._target_type = target_type
         self._names_only = names_only
         self._target_full_type = ''
         self._conversion_type = ''
         self._uniform_type = ''
         self._amount = int(first_dimension) * int(second_dimension)
         self._filenames = []
+        self._extensions = []
+
+        if ver.startswith('GL_'):
+            if basic_type == 'd' or target_type == 'd':
+                self._extensions.append('GL_ARB_gpu_shader_fp64')
 
         if first_dimension != '1':
             dimensional_type = 'mat' + first_dimension
             if first_dimension != second_dimension:
                 dimensional_type += 'x' + second_dimension
         elif second_dimension != '1':
             dimensional_type = 'vec' + second_dimension
         else:
             dimensional_type = ''
 
@@ -389,39 +394,41 @@ class RegularTestTuple(TestTuple):
             '{}-conversion-implicit-{}-{}-bad.{}'.format(self._stage, from_type, to_type,
                                                          self._stage))
 
         self._filenames.append(filename)
 
         if not self._names_only:
             with open(filename, 'w') as test_file:
                 test_file.write(TEMPLATES.get_template(
                     'compiler.{}.mako'.format(self._stage)).render_unicode(
                         ver=self._ver,
+                        extensions=self._extensions,
                         from_type=from_type,
                         to_type=to_type,
                         converted_from=converted_from))
 
     def _gen_exec_test(self, from_type, to_type,
                        uniform_from_type, uniform_to_type,
                        explicit, converted_from, conversions):
         filename = os.path.join(
             get_dir_name(self._ver, 'execution'),
             '{}-conversion-{}-{}-{}.shader_test'.format(self._stage, explicit,
                                                         from_type, to_type))
 
         self._filenames.append(filename)
 
         if not self._names_only:
             with open(filename, 'w') as test_file:
                 test_file.write(TEMPLATES.get_template(
                     'execution.{}.shader_test.mako'.format(self._stage)).render_unicode(
                         ver=self._ver,
+                        extensions=self._extensions,
                         amount=self._amount,
                         from_type=from_type,
                         to_type=to_type,
                         converted_from=converted_from,
                         uniform_from_type=uniform_from_type,
                         uniform_to_type=uniform_to_type,
                         conversions=conversions))
 
     def _gen_to_target(self):
         converted_from = 'from'
@@ -535,20 +542,21 @@ class ZeroSignTestTuple(TestTuple):
                                                                   from_type, to_type))
 
         self._filenames.append(filename)
 
         if not self._names_only:
             with open(filename, 'w') as test_file:
                 test_file.write(TEMPLATES.get_template(
                     'execution-zero-sign.{}.shader_test.mako'.format(
                         self._stage)).render_unicode(
                             ver=self._ver,
+                            extensions=self._extensions,
                             amount=self._amount,
                             from_type=from_type,
                             to_type=to_type,
                             converted_from=converted_from,
                             uniform_from_type=uniform_from_type,
                             uniform_to_type=uniform_to_type,
                             conversions=conversions))
 
     def _gen_to_target(self):
         if self._ver == '410':
diff --git a/generated_tests/templates/gen_conversion/compiler_base.mako b/generated_tests/templates/gen_conversion/compiler_base.mako
index 96ecc36..33166c8 100644
--- a/generated_tests/templates/gen_conversion/compiler_base.mako
+++ b/generated_tests/templates/gen_conversion/compiler_base.mako
@@ -1,20 +1,24 @@
 ## coding=utf-8
 <%inherit file="base.mako"/>\
 <%
     (glsl_version, glsl_version_int) = self.versioning()
 %>\
 /* [config]
  * expect_result: fail
  * glsl_version: ${glsl_version}
-% if ver == 'GL_ARB_gpu_shader_fp64':
- * require_extensions: ${ver}
+% if extensions:
+ * require_extensions:\
+% for extension in extensions:
+ ${extension}\
+% endfor
+
  * [end config]
  *
  * ${ver} spec states:
  *
  *     "No implicit conversions are
  *      provided to convert from unsigned to signed integer types, from
  *      floating-point to integer types, or from higher-precision to
  *      lower-precision types.  There are no implicit array or structure
  *      conversions."
 % else:
diff --git a/generated_tests/templates/gen_conversion/execution_base.mako b/generated_tests/templates/gen_conversion/execution_base.mako
index 2a3e065..09a3223 100644
--- a/generated_tests/templates/gen_conversion/execution_base.mako
+++ b/generated_tests/templates/gen_conversion/execution_base.mako
@@ -1,21 +1,21 @@
 ## coding=utf-8
 <%inherit file="base.mako"/>\
 <%
     (glsl_version, glsl_version_int) = self.versioning()
 %>\
 <%! from six.moves import range %>\
 [require]
 GLSL >= ${glsl_version}
-% if ver == 'GL_ARB_gpu_shader_fp64':
-${ver}
-% endif
+% for extension in extensions:
+${extension}
+% endfor
 ${next.body()}\
 [test]
 clear color 0.0 0.0 0.0 0.0
 
 % for conversion in conversions:
 clear
 uniform ${uniform_from_type} from \
 % for i in range(amount):
 ${conversion['from']} \
 % endfor
diff --git a/generated_tests/templates/gen_conversion/shader_base.mako b/generated_tests/templates/gen_conversion/shader_base.mako
index 33d88b8..d424e83 100644
--- a/generated_tests/templates/gen_conversion/shader_base.mako
+++ b/generated_tests/templates/gen_conversion/shader_base.mako
@@ -1,11 +1,11 @@
 ## coding=utf-8
 <%inherit file="base.mako"/>\
 <%
     (glsl_version, glsl_version_int) = self.versioning()
 %>\
 #version ${glsl_version_int}
-% if ver == 'GL_ARB_gpu_shader_fp64':
-#extension GL_ARB_gpu_shader_fp64 : require
-% endif
+% for extension in extensions:
+#extension ${extension} : require
+% endfor
 
 ${next.body()}\
-- 
2.7.4



More information about the Piglit mailing list