Commit bb1e750c by Geoff Lang Committed by Commit Bot

Validate that structure names match when linking uniforms.

GLSL 1.017 4.2.4: Structures must have the same name, sequence of type names, and type definitions, and field names to be considered the same type. TEST=conformance/glsl/misc/shaders-with-uniform-structs BUG=angleproejct:2013 Change-Id: Ieedaaca2d28ef4e1cc0b5480f413ebd513c1dc1f Reviewed-on: https://chromium-review.googlesource.com/524036 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent f2a06035
...@@ -2360,6 +2360,12 @@ bool Program::linkValidateVariablesBase(InfoLog &infoLog, const std::string &var ...@@ -2360,6 +2360,12 @@ bool Program::linkValidateVariablesBase(InfoLog &infoLog, const std::string &var
infoLog << "Precisions for " << variableName << " differ between vertex and fragment shaders"; infoLog << "Precisions for " << variableName << " differ between vertex and fragment shaders";
return false; return false;
} }
if (vertexVariable.structName != fragmentVariable.structName)
{
infoLog << "Structure names for " << variableName
<< " differ between vertex and fragment shaders";
return false;
}
if (vertexVariable.fields.size() != fragmentVariable.fields.size()) if (vertexVariable.fields.size() != fragmentVariable.fields.size())
{ {
......
...@@ -2950,6 +2950,54 @@ TEST_P(GLSLTest, InitUninitializedStructContainingArrays) ...@@ -2950,6 +2950,54 @@ TEST_P(GLSLTest, InitUninitializedStructContainingArrays)
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green); EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
} }
// Verify that two shaders with the same uniform name and members but different structure names will
// not link.
TEST_P(GLSLTest, StructureNameMatchingTest)
{
const char *vsSource =
"// Structures must have the same name, sequence of type names, and\n"
"// type definitions, and field names to be considered the same type.\n"
"// GLSL 1.017 4.2.4\n"
"precision mediump float;\n"
"struct info {\n"
" vec4 pos;\n"
" vec4 color;\n"
"};\n"
"\n"
"uniform info uni;\n"
"void main()\n"
"{\n"
" gl_Position = uni.pos;\n"
"}\n";
GLuint vs = CompileShader(GL_VERTEX_SHADER, vsSource);
ASSERT_NE(0u, vs);
glDeleteShader(vs);
const char *fsSource =
"// Structures must have the same name, sequence of type names, and\n"
"// type definitions, and field names to be considered the same type.\n"
"// GLSL 1.017 4.2.4\n"
"precision mediump float;\n"
"struct info1 {\n"
" vec4 pos;\n"
" vec4 color;\n"
"};\n"
"\n"
"uniform info1 uni;\n"
"void main()\n"
"{\n"
" gl_FragColor = uni.color;\n"
"}\n";
GLuint fs = CompileShader(GL_FRAGMENT_SHADER, fsSource);
ASSERT_NE(0u, fs);
glDeleteShader(fs);
GLuint program = CompileProgram(vsSource, fsSource);
EXPECT_EQ(0u, program);
}
// Test that an uninitialized nameless struct inside a for loop init statement works. // Test that an uninitialized nameless struct inside a for loop init statement works.
TEST_P(GLSLTest_ES3, UninitializedNamelessStructInForInitStatement) TEST_P(GLSLTest_ES3, UninitializedNamelessStructInForInitStatement)
{ {
......
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