From 64489ea8915d62b342ba2b8ef08027f5b82ba9f6 Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Fri, 2 Dec 2016 10:59:17 +1100 Subject: [PATCH] st/mesa/i965: validate sampler type across the whole program Currently we were only making sure types were the same within a single stage. This looks to have regressed with 953a0af8e3f73. https://bugs.freedesktop.org/show_bug.cgi?id=97524 --- src/mesa/drivers/dri/i965/brw_link.cpp | 1 + src/mesa/main/uniform_query.cpp | 2 ++ src/mesa/main/uniforms.c | 23 +++++++++++++++++------ src/mesa/program/ir_to_mesa.cpp | 1 + src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 1 + 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_link.cpp b/src/mesa/drivers/dri/i965/brw_link.cpp index 853f972..702ecb1 100644 --- a/src/mesa/drivers/dri/i965/brw_link.cpp +++ b/src/mesa/drivers/dri/i965/brw_link.cpp @@ -203,6 +203,7 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg) const struct brw_compiler *compiler = brw->screen->compiler; unsigned int stage; + shProg->SamplersValidated = GL_TRUE; for (stage = 0; stage < ARRAY_SIZE(shProg->_LinkedShaders); stage++) { struct gl_linked_shader *shader = shProg->_LinkedShaders[stage]; if (!shader) diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp index 03e6775..15a54c7 100644 --- a/src/mesa/main/uniform_query.cpp +++ b/src/mesa/main/uniform_query.cpp @@ -856,6 +856,8 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg, */ if (uni->type->is_sampler()) { bool flushed = false; + shProg->SamplersValidated = GL_TRUE; + for (int i = 0; i < MESA_SHADER_STAGES; i++) { struct gl_linked_shader *const sh = shProg->_LinkedShaders[i]; diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c index 51db39e..b7b8f1f 100644 --- a/src/mesa/main/uniforms.c +++ b/src/mesa/main/uniforms.c @@ -68,15 +68,14 @@ _mesa_update_shader_textures_used(struct gl_shader_program *shProg, struct gl_program *prog) { GLbitfield mask = prog->SamplersUsed; - struct gl_linked_shader *shader = - shProg->_LinkedShaders[_mesa_program_enum_to_shader_stage(prog->Target)]; + gl_shader_stage prog_stage = + _mesa_program_enum_to_shader_stage(prog->Target); + struct gl_linked_shader *shader = shProg->_LinkedShaders[prog_stage]; assert(shader); memset(prog->TexturesUsed, 0, sizeof(prog->TexturesUsed)); - shProg->SamplersValidated = GL_TRUE; - while (mask) { const int s = u_bit_scan(&mask); GLuint unit = prog->SamplerUnits[s]; @@ -92,8 +91,20 @@ _mesa_update_shader_textures_used(struct gl_shader_program *shProg, * types pointing to the same texture image unit within a program * object." */ - if (prog->TexturesUsed[unit] & ~(1 << tgt)) - shProg->SamplersValidated = GL_FALSE; + unsigned stages_mask = shProg->data->linked_stages; + while (stages_mask) { + const int stage = u_bit_scan(&stages_mask); + + /* Skip validation if we are yet to update textures used in this + * stage. + */ + if (prog_stage < stage) + break; + + struct gl_program *glprog = shProg->_LinkedShaders[stage]->Program; + if (glprog->TexturesUsed[unit] & ~(1 << tgt)) + shProg->SamplersValidated = GL_FALSE; + } prog->TexturesUsed[unit] |= (1 << tgt); } diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index c6102ef..de77700 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -3015,6 +3015,7 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) validate_ir_tree(ir); } + prog->SamplersValidated = GL_TRUE; for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { struct gl_program *linked_prog; diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index bd713ed..959d5f4 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -6865,6 +6865,7 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) build_program_resource_list(ctx, prog); + prog->SamplersValidated = GL_TRUE; for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { struct gl_program *linked_prog; -- 2.7.4