nir/inline: Also rewrite param derefs for texture instructions
authorJason Ekstrand <jason.ekstrand@intel.com>
Wed, 25 May 2016 17:51:33 +0000 (10:51 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Fri, 27 May 2016 17:28:27 +0000 (10:28 -0700)
Without this, samplers get left hanging as derefs to variables that don't
actually exist.

Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
src/compiler/nir/nir_inline_functions.c

index 234453720a946048ecd052f6a05dc086422ebd7e..c36748d6cf5863e815af775cd023d5e216bb1670 100644 (file)
@@ -59,14 +59,28 @@ convert_deref_to_param_deref(nir_instr *instr, nir_deref_var **deref,
 static void
 rewrite_param_derefs(nir_instr *instr, nir_call_instr *call)
 {
-   if (instr->type != nir_instr_type_intrinsic)
-      return;
+   switch (instr->type) {
+   case nir_instr_type_intrinsic: {
+      nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
+
+      for (unsigned i = 0;
+           i < nir_intrinsic_infos[intrin->intrinsic].num_variables; i++) {
+         convert_deref_to_param_deref(instr, &intrin->variables[i], call);
+      }
+      break;
+   }
 
-   nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
+   case nir_instr_type_tex: {
+      nir_tex_instr *tex = nir_instr_as_tex(instr);
+      if (tex->texture)
+         convert_deref_to_param_deref(&tex->instr, &tex->texture, call);
+      if (tex->sampler)
+         convert_deref_to_param_deref(&tex->instr, &tex->sampler, call);
+      break;
+   }
 
-   for (unsigned i = 0;
-        i < nir_intrinsic_infos[intrin->intrinsic].num_variables; i++) {
-      convert_deref_to_param_deref(instr, &intrin->variables[i], call);
+   default:
+      break; /* Nothing else has derefs */
    }
 }