nir: Make nir_lower_wpos_ytransform() match FragCoord by location.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 18 May 2016 16:31:49 +0000 (09:31 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Fri, 20 May 2016 21:29:04 +0000 (14:29 -0700)
gl_FragCoord is a shader input with location == VARYING_SLOT_POS.
ARB_fragment_programs have an equivalent input at VARYING_SLOT_POS,
but it isn't called gl_FragCoord.  We do want to transform it.

Matching by location guarantees we catch both.

Fixes several fp tests on a branch which uses this pass on i965.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Rob Clark <robdclark@gmail.com>
src/compiler/nir/nir_lower_wpos_ytransform.c

index 4dc9d950e06e13bd004ca27f78a21ecb08b57f93..c437b3a27970cb0cd562d0fe1f7ec98be978c03f 100644 (file)
@@ -286,7 +286,8 @@ lower_wpos_ytransform_block(lower_wpos_ytransform_state *state, nir_block *block
             nir_deref_var *dvar = intr->variables[0];
             nir_variable *var = dvar->var;
 
-            if (strcmp(var->name, "gl_FragCoord") == 0) {
+            if (var->data.mode == nir_var_shader_in &&
+                var->data.location == VARYING_SLOT_POS) {
                /* gl_FragCoord should not have array/struct deref's: */
                assert(dvar->deref.child == NULL);
                lower_fragcoord(state, intr);