summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/uniform_query.cpp
diff options
context:
space:
mode:
authorTapani Pälli <[email protected]>2014-10-14 12:39:54 +0300
committerTapani Pälli <[email protected]>2014-10-20 11:07:12 +0300
commit953a0af8e3f73ce0a42a5dc2bf25355453d7a7b0 (patch)
tree2aa9ea782bc430258590c7f516725218598a1feb /src/mesa/main/uniform_query.cpp
parent01d94193ac34239cc96e3f4aab7df0e37a82eb31 (diff)
mesa: validate sampler uniforms during gluniform calls
Patch fixes 'glsl-2types-of-textures-on-same-unit' in WebGL conformance test suite. No Piglit regressions, fixes gl-2.0-active-sampler-conflict. To avoid adding potentially heavy check during draw (valid_to_render), check is done during uniform updates by inspecting TexturesUsed mask. A new boolean variable is introduced to cache validation state. v2: take into account case where 2 uniforms use same unit (curro) also do the check only when SSO is not in use, SSO has own path for sampler validation. Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Francisco Jerez <[email protected]>
Diffstat (limited to 'src/mesa/main/uniform_query.cpp')
-rw-r--r--src/mesa/main/uniform_query.cpp44
1 files changed, 9 insertions, 35 deletions
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index 1592c9bfd24..c2776c087a5 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -1064,42 +1064,16 @@ extern "C" bool
_mesa_sampler_uniforms_are_valid(const struct gl_shader_program *shProg,
char *errMsg, size_t errMsgLength)
{
- const glsl_type *unit_types[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
-
- memset(unit_types, 0, sizeof(unit_types));
-
- for (unsigned i = 0; i < shProg->NumUserUniformStorage; i++) {
- const struct gl_uniform_storage *const storage =
- &shProg->UniformStorage[i];
- const glsl_type *const t = (storage->type->is_array())
- ? storage->type->fields.array : storage->type;
-
- if (!t->is_sampler())
- continue;
-
- const unsigned count = MAX2(1, storage->type->array_size());
- for (unsigned j = 0; j < count; j++) {
- const unsigned unit = storage->storage[j].i;
-
- /* The types of the samplers associated with a particular texture
- * unit must be an exact match. Page 74 (page 89 of the PDF) of the
- * OpenGL 3.3 core spec says:
- *
- * "It is not allowed to have variables of different sampler
- * types pointing to the same texture image unit within a program
- * object."
- */
- if (unit_types[unit] == NULL) {
- unit_types[unit] = t;
- } else if (unit_types[unit] != t) {
- _mesa_snprintf(errMsg, errMsgLength,
- "Texture unit %d is accessed both as %s and %s",
- unit, unit_types[unit]->name, t->name);
- return false;
- }
- }
+ /* Shader does not have samplers. */
+ if (shProg->NumUserUniformStorage == 0)
+ return true;
+
+ if (!shProg->SamplersValidated) {
+ _mesa_snprintf(errMsg, errMsgLength,
+ "active samplers with a different type "
+ "refer to the same texture image unit");
+ return false;
}
-
return true;
}