nir: Take a nir_shader and variable mode in assign_var_locations
authorJason Ekstrand <jason@jlekstrand.net>
Mon, 20 Jul 2020 19:51:04 +0000 (14:51 -0500)
committerMarge Bot <eric+marge@anholt.net>
Wed, 29 Jul 2020 17:38:58 +0000 (17:38 +0000)
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5966>

src/compiler/nir/nir.h
src/compiler/nir/nir_lower_io.c
src/gallium/drivers/freedreno/ir3/ir3_cmdline.c
src/gallium/drivers/lima/standalone/lima_compiler_cmdline.c
src/mesa/drivers/dri/i965/brw_program.c

index 7c04a773fbc4bfbb62595eaa1ec3da47a6d64317..280f441665377f42ca5a1ec6f160660e204b002d 100644 (file)
@@ -3982,7 +3982,8 @@ void nir_gather_ssa_types(nir_function_impl *impl,
                           BITSET_WORD *float_types,
                           BITSET_WORD *int_types);
 
-void nir_assign_var_locations(struct exec_list *var_list, unsigned *size,
+void nir_assign_var_locations(nir_shader *shader, nir_variable_mode mode,
+                              unsigned *size,
                               int (*type_size)(const struct glsl_type *, bool));
 
 /* Some helpers to do very simple linking */
index b004c62b81e25fc121011f2ef51fcb71f6bdbf90..f8c3fe6153560f71c4e371085c1f751c53701032 100644 (file)
@@ -121,19 +121,13 @@ shared_atomic_for_deref(nir_intrinsic_op deref_op)
 }
 
 void
-nir_assign_var_locations(struct exec_list *var_list, unsigned *size,
+nir_assign_var_locations(nir_shader *shader, nir_variable_mode mode,
+                         unsigned *size,
                          int (*type_size)(const struct glsl_type *, bool))
 {
    unsigned location = 0;
 
-   nir_foreach_variable(var, var_list) {
-      /*
-       * UBOs have their own address spaces, so don't count them towards the
-       * number of global uniforms
-       */
-      if (var->data.mode == nir_var_mem_ubo || var->data.mode == nir_var_mem_ssbo)
-         continue;
-
+   nir_foreach_variable_with_modes(var, shader, mode) {
       var->data.driver_location = location;
       bool bindless_type_size = var->data.mode == nir_var_shader_in ||
                                 var->data.mode == nir_var_shader_out ||
index c9dc7beff36ec23cc6cf6cd7c35a139ad564f376..294fb61e7526438e15671bc7113ac44c8aa2ae1b 100644 (file)
@@ -147,7 +147,7 @@ load_glsl(unsigned num_files, char* const* files, gl_shader_stage stage)
 
        switch (stage) {
        case MESA_SHADER_VERTEX:
-               nir_assign_var_locations(&nir->inputs,
+               nir_assign_var_locations(nir, nir_var_shader_in,
                                &nir->num_inputs,
                                ir3_glsl_type_size);
 
@@ -155,18 +155,18 @@ load_glsl(unsigned num_files, char* const* files, gl_shader_stage stage)
                NIR_PASS_V(nir, nir_lower_global_vars_to_local);
 
                sort_varyings(&nir->outputs);
-               nir_assign_var_locations(&nir->outputs,
+               nir_assign_var_locations(nir, nir_var_shader_out,
                                &nir->num_outputs,
                                ir3_glsl_type_size);
                fixup_varying_slots(&nir->outputs);
                break;
        case MESA_SHADER_FRAGMENT:
                sort_varyings(&nir->inputs);
-               nir_assign_var_locations(&nir->inputs,
+               nir_assign_var_locations(nir, nir_var_shader_in,
                                &nir->num_inputs,
                                ir3_glsl_type_size);
                fixup_varying_slots(&nir->inputs);
-               nir_assign_var_locations(&nir->outputs,
+               nir_assign_var_locations(nir, nir_var_shader_out,
                                &nir->num_outputs,
                                ir3_glsl_type_size);
                break;
@@ -177,7 +177,7 @@ load_glsl(unsigned num_files, char* const* files, gl_shader_stage stage)
                errx(1, "unhandled shader stage: %d", stage);
        }
 
-       nir_assign_var_locations(&nir->uniforms,
+       nir_assign_var_locations(nir, nir_var_uniform,
                        &nir->num_uniforms,
                        ir3_glsl_type_size);
 
index a05caf6e3067060e7235214aae0d15c717a0a071..044bbcccf7db8d5d294f4ec71786cc4869405e99 100644 (file)
@@ -140,30 +140,30 @@ load_glsl(unsigned num_files, char* const* files, gl_shader_stage stage)
 
    switch (stage) {
    case MESA_SHADER_VERTEX:
-      nir_assign_var_locations(&nir->inputs, &nir->num_inputs,
+      nir_assign_var_locations(nir, nir_var_shader_in, &nir->num_inputs,
                                st_glsl_type_size);
 
       /* Re-lower global vars, to deal with any dead VS inputs. */
       NIR_PASS_V(nir, nir_lower_global_vars_to_local);
 
       sort_varyings(&nir->outputs);
-      nir_assign_var_locations(&nir->outputs, &nir->num_outputs,
+      nir_assign_var_locations(nir, nir_var_shader_out, &nir->num_outputs,
                                st_glsl_type_size);
       fixup_varying_slots(&nir->outputs);
       break;
    case MESA_SHADER_FRAGMENT:
       sort_varyings(&nir->inputs);
-      nir_assign_var_locations(&nir->inputs, &nir->num_inputs,
+      nir_assign_var_locations(nir, nir_var_shader_in, &nir->num_inputs,
                                st_glsl_type_size);
       fixup_varying_slots(&nir->inputs);
-      nir_assign_var_locations(&nir->outputs, &nir->num_outputs,
+      nir_assign_var_locations(nir, nir_var_shader_out, &nir->num_outputs,
                                st_glsl_type_size);
       break;
    default:
       errx(1, "unhandled shader stage: %d", stage);
    }
 
-   nir_assign_var_locations(&nir->uniforms,
+   nir_assign_var_locations(nir, nir_var_uniform,
                             &nir->num_uniforms,
                             st_glsl_type_size);
 
index 6bb6f84182d8cadff57cb4bf086f6f9cef7d322b..b3db2cc61bbd8af91e98694f6cc4256c6ac09b51 100644 (file)
@@ -62,11 +62,11 @@ static bool
 brw_nir_lower_uniforms(nir_shader *nir, bool is_scalar)
 {
    if (is_scalar) {
-      nir_assign_var_locations(&nir->uniforms, &nir->num_uniforms,
+      nir_assign_var_locations(nir, nir_var_uniform, &nir->num_uniforms,
                                type_size_scalar_bytes);
       return nir_lower_io(nir, nir_var_uniform, type_size_scalar_bytes, 0);
    } else {
-      nir_assign_var_locations(&nir->uniforms, &nir->num_uniforms,
+      nir_assign_var_locations(nir, nir_var_uniform, &nir->num_uniforms,
                                type_size_vec4_bytes);
       return nir_lower_io(nir, nir_var_uniform, type_size_vec4_bytes, 0);
    }