Mesa (main): nir/lower_io: Rename vertex_index to array_index in helpers

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jun 9 07:59:52 UTC 2021


Module: Mesa
Branch: main
Commit: a59f1d628afca0cf370e6148d80f86e27ec0c013
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a59f1d628afca0cf370e6148d80f86e27ec0c013

Author: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Date:   Thu Apr 29 14:50:06 2021 -0700

nir/lower_io: Rename vertex_index to array_index in helpers

The helpers will be reused for per-primitive variables that are also
arrayed, so use a more general name.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Timur Kristóf <timur.kristof at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11252>

---

 src/compiler/nir/nir_lower_io.c                    | 70 +++++++++++-----------
 src/compiler/nir/nir_lower_io_arrays_to_elements.c | 16 ++---
 2 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c
index 1c070bc92ba..71043ed39de 100644
--- a/src/compiler/nir/nir_lower_io.c
+++ b/src/compiler/nir/nir_lower_io.c
@@ -178,7 +178,7 @@ static unsigned get_number_of_slots(struct lower_io_state *state,
 
 static nir_ssa_def *
 get_io_offset(nir_builder *b, nir_deref_instr *deref,
-              nir_ssa_def **vertex_index,
+              nir_ssa_def **array_index,
               int (*type_size)(const struct glsl_type *, bool),
               unsigned *component, bool bts)
 {
@@ -188,12 +188,12 @@ get_io_offset(nir_builder *b, nir_deref_instr *deref,
    assert(path.path[0]->deref_type == nir_deref_type_var);
    nir_deref_instr **p = &path.path[1];
 
-   /* For per-vertex input arrays (i.e. geometry shader inputs), keep the
-    * outermost array index separate.  Process the rest normally.
+   /* For arrayed I/O (e.g., per-vertex input arrays in geometry shader
+    * inputs), skip the outermost array index.  Process the rest normally.
     */
-   if (vertex_index != NULL) {
+   if (array_index != NULL) {
       assert((*p)->deref_type == nir_deref_type_array);
-      *vertex_index = nir_ssa_for_src(b, (*p)->arr.index, 1);
+      *array_index = nir_ssa_for_src(b, (*p)->arr.index, 1);
       p++;
    }
 
@@ -241,7 +241,7 @@ get_io_offset(nir_builder *b, nir_deref_instr *deref,
 
 static nir_ssa_def *
 emit_load(struct lower_io_state *state,
-          nir_ssa_def *vertex_index, nir_variable *var, nir_ssa_def *offset,
+          nir_ssa_def *array_index, nir_variable *var, nir_ssa_def *offset,
           unsigned component, unsigned num_components, unsigned bit_size,
           nir_alu_type dest_type)
 {
@@ -257,10 +257,10 @@ emit_load(struct lower_io_state *state,
           nir->options->use_interpolated_input_intrinsics &&
           var->data.interpolation != INTERP_MODE_FLAT) {
          if (var->data.interpolation == INTERP_MODE_EXPLICIT) {
-            assert(vertex_index != NULL);
+            assert(array_index != NULL);
             op = nir_intrinsic_load_input_vertex;
          } else {
-            assert(vertex_index == NULL);
+            assert(array_index == NULL);
 
             nir_intrinsic_op bary_op;
             if (var->data.sample ||
@@ -276,13 +276,13 @@ emit_load(struct lower_io_state *state,
             op = nir_intrinsic_load_interpolated_input;
          }
       } else {
-         op = vertex_index ? nir_intrinsic_load_per_vertex_input :
-                             nir_intrinsic_load_input;
+         op = array_index ? nir_intrinsic_load_per_vertex_input :
+                            nir_intrinsic_load_input;
       }
       break;
    case nir_var_shader_out:
-      op = vertex_index ? nir_intrinsic_load_per_vertex_output :
-                          nir_intrinsic_load_output;
+      op = array_index ? nir_intrinsic_load_per_vertex_output :
+                         nir_intrinsic_load_output;
       break;
    case nir_var_uniform:
       op = nir_intrinsic_load_uniform;
@@ -316,8 +316,8 @@ emit_load(struct lower_io_state *state,
       nir_intrinsic_set_io_semantics(load, semantics);
    }
 
-   if (vertex_index) {
-      load->src[0] = nir_src_for_ssa(vertex_index);
+   if (array_index) {
+      load->src[0] = nir_src_for_ssa(array_index);
       load->src[1] = nir_src_for_ssa(offset);
    } else if (barycentric) {
       load->src[0] = nir_src_for_ssa(barycentric);
@@ -335,7 +335,7 @@ emit_load(struct lower_io_state *state,
 
 static nir_ssa_def *
 lower_load(nir_intrinsic_instr *intrin, struct lower_io_state *state,
-           nir_ssa_def *vertex_index, nir_variable *var, nir_ssa_def *offset,
+           nir_ssa_def *array_index, nir_variable *var, nir_ssa_def *offset,
            unsigned component, const struct glsl_type *type)
 {
    assert(intrin->dest.is_ssa);
@@ -354,7 +354,7 @@ lower_load(nir_intrinsic_instr *intrin, struct lower_io_state *state,
                  (4 - component) / 2);
 
          nir_ssa_def *data32 =
-            emit_load(state, vertex_index, var, offset, component,
+            emit_load(state, array_index, var, offset, component,
                       num_comps * 2, 32, nir_type_uint32);
          for (unsigned i = 0; i < num_comps; i++) {
             comp64[dest_comp + i] =
@@ -372,11 +372,11 @@ lower_load(nir_intrinsic_instr *intrin, struct lower_io_state *state,
       /* Booleans are 32-bit */
       assert(glsl_type_is_boolean(type));
       return nir_b2b1(&state->builder,
-                      emit_load(state, vertex_index, var, offset, component,
+                      emit_load(state, array_index, var, offset, component,
                                 intrin->dest.ssa.num_components, 32,
                                 nir_type_bool32));
    } else {
-      return emit_load(state, vertex_index, var, offset, component,
+      return emit_load(state, array_index, var, offset, component,
                        intrin->dest.ssa.num_components,
                        intrin->dest.ssa.bit_size,
                        nir_get_nir_type_for_glsl_type(type));
@@ -385,16 +385,16 @@ lower_load(nir_intrinsic_instr *intrin, struct lower_io_state *state,
 
 static void
 emit_store(struct lower_io_state *state, nir_ssa_def *data,
-           nir_ssa_def *vertex_index, nir_variable *var, nir_ssa_def *offset,
+           nir_ssa_def *array_index, nir_variable *var, nir_ssa_def *offset,
            unsigned component, unsigned num_components,
            nir_component_mask_t write_mask, nir_alu_type src_type)
 {
    nir_builder *b = &state->builder;
 
    assert(var->data.mode == nir_var_shader_out);
-   nir_intrinsic_op op;
-   op = vertex_index ? nir_intrinsic_store_per_vertex_output :
-                       nir_intrinsic_store_output;
+   nir_intrinsic_op op =
+      array_index ? nir_intrinsic_store_per_vertex_output :
+                    nir_intrinsic_store_output;
 
    nir_intrinsic_instr *store =
       nir_intrinsic_instr_create(state->builder.shader, op);
@@ -408,10 +408,10 @@ emit_store(struct lower_io_state *state, nir_ssa_def *data,
 
    nir_intrinsic_set_write_mask(store, write_mask);
 
-   if (vertex_index)
-      store->src[1] = nir_src_for_ssa(vertex_index);
+   if (array_index)
+      store->src[1] = nir_src_for_ssa(array_index);
 
-   store->src[vertex_index ? 2 : 1] = nir_src_for_ssa(offset);
+   store->src[array_index ? 2 : 1] = nir_src_for_ssa(offset);
 
    unsigned gs_streams = 0;
    if (state->builder.shader->info.stage == MESA_SHADER_GEOMETRY) {
@@ -441,7 +441,7 @@ emit_store(struct lower_io_state *state, nir_ssa_def *data,
 
 static void
 lower_store(nir_intrinsic_instr *intrin, struct lower_io_state *state,
-            nir_ssa_def *vertex_index, nir_variable *var, nir_ssa_def *offset,
+            nir_ssa_def *array_index, nir_variable *var, nir_ssa_def *offset,
             unsigned component, const struct glsl_type *type)
 {
    assert(intrin->src[1].is_ssa);
@@ -471,7 +471,7 @@ lower_store(nir_intrinsic_instr *intrin, struct lower_io_state *state,
                   write_mask32 |= 3 << (i * 2);
             }
 
-            emit_store(state, data32, vertex_index, var, offset,
+            emit_store(state, data32, array_index, var, offset,
                        component, data32->num_components, write_mask32,
                        nir_type_uint32);
          }
@@ -486,12 +486,12 @@ lower_store(nir_intrinsic_instr *intrin, struct lower_io_state *state,
       /* Booleans are 32-bit */
       assert(glsl_type_is_boolean(type));
       nir_ssa_def *b32_val = nir_b2b32(&state->builder, intrin->src[1].ssa);
-      emit_store(state, b32_val, vertex_index, var, offset,
+      emit_store(state, b32_val, array_index, var, offset,
                  component, intrin->num_components,
                  nir_intrinsic_write_mask(intrin),
                  nir_type_bool32);
    } else {
-      emit_store(state, intrin->src[1].ssa, vertex_index, var, offset,
+      emit_store(state, intrin->src[1].ssa, array_index, var, offset,
                  component, intrin->num_components,
                  nir_intrinsic_write_mask(intrin),
                  nir_get_nir_type_for_glsl_type(type));
@@ -616,10 +616,10 @@ nir_lower_io_block(nir_block *block,
 
       b->cursor = nir_before_instr(instr);
 
-      const bool per_vertex = nir_is_arrayed_io(var, b->shader->info.stage);
+      const bool is_arrayed = nir_is_arrayed_io(var, b->shader->info.stage);
 
       nir_ssa_def *offset;
-      nir_ssa_def *vertex_index = NULL;
+      nir_ssa_def *array_index = NULL;
       unsigned component_offset = var->data.location_frac;
       bool bindless_type_size = var->data.mode == nir_var_shader_in ||
                                 var->data.mode == nir_var_shader_out ||
@@ -656,7 +656,7 @@ nir_lower_io_block(nir_block *block,
          continue;
       }
 
-      offset = get_io_offset(b, deref, per_vertex ? &vertex_index : NULL,
+      offset = get_io_offset(b, deref, is_arrayed ? &array_index : NULL,
                              state->type_size, &component_offset,
                              bindless_type_size);
 
@@ -664,12 +664,12 @@ nir_lower_io_block(nir_block *block,
 
       switch (intrin->intrinsic) {
       case nir_intrinsic_load_deref:
-         replacement = lower_load(intrin, state, vertex_index, var, offset,
+         replacement = lower_load(intrin, state, array_index, var, offset,
                                   component_offset, deref->type);
          break;
 
       case nir_intrinsic_store_deref:
-         lower_store(intrin, state, vertex_index, var, offset,
+         lower_store(intrin, state, array_index, var, offset,
                      component_offset, deref->type);
          break;
 
@@ -677,7 +677,7 @@ nir_lower_io_block(nir_block *block,
       case nir_intrinsic_interp_deref_at_sample:
       case nir_intrinsic_interp_deref_at_offset:
       case nir_intrinsic_interp_deref_at_vertex:
-         assert(vertex_index == NULL);
+         assert(array_index == NULL);
          replacement = lower_interpolate_at(intrin, state, var, offset,
                                             component_offset, deref->type);
          break;
diff --git a/src/compiler/nir/nir_lower_io_arrays_to_elements.c b/src/compiler/nir/nir_lower_io_arrays_to_elements.c
index ab15a162db5..901da66962b 100644
--- a/src/compiler/nir/nir_lower_io_arrays_to_elements.c
+++ b/src/compiler/nir/nir_lower_io_arrays_to_elements.c
@@ -35,7 +35,7 @@
 static unsigned
 get_io_offset(nir_builder *b, nir_deref_instr *deref, nir_variable *var,
               unsigned *element_index, unsigned *xfb_offset,
-              nir_ssa_def **vertex_index)
+              nir_ssa_def **array_index)
 {
    nir_deref_path path;
    nir_deref_path_init(&path, deref, NULL);
@@ -43,11 +43,11 @@ get_io_offset(nir_builder *b, nir_deref_instr *deref, nir_variable *var,
    assert(path.path[0]->deref_type == nir_deref_type_var);
    nir_deref_instr **p = &path.path[1];
 
-   /* For per-vertex input arrays (i.e. geometry shader inputs), skip the
-    * outermost array index.  Process the rest normally.
+   /* For arrayed I/O (e.g., per-vertex input arrays in geometry shader
+    * inputs), skip the outermost array index.  Process the rest normally.
     */
    if (nir_is_arrayed_io(var, b->shader->info.stage)) {
-      *vertex_index = nir_ssa_for_src(b, (*p)->arr.index, 1);
+      *array_index = nir_ssa_for_src(b, (*p)->arr.index, 1);
       p++;
    }
 
@@ -130,12 +130,12 @@ lower_array(nir_builder *b, nir_intrinsic_instr *intr, nir_variable *var,
    nir_variable **elements =
       get_array_elements(varyings, var, b->shader->info.stage);
 
-   nir_ssa_def *vertex_index = NULL;
+   nir_ssa_def *array_index = NULL;
    unsigned elements_index = 0;
    unsigned xfb_offset = 0;
    unsigned io_offset = get_io_offset(b, nir_src_as_deref(intr->src[0]),
                                       var, &elements_index, &xfb_offset,
-                                      &vertex_index);
+                                      &array_index);
 
    nir_variable *element = elements[elements_index];
    if (!element) {
@@ -165,8 +165,8 @@ lower_array(nir_builder *b, nir_intrinsic_instr *intr, nir_variable *var,
    nir_deref_instr *element_deref = nir_build_deref_var(b, element);
 
    if (nir_is_arrayed_io(var, b->shader->info.stage)) {
-      assert(vertex_index);
-      element_deref = nir_build_deref_array(b, element_deref, vertex_index);
+      assert(array_index);
+      element_deref = nir_build_deref_array(b, element_deref, array_index);
    }
 
    nir_intrinsic_instr *element_intr =



More information about the mesa-commit mailing list