[Piglit] [PATCH] gen_builtin_uniform_tests.py: Draw small rectangles per test, and probe them.

Kenneth Graunke kenneth at whitecape.org
Fri Apr 10 02:44:39 PDT 2015


On Friday, April 10, 2015 12:19:23 AM Eric Anholt wrote:
> 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)
> 
> or
> 
>     [...]
>     draw rect ortho 8 0 4 4
>     [...]
>     draw rect ortho 12 0 4 4
>     probe all rgba 0.0 1.0 0.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!).
> 
> Reviewed-by: Ian Romanick <ian.d.romanick at intel.com> (v2)
> ---
>  generated_tests/gen_builtin_uniform_tests.py | 65 ++++++++++++++++++++++------
>  1 file changed, 52 insertions(+), 13 deletions(-)
> 
> diff --git a/generated_tests/gen_builtin_uniform_tests.py b/generated_tests/gen_builtin_uniform_tests.py
> index 0b664c3..1b3b95c 100644
> --- a/generated_tests/gen_builtin_uniform_tests.py
> +++ b/generated_tests/gen_builtin_uniform_tests.py
> @@ -353,6 +353,17 @@ 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 always makes a 250x250 window, but
> +        # we may want to change that some day.
> +        self.win_width = 250
> +        self.win_height = 250

That's not actually true - you can put "SIZE width height" in the
[require] section to make whatever size window you like.  Perhaps

# shader_runner defaults to a 250x250 window; we may want to
# change that some day.

> +        self.tests_per_row = (self.win_width // self.rect_width)
> +        self.test_rows = (self.win_height // self.rect_height)

It might make sense to make the window size a multiple of the rectangle
size (i.e. 256x256), but...meh. :)  This'll work fine.

> +
>          if use_if:
>              self._comparator = BoolIfComparator(signature)
>          elif signature.rettype.base_type == glsl_bool:
> @@ -367,17 +378,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])

FWIW, it looks like this needs your patch from August to work -
"shader_runner: Add a non-relative, rgba variant of relative probe rect rgb."

I just sent comments and an R-b for that, in case you still need one.

This patch is also:
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

Sorry for taking over 7 months to look at this, especially when you
explicitly asked me to.  Thanks for Cc'ing me again.

>      def make_additional_requirements(self):
>          """Return a string that should be included in the test's
> @@ -431,6 +446,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 +504,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 +708,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()):
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20150410/d49443fc/attachment.sig>


More information about the Piglit mailing list