Commit d7f083ef authored by zmo@chromium.org's avatar zmo@chromium.org

Uniforms and attributes name conflicts should cause link failure

BUG=286538
TEST=gpu_unittests, webgl conformance tests

Review URL: https://chromiumcodereview.appspot.com/23819037

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222128 0039d316-1c4b-4281-b951-d872f2087c98
parent abd5b932
...@@ -558,6 +558,10 @@ bool Program::Link(ShaderManager* manager, ...@@ -558,6 +558,10 @@ bool Program::Link(ShaderManager* manager,
"declared in vertex shader"); "declared in vertex shader");
return false; return false;
} }
if (DetectGlobalNameConflicts()) {
set_log_info("Name conflicts between an uniform and an attribute");
return false;
}
if (!CheckVaryingsPacking()) { if (!CheckVaryingsPacking()) {
set_log_info("Varyings over maximum register limit"); set_log_info("Varyings over maximum register limit");
return false; return false;
...@@ -1072,6 +1076,27 @@ bool Program::DetectVaryingsMismatch() const { ...@@ -1072,6 +1076,27 @@ bool Program::DetectVaryingsMismatch() const {
return false; return false;
} }
bool Program::DetectGlobalNameConflicts() const {
DCHECK(attached_shaders_[0] &&
attached_shaders_[0]->shader_type() == GL_VERTEX_SHADER &&
attached_shaders_[1] &&
attached_shaders_[1]->shader_type() == GL_FRAGMENT_SHADER);
const ShaderTranslator::VariableMap* uniforms[2];
uniforms[0] = &(attached_shaders_[0]->uniform_map());
uniforms[1] = &(attached_shaders_[1]->uniform_map());
const ShaderTranslator::VariableMap* attribs =
&(attached_shaders_[0]->attrib_map());
for (ShaderTranslator::VariableMap::const_iterator iter =
attribs->begin(); iter != attribs->end(); ++iter) {
for (int ii = 0; ii < 2; ++ii) {
if (uniforms[ii]->find(iter->first) != uniforms[ii]->end())
return true;
}
}
return false;
}
bool Program::CheckVaryingsPacking() const { bool Program::CheckVaryingsPacking() const {
DCHECK(attached_shaders_[0] && DCHECK(attached_shaders_[0] &&
attached_shaders_[0]->shader_type() == GL_VERTEX_SHADER && attached_shaders_[0]->shader_type() == GL_VERTEX_SHADER &&
......
...@@ -195,6 +195,9 @@ class GPU_EXPORT Program : public base::RefCounted<Program> { ...@@ -195,6 +195,9 @@ class GPU_EXPORT Program : public base::RefCounted<Program> {
// is not declared in vertex shader. // is not declared in vertex shader.
bool DetectVaryingsMismatch() const; bool DetectVaryingsMismatch() const;
// Return true if an uniform and an attribute share the same name.
bool DetectGlobalNameConflicts() const;
// Return false if varyings can't be packed into the max available // Return false if varyings can't be packed into the max available
// varying registers. // varying registers.
bool CheckVaryingsPacking() const; bool CheckVaryingsPacking() const;
......
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