[Piglit] [PATCH 2/2] arb_gpu_shader5: Fix rounding instability in UBO and sampler indexing vs-nonuniform-control-flow tests.
Mark Janes
mark.a.janes at intel.com
Tue Jun 30 12:33:04 PDT 2015
Tested-by: Mark Janes <mark.a.janes at intel.com>
Francisco Jerez <currojerez at riseup.net> writes:
> Fixes a rounding instability that would cause shader_runner to probe
> pixels offset by one for some points close to the right edge of the
> window on systems using x87 floating point arithmetic with certain
> compiler versions (the test seemed to work fine when built with GCC
> v5.1.0, but failed on some systems with GCC v4.9.2).
>
> The reason for the instability was that the default window height and
> width of 250 pixels was evenly divisible by all fractions used as
> point coordinates, what would cause the coordinates passed to relative
> rgba probes to lie precisely on the boundary between four pixels,
> giving unpredictable results in presence of the slightest rounding
> error.
>
> Instead use a coprime of 10 as window size to guarantee that there's
> always one fragment closer than the other three. The 1/250 half-pixel
> offset previously used in the vertex shader now becomes unnecessary
> because the different fragment locations are sufficient to guarantee
> consistent rasterization results.
>
> This gets rid of the points which had one of the coordinates equal to
> 0 and replaces them with points close to the top and right edges
> because they would have necessarily been at a half-integer distance
> from the closest fragments regardless of the window size.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90993
> Reported-by: Mark Janes <mark.a.janes at intel.com>
> ---
> .../vs-nonuniform-control-flow.shader_test | 53 ++++++++++++----------
> .../vs-nonuniform-control-flow.shader_test | 53 ++++++++++++----------
> 2 files changed, 58 insertions(+), 48 deletions(-)
>
> diff --git a/tests/spec/arb_gpu_shader5/execution/sampler_array_indexing/vs-nonuniform-control-flow.shader_test b/tests/spec/arb_gpu_shader5/execution/sampler_array_indexing/vs-nonuniform-control-flow.shader_test
> index 1c81186..3945987 100644
> --- a/tests/spec/arb_gpu_shader5/execution/sampler_array_indexing/vs-nonuniform-control-flow.shader_test
> +++ b/tests/spec/arb_gpu_shader5/execution/sampler_array_indexing/vs-nonuniform-control-flow.shader_test
> @@ -17,6 +17,13 @@
> GLSL >= 1.50
> GL_ARB_gpu_shader5
>
> +# Take a coprime of 10 as window size to guarantee that the decimal
> +# fractions used below as point coordinates don't evenly divide the
> +# framebuffer size, what would result in points ending up precisely
> +# halfway from the centers of two fragments causing rounding
> +# instability during rasterization and pixel probes.
> +SIZE 251 251
> +
> [vertex shader]
> #version 150
> #extension GL_ARB_gpu_shader5: require
> @@ -37,9 +44,7 @@ void main()
> v[i] = texture(s[(n + i) % 4u], vec2(0.5, 0.5)).x;
> }
>
> - gl_Position = vec4(-1 + 1.0 / 250.0 + vertex.x * 2,
> - -1 + 1.0 / 250.0 + vertex.y * 2,
> - 0, 1);
> + gl_Position = vec4(-1 + vertex.x * 2, -1 + vertex.y * 2, 0, 1);
> color = v;
> }
>
> @@ -56,54 +61,54 @@ void main()
>
> [vertex data]
> vertex/float/3
> -0.0 0.0 0.0
> -0.0 0.1 0.0
> -0.0 0.2 0.0
> -0.0 0.3 0.0
> -0.0 0.4 0.0
> -0.0 0.5 0.0
> -0.1 0.0 0.0
> 0.1 0.1 0.0
> 0.1 0.2 0.0
> 0.1 0.3 0.0
> 0.1 0.4 0.0
> 0.1 0.5 0.0
> -0.2 0.0 0.0
> +0.1 0.6 0.0
> 0.2 0.1 0.0
> 0.2 0.2 0.0
> 0.2 0.3 0.0
> 0.2 0.4 0.0
> 0.2 0.5 0.0
> -0.3 0.0 0.0
> +0.2 0.6 0.0
> 0.3 0.1 0.0
> 0.3 0.2 0.0
> 0.3 0.3 0.0
> 0.3 0.4 0.0
> 0.3 0.5 0.0
> -0.4 0.0 0.0
> +0.3 0.6 0.0
> 0.4 0.1 0.0
> 0.4 0.2 0.0
> 0.4 0.3 0.0
> 0.4 0.4 0.0
> 0.4 0.5 0.0
> -0.5 0.0 0.0
> +0.4 0.6 0.0
> 0.5 0.1 0.0
> 0.5 0.2 0.0
> 0.5 0.3 0.0
> 0.5 0.4 0.0
> 0.5 0.5 0.0
> -0.6 0.0 0.0
> +0.5 0.6 0.0
> 0.6 0.1 0.0
> 0.6 0.2 0.0
> 0.6 0.3 0.0
> 0.6 0.4 0.0
> 0.6 0.5 0.0
> -0.7 0.0 0.0
> +0.6 0.6 0.0
> 0.7 0.1 0.0
> 0.7 0.2 0.0
> 0.7 0.3 0.0
> 0.7 0.4 0.0
> 0.7 0.5 0.0
> +0.7 0.6 0.0
> +0.8 0.1 0.0
> +0.8 0.2 0.0
> +0.8 0.3 0.0
> +0.8 0.4 0.0
> +0.8 0.5 0.0
> +0.8 0.6 0.0
>
> [test]
> clear color 0.2 0.2 0.2 0.2
> @@ -137,35 +142,35 @@ draw arrays GL_POINTS 0 48
> # the implementation doesn't take this possibility into account.
> # Probe a bunch of pixels for good measure.
> #
> -relative probe rgba (0.0, 0.1) (0.4, 0.6, 0.8, 0.2)
> -relative probe rgba (0.0, 0.2) (0.4, 0.6, 0.8, 0.2)
> -relative probe rgba (0.0, 0.4) (0.4, 0.6, 0.8, 0.2)
> -relative probe rgba (0.0, 0.5) (0.4, 0.6, 0.8, 0.2)
> -relative probe rgba (0.1, 0.0) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.1, 0.2) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.1, 0.3) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.1, 0.5) (0.4, 0.6, 0.8, 0.2)
> +relative probe rgba (0.1, 0.6) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.2, 0.1) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.2, 0.2) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.2, 0.4) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.2, 0.5) (0.4, 0.6, 0.8, 0.2)
> -relative probe rgba (0.3, 0.0) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.3, 0.2) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.3, 0.3) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.3, 0.5) (0.4, 0.6, 0.8, 0.2)
> +relative probe rgba (0.3, 0.6) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.4, 0.1) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.4, 0.2) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.4, 0.4) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.4, 0.5) (0.4, 0.6, 0.8, 0.2)
> -relative probe rgba (0.5, 0.0) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.5, 0.2) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.5, 0.3) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.5, 0.5) (0.4, 0.6, 0.8, 0.2)
> +relative probe rgba (0.5, 0.6) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.6, 0.1) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.6, 0.2) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.6, 0.4) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.6, 0.5) (0.4, 0.6, 0.8, 0.2)
> -relative probe rgba (0.7, 0.0) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.7, 0.2) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.7, 0.3) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.7, 0.5) (0.4, 0.6, 0.8, 0.2)
> +relative probe rgba (0.7, 0.6) (0.4, 0.6, 0.8, 0.2)
> +relative probe rgba (0.8, 0.1) (0.4, 0.6, 0.8, 0.2)
> +relative probe rgba (0.8, 0.2) (0.4, 0.6, 0.8, 0.2)
> +relative probe rgba (0.8, 0.4) (0.4, 0.6, 0.8, 0.2)
> +relative probe rgba (0.8, 0.5) (0.4, 0.6, 0.8, 0.2)
> diff --git a/tests/spec/arb_gpu_shader5/execution/ubo_array_indexing/vs-nonuniform-control-flow.shader_test b/tests/spec/arb_gpu_shader5/execution/ubo_array_indexing/vs-nonuniform-control-flow.shader_test
> index a9d126b..153875c 100644
> --- a/tests/spec/arb_gpu_shader5/execution/ubo_array_indexing/vs-nonuniform-control-flow.shader_test
> +++ b/tests/spec/arb_gpu_shader5/execution/ubo_array_indexing/vs-nonuniform-control-flow.shader_test
> @@ -16,6 +16,13 @@
> GLSL >= 1.50
> GL_ARB_gpu_shader5
>
> +# Take a coprime of 10 as window size to guarantee that the decimal
> +# fractions used below as point coordinates don't evenly divide the
> +# framebuffer size, what would result in points ending up precisely
> +# halfway from the centers of two fragments causing rounding
> +# instability during rasterization and pixel probes.
> +SIZE 251 251
> +
> [vertex shader]
> #version 150
> #extension GL_ARB_gpu_shader5: require
> @@ -38,9 +45,7 @@ void main()
> v[i] = arr[(n + i) % 4u].color.x;
> }
>
> - gl_Position = vec4(-1 + 1.0 / 250.0 + vertex.x * 2,
> - -1 + 1.0 / 250.0 + vertex.y * 2,
> - 0, 1);
> + gl_Position = vec4(-1 + vertex.x * 2, -1 + vertex.y * 2, 0, 1);
> color = v;
> }
>
> @@ -57,54 +62,54 @@ void main()
>
> [vertex data]
> vertex/float/3
> -0.0 0.0 0.0
> -0.0 0.1 0.0
> -0.0 0.2 0.0
> -0.0 0.3 0.0
> -0.0 0.4 0.0
> -0.0 0.5 0.0
> -0.1 0.0 0.0
> 0.1 0.1 0.0
> 0.1 0.2 0.0
> 0.1 0.3 0.0
> 0.1 0.4 0.0
> 0.1 0.5 0.0
> -0.2 0.0 0.0
> +0.1 0.6 0.0
> 0.2 0.1 0.0
> 0.2 0.2 0.0
> 0.2 0.3 0.0
> 0.2 0.4 0.0
> 0.2 0.5 0.0
> -0.3 0.0 0.0
> +0.2 0.6 0.0
> 0.3 0.1 0.0
> 0.3 0.2 0.0
> 0.3 0.3 0.0
> 0.3 0.4 0.0
> 0.3 0.5 0.0
> -0.4 0.0 0.0
> +0.3 0.6 0.0
> 0.4 0.1 0.0
> 0.4 0.2 0.0
> 0.4 0.3 0.0
> 0.4 0.4 0.0
> 0.4 0.5 0.0
> -0.5 0.0 0.0
> +0.4 0.6 0.0
> 0.5 0.1 0.0
> 0.5 0.2 0.0
> 0.5 0.3 0.0
> 0.5 0.4 0.0
> 0.5 0.5 0.0
> -0.6 0.0 0.0
> +0.5 0.6 0.0
> 0.6 0.1 0.0
> 0.6 0.2 0.0
> 0.6 0.3 0.0
> 0.6 0.4 0.0
> 0.6 0.5 0.0
> -0.7 0.0 0.0
> +0.6 0.6 0.0
> 0.7 0.1 0.0
> 0.7 0.2 0.0
> 0.7 0.3 0.0
> 0.7 0.4 0.0
> 0.7 0.5 0.0
> +0.7 0.6 0.0
> +0.8 0.1 0.0
> +0.8 0.2 0.0
> +0.8 0.3 0.0
> +0.8 0.4 0.0
> +0.8 0.5 0.0
> +0.8 0.6 0.0
>
> [test]
> clear color 0.2 0.2 0.2 0.2
> @@ -126,35 +131,35 @@ draw arrays GL_POINTS 0 48
> # the implementation doesn't take this possibility into account.
> # Probe a bunch of pixels for good measure.
> #
> -relative probe rgba (0.0, 0.1) (0.4, 0.6, 0.8, 0.2)
> -relative probe rgba (0.0, 0.2) (0.4, 0.6, 0.8, 0.2)
> -relative probe rgba (0.0, 0.4) (0.4, 0.6, 0.8, 0.2)
> -relative probe rgba (0.0, 0.5) (0.4, 0.6, 0.8, 0.2)
> -relative probe rgba (0.1, 0.0) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.1, 0.2) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.1, 0.3) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.1, 0.5) (0.4, 0.6, 0.8, 0.2)
> +relative probe rgba (0.1, 0.6) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.2, 0.1) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.2, 0.2) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.2, 0.4) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.2, 0.5) (0.4, 0.6, 0.8, 0.2)
> -relative probe rgba (0.3, 0.0) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.3, 0.2) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.3, 0.3) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.3, 0.5) (0.4, 0.6, 0.8, 0.2)
> +relative probe rgba (0.3, 0.6) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.4, 0.1) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.4, 0.2) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.4, 0.4) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.4, 0.5) (0.4, 0.6, 0.8, 0.2)
> -relative probe rgba (0.5, 0.0) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.5, 0.2) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.5, 0.3) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.5, 0.5) (0.4, 0.6, 0.8, 0.2)
> +relative probe rgba (0.5, 0.6) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.6, 0.1) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.6, 0.2) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.6, 0.4) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.6, 0.5) (0.4, 0.6, 0.8, 0.2)
> -relative probe rgba (0.7, 0.0) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.7, 0.2) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.7, 0.3) (0.4, 0.6, 0.8, 0.2)
> relative probe rgba (0.7, 0.5) (0.4, 0.6, 0.8, 0.2)
> +relative probe rgba (0.7, 0.6) (0.4, 0.6, 0.8, 0.2)
> +relative probe rgba (0.8, 0.1) (0.4, 0.6, 0.8, 0.2)
> +relative probe rgba (0.8, 0.2) (0.4, 0.6, 0.8, 0.2)
> +relative probe rgba (0.8, 0.4) (0.4, 0.6, 0.8, 0.2)
> +relative probe rgba (0.8, 0.5) (0.4, 0.6, 0.8, 0.2)
> --
> 2.4.3
More information about the Piglit
mailing list