nir: Add nir_foreach_shader_in/out_variable helpers
Reviewed-by: Jose Maria Casanova Crespo <jmcasanova@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5966>
diff --git a/src/amd/compiler/aco_instruction_selection_setup.cpp b/src/amd/compiler/aco_instruction_selection_setup.cpp
index 0ef682d..f39f847 100644
--- a/src/amd/compiler/aco_instruction_selection_setup.cpp
+++ b/src/amd/compiler/aco_instruction_selection_setup.cpp
@@ -1103,11 +1103,11 @@
void
setup_vs_variables(isel_context *ctx, nir_shader *nir)
{
- nir_foreach_variable(variable, &nir->inputs)
+ nir_foreach_shader_in_variable(variable, nir)
{
variable->data.driver_location = variable->data.location * 4;
}
- nir_foreach_variable(variable, &nir->outputs)
+ nir_foreach_shader_out_variable(variable, nir)
{
if (ctx->stage == vertex_vs || ctx->stage == ngg_vertex_gs)
variable->data.driver_location = variable->data.location * 4;
@@ -1137,7 +1137,7 @@
if (ctx->stage == vertex_geometry_gs || ctx->stage == tess_eval_geometry_gs)
ctx->program->config->lds_size = ctx->program->info->gs_ring_info.lds_size; /* Already in units of the alloc granularity */
- nir_foreach_variable(variable, &nir->outputs) {
+ nir_foreach_shader_out_variable(variable, nir) {
variable->data.driver_location = variable->data.location * 4;
}
@@ -1201,7 +1201,7 @@
void
setup_tcs_variables(isel_context *ctx, nir_shader *nir)
{
- nir_foreach_variable(variable, &nir->outputs) {
+ nir_foreach_shader_out_variable(variable, nir) {
assert(variable->data.location >= 0 && variable->data.location <= UINT8_MAX);
if (variable->data.location == VARYING_SLOT_TESS_LEVEL_OUTER)
@@ -1222,7 +1222,7 @@
ctx->tcs_num_patches = ctx->args->options->key.tes.num_patches;
ctx->tcs_num_outputs = ctx->program->info->tes.num_linked_inputs;
- nir_foreach_variable(variable, &nir->outputs) {
+ nir_foreach_shader_out_variable(variable, nir) {
if (ctx->stage == tess_eval_vs || ctx->stage == ngg_tess_eval_gs)
variable->data.driver_location = variable->data.location * 4;
}
@@ -1239,7 +1239,7 @@
{
switch (nir->info.stage) {
case MESA_SHADER_FRAGMENT: {
- nir_foreach_variable(variable, &nir->outputs)
+ nir_foreach_shader_out_variable(variable, nir)
{
int idx = variable->data.location + variable->data.index;
variable->data.driver_location = idx * 4;
diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c
index 47539cf..94b920f 100644
--- a/src/amd/llvm/ac_nir_to_llvm.c
+++ b/src/amd/llvm/ac_nir_to_llvm.c
@@ -5354,7 +5354,7 @@
ctx.main_function = LLVMGetBasicBlockParent(LLVMGetInsertBlock(ctx.ac.builder));
- nir_foreach_variable(variable, &nir->outputs)
+ nir_foreach_shader_out_variable(variable, nir)
ac_handle_shader_output_decl(&ctx.ac, ctx.abi, nir, variable,
ctx.stage);
diff --git a/src/amd/vulkan/radv_nir_to_llvm.c b/src/amd/vulkan/radv_nir_to_llvm.c
index cc98eef..b962f25 100644
--- a/src/amd/vulkan/radv_nir_to_llvm.c
+++ b/src/amd/vulkan/radv_nir_to_llvm.c
@@ -1367,7 +1367,7 @@
static void
handle_vs_inputs(struct radv_shader_context *ctx,
struct nir_shader *nir) {
- nir_foreach_variable(variable, &nir->inputs)
+ nir_foreach_shader_in_variable(variable, nir)
handle_vs_input_decl(ctx, variable);
}
@@ -1377,7 +1377,7 @@
{
bool uses_center = false;
bool uses_centroid = false;
- nir_foreach_variable(variable, &nir->inputs) {
+ nir_foreach_shader_in_variable(variable, nir) {
if (glsl_get_base_type(glsl_without_array(variable->type)) != GLSL_TYPE_FLOAT ||
variable->data.sample)
continue;
@@ -4090,7 +4090,7 @@
ac_emit_barrier(&ctx.ac, ctx.stage);
}
- nir_foreach_variable(variable, &shaders[i]->outputs)
+ nir_foreach_shader_out_variable(variable, shaders[i])
scan_shader_output_decl(&ctx, variable, shaders[i], shaders[i]->info.stage);
ac_setup_rings(&ctx);
@@ -4409,7 +4409,7 @@
ac_setup_rings(&ctx);
- nir_foreach_variable(variable, &geom_shader->outputs) {
+ nir_foreach_shader_out_variable(variable, geom_shader) {
scan_shader_output_decl(&ctx, variable, geom_shader, MESA_SHADER_VERTEX);
ac_handle_shader_output_decl(&ctx.ac, &ctx.abi, geom_shader,
variable, MESA_SHADER_VERTEX);
diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c
index 2c5a89b..9d5eb05 100644
--- a/src/amd/vulkan/radv_shader.c
+++ b/src/amd/vulkan/radv_shader.c
@@ -586,7 +586,7 @@
static nir_variable *
find_layer_in_var(nir_shader *nir)
{
- nir_foreach_variable(var, &nir->inputs) {
+ nir_foreach_shader_in_variable(var, nir) {
if (var->data.location == VARYING_SLOT_LAYER) {
return var;
}
diff --git a/src/amd/vulkan/radv_shader_info.c b/src/amd/vulkan/radv_shader_info.c
index eca46c8..8f2b6a1 100644
--- a/src/amd/vulkan/radv_shader_info.c
+++ b/src/amd/vulkan/radv_shader_info.c
@@ -679,14 +679,14 @@
info->loads_dynamic_offsets = true;
}
- nir_foreach_variable(variable, &nir->inputs)
+ nir_foreach_shader_in_variable(variable, nir)
gather_info_input_decl(nir, variable, info, key);
nir_foreach_block(block, func->impl) {
gather_info_block(nir, block, info);
}
- nir_foreach_variable(variable, &nir->outputs)
+ nir_foreach_shader_out_variable(variable, nir)
gather_info_output_decl(nir, variable, info, key);
if (nir->info.stage == MESA_SHADER_VERTEX ||
diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c
index fa4910f..17359c7 100644
--- a/src/broadcom/compiler/nir_to_vir.c
+++ b/src/broadcom/compiler/nir_to_vir.c
@@ -1517,7 +1517,7 @@
* from the start of the attribute to the number of components we
* declare we need in c->vattr_sizes[].
*/
- nir_foreach_variable(var, &c->s->inputs) {
+ nir_foreach_shader_in_variable(var, c->s) {
/* No VS attribute array support. */
assert(MAX2(glsl_get_length(var->type), 1) == 1);
@@ -1582,7 +1582,7 @@
static bool
program_reads_point_coord(struct v3d_compile *c)
{
- nir_foreach_variable(var, &c->s->inputs) {
+ nir_foreach_shader_in_variable(var, c->s) {
if (util_varying_is_point_coord(var->data.location,
c->fs_key->point_sprite_mask)) {
return true;
@@ -1598,13 +1598,13 @@
nir_variable ***vars)
{
*num_entries = 0;
- nir_foreach_variable(var, &c->s->inputs)
+ nir_foreach_shader_in_variable(var, c->s)
(*num_entries)++;
*vars = ralloc_array(c, nir_variable *, *num_entries);
unsigned i = 0;
- nir_foreach_variable(var, &c->s->inputs)
+ nir_foreach_shader_in_variable(var, c->s)
(*vars)[i++] = var;
/* Sort the variables so that we emit the input setup in
@@ -1687,7 +1687,7 @@
if (c->s->info.stage != MESA_SHADER_FRAGMENT)
return;
- nir_foreach_variable(var, &c->s->outputs) {
+ nir_foreach_shader_out_variable(var, c->s) {
unsigned array_len = MAX2(glsl_get_length(var->type), 1);
unsigned loc = var->data.driver_location * 4;
diff --git a/src/broadcom/compiler/v3d_nir_lower_io.c b/src/broadcom/compiler/v3d_nir_lower_io.c
index 4b616b0..4761b58 100644
--- a/src/broadcom/compiler/v3d_nir_lower_io.c
+++ b/src/broadcom/compiler/v3d_nir_lower_io.c
@@ -173,7 +173,7 @@
nir_ssa_def *src = nir_ssa_for_src(b, intr->src[0],
intr->num_components);
nir_variable *var = NULL;
- nir_foreach_variable(scan_var, &c->s->outputs) {
+ nir_foreach_shader_out_variable(scan_var, c->s) {
int components = scan_var->data.compact ?
glsl_get_length(scan_var->type) :
glsl_get_components(scan_var->type);
@@ -368,7 +368,7 @@
v3d_nir_lower_io_update_output_var_base(struct v3d_compile *c,
struct v3d_nir_lower_io_state *state)
{
- nir_foreach_variable_safe(var, &c->s->outputs) {
+ nir_foreach_shader_out_variable_safe(var, c->s) {
if (var->data.location == VARYING_SLOT_POS &&
state->pos_vpm_offset != -1) {
var->data.driver_location = state->pos_vpm_offset;
diff --git a/src/broadcom/compiler/v3d_nir_lower_logic_ops.c b/src/broadcom/compiler/v3d_nir_lower_logic_ops.c
index 832f6bb..90ee329 100644
--- a/src/broadcom/compiler/v3d_nir_lower_logic_ops.c
+++ b/src/broadcom/compiler/v3d_nir_lower_logic_ops.c
@@ -352,7 +352,7 @@
if (intr->intrinsic != nir_intrinsic_store_output)
continue;
- nir_foreach_variable(var, &c->s->outputs) {
+ nir_foreach_shader_out_variable(var, c->s) {
const int driver_loc = var->data.driver_location;
if (driver_loc != nir_intrinsic_base(intr))
continue;
diff --git a/src/broadcom/compiler/vir.c b/src/broadcom/compiler/vir.c
index 4482f78..44587d3 100644
--- a/src/broadcom/compiler/vir.c
+++ b/src/broadcom/compiler/vir.c
@@ -859,7 +859,7 @@
static void
v3d_fixup_fs_output_types(struct v3d_compile *c)
{
- nir_foreach_variable(var, &c->s->outputs) {
+ nir_foreach_shader_out_variable(var, c->s) {
uint32_t mask = 0;
switch (var->data.location) {
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index d6616a8..c33cdc6 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -2209,14 +2209,14 @@
assert(shader->info.stage == MESA_SHADER_VERTEX);
*dual_slot = 0;
- nir_foreach_variable(var, &shader->inputs) {
+ nir_foreach_shader_in_variable(var, shader) {
if (glsl_type_is_dual_slot(glsl_without_array(var->type))) {
unsigned slots = glsl_count_attribute_slots(var->type, true);
*dual_slot |= BITFIELD64_MASK(slots) << var->data.location;
}
}
- nir_foreach_variable(var, &shader->inputs) {
+ nir_foreach_shader_in_variable(var, shader) {
var->data.location +=
util_bitcount64(*dual_slot & BITFIELD64_MASK(var->data.location));
}
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 02d0a60..b15de3b 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -624,6 +624,18 @@
#define nir_foreach_variable_safe(var, var_list) \
foreach_list_typed_safe(nir_variable, var, node, var_list)
+#define nir_foreach_shader_in_variable(var, shader) \
+ nir_foreach_variable(var, &(shader)->inputs)
+
+#define nir_foreach_shader_in_variable_safe(var, shader) \
+ nir_foreach_variable_safe(var, &(shader)->inputs)
+
+#define nir_foreach_shader_out_variable(var, shader) \
+ nir_foreach_variable(var, &(shader)->outputs)
+
+#define nir_foreach_shader_out_variable_safe(var, shader) \
+ nir_foreach_variable_safe(var, &(shader)->outputs)
+
static inline bool
nir_variable_is_global(const nir_variable *var)
{
diff --git a/src/compiler/nir/nir_gather_xfb_info.c b/src/compiler/nir/nir_gather_xfb_info.c
index 7a3ce79..46dd598 100644
--- a/src/compiler/nir/nir_gather_xfb_info.c
+++ b/src/compiler/nir/nir_gather_xfb_info.c
@@ -202,7 +202,7 @@
unsigned num_outputs = 0;
unsigned num_varyings = 0;
nir_xfb_varyings_info *varyings_info = NULL;
- nir_foreach_variable(var, &shader->outputs) {
+ nir_foreach_shader_out_variable(var, shader) {
if (var->data.explicit_xfb_buffer) {
num_outputs += glsl_count_attribute_slots(var->type, false);
num_varyings += glsl_varying_count(var->type);
@@ -218,7 +218,7 @@
}
/* Walk the list of outputs and add them to the array */
- nir_foreach_variable(var, &shader->outputs) {
+ nir_foreach_shader_out_variable(var, shader) {
if (!var->data.explicit_xfb_buffer)
continue;
diff --git a/src/compiler/nir/nir_linking_helpers.c b/src/compiler/nir/nir_linking_helpers.c
index 7450844..d3a249e 100644
--- a/src/compiler/nir/nir_linking_helpers.c
+++ b/src/compiler/nir/nir_linking_helpers.c
@@ -175,7 +175,7 @@
uint64_t read[4] = { 0 }, written[4] = { 0 };
uint64_t patches_read[4] = { 0 }, patches_written[4] = { 0 };
- nir_foreach_variable(var, &producer->outputs) {
+ nir_foreach_shader_out_variable(var, producer) {
for (unsigned i = 0; i < get_num_components(var); i++) {
if (var->data.patch) {
patches_written[var->data.location_frac + i] |=
@@ -187,7 +187,7 @@
}
}
- nir_foreach_variable(var, &consumer->inputs) {
+ nir_foreach_shader_in_variable(var, consumer) {
for (unsigned i = 0; i < get_num_components(var); i++) {
if (var->data.patch) {
patches_read[var->data.location_frac + i] |=
@@ -493,7 +493,7 @@
/* Count the number of varying that can be packed and create a mapping
* of those varyings to the array we will pass to qsort.
*/
- nir_foreach_variable(var, &producer->outputs) {
+ nir_foreach_shader_out_variable(var, producer) {
/* Only remap things that aren't builtins. */
if (var->data.location >= VARYING_SLOT_VAR0 &&
@@ -838,7 +838,7 @@
{
nir_variable *input_vars[MAX_VARYING] = { 0 };
- nir_foreach_variable(var, &consumer->inputs) {
+ nir_foreach_shader_in_variable(var, consumer) {
if (var->data.location >= VARYING_SLOT_VAR0 &&
var->data.location - VARYING_SLOT_VAR0 < MAX_VARYING) {
@@ -847,7 +847,7 @@
}
}
- nir_foreach_variable(var, &producer->outputs) {
+ nir_foreach_shader_out_variable(var, producer) {
if (var->data.location >= VARYING_SLOT_VAR0 &&
var->data.location - VARYING_SLOT_VAR0 < MAX_VARYING) {
@@ -872,7 +872,7 @@
static nir_variable *
get_matching_input_var(nir_shader *consumer, nir_variable *out_var)
{
- nir_foreach_variable(var, &consumer->inputs) {
+ nir_foreach_shader_in_variable(var, consumer) {
if (does_varying_match(out_var, var))
return var;
}
@@ -1253,7 +1253,7 @@
uint64_t producer_output_mask = 0;
uint64_t producer_patch_output_mask = 0;
- nir_foreach_variable(variable, &producer->outputs) {
+ nir_foreach_shader_out_variable(variable, producer) {
uint64_t mask = get_linked_variable_io_mask(variable, producer->info.stage);
uint64_t loc = get_linked_variable_location(variable->data.location, variable->data.patch);
@@ -1266,7 +1266,7 @@
uint64_t consumer_input_mask = 0;
uint64_t consumer_patch_input_mask = 0;
- nir_foreach_variable(variable, &consumer->inputs) {
+ nir_foreach_shader_in_variable(variable, consumer) {
uint64_t mask = get_linked_variable_io_mask(variable, consumer->info.stage);
uint64_t loc = get_linked_variable_location(variable->data.location, variable->data.patch);
@@ -1279,7 +1279,7 @@
uint64_t io_mask = producer_output_mask | consumer_input_mask;
uint64_t patch_io_mask = producer_patch_output_mask | consumer_patch_input_mask;
- nir_foreach_variable(variable, &producer->outputs) {
+ nir_foreach_shader_out_variable(variable, producer) {
uint64_t loc = get_linked_variable_location(variable->data.location, variable->data.patch);
if (variable->data.patch)
@@ -1288,7 +1288,7 @@
variable->data.driver_location = util_bitcount64(io_mask & u_bit_consecutive64(0, loc)) * 4;
}
- nir_foreach_variable(variable, &consumer->inputs) {
+ nir_foreach_shader_in_variable(variable, consumer) {
uint64_t loc = get_linked_variable_location(variable->data.location, variable->data.patch);
if (variable->data.patch)
diff --git a/src/compiler/nir/nir_lower_alpha_test.c b/src/compiler/nir/nir_lower_alpha_test.c
index b652fb7..29c520c 100644
--- a/src/compiler/nir/nir_lower_alpha_test.c
+++ b/src/compiler/nir/nir_lower_alpha_test.c
@@ -61,7 +61,7 @@
break;
case nir_intrinsic_store_output:
/* already had i/o lowered.. lookup the matching output var: */
- nir_foreach_variable(var, &shader->outputs) {
+ nir_foreach_shader_out_variable(var, shader) {
int drvloc = var->data.driver_location;
if (nir_intrinsic_base(intr) == drvloc) {
out = var;
diff --git a/src/compiler/nir/nir_lower_bitmap.c b/src/compiler/nir/nir_lower_bitmap.c
index 880053d..f9173a6 100644
--- a/src/compiler/nir/nir_lower_bitmap.c
+++ b/src/compiler/nir/nir_lower_bitmap.c
@@ -58,7 +58,7 @@
nir_variable *texcoord = NULL;
/* find gl_TexCoord, if it exists: */
- nir_foreach_variable(var, &shader->inputs) {
+ nir_foreach_shader_in_variable(var, shader) {
if (var->data.location == VARYING_SLOT_TEX0) {
texcoord = var;
break;
diff --git a/src/compiler/nir/nir_lower_clamp_color_outputs.c b/src/compiler/nir/nir_lower_clamp_color_outputs.c
index 07ed1d7..e5aa9d9 100644
--- a/src/compiler/nir/nir_lower_clamp_color_outputs.c
+++ b/src/compiler/nir/nir_lower_clamp_color_outputs.c
@@ -68,7 +68,7 @@
break;
case nir_intrinsic_store_output:
/* already had i/o lowered.. lookup the matching output var: */
- nir_foreach_variable(var, &state->shader->outputs) {
+ nir_foreach_shader_out_variable(var, state->shader) {
int drvloc = var->data.driver_location;
if (nir_intrinsic_base(intr) == drvloc) {
out = var;
diff --git a/src/compiler/nir/nir_lower_clip.c b/src/compiler/nir/nir_lower_clip.c
index e0679c6..3a4775f 100644
--- a/src/compiler/nir/nir_lower_clip.c
+++ b/src/compiler/nir/nir_lower_clip.c
@@ -184,7 +184,7 @@
nir_variable **clipvertex,
nir_variable **position)
{
- nir_foreach_variable(var, &shader->outputs) {
+ nir_foreach_shader_out_variable(var, shader) {
switch (var->data.location) {
case VARYING_SLOT_POS:
*position = var;
@@ -464,7 +464,7 @@
unsigned *ucp_enables)
{
assert(shader->info.stage == MESA_SHADER_FRAGMENT);
- nir_foreach_variable(var, &shader->inputs) {
+ nir_foreach_shader_in_variable(var, shader) {
switch (var->data.location) {
case VARYING_SLOT_CLIP_DIST0:
assert(var->data.compact);
diff --git a/src/compiler/nir/nir_lower_clip_disable.c b/src/compiler/nir/nir_lower_clip_disable.c
index 2925d03..ae08645 100644
--- a/src/compiler/nir/nir_lower_clip_disable.c
+++ b/src/compiler/nir/nir_lower_clip_disable.c
@@ -101,7 +101,7 @@
{
bool progress = false;
- nir_foreach_variable(var, &shader->outputs) {
+ nir_foreach_shader_out_variable(var, shader) {
if (var->data.location == VARYING_SLOT_CLIP_DIST0) {
unsigned size = glsl_get_length(var->type);
/* if currently-enabled planes match used planes then no-op */
diff --git a/src/compiler/nir/nir_lower_drawpixels.c b/src/compiler/nir/nir_lower_drawpixels.c
index f2e6472..b4b2cfd 100644
--- a/src/compiler/nir/nir_lower_drawpixels.c
+++ b/src/compiler/nir/nir_lower_drawpixels.c
@@ -45,7 +45,7 @@
nir_variable *texcoord = NULL;
/* find gl_TexCoord, if it exists: */
- nir_foreach_variable(var, &state->shader->inputs) {
+ nir_foreach_shader_in_variable(var, state->shader) {
if (var->data.location == VARYING_SLOT_TEX0) {
texcoord = var;
break;
@@ -267,7 +267,7 @@
/* The intrinsic doesn't carry the variable. We need to find it
* manually.
*/
- nir_foreach_variable(var, &state->b.shader->inputs) {
+ nir_foreach_shader_in_variable(var, state->b.shader) {
if ((var->data.driver_location == nir_intrinsic_base(intr)) &&
(nir_intrinsic_component(intr) >= var->data.location_frac &&
nir_intrinsic_component(intr) <
diff --git a/src/compiler/nir/nir_lower_flatshade.c b/src/compiler/nir/nir_lower_flatshade.c
index 8185784..15fbb7d 100644
--- a/src/compiler/nir/nir_lower_flatshade.c
+++ b/src/compiler/nir/nir_lower_flatshade.c
@@ -42,7 +42,7 @@
{
bool progress = false;
- nir_foreach_variable(var, &shader->inputs) {
+ nir_foreach_shader_in_variable(var, shader) {
progress |= lower_input(shader, var);
}
diff --git a/src/compiler/nir/nir_lower_input_attachments.c b/src/compiler/nir/nir_lower_input_attachments.c
index 16c7509..75b9e1f 100644
--- a/src/compiler/nir/nir_lower_input_attachments.c
+++ b/src/compiler/nir/nir_lower_input_attachments.c
@@ -27,7 +27,7 @@
static nir_ssa_def *
load_frag_coord(nir_builder *b)
{
- nir_foreach_variable(var, &b->shader->inputs) {
+ nir_foreach_shader_in_variable(var, b->shader) {
if (var->data.location == VARYING_SLOT_POS)
return nir_load_var(b, var);
}
diff --git a/src/compiler/nir/nir_lower_mediump_outputs.c b/src/compiler/nir/nir_lower_mediump_outputs.c
index 13c03f9..eabdcbd 100644
--- a/src/compiler/nir/nir_lower_mediump_outputs.c
+++ b/src/compiler/nir/nir_lower_mediump_outputs.c
@@ -47,7 +47,7 @@
if (intr->intrinsic != nir_intrinsic_store_output)
continue;
- nir_foreach_variable (var, &nir->outputs) {
+ nir_foreach_shader_out_variable(var, nir) {
if (var->data.driver_location != nir_intrinsic_base(intr))
continue; /* not found yet */
diff --git a/src/compiler/nir/nir_lower_point_size_mov.c b/src/compiler/nir/nir_lower_point_size_mov.c
index f5e18d7..efe162c 100644
--- a/src/compiler/nir/nir_lower_point_size_mov.c
+++ b/src/compiler/nir/nir_lower_point_size_mov.c
@@ -72,7 +72,7 @@
shader->info.stage != MESA_SHADER_COMPUTE);
nir_variable *out = NULL;
- nir_foreach_variable(var, &shader->outputs) {
+ nir_foreach_shader_out_variable(var, shader) {
if (var->data.location == VARYING_SLOT_PSIZ) {
out = var;
break;
diff --git a/src/compiler/nir/nir_lower_two_sided_color.c b/src/compiler/nir/nir_lower_two_sided_color.c
index 80cf27f..700d759 100644
--- a/src/compiler/nir/nir_lower_two_sided_color.c
+++ b/src/compiler/nir/nir_lower_two_sided_color.c
@@ -69,7 +69,7 @@
static nir_variable *
create_face_input(nir_shader *shader)
{
- nir_foreach_variable(var, &shader->inputs) {
+ nir_foreach_shader_in_variable(var, shader) {
if (var->data.location == VARYING_SLOT_FACE)
return var;
}
@@ -108,7 +108,7 @@
setup_inputs(lower_2side_state *state)
{
/* find color inputs: */
- nir_foreach_variable(var, &state->shader->inputs) {
+ nir_foreach_shader_in_variable(var, state->shader) {
switch (var->data.location) {
case VARYING_SLOT_COL0:
case VARYING_SLOT_COL1:
diff --git a/src/compiler/nir/nir_range_analysis.c b/src/compiler/nir/nir_range_analysis.c
index 87ee919..3d2ff8b 100644
--- a/src/compiler/nir/nir_range_analysis.c
+++ b/src/compiler/nir/nir_range_analysis.c
@@ -1141,7 +1141,7 @@
static nir_variable *
lookup_input(nir_shader *shader, unsigned driver_location)
{
- nir_foreach_variable(var, &shader->inputs) {
+ nir_foreach_shader_in_variable(var, shader) {
if (driver_location == var->data.driver_location)
return var;
}
diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c
index 8c4df26..77c0b80 100644
--- a/src/freedreno/ir3/ir3_compiler_nir.c
+++ b/src/freedreno/ir3/ir3_compiler_nir.c
@@ -3342,7 +3342,7 @@
}
/* Setup inputs: */
- nir_foreach_variable (var, &ctx->s->inputs) {
+ nir_foreach_shader_in_variable (var, ctx->s) {
setup_input(ctx, var);
}
@@ -3390,7 +3390,7 @@
}
/* Setup outputs: */
- nir_foreach_variable (var, &ctx->s->outputs) {
+ nir_foreach_shader_out_variable (var, ctx->s) {
setup_output(ctx, var);
}
diff --git a/src/freedreno/ir3/ir3_nir.c b/src/freedreno/ir3/ir3_nir.c
index 068191a..b4b62ef 100644
--- a/src/freedreno/ir3/ir3_nir.c
+++ b/src/freedreno/ir3/ir3_nir.c
@@ -310,7 +310,7 @@
ir3_nir_lower_layer_id(nir_shader *nir)
{
unsigned layer_id_loc = ~0;
- nir_foreach_variable(var, &nir->inputs) {
+ nir_foreach_shader_in_variable(var, nir) {
if (var->data.location == VARYING_SLOT_LAYER) {
layer_id_loc = var->data.driver_location;
break;
diff --git a/src/freedreno/ir3/ir3_nir_lower_tess.c b/src/freedreno/ir3/ir3_nir_lower_tess.c
index 730b550..06ae6c6 100644
--- a/src/freedreno/ir3/ir3_nir_lower_tess.c
+++ b/src/freedreno/ir3/ir3_nir_lower_tess.c
@@ -928,8 +928,8 @@
unreachable("bad shader stage");
}
- nir_foreach_variable(in_var, &consumer->shader->nir->inputs) {
- nir_foreach_variable(out_var, &producer->shader->nir->outputs) {
+ nir_foreach_shader_in_variable(in_var, consumer->shader->nir) {
+ nir_foreach_shader_out_variable(out_var, producer->shader->nir) {
if (in_var->data.location == out_var->data.location) {
locs[in_var->data.driver_location] =
producer->output_loc[out_var->data.driver_location] * factor;
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
index 8daa0e0..d2336c1 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
@@ -1963,7 +1963,7 @@
nir_remove_dead_derefs(nir);
nir_remove_dead_variables(nir, nir_var_function_temp, NULL);
- nir_foreach_variable(variable, &nir->outputs)
+ nir_foreach_shader_out_variable(variable, nir)
handle_shader_output_decl(bld_base, nir, variable);
bld_base->regs = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
diff --git a/src/gallium/auxiliary/nir/nir_draw_helpers.c b/src/gallium/auxiliary/nir/nir_draw_helpers.c
index 33fdf4a..3349d0f 100644
--- a/src/gallium/auxiliary/nir/nir_draw_helpers.c
+++ b/src/gallium/auxiliary/nir/nir_draw_helpers.c
@@ -49,7 +49,7 @@
static nir_ssa_def *
load_frag_coord(nir_builder *b)
{
- nir_foreach_variable(var, &b->shader->inputs) {
+ nir_foreach_shader_in_variable(var, b->shader) {
if (var->data.location == VARYING_SLOT_POS)
return nir_load_var(b, var);
}
@@ -216,7 +216,7 @@
return;
int highest_location = -1, highest_drv_location = -1;
- nir_foreach_variable(var, &shader->inputs) {
+ nir_foreach_shader_in_variable(var, shader) {
if ((int)var->data.location > highest_location)
highest_location = var->data.location;
if ((int)var->data.driver_location > highest_drv_location)
@@ -340,7 +340,7 @@
return;
int highest_location = -1, highest_drv_location = -1;
- nir_foreach_variable(var, &shader->inputs) {
+ nir_foreach_shader_in_variable(var, shader) {
if ((int)var->data.location > highest_location)
highest_location = var->data.location;
if ((int)var->data.driver_location > highest_drv_location)
diff --git a/src/gallium/auxiliary/nir/nir_to_tgsi_info.c b/src/gallium/auxiliary/nir/nir_to_tgsi_info.c
index b9af10f..25b7066 100644
--- a/src/gallium/auxiliary/nir/nir_to_tgsi_info.c
+++ b/src/gallium/auxiliary/nir/nir_to_tgsi_info.c
@@ -489,7 +489,7 @@
i = 0;
uint64_t processed_inputs = 0;
- nir_foreach_variable(variable, &nir->inputs) {
+ nir_foreach_shader_in_variable(variable, nir) {
unsigned semantic_name, semantic_index;
const struct glsl_type *type = variable->type;
@@ -573,7 +573,7 @@
i = 0;
uint64_t processed_outputs = 0;
unsigned num_outputs = 0;
- nir_foreach_variable(variable, &nir->outputs) {
+ nir_foreach_shader_out_variable(variable, nir) {
unsigned semantic_name, semantic_index;
i = variable->data.driver_location;
diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c
index ebaeb7b..3352510 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c
@@ -1068,7 +1068,7 @@
/* setup input linking */
struct etna_shader_io_file *sf = &v->infile;
if (s->info.stage == MESA_SHADER_VERTEX) {
- nir_foreach_variable(var, &s->inputs) {
+ nir_foreach_shader_in_variable(var, s) {
unsigned idx = var->data.driver_location;
sf->reg[idx].reg = idx;
sf->reg[idx].slot = var->data.location;
@@ -1077,7 +1077,7 @@
}
} else {
unsigned count = 0;
- nir_foreach_variable(var, &s->inputs) {
+ nir_foreach_shader_in_variable(var, s) {
unsigned idx = var->data.driver_location;
sf->reg[idx].reg = idx + 1;
sf->reg[idx].slot = var->data.location;
diff --git a/src/gallium/drivers/freedreno/a2xx/ir2_nir.c b/src/gallium/drivers/freedreno/a2xx/ir2_nir.c
index 44e53af..8813686 100644
--- a/src/gallium/drivers/freedreno/a2xx/ir2_nir.c
+++ b/src/gallium/drivers/freedreno/a2xx/ir2_nir.c
@@ -127,7 +127,7 @@
/* TODO we dont want to get shaders writing to depth for depth textures */
if (s->info.stage == MESA_SHADER_FRAGMENT) {
- nir_foreach_variable(var, &s->outputs) {
+ nir_foreach_shader_out_variable(var, s) {
if (var->data.location == FRAG_RESULT_DEPTH)
return -1;
}
@@ -495,7 +495,7 @@
}
/* get slot from idx */
- nir_foreach_variable(var, &ctx->nir->inputs) {
+ nir_foreach_shader_in_variable(var, ctx->nir) {
if (var->data.driver_location == idx) {
slot = var->data.location;
break;
@@ -538,7 +538,7 @@
{
int slot = -1;
unsigned idx = nir_intrinsic_base(intr);
- nir_foreach_variable(var, &ctx->nir->outputs) {
+ nir_foreach_shader_out_variable(var, ctx->nir) {
if (var->data.driver_location == idx) {
slot = var->data.location;
break;
@@ -1129,7 +1129,7 @@
}
/* Setup inputs: */
- nir_foreach_variable(in, &ctx->nir->inputs)
+ nir_foreach_shader_in_variable(in, ctx->nir)
setup_input(ctx, in);
if (so->type == MESA_SHADER_FRAGMENT) {
diff --git a/src/gallium/drivers/iris/iris_program.c b/src/gallium/drivers/iris/iris_program.c
index 91336df..0640828 100644
--- a/src/gallium/drivers/iris/iris_program.c
+++ b/src/gallium/drivers/iris/iris_program.c
@@ -274,7 +274,7 @@
}
nir_variable *var = NULL;
- nir_foreach_variable(v, &nir->outputs) {
+ nir_foreach_shader_out_variable(v, nir) {
if (v->data.location == VARYING_SLOT_EDGE) {
var = v;
break;
diff --git a/src/gallium/drivers/lima/ir/gp/nir.c b/src/gallium/drivers/lima/ir/gp/nir.c
index 223db08..fd7acc7 100644
--- a/src/gallium/drivers/lima/ir/gp/nir.c
+++ b/src/gallium/drivers/lima/ir/gp/nir.c
@@ -487,7 +487,7 @@
if (!gpir_codegen_prog(comp))
goto err_out0;
- nir_foreach_variable(var, &nir->outputs) {
+ nir_foreach_shader_out_variable(var, nir) {
bool varying = true;
switch (var->data.location) {
case VARYING_SLOT_POS:
diff --git a/src/gallium/drivers/lima/ir/pp/nir.c b/src/gallium/drivers/lima/ir/pp/nir.c
index a2f3406..f101cfc 100644
--- a/src/gallium/drivers/lima/ir/pp/nir.c
+++ b/src/gallium/drivers/lima/ir/pp/nir.c
@@ -916,7 +916,7 @@
}
/* Validate outputs, we support only gl_FragColor */
- nir_foreach_variable(var, &nir->outputs) {
+ nir_foreach_shader_out_variable(var, nir) {
switch (var->data.location) {
case FRAG_RESULT_COLOR:
case FRAG_RESULT_DATA0:
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
index c5b1172..4475d7c 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
@@ -972,7 +972,7 @@
if (prog->getType() == Program::TYPE_COMPUTE)
return true;
- nir_foreach_variable(var, &nir->inputs) {
+ nir_foreach_shader_in_variable(var, nir) {
const glsl_type *type = var->type;
int slot = var->data.location;
uint16_t slots = calcSlots(type, prog->getType(), nir->info, true, var);
@@ -1028,7 +1028,7 @@
info->numInputs = std::max<uint8_t>(info->numInputs, vary);
}
- nir_foreach_variable(var, &nir->outputs) {
+ nir_foreach_shader_out_variable(var, nir) {
const glsl_type *type = var->type;
int slot = var->data.location;
uint16_t slots = calcSlots(type, prog->getType(), nir->info, false, var);
diff --git a/src/gallium/drivers/r600/sfn/sfn_nir.cpp b/src/gallium/drivers/r600/sfn/sfn_nir.cpp
index 0a4246f..250c9e7 100644
--- a/src/gallium/drivers/r600/sfn/sfn_nir.cpp
+++ b/src/gallium/drivers/r600/sfn/sfn_nir.cpp
@@ -266,7 +266,7 @@
bool ShaderFromNir::process_declaration()
{
// scan declarations
- nir_foreach_variable(variable, &sh->inputs) {
+ nir_foreach_shader_in_variable(variable, sh) {
if (!impl->process_inputs(variable)) {
fprintf(stderr, "R600: error parsing input varible %s\n", variable->name);
return false;
@@ -274,7 +274,7 @@
}
// scan declarations
- nir_foreach_variable(variable, &sh->outputs) {
+ nir_foreach_shader_out_variable(variable, sh) {
if (!impl->process_outputs(variable)) {
fprintf(stderr, "R600: error parsing outputs varible %s\n", variable->name);
return false;
diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm_vs.c b/src/gallium/drivers/radeonsi/si_shader_llvm_vs.c
index a168cec..62ec43c 100644
--- a/src/gallium/drivers/radeonsi/si_shader_llvm_vs.c
+++ b/src/gallium/drivers/radeonsi/si_shader_llvm_vs.c
@@ -235,7 +235,7 @@
{
uint64_t processed_inputs = 0;
- nir_foreach_variable (variable, &nir->inputs) {
+ nir_foreach_shader_in_variable (variable, nir) {
unsigned attrib_count = glsl_count_attribute_slots(variable->type, true);
unsigned input_idx = variable->data.driver_location;
unsigned loc = variable->data.location;
diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c
index f26a93c..395305f 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -610,7 +610,7 @@
i = 0;
uint64_t processed_inputs = 0;
- nir_foreach_variable (variable, &nir->inputs) {
+ nir_foreach_shader_in_variable (variable, nir) {
unsigned semantic_name, semantic_index;
const struct glsl_type *type = variable->type;
@@ -691,7 +691,7 @@
}
}
- nir_foreach_variable (variable, &nir->outputs) {
+ nir_foreach_shader_out_variable (variable, nir) {
const struct glsl_type *type = variable->type;
if (nir_is_per_vertex_io(variable, nir->info.stage)) {
assert(glsl_type_is_array(type));
@@ -874,11 +874,11 @@
* as individual components.
*/
if (nir->info.stage != MESA_SHADER_FRAGMENT) {
- nir_foreach_variable (variable, &nir->inputs)
+ nir_foreach_shader_in_variable (variable, nir)
variable->data.driver_location *= 4;
}
- nir_foreach_variable (variable, &nir->outputs)
+ nir_foreach_shader_out_variable (variable, nir)
variable->data.driver_location *= 4;
}
diff --git a/src/gallium/drivers/v3d/v3d_program.c b/src/gallium/drivers/v3d/v3d_program.c
index 07a596d..3a431de 100644
--- a/src/gallium/drivers/v3d/v3d_program.c
+++ b/src/gallium/drivers/v3d/v3d_program.c
@@ -47,7 +47,7 @@
static gl_varying_slot
v3d_get_slot_for_driver_location(nir_shader *s, uint32_t driver_location)
{
- nir_foreach_variable(var, &s->outputs) {
+ nir_foreach_shader_out_variable(var, s) {
if (var->data.driver_location == driver_location) {
return var->data.location;
}
@@ -180,7 +180,7 @@
struct v3d_varying_slot *outputs,
uint8_t *num_outputs)
{
- nir_foreach_variable(var, &s->outputs) {
+ nir_foreach_shader_out_variable(var, s) {
const int array_len = MAX2(glsl_get_length(var->type), 1);
for (int j = 0; j < array_len; j++) {
const int slot = var->data.location + j;
@@ -212,7 +212,7 @@
.base.shader_state = so,
};
- nir_foreach_variable(var, &s->outputs) {
+ nir_foreach_shader_out_variable(var, s) {
if (var->data.location == FRAG_RESULT_COLOR) {
key.cbufs |= 1 << 0;
} else if (var->data.location >= FRAG_RESULT_DATA0) {
diff --git a/src/gallium/drivers/vc4/vc4_nir_lower_blend.c b/src/gallium/drivers/vc4/vc4_nir_lower_blend.c
index 192abe9..dcd0a12 100644
--- a/src/gallium/drivers/vc4/vc4_nir_lower_blend.c
+++ b/src/gallium/drivers/vc4/vc4_nir_lower_blend.c
@@ -589,7 +589,7 @@
continue;
nir_variable *output_var = NULL;
- nir_foreach_variable(var, &c->s->outputs) {
+ nir_foreach_shader_out_variable(var, c->s) {
if (var->data.driver_location ==
nir_intrinsic_base(intr)) {
output_var = var;
diff --git a/src/gallium/drivers/vc4/vc4_nir_lower_io.c b/src/gallium/drivers/vc4/vc4_nir_lower_io.c
index 39ecfb6..eb9bcff 100644
--- a/src/gallium/drivers/vc4/vc4_nir_lower_io.c
+++ b/src/gallium/drivers/vc4/vc4_nir_lower_io.c
@@ -240,7 +240,7 @@
}
nir_variable *input_var = NULL;
- nir_foreach_variable(var, &c->s->inputs) {
+ nir_foreach_shader_in_variable(var, c->s) {
if (var->data.driver_location == nir_intrinsic_base(intr)) {
input_var = var;
break;
@@ -291,7 +291,7 @@
nir_intrinsic_instr *intr)
{
nir_variable *output_var = NULL;
- nir_foreach_variable(var, &c->s->outputs) {
+ nir_foreach_shader_out_variable(var, c->s) {
if (var->data.driver_location == nir_intrinsic_base(intr)) {
output_var = var;
break;
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c
index 6a429d4..9c89ef6 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -1580,13 +1580,13 @@
ntq_setup_inputs(struct vc4_compile *c)
{
unsigned num_entries = 0;
- nir_foreach_variable(var, &c->s->inputs)
+ nir_foreach_shader_in_variable(var, c->s)
num_entries++;
nir_variable *vars[num_entries];
unsigned i = 0;
- nir_foreach_variable(var, &c->s->inputs)
+ nir_foreach_shader_in_variable(var, c->s)
vars[i++] = var;
/* Sort the variables so that we emit the input setup in
@@ -1625,7 +1625,7 @@
static void
ntq_setup_outputs(struct vc4_compile *c)
{
- nir_foreach_variable(var, &c->s->outputs) {
+ nir_foreach_shader_out_variable(var, c->s) {
unsigned array_len = MAX2(glsl_get_length(var->type), 1);
unsigned loc = var->data.driver_location * 4;
diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
index f8abd90..9fad2bb 100644
--- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
+++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
@@ -2305,10 +2305,10 @@
ctx.so_outputs = _mesa_hash_table_create(ctx.mem_ctx, _mesa_hash_u32,
_mesa_key_u32_equal);
- nir_foreach_variable(var, &s->inputs)
+ nir_foreach_shader_in_variable(var, s)
emit_input(&ctx, var);
- nir_foreach_variable(var, &s->outputs)
+ nir_foreach_shader_out_variable(var, s)
emit_output(&ctx, var);
if (so_info)
diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c
index a17bc19..865e140 100644
--- a/src/gallium/drivers/zink/zink_compiler.c
+++ b/src/gallium/drivers/zink/zink_compiler.c
@@ -183,7 +183,7 @@
static bool
check_psiz(struct nir_shader *s)
{
- nir_foreach_variable(var, &s->outputs) {
+ nir_foreach_shader_out_variable(var, s) {
if (var->data.location == VARYING_SLOT_PSIZ) {
/* genuine PSIZ outputs will have this set */
return !!var->data.explicit_location;
diff --git a/src/gallium/frontends/clover/nir/invocation.cpp b/src/gallium/frontends/clover/nir/invocation.cpp
index 8b52379..5505853 100644
--- a/src/gallium/frontends/clover/nir/invocation.cpp
+++ b/src/gallium/frontends/clover/nir/invocation.cpp
@@ -101,7 +101,7 @@
// Calculate input offsets.
unsigned offset = 0;
- nir_foreach_variable_safe(var, &nir->inputs) {
+ nir_foreach_shader_in_variable_safe(var, nir) {
offset = align(offset, glsl_get_cl_alignment(var->type));
var->data.driver_location = offset;
offset += glsl_get_cl_size(var->type);
diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp
index 4ba0c8e..a89c53e 100644
--- a/src/intel/compiler/brw_fs.cpp
+++ b/src/intel/compiler/brw_fs.cpp
@@ -8335,7 +8335,7 @@
{
prog_data->flat_inputs = 0;
- nir_foreach_variable(var, &shader->inputs) {
+ nir_foreach_shader_in_variable(var, shader) {
unsigned slots = glsl_count_attribute_slots(var->type, false);
for (unsigned s = 0; s < slots; s++) {
int input_index = prog_data->urb_setup[var->data.location + s];
diff --git a/src/intel/compiler/brw_fs_nir.cpp b/src/intel/compiler/brw_fs_nir.cpp
index 15df3dc..afbb436 100644
--- a/src/intel/compiler/brw_fs_nir.cpp
+++ b/src/intel/compiler/brw_fs_nir.cpp
@@ -59,7 +59,7 @@
* allocating them. With ARB_enhanced_layouts, multiple output variables
* may occupy the same slot, but have different type sizes.
*/
- nir_foreach_variable(var, &nir->outputs) {
+ nir_foreach_shader_out_variable(var, nir) {
const int loc = var->data.driver_location;
const unsigned var_vec4s =
var->data.compact ? DIV_ROUND_UP(glsl_get_length(var->type), 4)
diff --git a/src/intel/compiler/brw_interpolation_map.c b/src/intel/compiler/brw_interpolation_map.c
index 454cc3e..e7c3919 100644
--- a/src/intel/compiler/brw_interpolation_map.c
+++ b/src/intel/compiler/brw_interpolation_map.c
@@ -75,7 +75,7 @@
prog_data->contains_noperspective_varying = true;
}
- foreach_list_typed(nir_variable, var, node, &nir->inputs) {
+ nir_foreach_shader_in_variable(var, nir) {
unsigned location = var->data.location;
unsigned slot_count = glsl_count_attribute_slots(var->type, false);
diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c
index 61c1e19..22f4d24 100644
--- a/src/intel/compiler/brw_nir.c
+++ b/src/intel/compiler/brw_nir.c
@@ -163,9 +163,8 @@
const uint8_t *vs_attrib_wa_flags)
{
/* Start with the location of the variable's base. */
- foreach_list_typed(nir_variable, var, node, &nir->inputs) {
+ nir_foreach_shader_in_variable(var, nir)
var->data.driver_location = var->data.location;
- }
/* Now use nir_lower_io to walk dereference chains. Attribute arrays are
* loaded as one vec4 or dvec4 per element (or matrix column), depending on
@@ -290,9 +289,8 @@
brw_nir_lower_vue_inputs(nir_shader *nir,
const struct brw_vue_map *vue_map)
{
- foreach_list_typed(nir_variable, var, node, &nir->inputs) {
+ nir_foreach_shader_in_variable(var, nir)
var->data.driver_location = var->data.location;
- }
/* Inputs are stored in vec4 slots, so use type_size_vec4(). */
nir_lower_io(nir, nir_var_shader_in, type_size_vec4,
@@ -343,9 +341,8 @@
void
brw_nir_lower_tes_inputs(nir_shader *nir, const struct brw_vue_map *vue_map)
{
- foreach_list_typed(nir_variable, var, node, &nir->inputs) {
+ nir_foreach_shader_in_variable(var, nir)
var->data.driver_location = var->data.location;
- }
nir_lower_io(nir, nir_var_shader_in, type_size_vec4,
nir_lower_io_lower_64bit_to_32);
@@ -372,7 +369,7 @@
const struct gen_device_info *devinfo,
const struct brw_wm_prog_key *key)
{
- foreach_list_typed(nir_variable, var, node, &nir->inputs) {
+ nir_foreach_shader_in_variable(var, nir) {
var->data.driver_location = var->data.location;
/* Apply default interpolation mode.
@@ -416,7 +413,7 @@
void
brw_nir_lower_vue_outputs(nir_shader *nir)
{
- nir_foreach_variable(var, &nir->outputs) {
+ nir_foreach_shader_out_variable(var, nir) {
var->data.driver_location = var->data.location;
}
@@ -428,7 +425,7 @@
brw_nir_lower_tcs_outputs(nir_shader *nir, const struct brw_vue_map *vue_map,
GLenum tes_primitive_mode)
{
- nir_foreach_variable(var, &nir->outputs) {
+ nir_foreach_shader_out_variable(var, nir) {
var->data.driver_location = var->data.location;
}
@@ -454,7 +451,7 @@
void
brw_nir_lower_fs_outputs(nir_shader *nir)
{
- nir_foreach_variable(var, &nir->outputs) {
+ nir_foreach_shader_out_variable(var, nir) {
var->data.driver_location =
SET_FIELD(var->data.index, BRW_NIR_FRAG_OUTPUT_INDEX) |
SET_FIELD(var->data.location, BRW_NIR_FRAG_OUTPUT_LOCATION);
diff --git a/src/intel/compiler/brw_nir_lower_alpha_to_coverage.c b/src/intel/compiler/brw_nir_lower_alpha_to_coverage.c
index 660d218..1eed9cd 100644
--- a/src/intel/compiler/brw_nir_lower_alpha_to_coverage.c
+++ b/src/intel/compiler/brw_nir_lower_alpha_to_coverage.c
@@ -89,7 +89,7 @@
/* Bail out early if we don't have gl_SampleMask */
bool is_sample_mask = false;
- nir_foreach_variable(var, &shader->outputs) {
+ nir_foreach_shader_out_variable(var, shader) {
if (var->data.location == FRAG_RESULT_SAMPLE_MASK) {
is_sample_mask = true;
break;
@@ -115,7 +115,7 @@
switch (intr->intrinsic) {
case nir_intrinsic_store_output:
- nir_foreach_variable(var, &shader->outputs) {
+ nir_foreach_shader_out_variable(var, shader) {
int drvloc = var->data.driver_location;
if (nir_intrinsic_base(intr) == drvloc) {
out = var;
diff --git a/src/intel/vulkan/anv_nir_lower_multiview.c b/src/intel/vulkan/anv_nir_lower_multiview.c
index d239074..75bc018 100644
--- a/src/intel/vulkan/anv_nir_lower_multiview.c
+++ b/src/intel/vulkan/anv_nir_lower_multiview.c
@@ -172,7 +172,7 @@
/* Update position to refer to an array. */
nir_variable *pos_var = NULL;
- nir_foreach_variable(var, &shader->outputs) {
+ nir_foreach_shader_out_variable(var, shader) {
if (var->data.location == VARYING_SLOT_POS) {
assert(var->type == glsl_vec4_type());
var->type = glsl_array_type(glsl_vec4_type(), view_count, 0);
@@ -571,7 +571,7 @@
return false;
bool vs_writes_position = false;
- nir_foreach_variable(var, &shaders[MESA_SHADER_VERTEX]->outputs) {
+ nir_foreach_shader_out_variable(var, shaders[MESA_SHADER_VERTEX]) {
if (var->data.location == VARYING_SLOT_POS) {
vs_writes_position = true;
break;
diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c
index 82a2752..ca26505 100644
--- a/src/intel/vulkan/anv_pipeline.c
+++ b/src/intel/vulkan/anv_pipeline.c
@@ -1013,7 +1013,7 @@
*/
nir_function_impl *impl = nir_shader_get_entrypoint(stage->nir);
bool deleted_output = false;
- nir_foreach_variable_safe(var, &stage->nir->outputs) {
+ nir_foreach_shader_out_variable_safe(var, stage->nir) {
/* TODO: We don't delete depth/stencil writes. We probably could if the
* subpass doesn't have a depth/stencil attachment.
*/
diff --git a/src/mesa/program/prog_to_nir.c b/src/mesa/program/prog_to_nir.c
index fcdeec1..67589a8 100644
--- a/src/mesa/program/prog_to_nir.c
+++ b/src/mesa/program/prog_to_nir.c
@@ -815,7 +815,7 @@
{
nir_builder *b = &c->build;
- nir_foreach_variable(var, &b->shader->outputs) {
+ nir_foreach_shader_out_variable(var, b->shader) {
nir_ssa_def *src = nir_load_reg(b, c->output_regs[var->data.location]);
if (c->prog->Target == GL_FRAGMENT_PROGRAM_ARB &&
var->data.location == FRAG_RESULT_DEPTH) {
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index 78753f7..6b1c1d6 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -107,7 +107,7 @@
bool removed_inputs = false;
nir->num_inputs = util_bitcount64(nir->info.inputs_read);
- nir_foreach_variable_safe(var, &nir->inputs) {
+ nir_foreach_shader_in_variable_safe(var, nir) {
/* NIR already assigns dual-slot inputs to two locations so all we have
* to do is compact everything down.
*/
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 97861cc..0b5deea 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -1285,7 +1285,7 @@
if (key->persample_shading) {
nir_shader *shader = state.ir.nir;
- nir_foreach_variable(var, &shader->inputs)
+ nir_foreach_shader_in_variable(var, shader)
var->data.sample = true;
finalize = true;
}
diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c
index bd5377b..4ca807a 100644
--- a/src/panfrost/midgard/midgard_compile.c
+++ b/src/panfrost/midgard/midgard_compile.c
@@ -279,7 +279,7 @@
nir_variable *z_var = NULL, *s_var = NULL;
- nir_foreach_variable(var, &nir->outputs) {
+ nir_foreach_shader_out_variable(var, nir) {
if (var->data.location == FRAG_RESULT_DEPTH)
z_var = var;
else if (var->data.location == FRAG_RESULT_STENCIL)