st/mesa: don't lower_global_vars_to_local for VS if there are no dead inputs
authorMarek Olšák <marek.olsak@amd.com>
Tue, 22 Oct 2019 19:32:17 +0000 (15:32 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 24 Oct 2019 01:12:52 +0000 (21:12 -0400)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/state_tracker/st_glsl_to_nir.cpp

index 0e5bdaea59ddcfaa2f160d162b3e346b054a63d5..6ec14076b582cf4c9c163eea8444fc2e6f3a0ac4 100644 (file)
@@ -86,6 +86,8 @@ st_nir_fixup_varying_slots(struct st_context *st, struct exec_list *var_list)
 static void
 st_nir_assign_vs_in_locations(nir_shader *nir)
 {
+   bool removed_inputs = false;
+
    nir->num_inputs = util_bitcount64(nir->info.inputs_read);
    nir_foreach_variable_safe(var, &nir->inputs) {
       /* NIR already assigns dual-slot inputs to two locations so all we have
@@ -107,8 +109,13 @@ st_nir_assign_vs_in_locations(nir_shader *nir)
          exec_node_remove(&var->node);
          var->data.mode = nir_var_shader_temp;
          exec_list_push_tail(&nir->globals, &var->node);
+         removed_inputs = true;
       }
    }
+
+   /* Re-lower global vars, to deal with any dead VS inputs. */
+   if (removed_inputs)
+      NIR_PASS_V(nir, nir_lower_global_vars_to_local);
 }
 
 static int
@@ -846,8 +853,6 @@ st_nir_assign_varying_locations(struct st_context *st, nir_shader *nir)
    if (nir->info.stage == MESA_SHADER_VERTEX) {
       /* Needs special handling so drvloc matches the vbo state: */
       st_nir_assign_vs_in_locations(nir);
-      /* Re-lower global vars, to deal with any dead VS inputs. */
-      NIR_PASS_V(nir, nir_lower_global_vars_to_local);
 
       nir_assign_io_var_locations(&nir->outputs,
                                   &nir->num_outputs,