Takes care of a couple of a very simple import issue, and a couple of complex ones.
The simple one is the unused import of sys. The complex on deals with using 'from builtin_function import *'. This provides the expected glsl_* and helper functions, but it provides unexpected values like numpy as the np namespace. This allows numpy to be used both via the explicit numpy import and np which is exported by built_function. By importing builtin_function as builtin this double import is removed, and all functions provided by builtin_function are explicitly enumerated. Then numpy is imported as np, and all uses of numpy are replaced with np. Signed-off-by: Dylan Baker <[email protected]> --- generated_tests/gen_builtin_uniform_tests.py | 36 +++++++++++++++------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/generated_tests/gen_builtin_uniform_tests.py b/generated_tests/gen_builtin_uniform_tests.py index d89a6f3..e304166 100644 --- a/generated_tests/gen_builtin_uniform_tests.py +++ b/generated_tests/gen_builtin_uniform_tests.py @@ -44,13 +44,14 @@ # With the optional argument --names-only, it only outputs the names # of the files; it doesn't generate them. -from builtin_function import * import abc -import numpy import optparse import os import os.path -import sys + +import numpy as np + +import builtin_function as builtin def compute_offset_and_scale(test_vectors): @@ -60,8 +61,8 @@ def compute_offset_and_scale(test_vectors): used to transform the test vectors so that their outputs can be stored in gl_FragColor without overflow. """ - low = min(numpy.min(tv.result) for tv in test_vectors) - hi = max(numpy.max(tv.result) for tv in test_vectors) + low = min(np.min(tv.result) for tv in test_vectors) + hi = max(np.max(tv.result) for tv in test_vectors) span = hi - low center = (hi + low)/2.0 span *= 2.0 @@ -92,7 +93,7 @@ def shader_runner_type(glsl_type): Boolean values and vectors are converted to ints, and square matrices are written in "matNxN" form. """ - if glsl_type.base_type == glsl_bool: + if glsl_type.base_type == builtin.glsl_bool: if glsl_type.is_scalar: return 'int' else: @@ -162,7 +163,7 @@ class BoolComparator(Comparator): floats representing the expected color produced by the test. """ value = value*1.0 # convert bools to floats - value = column_major_values(value) + value = builtin.column_major_values(value) value += [0.0] * self.__padding return value @@ -186,7 +187,7 @@ class BoolIfComparator(Comparator): output_var = vecp(0.0, 0.0, 1.0, 1.0); """ def __init__(self, signature): - assert signature.rettype == glsl_bool + assert signature.rettype == builtin.glsl_bool self.__padding = 4 - signature.rettype.num_rows def make_result_handler(self, invocation, output_var): @@ -246,7 +247,8 @@ class IntComparator(Comparator): def make_result_test(self, test_num, test_vector, draw): test = 'uniform {0} expected {1}\n'.format( shader_runner_type(self.__signature.rettype), - shader_runner_format(column_major_values(test_vector.result))) + shader_runner_format(builtin.column_major_values( + test_vector.result))) test += draw test += 'probe rgba {0} 0 0.0 1.0 0.0 1.0\n'.format(test_num) return test @@ -313,7 +315,8 @@ class FloatComparator(Comparator): def make_result_test(self, test_num, test_vector, draw): test = 'uniform {0} expected {1}\n'.format( shader_runner_type(self.__signature.rettype), - shader_runner_format(column_major_values(test_vector.result))) + shader_runner_format(builtin.column_major_values( + test_vector.result))) test += 'uniform float tolerance {0}\n'.format( shader_runner_format([test_vector.tolerance])) test += draw @@ -345,11 +348,12 @@ class ShaderTest(object): self._test_vectors = test_vectors if use_if: self._comparator = BoolIfComparator(signature) - elif signature.rettype.base_type == glsl_bool: + elif signature.rettype.base_type == builtin.glsl_bool: self._comparator = BoolComparator(signature) - elif signature.rettype.base_type == glsl_float: + elif signature.rettype.base_type == builtin.glsl_float: self._comparator = FloatComparator(signature) - elif signature.rettype.base_type in (glsl_int, glsl_uint): + elif signature.rettype.base_type in (builtin.glsl_int, + builtin.glsl_uint): self._comparator = IntComparator(signature) else: raise Exception('Unexpected rettype {0}'.format(signature.rettype)) @@ -464,7 +468,7 @@ class ShaderTest(object): test += 'uniform {0} arg{1} {2}\n'.format( shader_runner_type(self._signature.argtypes[i]), i, shader_runner_format( - column_major_values(test_vector.arguments[i]))) + builtin.column_major_values(test_vector.arguments[i]))) # Note: shader_runner uses a 250x250 window so we must # ensure that test_num <= 250. test += self._comparator.make_result_test( @@ -683,8 +687,8 @@ fb tex 2d 0 def all_tests(): for use_if in [False, True]: - for signature, test_vectors in sorted(test_suite.items()): - if use_if and signature.rettype != glsl_bool: + for signature, test_vectors in sorted(builtin.test_suite.items()): + if use_if and signature.rettype != builtin.glsl_bool: continue yield VertexShaderTest(signature, test_vectors, use_if) yield GeometryShaderTest(signature, test_vectors, use_if) -- 2.2.0 _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
