nir/drawpixels: handle load_color0, load_input, load_interpolated_input
authorMarek Olšák <marek.olsak@amd.com>
Tue, 1 Oct 2019 01:29:11 +0000 (21:29 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 10 Oct 2019 19:49:18 +0000 (15:49 -0400)
for radeonsi

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/compiler/nir/nir_lower_drawpixels.c

index c4c0c508757ef07dad3af98e8d2033da1bc40dc6..c0da1a4a258c82dad15bbb642b0e53eae4e6a365 100644 (file)
@@ -239,7 +239,9 @@ lower_drawpixels_block(lower_drawpixels_state *state, nir_block *block)
    nir_foreach_instr_safe(instr, block) {
       if (instr->type == nir_instr_type_intrinsic) {
          nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
-         if (intr->intrinsic == nir_intrinsic_load_deref) {
+
+         switch (intr->intrinsic) {
+         case nir_intrinsic_load_deref: {
             nir_deref_instr *deref = nir_src_as_deref(intr->src[0]);
             nir_variable *var = nir_deref_instr_get_variable(deref);
 
@@ -252,6 +254,29 @@ lower_drawpixels_block(lower_drawpixels_state *state, nir_block *block)
                assert(deref->deref_type == nir_deref_type_var);
                lower_texcoord(state, intr);
             }
+            break;
+         }
+
+         case nir_intrinsic_load_color0:
+            lower_color(state, intr);
+            break;
+
+         case nir_intrinsic_load_interpolated_input:
+         case nir_intrinsic_load_input: {
+            /* The intrinsic doesn't carry the variable. We need to find it
+             * manually.
+             */
+            nir_foreach_variable(var, &state->b.shader->inputs) {
+               if ((var->data.driver_location == nir_intrinsic_base(intr)) &&
+                   (nir_intrinsic_component(intr) >= var->data.location_frac  &&
+                    nir_intrinsic_component(intr) <
+                     (var->data.location_frac + glsl_get_components(var->type))))
+                  lower_texcoord(state, intr);
+            }
+            break;
+         }
+         default:
+            break;
          }
       }
    }