anv/lower_push_constants: fixup for nir_foreach_block()
authorJason Ekstrand <jason.ekstrand@intel.com>
Wed, 20 Apr 2016 04:20:26 +0000 (21:20 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 28 Apr 2016 22:52:17 +0000 (15:52 -0700)
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
src/intel/vulkan/anv_nir_lower_push_constants.c

index 7f875eba97c149fd127d3c6387952042a0b4c30e..2d841009c6f6e70f0f917c2c4e06680a52dfc036 100644 (file)
 
 #include "anv_nir.h"
 
-static bool
-lower_push_constants_block(nir_block *block, void *void_state)
+void
+anv_nir_lower_push_constants(nir_shader *shader)
 {
-   nir_foreach_instr(block, instr) {
-      if (instr->type != nir_instr_type_intrinsic)
+   nir_foreach_function(shader, function) {
+      if (!function->impl)
          continue;
 
-      nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
+      nir_foreach_block(block, function->impl) {
+         nir_foreach_instr(block, instr) {
+            if (instr->type != nir_instr_type_intrinsic)
+               continue;
 
-      /* TODO: Handle indirect push constants */
-      if (intrin->intrinsic != nir_intrinsic_load_push_constant)
-         continue;
+            nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
 
-      assert(intrin->const_index[0] % 4 == 0);
-      assert(intrin->const_index[1] == 128);
+            /* TODO: Handle indirect push constants */
+            if (intrin->intrinsic != nir_intrinsic_load_push_constant)
+               continue;
 
-      /* We just turn them into uniform loads with the appropreate offset */
-      intrin->intrinsic = nir_intrinsic_load_uniform;
-   }
+            assert(intrin->const_index[0] % 4 == 0);
+            assert(intrin->const_index[1] == 128);
 
-   return true;
-}
-
-void
-anv_nir_lower_push_constants(nir_shader *shader)
-{
-   nir_foreach_function(shader, function) {
-      if (function->impl)
-         nir_foreach_block_call(function->impl, lower_push_constants_block, NULL);
+            /* We just turn them into uniform loads */
+            intrin->intrinsic = nir_intrinsic_load_uniform;
+         }
+      }
    }
 }