Redeclare built-in variables in separable shaders
authorWeiwan Liu <weiwliu@nvidia.com>
Fri, 31 Mar 2017 22:51:24 +0000 (15:51 -0700)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Fri, 7 Apr 2017 16:03:30 +0000 (12:03 -0400)
Change adds redeclaration of the built-in gl_perVertex struct
before using any of its member variables. Per spec, it is
necessary to do so for separable shaders.

Affects:

KHR-GL45.shader_image_size.* (46 tests)

Component: OpenGL

VK-GL-CTS issue: 343

Change-Id: I53372e9d98ee96201ab7f760e7ed16d78832f283

external/openglcts/modules/gl/gl4cShaderImageSizeTests.cpp

index fbed182..5f0e3b9 100644 (file)
@@ -633,7 +633,8 @@ public:
                }
                else if (stage == 1)
                { // TCS
-                       const char* const glsl_vs = "#version 430 core" NL "void main() { gl_Position = vec4(0.0, 0.0, 0.0, 1.0);}";
+                       const char* const glsl_vs = "#version 430 core" NL "out gl_PerVertex { vec4 gl_Position; };" NL
+                                                                               "void main() { gl_Position = vec4(0.0, 0.0, 0.0, 1.0);}";
                        const char* const glsl_tes = "#version 430 core" NL "layout(quads, point_mode) in;" NL "void main() {}";
                        std::string               tcs     = GenShader<T>(stage, ms_and_1d, subroutine);
                        const char* const glsl_tcs = tcs.c_str();
@@ -646,8 +647,9 @@ public:
                }
                else if (stage == 2)
                { // TES
-                       const char* const glsl_vs = "#version 430 core" NL "void main() { gl_Position = vec4(0.0, 0.0, 0.0, 1.0);}";
-                       std::string               tes    = GenShader<T>(stage, ms_and_1d, subroutine);
+                       const char* const glsl_vs = "#version 430 core" NL "out gl_PerVertex { vec4 gl_Position; };" NL
+                                                                               "void main() { gl_Position = vec4(0.0, 0.0, 0.0, 1.0);}";
+                       std::string               tes     = GenShader<T>(stage, ms_and_1d, subroutine);
                        const char* const glsl_tes = tes.c_str();
                        m_program[0]                       = glCreateShaderProgramv(GL_VERTEX_SHADER, 1, &glsl_vs);
                        m_program[1]                       = glCreateShaderProgramv(GL_TESS_EVALUATION_SHADER, 1, &glsl_tes);
@@ -656,7 +658,8 @@ public:
                }
                else if (stage == 3)
                { // GS
-                       const char* const glsl_vs = "#version 430 core" NL "void main() { gl_Position = vec4(0.0, 0.0, 0.0, 1.0);}";
+                       const char* const glsl_vs = "#version 430 core" NL "out gl_PerVertex { vec4 gl_Position; };" NL
+                                                                               "void main() { gl_Position = vec4(0.0, 0.0, 0.0, 1.0);}";
                        std::string               gs      = GenShader<T>(stage, ms_and_1d, subroutine);
                        const char* const glsl_gs = gs.c_str();
                        m_program[0]                      = glCreateShaderProgramv(GL_VERTEX_SHADER, 1, &glsl_vs);
@@ -673,7 +676,8 @@ public:
                }
                else if (stage == 5)
                { // FS
-                       const char* const glsl_vs = "#version 430 core" NL "void main() { gl_Position = vec4(0.0, 0.0, 0.0, 1.0);}";
+                       const char* const glsl_vs = "#version 430 core" NL "out gl_PerVertex { vec4 gl_Position; };" NL
+                                                                               "void main() { gl_Position = vec4(0.0, 0.0, 0.0, 1.0);}";
                        std::string               fs      = GenShader<T>(stage, ms_and_1d, subroutine);
                        const char* const glsl_fs = fs.c_str();
                        m_program[0]                      = glCreateShaderProgramv(GL_VERTEX_SHADER, 1, &glsl_vs);