From 59f1186af216784cfb560d2bb2ed63c7a6b67c98 Mon Sep 17 00:00:00 2001 From: Qiang Yu Date: Wed, 26 Feb 2025 10:47:39 +0800 Subject: [PATCH] glsl: pack vertex pipeline varying linkage into a function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No functional change, prepare for add mesh pipeline varying linking. Reviewed-by: Ian Romanick Acked-by: Marek Olšák Part-of: --- src/compiler/glsl/gl_nir_link_varyings.c | 46 ++++++++++++++---------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/src/compiler/glsl/gl_nir_link_varyings.c b/src/compiler/glsl/gl_nir_link_varyings.c index 72cb4d901bf..e1ff3be5d0f 100644 --- a/src/compiler/glsl/gl_nir_link_varyings.c +++ b/src/compiler/glsl/gl_nir_link_varyings.c @@ -4361,25 +4361,15 @@ gl_assign_attribute_or_color_locations(const struct gl_constants *consts, return true; } -bool -gl_nir_link_varyings(const struct pipe_screen *screen, - const struct gl_constants *consts, - const struct gl_extensions *exts, - gl_api api, struct gl_shader_program *prog) +static bool +link_vertex_pipeline_varyings(const struct pipe_screen *screen, + const struct gl_constants *consts, + const struct gl_extensions *exts, + gl_api api, struct gl_shader_program *prog, + void *mem_ctx) { - void *mem_ctx = ralloc_context(NULL); - - unsigned first, last; - - MESA_TRACE_FUNC(); - - first = MESA_SHADER_MESH_STAGES; - last = 0; - - /* We need to initialise the program resource list because the varying - * packing pass my start inserting varyings onto the list. - */ - init_program_resource_list(prog); + unsigned first = MESA_SHADER_MESH_STAGES; + unsigned last = 0; /* Determine first and last stage. */ for (unsigned i = 0; i < MESA_SHADER_MESH_STAGES; i++) { @@ -4392,6 +4382,26 @@ gl_nir_link_varyings(const struct pipe_screen *screen, bool r = link_varyings(screen, prog, first, last, consts, exts, api, mem_ctx); + return r; +} + +bool +gl_nir_link_varyings(const struct pipe_screen *screen, + const struct gl_constants *consts, + const struct gl_extensions *exts, + gl_api api, struct gl_shader_program *prog) +{ + void *mem_ctx = ralloc_context(NULL); + + MESA_TRACE_FUNC(); + + /* We need to initialise the program resource list because the varying + * packing pass my start inserting varyings onto the list. + */ + init_program_resource_list(prog); + + bool r = link_vertex_pipeline_varyings(screen, consts, exts, api, prog, mem_ctx); + ralloc_free(mem_ctx); return r; }