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
@@ -586,14 +586,12 @@ type_size_vec4(const struct glsl_type *type, bool bindless)
|
||||
static nir_variable *
|
||||
find_layer_in_var(nir_shader *nir)
|
||||
{
|
||||
nir_foreach_shader_in_variable(var, nir) {
|
||||
if (var->data.location == VARYING_SLOT_LAYER) {
|
||||
return var;
|
||||
}
|
||||
}
|
||||
|
||||
nir_variable *var =
|
||||
nir_variable_create(nir, nir_var_shader_in, glsl_int_type(), "layer id");
|
||||
nir_find_variable_with_location(nir, nir_var_shader_in, VARYING_SLOT_LAYER);
|
||||
if (var != NULL)
|
||||
return var;
|
||||
|
||||
var = nir_variable_create(nir, nir_var_shader_in, glsl_int_type(), "layer id");
|
||||
var->data.location = VARYING_SLOT_LAYER;
|
||||
var->data.interpolation = INTERP_MODE_FLAT;
|
||||
return var;
|
||||
|
Reference in New Issue
Block a user