Commit 547cbd46 by Olli Etuaho Committed by Commit Bot

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/447557Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent a55102c5
...@@ -106,9 +106,12 @@ struct Uniform : public ShaderVariable ...@@ -106,9 +106,12 @@ struct Uniform : public ShaderVariable
return !operator==(other); return !operator==(other);
} }
int binding;
// Decide whether two uniforms are the same at shader link time, // Decide whether two uniforms are the same at shader link time,
// assuming one from vertex shader and the other from fragment shader. // assuming one from vertex shader and the other from fragment shader.
// See GLSL ES Spec 3.00.3, sec 4.3.5. // GLSL ES Spec 3.00.3, section 4.3.5.
// GLSL ES Spec 3.10.4, section 4.4.5
bool isSameUniformAtLinkTime(const Uniform &other) const; bool isSameUniformAtLinkTime(const Uniform &other) const;
}; };
......
...@@ -181,7 +181,7 @@ bool ShaderVariable::isSameVariableAtLinkTime(const ShaderVariable &other, ...@@ -181,7 +181,7 @@ bool ShaderVariable::isSameVariableAtLinkTime(const ShaderVariable &other,
return true; return true;
} }
Uniform::Uniform() Uniform::Uniform() : binding(-1)
{ {
} }
...@@ -189,23 +189,28 @@ Uniform::~Uniform() ...@@ -189,23 +189,28 @@ Uniform::~Uniform()
{ {
} }
Uniform::Uniform(const Uniform &other) : ShaderVariable(other) Uniform::Uniform(const Uniform &other) : ShaderVariable(other), binding(other.binding)
{ {
} }
Uniform &Uniform::operator=(const Uniform &other) Uniform &Uniform::operator=(const Uniform &other)
{ {
ShaderVariable::operator=(other); ShaderVariable::operator=(other);
binding = other.binding;
return *this; return *this;
} }
bool Uniform::operator==(const Uniform &other) const bool Uniform::operator==(const Uniform &other) const
{ {
return ShaderVariable::operator==(other); return ShaderVariable::operator==(other) && binding == other.binding;
} }
bool Uniform::isSameUniformAtLinkTime(const Uniform &other) const bool Uniform::isSameUniformAtLinkTime(const Uniform &other) const
{ {
if (binding != -1 && other.binding != -1 && binding != other.binding)
{
return false;
}
return ShaderVariable::isSameVariableAtLinkTime(other, true); return ShaderVariable::isSameVariableAtLinkTime(other, true);
} }
......
...@@ -569,6 +569,7 @@ Uniform CollectVariables::recordUniform(const TIntermSymbol &variable) const ...@@ -569,6 +569,7 @@ Uniform CollectVariables::recordUniform(const TIntermSymbol &variable) const
{ {
Uniform uniform; Uniform uniform;
setCommonVariableProperties(variable.getType(), variable.getSymbol(), &uniform); setCommonVariableProperties(variable.getType(), variable.getSymbol(), &uniform);
uniform.binding = variable.getType().getLayoutQualifier().binding;
return uniform; return uniform;
} }
......
...@@ -2391,6 +2391,8 @@ bool Program::linkValidateVariablesBase(InfoLog &infoLog, const std::string &var ...@@ -2391,6 +2391,8 @@ bool Program::linkValidateVariablesBase(InfoLog &infoLog, const std::string &var
return true; 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) 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 #if ANGLE_PROGRAM_LINK_VALIDATE_UNIFORM_PRECISION == ANGLE_ENABLED
...@@ -2404,6 +2406,14 @@ bool Program::linkValidateUniforms(InfoLog &infoLog, const std::string &uniformN ...@@ -2404,6 +2406,14 @@ bool Program::linkValidateUniforms(InfoLog &infoLog, const std::string &uniformN
return false; 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; return true;
} }
......
...@@ -1434,12 +1434,3 @@ ...@@ -1434,12 +1434,3 @@
1442 OPENGL D3D11 : dEQP-GLES31.functional.layout_binding.ssbo.* = FAIL 1442 OPENGL D3D11 : dEQP-GLES31.functional.layout_binding.ssbo.* = FAIL
1442 OPENGL D3D11 : dEQP-GLES31.functional.layout_binding.image.image2d.* = FAIL 1442 OPENGL D3D11 : dEQP-GLES31.functional.layout_binding.image.image2d.* = FAIL
1442 OPENGL D3D11 : dEQP-GLES31.functional.layout_binding.image.image3d.* = FAIL 1442 OPENGL D3D11 : dEQP-GLES31.functional.layout_binding.image.image3d.* = FAIL
1893 OPENGL D3D11 : dEQP-GLES31.functional.layout_binding.negative.sampler.sampler2d.binding_contradictory = FAIL
1893 OPENGL D3D11 : dEQP-GLES31.functional.layout_binding.negative.sampler.sampler2d.binding_contradictory_array = FAIL
1893 OPENGL D3D11 : dEQP-GLES31.functional.layout_binding.negative.sampler.sampler3d.binding_contradictory = FAIL
1893 OPENGL D3D11 : dEQP-GLES31.functional.layout_binding.negative.sampler.sampler3d.binding_contradictory_array = FAIL
1893 OPENGL D3D11 : dEQP-GLES31.functional.layout_binding.negative.image.image2d.binding_contradictory = FAIL
1893 OPENGL D3D11 : dEQP-GLES31.functional.layout_binding.negative.image.image2d.binding_contradictory_array = FAIL
1893 OPENGL D3D11 : dEQP-GLES31.functional.layout_binding.negative.image.image3d.binding_contradictory = FAIL
1893 OPENGL D3D11 : dEQP-GLES31.functional.layout_binding.negative.image.image3d.binding_contradictory_array = FAIL
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment