Mesa (main): st,nir: Use nir_shader::xfb_info in nir_lower_io_passes

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue May 31 23:42:12 UTC 2022


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

Author: Jason Ekstrand <jason.ekstrand at collabora.com>
Date:   Fri May 27 13:36:50 2022 -0500

st,nir: Use nir_shader::xfb_info in nir_lower_io_passes

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Reviewed-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16750>

---

 src/compiler/nir/nir.h                       |  2 +-
 src/compiler/nir/nir_lower_io.c              | 25 ++++++++++---------------
 src/gallium/drivers/radeonsi/si_shader_nir.c |  2 +-
 src/mesa/state_tracker/st_glsl_to_nir.cpp    |  8 ++------
 4 files changed, 14 insertions(+), 23 deletions(-)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 7e519c2ed58..a3e7485ff30 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -4594,7 +4594,7 @@ bool nir_lower_io(nir_shader *shader,
 bool nir_io_add_const_offset_to_base(nir_shader *nir, nir_variable_mode modes);
 
 void
-nir_lower_io_passes(nir_shader *nir, struct nir_xfb_info *xfb);
+nir_lower_io_passes(nir_shader *nir);
 
 bool
 nir_lower_vars_to_explicit_types(nir_shader *shader,
diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c
index a5e33bdd6a2..1e9e60d7b49 100644
--- a/src/compiler/nir/nir_lower_io.c
+++ b/src/compiler/nir/nir_lower_io.c
@@ -2944,13 +2944,13 @@ nir_lower_color_inputs(nir_shader *nir)
 }
 
 static bool
-nir_add_xfb_info(nir_shader *nir, nir_xfb_info *info)
+nir_add_xfb_info(nir_shader *nir)
 {
    nir_function_impl *impl = nir_shader_get_entrypoint(nir);
    bool progress = false;
 
    for (unsigned i = 0; i < NIR_MAX_XFB_BUFFERS; i++)
-      nir->info.xfb_stride[i] = info->buffers[i].stride;
+      nir->info.xfb_stride[i] = nir->xfb_info->buffers[i].stride;
 
    nir_foreach_block (block, impl) {
       nir_foreach_instr_safe (instr, block) {
@@ -2980,9 +2980,9 @@ nir_add_xfb_info(nir_shader *nir, nir_xfb_info *info)
          nir_io_xfb xfb[2];
          memset(xfb, 0, sizeof(xfb));
 
-         for (unsigned i = 0; i < info->output_count; i++) {
-            if (info->outputs[i].location == sem.location) {
-               nir_xfb_output_info *out = &info->outputs[i];
+         for (unsigned i = 0; i < nir->xfb_info->output_count; i++) {
+            nir_xfb_output_info *out = &nir->xfb_info->outputs[i];
+            if (out->location == sem.location) {
                unsigned xfb_mask = writemask & out->component_mask;
 
                /*fprintf(stdout, "output%u: buffer=%u, offset=%u, location=%u, "
@@ -3026,23 +3026,18 @@ type_size_vec4(const struct glsl_type *type, bool bindless)
 }
 
 void
-nir_lower_io_passes(nir_shader *nir, nir_xfb_info *xfb)
+nir_lower_io_passes(nir_shader *nir)
 {
    if (!nir->options->lower_io_variables)
       return;
 
-   /* Ignore transform feedback for stages that can't have it. */
-   if (nir->info.stage != MESA_SHADER_VERTEX &&
-       nir->info.stage != MESA_SHADER_TESS_EVAL &&
-       nir->info.stage != MESA_SHADER_GEOMETRY)
-      xfb = NULL;
-
    bool has_indirect_inputs =
       (nir->options->support_indirect_inputs >> nir->info.stage) & 0x1;
 
    /* Transform feedback requires that indirect outputs are lowered. */
    bool has_indirect_outputs =
-      (nir->options->support_indirect_outputs >> nir->info.stage) & 0x1 && !xfb;
+      (nir->options->support_indirect_outputs >> nir->info.stage) & 0x1 &&
+      nir->xfb_info == NULL;
 
    if (!has_indirect_inputs || !has_indirect_outputs) {
       NIR_PASS_V(nir, nir_lower_io_to_temporaries,
@@ -3075,8 +3070,8 @@ nir_lower_io_passes(nir_shader *nir, nir_xfb_info *xfb)
    NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp |
               nir_var_shader_in | nir_var_shader_out, NULL);
 
-   if (xfb)
-      NIR_PASS_V(nir, nir_add_xfb_info, xfb);
+   if (nir->xfb_info)
+      NIR_PASS_V(nir, nir_add_xfb_info);
 
    nir->info.io_lowered = true;
 }
diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c
index 612e75b8130..8b267023504 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -319,7 +319,7 @@ char *si_finalize_nir(struct pipe_screen *screen, void *nirptr)
    struct si_screen *sscreen = (struct si_screen *)screen;
    struct nir_shader *nir = (struct nir_shader *)nirptr;
 
-   nir_lower_io_passes(nir, NULL);
+   nir_lower_io_passes(nir);
 
    /* Remove dead derefs, so that we can remove uniforms. */
    NIR_PASS_V(nir, nir_opt_dce);
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index dc3a17d79be..113b2cbfa14 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -1074,12 +1074,8 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog,
    /* Lower load_deref/store_deref of inputs and outputs.
     * This depends on st_nir_assign_varying_locations.
     */
-   if (nir->options->lower_io_variables) {
-      nir_xfb_info *xfb = shader_program ?
-         gl_to_nir_xfb_info(prog->sh.LinkedTransformFeedback, NULL) : NULL;
-      nir_lower_io_passes(nir, xfb);
-      ralloc_free(xfb);
-   }
+   if (nir->options->lower_io_variables)
+      nir_lower_io_passes(nir);
 
    /* Set num_uniforms in number of attribute slots (vec4s) */
    nir->num_uniforms = DIV_ROUND_UP(prog->Parameters->NumParameterValues, 4);



More information about the mesa-commit mailing list