Add more cases for block/non-block uniforms match
authorJuan A. Suarez Romero <jasuarez@igalia.com>
Tue, 30 Jan 2018 09:55:40 +0000 (10:55 +0100)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Wed, 14 Feb 2018 08:54:14 +0000 (03:54 -0500)
Cover more situations as described in GLSL 3.20 spec, section 4.3.9.

- It is a link-error when using the same name inside a block with non
instance name and outside a block, but it is correct if the block has
instance name.

- It is a link-error when using the same name inside two different
blocks with non instance name.

Components: OpenGL

VK-GL-CTS issue: 972

Affects:
KHR-GLES3.shaders.uniform_block.common.name_matching
KHR-GL33.shaders.uniform_block.common.name_matching

Change-Id: Ie91300685e807774a9cc9bbb9139936133a8ae1c

external/openglcts/modules/common/glcUniformBlockTests.cpp

index 656e0e4..f7d3fe6 100644 (file)
@@ -735,7 +735,7 @@ public:
                                                "  color = b.v;\n"
                                                "}");
 
-               // check if linking succeeds when both matched blocks are lacking an instance name
+               // check if linking succeeds when both blocks have a different instance name
                if (!Test(vs3, fs3, GL_TRUE))
                        return STOP;
 
@@ -751,10 +751,45 @@ public:
                                                "  color = vec4(f);\n"
                                                "}\n");
 
-               // check if link error is generated when the same name is used for block and non-block uniform
+               // check if link error is generated when the same name is used for block
+               // with no intance name and non-block uniform
                if (!Test(vs4, fs4, GL_FALSE))
                        return STOP;
 
+               std::string vs5("precision highp float;\n"
+                                               "layout (std140) uniform Data { float f; } a;\n"
+                                               "void main() {\n"
+                                               "  gl_Position = vec4(a.f);\n"
+                                               "}\n");
+               std::string fs5("precision highp float;\n"
+                                               "uniform float f;\n"
+                                               "out vec4 color;\n"
+                                               "void main() {\n"
+                                               "  color = vec4(f);\n"
+                                               "}\n");
+
+               // check if link succeeds when the same name is used for block with
+               // instance name and non-block uniform
+               if (!Test(vs5, fs5, GL_TRUE))
+                       return STOP;
+
+
+               std::string vs6("precision highp float;\n"
+                                               "uniform Data1 { float u; vec4 v; };\n"
+                                               "void main() {\n"
+                                               "  gl_Position = v;\n"
+                                               "}");
+               std::string fs6("precision highp float;\n"
+                                               "out vec4 color;\n"
+                                               "uniform Data2 { vec4 v; };\n"
+                                               "void main() {\n"
+                                               "  color = v;\n"
+                                               "}");
+
+               // check if link error is generated when same name is used in two different blocks
+               if (!Test(vs6, fs6, GL_FALSE))
+                       return STOP;
+
                m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
                return STOP;
        }