diff options
author | Eric Anholt <eric@anholt.net> | 2014-08-28 16:03:24 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2015-04-10 13:41:29 -0700 |
commit | 2d4b9b84c20d7cba298e8c674b214ae89262730c (patch) | |
tree | 4325babebfa12328ba89e0bd788634a8bc60c2e2 /generated_tests | |
parent | 4868ae91cf5a1605452f3bed5d2adcb7a29b31ce (diff) |
gen_builtin_uniform_tests.py: Draw small rectangles per test, and probe them.
Before, we were drawing the whole window every time, while we only
probed a single pixel. Instead, draw 4x4 rectangles across the
window, and probe the whole rectangle. 4x4 is chosen to at least get
several subspans rendering at the same time, in case drivers have bugs
in that area.
For what the effect looks like on generated shader_test code, before
we had generated tests that looked like:
[...]
draw rect -1 -1 2 2
probe rgb 2 0 0.0 1.0 0.0 1.0
[...]
draw rect -1 -1 2 2
probe rgb 3 0 0.0 1.0 0.0 1.0
and now we have:
[...]
draw rect ortho 8 0 4 4
[...]
draw rect ortho 12 0 4 4
probe rect rgba (8, 0, 4, 4) (0.0, 1.0, 0.0, 1.0)
probe rect rgba (12, 0, 4, 4) (1.0, 1.0, 1.0, 1.0)
Piglit (-t glsl-1.10/execution/built-in-functions/fs-op) runtime effects:
i965: -2.84009% +/- 2.67378% (n=26)
simulated VC4: -99.082% +/- 0.61943% (n=4). (yes, from 15 minutes to 9 seconds)
v2: Use probe rect instead of probe all rgba for the all-the-same-color case,
to avoid spurious failures on windows.
v3: Rebase on CS changes (avoids any generated code difference on CS).
Drop the rest of the read-all-the-screen bits, since I dropped the
window sizing patch to these tests due to issues with Linux window
managers clamping size (not just Windows!).
v4: Reword comment about default window size (Review feedback by Ken).
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> (v2)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'generated_tests')
-rw-r--r-- | generated_tests/gen_builtin_uniform_tests.py | 68 |
1 files changed, 55 insertions, 13 deletions
diff --git a/generated_tests/gen_builtin_uniform_tests.py b/generated_tests/gen_builtin_uniform_tests.py index 0b664c3c9..b0c2e7bf7 100644 --- a/generated_tests/gen_builtin_uniform_tests.py +++ b/generated_tests/gen_builtin_uniform_tests.py @@ -353,6 +353,20 @@ class ShaderTest(object): """ self._signature = signature self._test_vectors = test_vectors + + # Size of the rectangles drawn by the test. + self.rect_width = 4 + self.rect_height = 4 + # shader_runner currently defaults to a 250x250 window. We + # could reduce window size to cut test time, but there are + # platform-dependent limits we haven't really characterized + # (smaller on Linux than Windows, but still present in some + # window managers). + self.win_width = 250 + self.win_height = 250 + self.tests_per_row = (self.win_width // self.rect_width) + self.test_rows = (self.win_height // self.rect_height) + if use_if: self._comparator = BoolIfComparator(signature) elif signature.rettype.base_type == glsl_bool: @@ -367,17 +381,21 @@ class ShaderTest(object): def glsl_version(self): return self._signature.version_introduced - def draw_command(self): - return 'draw rect -1 -1 2 2\n' + def draw_command(self, test_num): + x = (test_num % self.tests_per_row) * self.rect_width + y = (test_num // self.tests_per_row) * self.rect_height + assert(y < self.test_rows) + return 'draw rect ortho {0} {1} {2} {3}\n'.format(x, y, + self.rect_width, + self.rect_height) 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]) + return 'probe rect rgba ({0}, {1}, {2}, {3}) ({4}, {5}, {6}, {7})\n'.format( + (test_num % self.tests_per_row) * self.rect_width, + (test_num // self.tests_per_row) * self.rect_height, + self.rect_width, + self.rect_height, + 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 @@ -431,6 +449,13 @@ class ShaderTest(object): """ return None + def needs_probe_per_draw(self): + """Returns whether the test needs the probe to be immediately after each + + draw call. + """ + return False + def make_test_shader(self, additional_declarations, prefix_statements, output_var, suffix_statements): """Generate the shader code necessary to test the built-in. @@ -482,9 +507,15 @@ class ShaderTest(object): i, shader_runner_format( column_major_values(test_vector.arguments[i]))) test += self._comparator.draw_test(test_vector, - self.draw_command()) - test += self.probe_command(test_num, - self._comparator.result_vector(test_vector)) + self.draw_command(test_num)) + if self.needs_probe_per_draw(): + result_color = self._comparator.result_vector(test_vector) + test += self.probe_command(test_num, result_color) + + if not self.needs_probe_per_draw(): + for test_num, test_vector in enumerate(self._test_vectors): + result_color = self._comparator.result_vector(test_vector) + test += self.probe_command(test_num, result_color) return test def filename(self): @@ -680,9 +711,20 @@ fb tex 2d 0 '''.format(len(self._test_vectors)) - def draw_command(self): + def draw_command(self, test_num): return 'compute 1 1 1\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 needs_probe_per_draw(self): + return True + def all_tests(): for use_if in [False, True]: for signature, test_vectors in sorted(test_suite.items()): |