Commit 680f4e42 authored by Dylan Baker's avatar Dylan Baker

gen_shader_precision_tests.py: python2/3 hybridize

This produces no changes in output.
Signed-off-by: default avatarDylan Baker <dylanx.c.baker@intel.com>
Reviewed-by: Jordan Justen's avatarJordan Justen <jordan.l.justen@intel.com>
parent c97fd5f9
......@@ -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
......
<%!
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))}
......
<%!
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))}
......
<%!
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))}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment