nir: Add nir_foreach_shader_in/out_variable helpers
authorJason Ekstrand <jason@jlekstrand.net>
Sat, 18 Jul 2020 23:24:25 +0000 (18:24 -0500)
committerMarge Bot <eric+marge@anholt.net>
Wed, 29 Jul 2020 17:38:57 +0000 (17:38 +0000)
Reviewed-by: Jose Maria Casanova Crespo <jmcasanova@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5966>

58 files changed:
src/amd/compiler/aco_instruction_selection_setup.cpp
src/amd/llvm/ac_nir_to_llvm.c
src/amd/vulkan/radv_nir_to_llvm.c
src/amd/vulkan/radv_shader.c
src/amd/vulkan/radv_shader_info.c
src/broadcom/compiler/nir_to_vir.c
src/broadcom/compiler/v3d_nir_lower_io.c
src/broadcom/compiler/v3d_nir_lower_logic_ops.c
src/broadcom/compiler/vir.c
src/compiler/nir/nir.c
src/compiler/nir/nir.h
src/compiler/nir/nir_gather_xfb_info.c
src/compiler/nir/nir_linking_helpers.c
src/compiler/nir/nir_lower_alpha_test.c
src/compiler/nir/nir_lower_bitmap.c
src/compiler/nir/nir_lower_clamp_color_outputs.c
src/compiler/nir/nir_lower_clip.c
src/compiler/nir/nir_lower_clip_disable.c
src/compiler/nir/nir_lower_drawpixels.c
src/compiler/nir/nir_lower_flatshade.c
src/compiler/nir/nir_lower_input_attachments.c
src/compiler/nir/nir_lower_mediump_outputs.c
src/compiler/nir/nir_lower_point_size_mov.c
src/compiler/nir/nir_lower_two_sided_color.c
src/compiler/nir/nir_range_analysis.c
src/freedreno/ir3/ir3_compiler_nir.c
src/freedreno/ir3/ir3_nir.c
src/freedreno/ir3/ir3_nir_lower_tess.c
src/gallium/auxiliary/gallivm/lp_bld_nir.c
src/gallium/auxiliary/nir/nir_draw_helpers.c
src/gallium/auxiliary/nir/nir_to_tgsi_info.c
src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c
src/gallium/drivers/freedreno/a2xx/ir2_nir.c
src/gallium/drivers/iris/iris_program.c
src/gallium/drivers/lima/ir/gp/nir.c
src/gallium/drivers/lima/ir/pp/nir.c
src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
src/gallium/drivers/r600/sfn/sfn_nir.cpp
src/gallium/drivers/radeonsi/si_shader_llvm_vs.c
src/gallium/drivers/radeonsi/si_shader_nir.c
src/gallium/drivers/v3d/v3d_program.c
src/gallium/drivers/vc4/vc4_nir_lower_blend.c
src/gallium/drivers/vc4/vc4_nir_lower_io.c
src/gallium/drivers/vc4/vc4_program.c
src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
src/gallium/drivers/zink/zink_compiler.c
src/gallium/frontends/clover/nir/invocation.cpp
src/intel/compiler/brw_fs.cpp
src/intel/compiler/brw_fs_nir.cpp
src/intel/compiler/brw_interpolation_map.c
src/intel/compiler/brw_nir.c
src/intel/compiler/brw_nir_lower_alpha_to_coverage.c
src/intel/vulkan/anv_nir_lower_multiview.c
src/intel/vulkan/anv_pipeline.c
src/mesa/program/prog_to_nir.c
src/mesa/state_tracker/st_glsl_to_nir.cpp
src/mesa/state_tracker/st_program.c
src/panfrost/midgard/midgard_compile.c

index 0ef682dc1353ad46bfef17a40e4da0eb301acd22..f39f8476b80e5ab13dc402f95755840ef21c3442 100644 (file)
@@ -1103,11 +1103,11 @@ setup_vs_output_info(isel_context *ctx, nir_shader *nir,
 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 @@ void setup_gs_variables(isel_context *ctx, nir_shader *nir)
    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 @@ setup_tcs_info(isel_context *ctx, nir_shader *nir, nir_shader *vs)
 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 @@ setup_tes_variables(isel_context *ctx, nir_shader *nir)
    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 @@ setup_variables(isel_context *ctx, nir_shader *nir)
 {
    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;
index 47539cfb56a1248123311c1ada961a1c26bff6ee..94b920f748a42babdbca575336a1e09afc620fd0 100644 (file)
@@ -5354,7 +5354,7 @@ void ac_nir_translate(struct ac_llvm_context *ac, struct ac_shader_abi *abi,
 
        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);
 
index cc98eef0b9938308e271142a4331625792e6c938..b962f25e6d6d9c540829154dc7e1d5871f60d9d4 100644 (file)
@@ -1367,7 +1367,7 @@ handle_vs_input_decl(struct radv_shader_context *ctx,
 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 @@ prepare_interp_optimize(struct radv_shader_context *ctx,
 {
        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 @@ LLVMModuleRef ac_translate_nir_to_llvm(struct ac_llvm_compiler *ac_llvm,
                        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 @@ radv_compile_gs_copy_shader(struct ac_llvm_compiler *ac_llvm,
 
        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);
index 2c5a89b255924db9b7473c5d3dbd336b77b58ec4..9d5eb0598be119b4bf0b79a5d903541f4b538f42 100644 (file)
@@ -586,7 +586,7 @@ type_size_vec4(const struct glsl_type *type, bool bindless)
 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;
                }
index eca46c811578c44fa102fced0c278fd26190832c..8f2b6a1f5b1f2cfb1f8b3e6378aa6c19ae1735ae 100644 (file)
@@ -679,14 +679,14 @@ radv_nir_shader_info_pass(const struct nir_shader *nir,
                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 ||
index fa4910fea3fc0c60e65cc2f5ae2d3c675c748fc7..17359c72ff160f6e869220b1f1def0d5ef16c037 100644 (file)
@@ -1517,7 +1517,7 @@ ntq_setup_vs_inputs(struct v3d_compile *c)
          * 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 @@ ntq_setup_vs_inputs(struct v3d_compile *c)
 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 @@ get_sorted_input_variables(struct v3d_compile *c,
                            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 @@ ntq_setup_outputs(struct v3d_compile *c)
         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;
 
index 4b616b054a72f856aa6dad198af8db0b63a9a535..4761b58722e08943d932588e2c83134ea4554302 100644 (file)
@@ -173,7 +173,7 @@ v3d_nir_lower_vpm_output(struct v3d_compile *c, nir_builder *b,
         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 @@ static void
 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;
index 832f6bb6a9dc2a3b901feb44bf22b1d2cd7bc6f6..90ee3299c0ee67c965f55a942da8b211f115ea00 100644 (file)
@@ -352,7 +352,7 @@ v3d_nir_lower_logic_ops_block(nir_block *block, struct v3d_compile *c)
                 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;
index 4482f7825a6d31d1336a83962fcd3c233a5bc2dd..44587d3e6e983c2167681b85d3bfe438809f6ed2 100644 (file)
@@ -859,7 +859,7 @@ v3d_nir_lower_gs_early(struct v3d_compile *c)
 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) {
index d6616a80bc80e89125cdcee7700fdf6f5fdc6789..c33cdc690321b85348fd8fd80232d58d000dfafa 100644 (file)
@@ -2209,14 +2209,14 @@ nir_remap_dual_slot_attributes(nir_shader *shader, uint64_t *dual_slot)
    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));
    }
index 02d0a6000dae0807e584af69c27e88c9ad848fcc..b15de3b5dd304cc6b07580675317d94e0abd1d0e 100644 (file)
@@ -624,6 +624,18 @@ typedef struct nir_variable {
 #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)
 {
index 7a3ce7966d39c908900dd4dbc5b6e1b89628b346..46dd598d3e1057b2dd7ef1e71975a21b0056e813 100644 (file)
@@ -202,7 +202,7 @@ nir_gather_xfb_info_with_varyings(const nir_shader *shader,
    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 @@ nir_gather_xfb_info_with_varyings(const nir_shader *shader,
    }
 
    /* 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;
 
index 74508440eb1a744e9c0f3582be93357469ecfbea..d3a249edd82df7aac5ee26aa25ac8c340466982b 100644 (file)
@@ -175,7 +175,7 @@ nir_remove_unused_varyings(nir_shader *producer, nir_shader *consumer)
    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_remove_unused_varyings(nir_shader *producer, nir_shader *consumer)
       }
    }
 
-   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 @@ gather_varying_component_info(nir_shader *producer, nir_shader *consumer,
    /* 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_link_xfb_varyings(nir_shader *producer, nir_shader *consumer)
 {
    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_link_xfb_varyings(nir_shader *producer, nir_shader *consumer)
       }
    }
 
-   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 @@ does_varying_match(nir_variable *out_var, nir_variable *in_var)
 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 @@ nir_assign_linked_io_var_locations(nir_shader *producer, nir_shader *consumer)
    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 @@ nir_assign_linked_io_var_locations(nir_shader *producer, nir_shader *consumer)
    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 @@ nir_assign_linked_io_var_locations(nir_shader *producer, nir_shader *consumer)
    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 @@ nir_assign_linked_io_var_locations(nir_shader *producer, nir_shader *consumer)
          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)
index b652fb796be71cc427c6c1dca30a019d92dcb4ae..29c520cfd9dc46fc7614cf96ef1bb082265c451e 100644 (file)
@@ -61,7 +61,7 @@ nir_lower_alpha_test(nir_shader *shader, enum compare_func func,
                   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;
index 880053d31fee8babb87d2b4557991bf938bd9a21..f9173a64796797220d5a485061bf7b9492cfbe60 100644 (file)
@@ -58,7 +58,7 @@ get_texcoord(nir_shader *shader)
    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;
index 07ed1d7925b2bf279d6fb8a696dc08bc77afae18..e5aa9d994c5d8a29c0dea72abe832088b69d7f99 100644 (file)
@@ -68,7 +68,7 @@ lower_intrinsic(lower_state *state, nir_intrinsic_instr *intr)
       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;
index e0679c65240220903c62e2d88fcba9e2e2a3c03c..3a4775f971b8dbf154519c1068e5327a82ac5dfc 100644 (file)
@@ -184,7 +184,7 @@ find_clipvertex_and_position_outputs(nir_shader *shader,
                                      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 @@ fs_has_clip_dist_input_var(nir_shader *shader, nir_variable **io_vars,
                             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);
index 2925d033bd00494d8227f3f33568e281e07225f5..ae086459c0c1b8788ab6cdce64f09b317b557f83 100644 (file)
@@ -101,7 +101,7 @@ nir_lower_clip_disable(nir_shader *shader, unsigned clip_plane_enable)
 {
    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 */
index f2e64722be8e491d030023f4e0c761bc0e490b4c..b4b2cfd6b83a0f751861973a006b7010d36ae9ce 100644 (file)
@@ -45,7 +45,7 @@ get_texcoord(lower_drawpixels_state *state)
       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 @@ lower_drawpixels_block(lower_drawpixels_state *state, nir_block *block)
             /* 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) <
index 8185784739832406010f0ea7f2bd57344ec299f1..15fbb7d13d5d84cd34ffead9a143f66e9634fe3e 100644 (file)
@@ -42,7 +42,7 @@ nir_lower_flatshade(nir_shader *shader)
 {
    bool progress = false;
 
-   nir_foreach_variable(var, &shader->inputs) {
+   nir_foreach_shader_in_variable(var, shader) {
       progress |= lower_input(shader, var);
    }
 
index 16c7509f5f19f4fb9886abfc48e9a6dfba997a07..75b9e1faff975b0433fa6d0821fc0fdf439674d3 100644 (file)
@@ -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);
    }
index 13c03f9b6245f2f01f13671776f2bbc45c2fcc1d..eabdcbd8dd0b7fb12d58dcf6b8ef855eff4f5462 100644 (file)
@@ -47,7 +47,7 @@ nir_lower_mediump_outputs(nir_shader *nir)
          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 */
 
index f5e18d75baf7026517bfa241540b5c44fcadd08f..efe162c8d8fbd2e7b30f4b8ea7ea5151b6715217 100644 (file)
@@ -72,7 +72,7 @@ nir_lower_point_size_mov(nir_shader *shader,
           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;
index 80cf27f6ffacd6dad981eef776ecb98690681adf..700d759d27fb204efa821bfd9d3dfcad27825ba2 100644 (file)
@@ -69,7 +69,7 @@ create_input(nir_shader *shader, gl_varying_slot slot,
 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 @@ static int
 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:
index 87ee919710d545a900c3176ab4432350ad462cb2..3d2ff8b2c84305a92e8d38da048d1641a9bae346 100644 (file)
@@ -1141,7 +1141,7 @@ search_phi_bcsel(nir_ssa_scalar scalar, nir_ssa_scalar *buf, unsigned buf_size,
 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;
    }
index 8c4df26b99a898924555254d3c80c7c898334d40..77c0b800d9a26c24dec335f9bd50d9f293300c58 100644 (file)
@@ -3342,7 +3342,7 @@ emit_instructions(struct ir3_context *ctx)
        }
 
        /* 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 @@ emit_instructions(struct ir3_context *ctx)
        }
 
        /* Setup outputs: */
-       nir_foreach_variable (var, &ctx->s->outputs) {
+       nir_foreach_shader_out_variable (var, ctx->s) {
                setup_output(ctx, var);
        }
 
index 068191a903ab1b2cdc8f51174e432a3167502788..b4b62ef99b385e88ccff453148c772f8dfab0166 100644 (file)
@@ -310,7 +310,7 @@ static bool
 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;
index 730b550230d24c404af17e78d40d543cec0ee30f..06ae6c6de2cf4e2dc3290b3ab59501f87d2f135d 100644 (file)
@@ -928,8 +928,8 @@ ir3_link_geometry_stages(const struct ir3_shader_variant *producer,
                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;
index 8daa0e09d8d1740e092db4d38428f2d77a431623..d2336c173657024d8dd08ccd9e0ac722c22c86ef 100644 (file)
@@ -1963,7 +1963,7 @@ bool lp_build_nir_llvm(
    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,
index 33fdf4aee690c2800112b271c7f15ca4eb3e2596..3349d0f5eb0fbf23c2774713ba0444b69b636657 100644 (file)
@@ -49,7 +49,7 @@ typedef struct {
 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 @@ nir_lower_aaline_fs(struct nir_shader *shader, int *varying)
       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 @@ nir_lower_aapoint_fs(struct nir_shader *shader, int *varying)
       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)
index b9af10f2ca16583db6153cd78cee16fd648f312b..25b7066bc6e1cfc15461a64dfe0fa1721b7088a8 100644 (file)
@@ -489,7 +489,7 @@ void nir_tgsi_scan_shader(const struct nir_shader *nir,
 
    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 @@ void nir_tgsi_scan_shader(const struct nir_shader *nir,
    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;
index ebaeb7bb5c8f15578b94b9e096fa72e0f34bac20..3352510ac05fdc6473e4a26dd6be186bd5e89f01 100644 (file)
@@ -1068,7 +1068,7 @@ etna_compile_shader_nir(struct etna_shader_variant *v)
    /* 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 @@ etna_compile_shader_nir(struct etna_shader_variant *v)
       }
    } 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;
index 44e53afaa3c5c399de8986dd76052abde78f54b0..88136861871ff1ed4e5a512cd6f325cd81aeabd1 100644 (file)
@@ -127,7 +127,7 @@ ir2_optimize_nir(nir_shader *s, bool lower)
 
        /* 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 @@ load_input(struct ir2_context *ctx, nir_dest *dst, unsigned idx)
        }
 
        /* 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 @@ output_slot(struct ir2_context *ctx, nir_intrinsic_instr *intr)
 {
        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 @@ ir2_nir_compile(struct ir2_context *ctx, bool binning)
        }
 
        /* 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) {
index 91336dfa2fd8cf878d77b6cc2c6dc1012f06d289..0640828ca2c003e6267e7efa74a1bb7b11fce4bf 100644 (file)
@@ -274,7 +274,7 @@ iris_fix_edge_flags(nir_shader *nir)
    }
 
    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;
index 223db082424618b5e5e83ae733875e8ef01a74d5..fd7acc77773aaf2e2ac240afca66f65ff83ff6d1 100644 (file)
@@ -487,7 +487,7 @@ bool gpir_compile_nir(struct lima_vs_shader_state *prog, struct nir_shader *nir,
    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:
index a2f3406e41410ff0bed9e82fae5f5c8fc01e475d..f101cfcd1ef74cd3348608699ef662d2bdbd5c5d 100644 (file)
@@ -916,7 +916,7 @@ bool ppir_compile_nir(struct lima_fs_shader_state *prog, struct nir_shader *nir,
    }
 
    /* 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:
index c5b11726ceca1bb2d3980777bd10bd7da9f29844..4475d7cf8069e419463702120ccb2b52e3d83cf0 100644 (file)
@@ -972,7 +972,7 @@ bool Converter::assignSlots() {
    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 @@ bool Converter::assignSlots() {
       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);
index 0a4246fb0675065e9f4d291ba67e7cc86d54759a..250c9e7d2cfbd92e2a8e387d9d18a6a6dfba27b1 100644 (file)
@@ -266,7 +266,7 @@ bool ShaderFromNir::emit_instruction(nir_instr *instr)
 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 @@ bool ShaderFromNir::process_declaration()
    }
 
    // 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;
index a168cec39d74d68146c4f3eb9ba4cb91a1f574e4..62ec43cd1953537a4a7098010bdf9a968beeffe2 100644 (file)
@@ -235,7 +235,7 @@ void si_llvm_load_vs_inputs(struct si_shader_context *ctx, struct nir_shader *ni
 {
    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;
index f26a93c16bcf3e2a2fa7573e6f27f1117a0ba4ab..395305f7f8aa8aca8c9332591b0588e886e46589 100644 (file)
@@ -610,7 +610,7 @@ void si_nir_scan_shader(const struct nir_shader *nir, struct si_shader_info *inf
 
    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 @@ void si_nir_scan_shader(const struct nir_shader *nir, struct si_shader_info *inf
       }
    }
 
-   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 @@ void si_nir_adjust_driver_locations(struct nir_shader *nir)
     * 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;
 }
 
index 07a596d3eaf9d4b7ee232ce4dba19b01095ee59d..3a431de56bf9a31fac9977e33581eb65eff0a3d8 100644 (file)
@@ -47,7 +47,7 @@ v3d_setup_shared_precompile_key(struct v3d_uncompiled_shader *uncompiled,
 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 @@ precompile_all_outputs(nir_shader *s,
                        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 @@ v3d_shader_precompile(struct v3d_context *v3d,
                         .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) {
index 192abe99291a741fbd5b87eaa187a01b7d68b1e3..dcd0a12373cc01ca0b1672c6b113aa640a7b882e 100644 (file)
@@ -589,7 +589,7 @@ vc4_nir_lower_blend_block(nir_block *block, struct vc4_compile *c)
                         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;
index 39ecfb6e50c3d5f81728eb6dddd1a8a11e4fde89..eb9bcfffd66ec57cff2e4ea2f8b4fd94b9f17ef9 100644 (file)
@@ -240,7 +240,7 @@ vc4_nir_lower_fs_input(struct vc4_compile *c, nir_builder *b,
         }
 
         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 @@ vc4_nir_lower_output(struct vc4_compile *c, nir_builder *b,
                      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;
index 6a429d427b10a05a85b90f85c7e40820dbd104c1..9c89ef6843f35f842f2394a03f24dfb4500193af 100644 (file)
@@ -1580,13 +1580,13 @@ static void
 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 @@ ntq_setup_inputs(struct vc4_compile *c)
 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;
 
index f8abd9016409e9b8061c08061bb7a2969f68b8f7..9fad2bbd433df141f9035c3110a9f1faf77744e1 100644 (file)
@@ -2305,10 +2305,10 @@ nir_to_spirv(struct nir_shader *s, const struct pipe_stream_output_info *so_info
    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)
index a17bc19432e286d8c9018d2002a6cc1baac15d32..865e1409ff774ef5c9563906b9b6041000d12c71 100644 (file)
@@ -183,7 +183,7 @@ optimize_nir(struct nir_shader *s)
 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;
index 8b52379314c0e9142d36de63c5c4fb7e0259c16f..550585375b57baf3c37262f50c1a9c9db8e12b66 100644 (file)
@@ -101,7 +101,7 @@ module clover::nir::spirv_to_nir(const module &mod, const device &dev,
 
       // 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);
index 4ba0c8ed073339cb0bdfdf60eb0228b4ec891571..a89c53ea5a51b19cbae5df7305ec75975ef792f2 100644 (file)
@@ -8335,7 +8335,7 @@ brw_compute_flat_inputs(struct brw_wm_prog_data *prog_data,
 {
    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];
index 15df3dc77634b82999bd21652b024a5aa555a26b..afbb436b95a1a0319fbe71f6a9979e9bb03febf5 100644 (file)
@@ -59,7 +59,7 @@ fs_visitor::nir_setup_outputs()
     * 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)
index 454cc3e2c244bfb8a16e8a351d84266d1f17f919..e7c3919f41f55a4eeb571ba3e35a689f69e0cd9c 100644 (file)
@@ -75,7 +75,7 @@ brw_setup_vue_interpolation(struct brw_vue_map *vue_map, nir_shader *nir,
       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);
 
index 61c1e190b23b63c6fe50f6f8b08de32db14f5b39..22f4d24e2be7424672aba9a09fdb621f66173f4d 100644 (file)
@@ -163,9 +163,8 @@ brw_nir_lower_vs_inputs(nir_shader *nir,
                         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 @@ void
 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 @@ brw_nir_lower_vue_inputs(nir_shader *nir,
 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 @@ brw_nir_lower_fs_inputs(nir_shader *nir,
                         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 @@ brw_nir_lower_fs_inputs(nir_shader *nir,
 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 @@ void
 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 @@ brw_nir_lower_tcs_outputs(nir_shader *nir, const struct brw_vue_map *vue_map,
 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);
index 660d218e7647bee5b7f61d8f548d93c581e880f6..1eed9cd62b4ce2062ab10f207c49ac9c19ea0e6b 100644 (file)
@@ -89,7 +89,7 @@ brw_nir_lower_alpha_to_coverage(nir_shader *shader)
 
    /* 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 @@ brw_nir_lower_alpha_to_coverage(nir_shader *shader)
 
                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;
index d239074c61bc54414ddcd2c9cad76c5637a0a829..75bc01868ba16ab00334b137ba7eb84113cbf9d9 100644 (file)
@@ -172,7 +172,7 @@ lower_multiview_with_primitive_replication(nir_shader *shader,
 
    /* 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 @@ anv_check_for_primitive_replication(nir_shader **shaders,
       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;
index 82a2752b760369a2d28c6e45b40b161bd90d7039..ca265056d70c1499de02ff46d21ae05144a12b0a 100644 (file)
@@ -1013,7 +1013,7 @@ anv_pipeline_link_fs(const struct brw_compiler *compiler,
     */
    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.
        */
index fcdeec1047d269ac79faa5794dc0f93410c50914..67589a8132737af1b8b1f7f8360d0a6cd8a7e350 100644 (file)
@@ -815,7 +815,7 @@ ptn_add_output_stores(struct ptn_compile *c)
 {
    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) {
index 78753f781af40af782ac1226d86a53ec3fcf09ea..6b1c1d6c39131008734c86c367de6ea7565115db 100644 (file)
@@ -107,7 +107,7 @@ st_nir_assign_vs_in_locations(struct nir_shader *nir)
    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.
        */
index 97861cc404e7b9a52b66724e7a532369935e594b..0b5deea61d6b98d6cbe7e6e4771ce4aabbae6ded 100644 (file)
@@ -1285,7 +1285,7 @@ st_create_fp_variant(struct st_context *st,
 
       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;
       }
index bd5377b4a39d41f8885c07edfa536ebe5cdc5a8a..4ca807ab40f33ad2a9e5616668c13af0ebd010e3 100644 (file)
@@ -279,7 +279,7 @@ midgard_nir_lower_zs_store(nir_shader *nir)
 
         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)