mesa: update pipeline when re-linking a program in use

Updating was only done for bound program, so add the
same logic for existing pipelines.

This fixes piglit test arb_shader_storage_buffer_object-issue1258.
It might also help the following issue:
  https://gitlab.freedesktop.org/mesa/mesa/-/issues/1258

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4404>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4404>
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2020-04-01 14:23:53 +02:00 committed by Marge Bot
parent 1288ac7632
commit 61566f2ae1

View file

@ -1249,6 +1249,29 @@ _mesa_compile_shader(struct gl_context *ctx, struct gl_shader *sh)
}
struct update_programs_in_pipeline_params
{
struct gl_context *ctx;
struct gl_shader_program *shProg;
};
static void
update_programs_in_pipeline(GLuint key, void *data, void *userData)
{
struct update_programs_in_pipeline_params *params =
(struct update_programs_in_pipeline_params *) userData;
struct gl_pipeline_object *obj = (struct gl_pipeline_object *) data;
for (unsigned stage = 0; stage < MESA_SHADER_STAGES; stage++) {
if (obj->CurrentProgram[stage] &&
obj->CurrentProgram[stage]->Id == params->shProg->Name) {
struct gl_program *prog = prog = params->shProg->_LinkedShaders[stage]->Program;
_mesa_use_program(params->ctx, stage, params->shProg, prog, obj);
}
}
}
/**
* Link a program's shaders.
*/
@ -1279,7 +1302,7 @@ link_program(struct gl_context *ctx, struct gl_shader_program *shProg,
ctx->_Shader->CurrentProgram[stage]->Id == shProg->Name) {
programs_in_use |= 1 << stage;
}
}
}
ensure_builtin_types(ctx);
@ -1296,7 +1319,7 @@ link_program(struct gl_context *ctx, struct gl_shader_program *shProg,
* the state of any program pipeline for all stages where the program
* is attached."
*/
if (shProg->data->LinkStatus && programs_in_use) {
if (shProg->data->LinkStatus) {
while (programs_in_use) {
const int stage = u_bit_scan(&programs_in_use);
@ -1306,6 +1329,15 @@ link_program(struct gl_context *ctx, struct gl_shader_program *shProg,
_mesa_use_program(ctx, stage, shProg, prog, ctx->_Shader);
}
if (ctx->Pipeline.Objects) {
struct update_programs_in_pipeline_params params = {
.ctx = ctx,
.shProg = shProg
};
_mesa_HashWalk(ctx->Pipeline.Objects, update_programs_in_pipeline,
&params);
}
}
/* Capture .shader_test files. */