diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index 231147b74ef..1295f34136b 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -421,6 +421,19 @@ nir_find_variable_with_driver_location(nir_shader *shader, return NULL; } +nir_variable * +nir_find_state_variable(nir_shader *s, + gl_state_index16 tokens[STATE_LENGTH]) +{ + nir_foreach_variable_with_modes(var, s, nir_var_uniform) { + if (var->num_state_slots == 1 && + !memcmp(var->state_slots[0].tokens, tokens, + sizeof(var->state_slots[0].tokens))) + return var; + } + return NULL; +} + /* Annoyingly, qsort_r is not in the C standard library and, in particular, we * can't count on it on MSV and Android. So we stuff the CMP function into * each array element. It's a bit messy and burns more memory but the list of diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 96bc3a1f219..9e5b9abe838 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -4061,6 +4061,9 @@ nir_variable *nir_find_variable_with_driver_location(nir_shader *shader, nir_variable_mode mode, unsigned location); +nir_variable *nir_find_state_variable(nir_shader *s, + gl_state_index16 tokens[STATE_LENGTH]); + void nir_sort_variables_with_modes(nir_shader *shader, int (*compar)(const nir_variable *, const nir_variable *), diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c index 31fea0cbf7f..13f2b11dc4d 100644 --- a/src/mesa/main/ffvertex_prog.c +++ b/src/mesa/main/ffvertex_prog.c @@ -293,19 +293,6 @@ struct tnl_program { GLuint color_materials; }; -static nir_variable * -find_state_var(nir_shader *s, - gl_state_index16 tokens[STATE_LENGTH]) -{ - nir_foreach_variable_with_modes(var, s, nir_var_uniform) { - if (var->num_state_slots == 1 && - !memcmp(var->state_slots[0].tokens, tokens, - sizeof(var->state_slots[0].tokens))) - return var; - } - return NULL; -} - static nir_variable * register_state_var(struct tnl_program *p, gl_state_index s0, @@ -319,7 +306,7 @@ register_state_var(struct tnl_program *p, tokens[1] = s1; tokens[2] = s2; tokens[3] = s3; - nir_variable *var = find_state_var(p->b->shader, tokens); + nir_variable *var = nir_find_state_variable(p->b->shader, tokens); if (var) return var;