summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Arceri <tarceri@itsqueeze.com>2017-04-21 17:04:10 +1000
committerAndres Gomez <agomez@igalia.com>2017-04-26 12:34:27 +0300
commitb7916134a0102218d6b4ec0d482bfd0e3aeeba43 (patch)
treea722ff895d71d773d467f1a46a115811cc48c484
parente98c9af5598038dc8eaef6f654c9e1f752a83a35 (diff)
mesa: 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. Fixes: 953a0af8e3f73 ("mesa: validate sampler uniforms during gluniform calls") Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com> Reviewed-by: Tapani Pälli <tapani.palli@intel.com> https://bugs.freedesktop.org/show_bug.cgi?id=97524 (cherry picked from commit d682f8aa8e0edd166166f87fcd774dd2d57b4180) [Andres Gomez: there was an intermediate cleanup but this commit basically brings everything that was missing back] Signed-off-by: Andres Gomez <agomez@igalia.com> Conflicts: src/mesa/main/uniforms.c
-rw-r--r--src/mesa/main/uniform_query.cpp2
-rw-r--r--src/mesa/main/uniforms.c23
-rw-r--r--src/mesa/program/ir_to_mesa.cpp5
3 files changed, 24 insertions, 6 deletions
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index 145eff01756..3c95785d643 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 51db39e63a0..b7b8f1f9fdf 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 f7797e28fa3..29320ddcb7c 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -3060,6 +3060,11 @@ _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
}
if (prog->data->LinkStatus) {
+ /* Reset sampler validated to true, validation happens via the
+ * LinkShader call below.
+ */
+ prog->SamplersValidated = GL_TRUE;
+
if (!ctx->Driver.LinkShader(ctx, prog)) {
prog->data->LinkStatus = GL_FALSE;
}