nir: Add a find_variable_with_[driver_]location helper
We've hand-rolled this loop 10 places and those are just the ones I found easily. Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5966>
This commit is contained in:

committed by
Marge Bot

parent
fc1363cc60
commit
5c5555a862
@@ -55,16 +55,9 @@
|
||||
static nir_variable *
|
||||
get_texcoord(nir_shader *shader)
|
||||
{
|
||||
nir_variable *texcoord = NULL;
|
||||
|
||||
/* find gl_TexCoord, if it exists: */
|
||||
nir_foreach_shader_in_variable(var, shader) {
|
||||
if (var->data.location == VARYING_SLOT_TEX0) {
|
||||
texcoord = var;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
nir_variable *texcoord =
|
||||
nir_find_variable_with_location(shader, nir_var_shader_in,
|
||||
VARYING_SLOT_TEX0);
|
||||
/* otherwise create it: */
|
||||
if (texcoord == NULL) {
|
||||
texcoord = nir_variable_create(shader,
|
||||
|
Reference in New Issue
Block a user