From: Caio Marcelo de Oliveira Filho Date: Wed, 21 Aug 2019 16:38:10 +0000 (-0700) Subject: mesa/st: Do not rely on name to identify special uniforms X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1a96811fe1059de097a70121a8d1b905089422fd;p=mesa.git mesa/st: Do not rely on name to identify special uniforms Every uniform that have the "gl_" name also have some state slots. So use the state_slots like we did in 57b61849310 ("i965: account for NIR uniforms without name"). This removes the dependency on names, which are optional when using ARB_gl_spirv. Reviewed-by: Alejandro PiƱeiro --- diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp index b9ce22c4a6e..dac5ba2378d 100644 --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp @@ -183,7 +183,7 @@ st_nir_assign_uniform_locations(struct gl_context *ctx, loc = imageidx; imageidx += type_size(uniform->type); } - } else if (strncmp(uniform->name, "gl_", 3) == 0) { + } else if (uniform->state_slots) { const gl_state_index16 *const stateTokens = uniform->state_slots[0].tokens; /* This state reference has already been setup by ir_to_mesa, but we'll * get the same index back here. @@ -409,10 +409,8 @@ st_glsl_to_nir_post_opts(struct st_context *st, struct gl_program *prog, * get sent to the shader. */ nir_foreach_variable(var, &nir->uniforms) { - if (strncmp(var->name, "gl_", 3) == 0) { - const nir_state_slot *const slots = var->state_slots; - assert(var->state_slots != NULL); - + const nir_state_slot *const slots = var->state_slots; + if (slots != NULL) { const struct glsl_type *type = glsl_without_array(var->type); for (unsigned int i = 0; i < var->num_state_slots; i++) { unsigned comps;