Validate uniform binding at link time
GLSL ES Spec 3.10.4, section 4.4.5 has the rules for linking uniforms
with binding layout qualifiers. If a binding layout qualifier for a
uniform variable is specified in both vertex and fragment shaders, the
qualifiers must match.
BUG=angleproject:1893
TEST=dEQP-GLES31.functional.layout_binding.*binding_contradictory*
Change-Id: I0ae6a1a8967df818be8136510c22daee848b9da7
Reviewed-on: https://chromium-review.googlesource.com/447557
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/libANGLE/Program.cpp b/src/libANGLE/Program.cpp
index 6fd31a0..2cf4307 100644
--- a/src/libANGLE/Program.cpp
+++ b/src/libANGLE/Program.cpp
@@ -2391,6 +2391,8 @@
return true;
}
+// GLSL ES Spec 3.00.3, section 4.3.5.
+// GLSL ES Spec 3.10.4, section 4.4.5.
bool Program::linkValidateUniforms(InfoLog &infoLog, const std::string &uniformName, const sh::Uniform &vertexUniform, const sh::Uniform &fragmentUniform)
{
#if ANGLE_PROGRAM_LINK_VALIDATE_UNIFORM_PRECISION == ANGLE_ENABLED
@@ -2404,6 +2406,14 @@
return false;
}
+ if (vertexUniform.binding != -1 && fragmentUniform.binding != -1 &&
+ vertexUniform.binding != fragmentUniform.binding)
+ {
+ infoLog << "Binding layout qualifiers for " << uniformName
+ << " differ between vertex and fragment shaders.";
+ return false;
+ }
+
return true;
}