[Piglit] [PATCH] draw-vertices-2101010: Accept either SNORM conversion formula.
Roland Scheidegger
rscheidegger_lists at hispeed.ch
Fri Dec 29 22:38:44 UTC 2017
I'm pretty sure that helps llvmpipe too.
Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Am 26.12.2017 um 07:55 schrieb Kenneth Graunke:
> OpenGL defines two equations for converting from signed-normalized
> to floating point data. These are:
>
> f = (2c + 1)/(2^b - 1) (equation 2.2)
> f = max{c/2^(b-1) - 1), -1.0} (equation 2.3)
>
> ARB_vertex_type_2_10_10_10_rev specifies equation 2.2 is to be used.
>
> However, OpenGL 4.2 switched to use equation 2.3 in all scenarios.
> This matched an earlier OpenGL ES 3.0 decision to only have one formula,
> as well as a DirectX decision to change to equation 2.3. Some hardware
> also only supports equation 2.3. So, basically no one can rely on
> equation 2.2 happening, and some people do rely on 2.3.
>
> This patch continues to require equation 2.3 for GL 4.2+, but relaxes
> the test to allow either behavior for earlier GL versions.
>
> See the following discussion for more details:
> https://lists.freedesktop.org/archives/mesa-dev/2013-August/042680.html
>
> This makes this test pass on i965 with Haswell and later.
> ---
> .../draw-vertices-2101010.c | 48 ++++++++++++++--------
> 1 file changed, 32 insertions(+), 16 deletions(-)
>
> diff --git a/tests/spec/arb_vertex_type_2_10_10_10_rev/draw-vertices-2101010.c b/tests/spec/arb_vertex_type_2_10_10_10_rev/draw-vertices-2101010.c
> index 661fa9ca2..5ce4c0655 100644
> --- a/tests/spec/arb_vertex_type_2_10_10_10_rev/draw-vertices-2101010.c
> +++ b/tests/spec/arb_vertex_type_2_10_10_10_rev/draw-vertices-2101010.c
> @@ -187,20 +187,28 @@ static void test_int_vertices_abi(float x1, float y1, float x2, float y2, int in
> struct test {
> void (*test)(float x1, float y1, float x2, float y2, int index);
> int index;
> - float expected_color[4];
> + float expected_color_equation_22[4];
> + float expected_color_equation_23[4];
> const char *name;
> };
>
> struct test tests[] = {
> - {test_packed_int_vertices, 0, {1, 1, 1, 1}, "Int vertices - 2/10/10/10"},
> - {test_packed_int_vertices, 1, {1, 1, 1, 1}, "Unsigned Int vertices - 2/10/10/10"},
> - {test_packed_int_color_vertices, 0, {1, 0, 0, 0.333}, "Int Color - 2/10/10/10"},
> - {test_packed_int_color_vertices, 1, {1, 0, 0, 0}, "Unsigned Int Color - 2/10/10/10"},
> - {test_packed_int_color_vertices, 2, {0, 0, 1, 0.333}, "Int BGRA Color - 2/10/10/10"},
> - {test_packed_int_color_vertices, 3, {0, 0, 1, 0}, "Unsigned Int BGRA Color - 2/10/10/10"},
> -
> - {test_int_vertices_abi, 0, {1, 0, 0, 1}, "Int 2/10/10/10 - test ABI" },
> - {test_int_vertices_abi, 1, {1, 0, 0, 1}, "Unsigned 2/10/10/10 - test ABI" },
> + {test_packed_int_vertices, 0, {1, 1, 1, 1}, {1, 1, 1, 1},
> + "Int vertices - 2/10/10/10"},
> + {test_packed_int_vertices, 1, {1, 1, 1, 1}, {1, 1, 1, 1},
> + "Unsigned Int vertices - 2/10/10/10"},
> + {test_packed_int_color_vertices, 0, {1, 0, 0, 0.333}, {1, 0, 0, 0},
> + "Int Color - 2/10/10/10"},
> + {test_packed_int_color_vertices, 1, {1, 0, 0, 0}, {1, 0, 0, 0},
> + "Unsigned Int Color - 2/10/10/10"},
> + {test_packed_int_color_vertices, 2, {0, 0, 1, 0.333}, {0, 0, 1, 0},
> + "Int BGRA Color - 2/10/10/10"},
> + {test_packed_int_color_vertices, 3, {0, 0, 1, 0}, {0, 0, 1, 0},
> + "Unsigned Int BGRA Color - 2/10/10/10"},
> + {test_int_vertices_abi, 0, {1, 0, 0, 1}, {1, 0, 0, 1},
> + "Int 2/10/10/10 - test ABI" },
> + {test_int_vertices_abi, 1, {1, 0, 0, 1}, {1, 0, 0, 1},
> + "Unsigned 2/10/10/10 - test ABI" },
> {0}
> };
>
> @@ -213,7 +221,7 @@ piglit_display(void)
> /* To know what this is all about, see:
> * http://lists.freedesktop.org/archives/mesa-dev/2013-August/042680.html
> */
> - GLboolean snorm_equation_23 = piglit_get_gl_version() >= 42;
> + bool require_snorm_equation_23 = piglit_get_gl_version() >= 42;
>
> glClear(GL_COLOR_BUFFER_BIT);
> glEnableClientState(GL_VERTEX_ARRAY);
> @@ -222,14 +230,22 @@ piglit_display(void)
> for (i = 0; tests[i].test; i++) {
> glBindBuffer(GL_ARRAY_BUFFER, 0);
>
> - if (snorm_equation_23 && fabs(tests[i].expected_color[3] - 0.333) < 0.0001)
> - tests[i].expected_color[3] = 0;
> -
> - printf("%s\n", tests[i].name);
> tests[i].test(x, y, x+20, y+20, tests[i].index);
> if (!piglit_check_gl_error(GL_NO_ERROR))
> piglit_report_result(PIGLIT_FAIL);
> - pass = piglit_probe_pixel_rgba(x+5, y+5, tests[i].expected_color) && pass;
> +
> + printf("%s\n", tests[i].name);
> +
> + if (require_snorm_equation_23) {
> + pass = piglit_probe_pixel_rgba(x+5, y+5, tests[i].expected_color_equation_23) && pass;
> + } else {
> + bool equation_22_pass = piglit_probe_pixel_rgba(x+5, y+5, tests[i].expected_color_equation_22);
> + bool equation_23_pass = piglit_probe_pixel_rgba(x+5, y+5, tests[i].expected_color_equation_23);
> + if (!equation_22_pass && equation_23_pass) {
> + printf("warning: driver uses GL 4.2+ rules for signed normalized to float conversions\n");
> + }
> + pass = (equation_22_pass || equation_23_pass) && pass;
> + }
>
> x += 20;
> if (x > 300) {
>
More information about the Piglit
mailing list