[Piglit] [PATCH 1/4] arb_shader_precision: support scalar values in shader_runner_format
Micah Fedke
micah.fedke at collabora.co.uk
Wed Feb 18 22:06:15 PST 2015
Prep work for using arrays of tolerances in the shader_test files.
---
generated_tests/gen_shader_precision_tests.py | 34
+++++++++++++++++----------
1 file changed, 22 insertions(+), 12 deletions(-)
diff --git a/generated_tests/gen_shader_precision_tests.py
b/generated_tests/gen_shader_precision_tests.py
index 0d24a80..cfa5065 100644
--- a/generated_tests/gen_shader_precision_tests.py
+++ b/generated_tests/gen_shader_precision_tests.py
@@ -68,6 +68,10 @@ trig_builtins = ('sin', 'cos', 'tan',
'sinh', 'cosh', 'tanh', 'asinh',
'acosh', 'atanh')
+def _is_sequence(arg):
+ return (not hasattr(arg, "strip") and
+ hasattr(arg, "__iter__"))
+
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,20 +109,26 @@ def shader_runner_format(values):
"probe rgba" command. Bools are converted to 0's and 1's, and
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):
+ 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))
+ else:
+ retval = '{}'.format(values)
+
return retval
+
def main():
""" Main function """
-- 2.2.2
More information about the Piglit
mailing list