summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2014-08-28 16:01:00 -0700
committerEric Anholt <eric@anholt.net>2015-04-09 23:23:43 -0700
commit6676e180682f7b0130f7964d4e3f13eed6b44e21 (patch)
tree4036f2b52b91e48af967d4e61f65bcfdc3de96f3
parent0240f2aaf58618ab654a05f660f971198cea5a65 (diff)
gen_builtin_uniform_tests.py: Refactor how we generate draws/probes.
I'm going to change our drawing code a bunch, and this structures things to make the functional changes more obvious. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
-rw-r--r--generated_tests/gen_builtin_uniform_tests.py63
1 files changed, 39 insertions, 24 deletions
diff --git a/generated_tests/gen_builtin_uniform_tests.py b/generated_tests/gen_builtin_uniform_tests.py
index 9e2708f1e..0b664c3c9 100644
--- a/generated_tests/gen_builtin_uniform_tests.py
+++ b/generated_tests/gen_builtin_uniform_tests.py
@@ -129,11 +129,15 @@ class Comparator(object):
"""
@abc.abstractmethod
- def make_result_test(self, test_num, test_vector):
- """Return the shader_runner test code that is needed to test a
+ def draw_test(self, test_vector, draw_command):
+ """Return the shader_runner test code that is needed to run a
single test vector.
"""
+ @abc.abstractmethod
+ def result_vector(self, test_vector):
+ """Return the expected result color as a list of floats."""
+
def testname_suffix(self):
"""Return a string to be used as a suffix on the test name to
distinguish it from tests using other comparators."""
@@ -170,12 +174,11 @@ class BoolComparator(Comparator):
value += [0.0] * self.__padding
return value
- def make_result_test(self, test_num, test_vector, draw):
- test = draw
- test += 'probe rgba {0} 0 {1}\n'.format(
- test_num,
- shader_runner_format(self.convert_to_float(test_vector.result)))
- return test
+ def draw_test(self, test_vector, draw_command):
+ return draw_command
+
+ def result_vector(self, test_vector):
+ return self.convert_to_float(test_vector.result)
class BoolIfComparator(Comparator):
@@ -211,12 +214,11 @@ class BoolIfComparator(Comparator):
else:
return [0.0, 0.0, 1.0, 1.0]
- def make_result_test(self, test_num, test_vector, draw):
- test = draw
- test += 'probe rgba {0} 0 {1}\n'.format(
- test_num,
- shader_runner_format(self.convert_to_float(test_vector.result)))
- return test
+ def draw_test(self, test_vector, draw_command):
+ return draw_command
+
+ def result_vector(self, test_vector):
+ return self.convert_to_float(test_vector.result)
def testname_suffix(self):
return '-using-if'
@@ -247,14 +249,16 @@ class IntComparator(Comparator):
red='vec4(1.0, 0.0, 0.0, 1.0)')
return statements
- def make_result_test(self, test_num, test_vector, draw):
+ def draw_test(self, test_vector, draw_command):
test = 'uniform {0} expected {1}\n'.format(
shader_runner_type(self.__signature.rettype),
shader_runner_format(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)
+ test += draw_command
return test
+ def result_vector(self, test_vector):
+ return [0.0, 1.0, 0.0, 1.0]
+
class FloatComparator(Comparator):
"""Comparator that tests functions returning floats or vecs using a
@@ -314,16 +318,18 @@ class FloatComparator(Comparator):
red='vec4(1.0, 0.0, 0.0, 1.0)')
return statements
- def make_result_test(self, test_num, test_vector, draw):
+ def draw_test(self, test_vector, draw_command):
test = 'uniform {0} expected {1}\n'.format(
shader_runner_type(self.__signature.rettype),
shader_runner_format(column_major_values(test_vector.result)))
test += 'uniform float tolerance {0}\n'.format(
shader_runner_format([test_vector.tolerance]))
- test += draw
- test += 'probe rgba {0} 0 0.0 1.0 0.0 1.0\n'.format(test_num)
+ test += draw_command
return test
+ def result_vector(self, test_vector):
+ return [0.0, 1.0, 0.0, 1.0]
+
class ShaderTest(object):
"""Class used to build a test of a single built-in. This is an
@@ -364,6 +370,15 @@ class ShaderTest(object):
def draw_command(self):
return 'draw rect -1 -1 2 2\n'
+ def probe_command(self, test_num, probe_vector):
+ # Note: shader_runner uses a 250x250 window so we must
+ # ensure that test_num <= 250.
+ return 'probe rgb {0} 0 {1} {2} {3} {4}\n'.format(test_num % 250,
+ probe_vector[0],
+ probe_vector[1],
+ probe_vector[2],
+ probe_vector[3])
+
def make_additional_requirements(self):
"""Return a string that should be included in the test's
[require] section.
@@ -466,10 +481,10 @@ class ShaderTest(object):
shader_runner_type(self._signature.argtypes[i]),
i, shader_runner_format(
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(
- test_num % 250, test_vector, self.draw_command())
+ test += self._comparator.draw_test(test_vector,
+ self.draw_command())
+ test += self.probe_command(test_num,
+ self._comparator.result_vector(test_vector))
return test
def filename(self):