diff --git a/src/compiler/glsl/gl_nir_link_varyings.c b/src/compiler/glsl/gl_nir_link_varyings.c index 7be961c2d2d..4018652d86c 100644 --- a/src/compiler/glsl/gl_nir_link_varyings.c +++ b/src/compiler/glsl/gl_nir_link_varyings.c @@ -3653,6 +3653,28 @@ link_varyings(struct gl_shader_program *prog, unsigned first, return true; } +bool +gl_assign_attribute_or_color_locations(const struct gl_constants *consts, + struct gl_shader_program *prog) +{ + void *mem_ctx = ralloc_context(NULL); + + if (!assign_attribute_or_color_locations(mem_ctx, prog, consts, + MESA_SHADER_VERTEX, true)) { + ralloc_free(mem_ctx); + return false; + } + + if (!assign_attribute_or_color_locations(mem_ctx, prog, consts, + MESA_SHADER_FRAGMENT, true)) { + ralloc_free(mem_ctx); + return false; + } + + ralloc_free(mem_ctx); + return true; +} + bool gl_nir_link_varyings(const struct gl_constants *consts, const struct gl_extensions *exts, diff --git a/src/compiler/glsl/gl_nir_link_varyings.h b/src/compiler/glsl/gl_nir_link_varyings.h index 5d76ca58dc2..b568e3dfbd0 100644 --- a/src/compiler/glsl/gl_nir_link_varyings.h +++ b/src/compiler/glsl/gl_nir_link_varyings.h @@ -215,4 +215,8 @@ xfb_decl_is_varying(const struct xfb_decl *xfb_decl) return !xfb_decl->next_buffer_separator && !xfb_decl->skip_components; } +bool +gl_assign_attribute_or_color_locations(const struct gl_constants *consts, + struct gl_shader_program *prog); + #endif /* GLSL_LINK_VARYINGS_H */ diff --git a/src/compiler/glsl/gl_nir_linker.c b/src/compiler/glsl/gl_nir_linker.c index f9fb6b09a2e..142cc333467 100644 --- a/src/compiler/glsl/gl_nir_linker.c +++ b/src/compiler/glsl/gl_nir_linker.c @@ -25,6 +25,7 @@ #include "nir_builder.h" #include "gl_nir.h" #include "gl_nir_linker.h" +#include "gl_nir_link_varyings.h" #include "linker_util.h" #include "main/shader_types.h" #include "main/consts_exts.h" @@ -1246,6 +1247,9 @@ gl_nir_link_glsl(const struct gl_constants *consts, linked_shader[num_shaders++] = prog->_LinkedShaders[i]; } + if (!gl_assign_attribute_or_color_locations(consts, prog)) + return false; + if (!prelink_lowering(consts, exts, prog, linked_shader, num_shaders)) return false; diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp index 924c20b168f..7706da5393a 100644 --- a/src/compiler/glsl/linker.cpp +++ b/src/compiler/glsl/linker.cpp @@ -3523,16 +3523,6 @@ link_varyings(const struct gl_constants *consts, struct gl_shader_program *prog, } } - if (!assign_attribute_or_color_locations(mem_ctx, prog, consts, - MESA_SHADER_VERTEX, true)) { - return false; - } - - if (!assign_attribute_or_color_locations(mem_ctx, prog, consts, - MESA_SHADER_FRAGMENT, true)) { - return false; - } - prog->last_vert_prog = NULL; for (int i = MESA_SHADER_GEOMETRY; i >= MESA_SHADER_VERTEX; i--) { if (prog->_LinkedShaders[i] == NULL)