glsl-1.10: Avoid NIR optimization in gl_FrontFacing test
commit372d06b5ff881722b6be64b5e0af000369df8e9e
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 19 Jan 2022 00:23:13 +0000 (18 16:23 -0800)
committerMarge Bot <emma+marge@anholt.net>
Wed, 26 Jan 2022 19:43:00 +0000 (26 19:43 +0000)
tree055106ac37003b386681293a33c44f87a5651ed2
parent30ec7125e83f04edc3a39c517a0526b91ce85854
glsl-1.10: Avoid NIR optimization in gl_FrontFacing test

Use some non-obvious arithmetic to try to avoid some NIR optimizations
that hide a bug in the Intel compiler backend for Gfx12+ (Tigerlake and
newer) GPUs.  Basically, when NIR sees

   x = (gl_FrontFacing ? -1.0 : 1.0) * a;

it converts it to

    x = gl_FrontFacing ? -a : a;

This avoids the bad code generation for the (gl_FrontFacing ? -1.0 :
1.0) case.

v2: Make this a separate test.  Suggested by Marcin.

Reviewed-by: Marcin Ĺšlusarz <marcin.slusarz@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/piglit/-/merge_requests/627>
tests/spec/glsl-1.10/execution/fs-frontfacing-ternary-neg-1.0-1.0-alt.shader_test [new file with mode: 0644]