Mesa (main): glsl/nir: Stash the xfb_info in the nir_shader when linking XFB
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue May 31 23:42:12 UTC 2022
Module: Mesa
Branch: main
Commit: 16b0719441ab42986989b5c3940d6d7071cfc553
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=16b0719441ab42986989b5c3940d6d7071cfc553
Author: Jason Ekstrand <jason.ekstrand at collabora.com>
Date: Fri May 27 13:55:18 2022 -0500
glsl/nir: Stash the xfb_info in the nir_shader when linking XFB
This pass is used for shaders coming in from SPIR-V.
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/glsl/gl_nir_link_xfb.c | 4 ++--
src/compiler/nir/nir_gather_xfb_info.c | 14 +++++++-------
src/compiler/nir/nir_xfb_info.h | 4 ++--
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/compiler/glsl/gl_nir_link_xfb.c b/src/compiler/glsl/gl_nir_link_xfb.c
index e07bf9f00d4..b191a698583 100644
--- a/src/compiler/glsl/gl_nir_link_xfb.c
+++ b/src/compiler/glsl/gl_nir_link_xfb.c
@@ -74,7 +74,8 @@ gl_nir_link_assign_xfb_resources(const struct gl_constants *consts,
struct gl_linked_shader *sh = prog->_LinkedShaders[stage];
if (sh && stage != MESA_SHADER_TESS_CTRL) {
- xfb_info = nir_gather_xfb_info_with_varyings(sh->Program->nir, NULL, &varyings_info);
+ nir_gather_xfb_info_with_varyings(sh->Program->nir, NULL, &varyings_info);
+ xfb_info = sh->Program->nir->xfb_info;
break;
}
}
@@ -192,7 +193,6 @@ gl_nir_link_assign_xfb_resources(const struct gl_constants *consts,
linked_xfb->ActiveBuffers = buffers;
- ralloc_free(xfb_info);
ralloc_free(varyings_info);
}
diff --git a/src/compiler/nir/nir_gather_xfb_info.c b/src/compiler/nir/nir_gather_xfb_info.c
index b2618c11af0..7a15a5c4b83 100644
--- a/src/compiler/nir/nir_gather_xfb_info.c
+++ b/src/compiler/nir/nir_gather_xfb_info.c
@@ -181,12 +181,11 @@ compare_xfb_output_offsets(const void *_a, const void *_b)
void
nir_shader_gather_xfb_info(nir_shader *shader)
{
- ralloc_free(shader->xfb_info);
- shader->xfb_info = nir_gather_xfb_info_with_varyings(shader, shader, NULL);
+ nir_gather_xfb_info_with_varyings(shader, NULL, NULL);
}
-nir_xfb_info *
-nir_gather_xfb_info_with_varyings(const nir_shader *shader,
+void
+nir_gather_xfb_info_with_varyings(nir_shader *shader,
void *mem_ctx,
nir_xfb_varyings_info **varyings_info_out)
{
@@ -211,9 +210,9 @@ nir_gather_xfb_info_with_varyings(const nir_shader *shader,
}
}
if (num_outputs == 0 || num_varyings == 0)
- return NULL;
+ return;
- nir_xfb_info *xfb = nir_xfb_info_create(mem_ctx, num_outputs);
+ nir_xfb_info *xfb = nir_xfb_info_create(shader, num_outputs);
if (varyings_info_out != NULL) {
*varyings_info_out = nir_xfb_varyings_info_create(mem_ctx, num_varyings);
varyings_info = *varyings_info_out;
@@ -285,7 +284,8 @@ nir_gather_xfb_info_with_varyings(const nir_shader *shader,
}
#endif
- return xfb;
+ ralloc_free(shader->xfb_info);
+ shader->xfb_info = xfb;
}
static int
diff --git a/src/compiler/nir/nir_xfb_info.h b/src/compiler/nir/nir_xfb_info.h
index 83c2b0f67e6..301547f3392 100644
--- a/src/compiler/nir/nir_xfb_info.h
+++ b/src/compiler/nir/nir_xfb_info.h
@@ -76,8 +76,8 @@ nir_xfb_info_size(uint16_t output_count)
void nir_shader_gather_xfb_info(nir_shader *shader);
-nir_xfb_info *
-nir_gather_xfb_info_with_varyings(const nir_shader *shader,
+void
+nir_gather_xfb_info_with_varyings(nir_shader *shader,
void *mem_ctx,
nir_xfb_varyings_info **varyings_info);
More information about the mesa-commit
mailing list