Commit 372d06b5 authored by Ian Romanick's avatar Ian Romanick Committed by Marge Bot
Browse files

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's avatarMarcin Ślusarz <marcin.slusarz@intel.com>
Part-of: <!627>
parent 30ec7125
Pipeline #493597 passed with stages
in 11 minutes and 32 seconds
[require]
GLSL >= 1.10
[vertex shader passthrough]
[fragment shader]
uniform vec2 u;
void main()
{
float f = gl_FrontFacing ? -1.0 : 1.0;
// This non-obvious arithmetic is carefully crafted to try to avoid
// some NIR optimizations that hid 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.
f = (f + u.x) * u.y; // Remap (-1.0, 1.0) -> (0.75, 0.25)
gl_FragColor = vec4(0.0, f, 0.0, 1.0);
}
[test]
uniform vec2 u -2.0 -0.25
draw rect -1 -1 2 1
draw rect 1 0 -2 1
relative probe rgba (0, 0) (0.0, 0.75, 0.0, 1.0)
relative probe rgba (1, 0) (0.0, 0.75, 0.0, 1.0)
relative probe rgba (0, 1) (0.0, 0.25, 0.0, 1.0)
relative probe rgba (1, 1) (0.0, 0.25, 0.0, 1.0)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment