[Piglit] [PATCH 13/34] gen_shader_precision_tests.py: python2/3 hybridize
Dylan Baker
baker.dylan.c at gmail.com
Fri Feb 20 18:18:00 PST 2015
This produces no changes in output.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
generated_tests/gen_shader_precision_tests.py | 14 ++++++++------
.../templates/gen_shader_precision_tests/fs.mako | 11 +++++++----
.../templates/gen_shader_precision_tests/gs.mako | 11 +++++++----
.../templates/gen_shader_precision_tests/vs.mako | 11 +++++++----
4 files changed, 29 insertions(+), 18 deletions(-)
diff --git a/generated_tests/gen_shader_precision_tests.py b/generated_tests/gen_shader_precision_tests.py
index 0d24a80..e2d2381 100644
--- a/generated_tests/gen_shader_precision_tests.py
+++ b/generated_tests/gen_shader_precision_tests.py
@@ -46,10 +46,12 @@
This program outputs, to stdout, the name of each file it generates.
"""
-from builtin_function import *
-import mako.template
+from builtin_function import *
import os
+import six
+from six.moves import range
+
from templates import template_file
tolerances = {'pow': 16.0,
@@ -76,11 +78,11 @@ def make_indexers(signature):
if signature.rettype.num_cols == 1:
col_indexers = ['']
else:
- col_indexers = ['[{0}]'.format(i) for i in xrange(signature.rettype.num_cols)]
+ col_indexers = ['[{0}]'.format(i) for i in range(signature.rettype.num_cols)]
if signature.rettype.num_rows == 1:
row_indexers = ['']
else:
- row_indexers = ['[{0}]'.format(i) for i in xrange(signature.rettype.num_rows)]
+ row_indexers = ['[{0}]'.format(i) for i in range(signature.rettype.num_rows)]
return [col_indexer + row_indexer
for col_indexer in col_indexers for row_indexer in row_indexers]
@@ -122,7 +124,7 @@ def shader_runner_format(values):
def main():
""" Main function """
- for signature, test_vectors in sorted(test_suite.iteritems()):
+ for signature, test_vectors in sorted(six.iteritems(test_suite)):
arg_float_check = tuple(
arg.base_type == glsl_float for arg in signature.argtypes)
# Filter the test vectors down to only those which deal exclusively in float types
@@ -130,7 +132,7 @@ def main():
indexers = make_indexers(signature)
num_elements = signature.rettype.num_cols*signature.rettype.num_rows
invocation = signature.template.format( *['arg{0}'.format(i)
- for i in xrange(len(signature.argtypes))])
+ for i in range(len(signature.argtypes))])
if (signature.rettype.base_type == glsl_float and
arg_float_check and
all(arg_float_check) and
diff --git a/generated_tests/templates/gen_shader_precision_tests/fs.mako b/generated_tests/templates/gen_shader_precision_tests/fs.mako
index 4ea5e50..19ec737 100644
--- a/generated_tests/templates/gen_shader_precision_tests/fs.mako
+++ b/generated_tests/templates/gen_shader_precision_tests/fs.mako
@@ -1,3 +1,6 @@
+<%!
+ from six.moves import range
+%>
[require]
GLSL >= 4.00
@@ -45,13 +48,13 @@ ${', '.join('floatBitsToInt(expected{0})'.format(i) for i in indexers)}\
## check for differences in the sign bit for each result
##
bool signerr = \
-${' || '.join('(resultbits[{0}]>>31 != expectedbits[{0}]>>31)'.format(i) for i in xrange(0, num_elements))}\
+${' || '.join('(resultbits[{0}]>>31 != expectedbits[{0}]>>31)'.format(i) for i in range(0, num_elements))}\
;
##
## calculate the difference between the generated value and the expected value in ulps
##
${signature.rettype} ulps = ${signature.rettype}(\
-${', '.join('abs(resultbits[{0}] - expectedbits[{0}])'.format(i) for i in xrange(0, num_elements))}\
+${', '.join('abs(resultbits[{0}] - expectedbits[{0}])'.format(i) for i in range(0, num_elements))}\
);
##
## find the maximum error in ulps of all the calculations using a nested max() sort
@@ -72,7 +75,7 @@ max(\
% endfor
max(ulps${indexers[len(indexers)-2]}, ulps${indexers[len(indexers)-1]})\
## fill in completing parens
- % for i in xrange(0, num_elements-2):
+ % for i in range(0, num_elements-2):
)\
% endfor
;
@@ -110,7 +113,7 @@ piglit_vertex/float/2
[test]
% for test_num, test_vector in enumerate(test_vectors):
- % for i in xrange(len(test_vector.arguments)):
+ % for i in range(len(test_vector.arguments)):
uniform ${shader_runner_type(signature.argtypes[i])} arg${i} ${shader_runner_format( column_major_values(test_vector.arguments[i]))}
% endfor
uniform ${shader_runner_type(signature.rettype)} expected ${shader_runner_format(column_major_values(test_vector.result))}
diff --git a/generated_tests/templates/gen_shader_precision_tests/gs.mako b/generated_tests/templates/gen_shader_precision_tests/gs.mako
index 2912e55..de4a3c8 100644
--- a/generated_tests/templates/gen_shader_precision_tests/gs.mako
+++ b/generated_tests/templates/gen_shader_precision_tests/gs.mako
@@ -1,3 +1,6 @@
+<%!
+ from six.moves import range
+%>
[require]
GLSL >= 4.00
@@ -51,13 +54,13 @@ ${', '.join('floatBitsToInt(expected{0})'.format(i) for i in indexers)}\
## check for differences in the sign bit for each result
##
bool signerr = \
-${' || '.join('(resultbits[{0}]>>31 != expectedbits[{0}]>>31)'.format(i) for i in xrange(0, num_elements))}\
+${' || '.join('(resultbits[{0}]>>31 != expectedbits[{0}]>>31)'.format(i) for i in range(0, num_elements))}\
;
##
## calculate the difference between the generated value and the expected value in ulps
##
${signature.rettype} ulps = ${signature.rettype}(\
-${', '.join('abs(resultbits[{0}] - expectedbits[{0}])'.format(i) for i in xrange(0, num_elements))}\
+${', '.join('abs(resultbits[{0}] - expectedbits[{0}])'.format(i) for i in range(0, num_elements))}\
);
##
## find the maximum error in ulps of all the calculations using a nested max() sort
@@ -78,7 +81,7 @@ max(\
% endfor
max(ulps${indexers[len(indexers)-2]}, ulps${indexers[len(indexers)-1]})\
## fill in completing parens
- % for i in xrange(0, num_elements-2):
+ % for i in range(0, num_elements-2):
)\
% endfor
;
@@ -129,7 +132,7 @@ piglit_vertex/float/2
[test]
% for test_num, test_vector in enumerate(test_vectors):
- % for i in xrange(len(test_vector.arguments)):
+ % for i in range(len(test_vector.arguments)):
uniform ${shader_runner_type(signature.argtypes[i])} arg${i} ${shader_runner_format( column_major_values(test_vector.arguments[i]))}
% endfor
uniform ${shader_runner_type(signature.rettype)} expected ${shader_runner_format(column_major_values(test_vector.result))}
diff --git a/generated_tests/templates/gen_shader_precision_tests/vs.mako b/generated_tests/templates/gen_shader_precision_tests/vs.mako
index 31b3013..8d8fad6 100644
--- a/generated_tests/templates/gen_shader_precision_tests/vs.mako
+++ b/generated_tests/templates/gen_shader_precision_tests/vs.mako
@@ -1,3 +1,6 @@
+<%!
+ from six.moves import range
+%>
[require]
GLSL >= 4.00
@@ -41,13 +44,13 @@ ${', '.join('floatBitsToInt(expected{0})'.format(i) for i in indexers)}\
## check for differences in the sign bit for each result
##
bool signerr = \
-${' || '.join('(resultbits[{0}]>>31 != expectedbits[{0}]>>31)'.format(i) for i in xrange(0, num_elements))}\
+${' || '.join('(resultbits[{0}]>>31 != expectedbits[{0}]>>31)'.format(i) for i in range(0, num_elements))}\
;
##
## calculate the difference between the generated value and the expected value in ulps
##
${signature.rettype} ulps = ${signature.rettype}(\
-${', '.join('abs(resultbits[{0}] - expectedbits[{0}])'.format(i) for i in xrange(0, num_elements))}\
+${', '.join('abs(resultbits[{0}] - expectedbits[{0}])'.format(i) for i in range(0, num_elements))}\
);
##
## find the maximum error in ulps of all the calculations using a nested max() sort
@@ -68,7 +71,7 @@ max(\
% endfor
max(ulps${indexers[len(indexers)-2]}, ulps${indexers[len(indexers)-1]})\
## fill in completing parens
- % for i in xrange(0, num_elements-2):
+ % for i in range(0, num_elements-2):
)\
% endfor
;
@@ -114,7 +117,7 @@ piglit_vertex/float/2
[test]
% for test_num, test_vector in enumerate(test_vectors):
- % for i in xrange(len(test_vector.arguments)):
+ % for i in range(len(test_vector.arguments)):
uniform ${shader_runner_type(signature.argtypes[i])} arg${i} ${shader_runner_format( column_major_values(test_vector.arguments[i]))}
% endfor
uniform ${shader_runner_type(signature.rettype)} expected ${shader_runner_format(column_major_values(test_vector.result))}
--
2.3.0
More information about the Piglit
mailing list