mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 13:00:09 +01:00
mesa/st: delay nir spirv link
Following commit for st_nir_link_shaders->nir_link_opt_varyings may copy uniform variable from one shader to another, so delay the nir_spirv link which contains mesa uniform information update (gl_nir_link_uniforms) after it and align with glsl link. Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> Signed-off-by: Qiang Yu <yuq825@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12613>
This commit is contained in:
parent
5bf6987873
commit
3127282944
1 changed files with 18 additions and 32 deletions
|
|
@ -766,9 +766,10 @@ st_link_nir(struct gl_context *ctx,
|
|||
}
|
||||
|
||||
prog->nir = glsl_to_nir(st->ctx, shader_program, shader->Stage, options);
|
||||
st_nir_preprocess(st, prog, shader_program, shader->Stage);
|
||||
}
|
||||
|
||||
st_nir_preprocess(st, prog, shader_program, shader->Stage);
|
||||
|
||||
if (options->lower_to_scalar) {
|
||||
NIR_PASS_V(shader->Program->nir, nir_lower_load_const_to_scalar);
|
||||
}
|
||||
|
|
@ -776,28 +777,6 @@ st_link_nir(struct gl_context *ctx,
|
|||
|
||||
st_lower_patch_vertices_in(shader_program);
|
||||
|
||||
/* For SPIR-V, we have to perform the NIR linking before applying
|
||||
* st_nir_preprocess.
|
||||
*/
|
||||
if (shader_program->data->spirv) {
|
||||
static const gl_nir_linker_options opts = {
|
||||
true /*fill_parameters */
|
||||
};
|
||||
if (!gl_nir_link_spirv(ctx, shader_program, &opts))
|
||||
return GL_FALSE;
|
||||
|
||||
nir_build_program_resource_list(ctx, shader_program, true);
|
||||
|
||||
for (unsigned i = 0; i < num_shaders; i++) {
|
||||
struct gl_linked_shader *shader = linked_shader[i];
|
||||
struct gl_program *prog = shader->Program;
|
||||
|
||||
prog->ExternalSamplersUsed = gl_external_samplers(prog);
|
||||
_mesa_update_shader_textures_used(shader_program, prog);
|
||||
st_nir_preprocess(st, prog, shader_program, shader->Stage);
|
||||
}
|
||||
}
|
||||
|
||||
/* Linking the stages in the opposite order (from fragment to vertex)
|
||||
* ensures that inter-shader outputs written to in an earlier stage
|
||||
* are eliminated if they are (transitively) not used in a later
|
||||
|
|
@ -814,19 +793,26 @@ st_link_nir(struct gl_context *ctx,
|
|||
if (num_shaders == 1)
|
||||
st_nir_opts(linked_shader[0]->Program->nir);
|
||||
|
||||
if (!shader_program->data->spirv) {
|
||||
if (shader_program->data->spirv) {
|
||||
static const gl_nir_linker_options opts = {
|
||||
true /*fill_parameters */
|
||||
};
|
||||
if (!gl_nir_link_spirv(ctx, shader_program, &opts))
|
||||
return GL_FALSE;
|
||||
} else {
|
||||
if (!gl_nir_link_glsl(ctx, shader_program))
|
||||
return GL_FALSE;
|
||||
|
||||
for (unsigned i = 0; i < num_shaders; i++) {
|
||||
struct gl_program *prog = linked_shader[i]->Program;
|
||||
prog->ExternalSamplersUsed = gl_external_samplers(prog);
|
||||
_mesa_update_shader_textures_used(shader_program, prog);
|
||||
}
|
||||
|
||||
nir_build_program_resource_list(ctx, shader_program, false);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < num_shaders; i++) {
|
||||
struct gl_program *prog = linked_shader[i]->Program;
|
||||
prog->ExternalSamplersUsed = gl_external_samplers(prog);
|
||||
_mesa_update_shader_textures_used(shader_program, prog);
|
||||
}
|
||||
|
||||
nir_build_program_resource_list(ctx, shader_program,
|
||||
shader_program->data->spirv);
|
||||
|
||||
for (unsigned i = 0; i < num_shaders; i++) {
|
||||
struct gl_linked_shader *shader = linked_shader[i];
|
||||
nir_shader *nir = shader->Program->nir;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue