[Piglit] [PATCH v4 1/2] arb_shader_precision: support scalar values in shader_runner_format

Micah Fedke micah.fedke at collabora.co.uk
Fri Apr 3 09:45:05 PDT 2015


---
 generated_tests/gen_shader_precision_tests.py | 30 ++++++++++++++-------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/generated_tests/gen_shader_precision_tests.py b/generated_tests/gen_shader_precision_tests.py
index 4aea2ce..6c011a3 100644
--- a/generated_tests/gen_shader_precision_tests.py
+++ b/generated_tests/gen_shader_precision_tests.py
@@ -49,6 +49,7 @@
 from __future__ import print_function, division, absolute_import
 from builtin_function import *
 import os 
+import numpy
 
 import six
 from six.moves import range
@@ -71,6 +72,9 @@ trig_builtins = ('sin', 'cos', 'tan',
                  'sinh', 'cosh', 'tanh', 
                  'asinh', 'acosh', 'atanh')
 
+def _is_sequence(arg):
+    return isinstance(arg, (collections.Sequence, numpy.ndarray))
+
 def make_indexers(signature):
    """Build a list of strings which index into every possible
    value of the result.  For example, if the result is a vec2,
@@ -105,23 +109,21 @@ def shader_runner_type(glsl_type):
 
 def shader_runner_format(values):
     """Format the given values for use in a shader_runner "uniform" or
-    "probe rgba" command.  Bools are converted to 0's and 1's, and
-    values are separated by spaces.
+    "probe rgba" command.  Sequences of values are separated by spaces.
     """
-    transformed_values = []
-    retval = ''
-    for value in values:
-        if isinstance(value, (bool, np.bool_)):
-            transformed_values.append(int(value))
-        else:
-            transformed_values.append(value)
-    for x in transformed_values:
-        if isinstance(x,np.float32):
-            retval+=' {0}'.format('{0:1.8e}'.format(x))
-        else:
-            retval+=' {0}'.format(repr(x))
+
+    if _is_sequence(values):
+        retval = ''
+        for x in values:
+            assert isinstance(x, (float, np.float32))
+            retval+=' {0:1.8e}'.format(x)
+    else:
+        assert isinstance(values, (float, np.float32))
+        retval = '{0:1.8e}'.format(values)
+
     return retval
 
+
 def main():
     """ Main function """
 
-- 
2.3.5



More information about the Piglit mailing list