clover/nir: Use lower_vars_to_explicit for uniform and global
[mesa.git] / src / gallium / frontends / clover / nir / invocation.cpp
index 8ea6d3cf4d08f9b6bbe9cab4d009115e42e17d29..f2c53fc4b22b46c136595dd65c67aefc2b414d3d 100644 (file)
@@ -97,6 +97,7 @@ clover_lower_nir_instr(nir_builder *b, nir_instr *instr, void *_state)
          /* Even though we only place one scalar argument, clover will bind up to
           * three 32 bit values
          */
+         unsigned location = state->args.size();
          state->args.emplace_back(module::argument::scalar, 4, 4, 4,
                                   module::argument::zero_ext,
                                   module::argument::grid_offset);
@@ -106,7 +107,7 @@ clover_lower_nir_instr(nir_builder *b, nir_instr *instr, void *_state)
             state->offset_vars[i] =
                nir_variable_create(b->shader, nir_var_uniform, type,
                                    "global_invocation_id_offsets");
-            state->offset_vars[i]->data.location = b->shader->num_uniforms++;
+            state->offset_vars[i]->data.location = location + i;
          }
       }
 
@@ -219,16 +220,11 @@ module clover::nir::spirv_to_nir(const module &mod, const device &dev,
       auto args = sym.args;
       NIR_PASS_V(nir, clover_lower_nir, args, dev.max_block_size().size());
 
-      // Calculate input offsets.
-      unsigned offset = 0;
-      nir_foreach_uniform_variable(var, nir) {
-         offset = align(offset, glsl_get_cl_alignment(var->type));
-         var->data.driver_location = offset;
-         offset += glsl_get_cl_size(var->type);
-      }
-
+      NIR_PASS_V(nir, nir_lower_mem_constant_vars,
+                 glsl_get_cl_type_size_align);
       NIR_PASS_V(nir, nir_lower_vars_to_explicit_types,
-                 nir_var_mem_shared | nir_var_function_temp,
+                 nir_var_uniform | nir_var_mem_shared |
+                 nir_var_mem_global | nir_var_function_temp,
                  glsl_get_cl_type_size_align);
 
       /* use offsets for kernel inputs (uniform) */