glsl: call assign_attribute_or_color_locations() in NIR linker

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22846>
This commit is contained in:
Timothy Arceri
2023-04-06 14:18:44 +10:00
committed by Marge Bot
parent f3c6718f73
commit fa56e911b8
4 changed files with 30 additions and 10 deletions

View File

@@ -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,

View File

@@ -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 */

View File

@@ -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;

View File

@@ -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)