Fix maximum location for varying location limit test
authorIago Toral Quiroga <itoral@igalia.com>
Thu, 23 Nov 2017 08:30:35 +0000 (09:30 +0100)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Tue, 28 Nov 2017 10:29:33 +0000 (05:29 -0500)
The varying location limit tests for enhanced layouts produces
shader code where it attempts to use a location that is 1 slot
beyond the limit available for each shader stage and expects
linker errors as a result.

However, the functions it uses to compute the maximum location
slot available in a shader stage also consider the stage it will
be linked to to cap that limit (which is required to produce valid
shader code in other tests that also use these functions).

This affects scenarios where, for example, one stage allows up to
32 output locations but the stage it is linked to only accepts
up to 16 inputs. In such scenario, these functions will return
a limit of 16 for the stage that can output 32 so the shader code
produced can link.

However, the varying location limit test intends to produce an
invalid location by adding 1 to the maximum location slot for that
stage (so it wants to produce 32 + 1 = 33 in the case above), so
in this particular case we want the connecting stage to be
ignored.

Add a boolean flag to these functions so we can select between both
behaviors when computing the maximum location for a given stage
and make the varying location limit test force the behavior where
the maximum location in the connecting shader stages is ignored.

Components: OpenGL
VK-GL-CTS issue: 863

Affects:
KHR-GL45.enhanced_layouts.varying_location_limit
KHR-GL46.enhanced_layouts.varying_location_limit
KHR-GL45.enhanced_layouts.varying_locations
KHR-GL46.enhanced_layouts.varying_locations
KHR-GL45.enhanced_layouts.varying_array_locations
KHR-GL46.enhanced_layouts.varying_array_locations
KHR-GL45.enhanced_layouts.varying_components
KHR-GL46.enhanced_layouts.varying_components
KHR-GL45.enhanced_layouts.varying_array_components
KHR-GL46.enhanced_layouts.varying_array_components

Change-Id: If766582bf494942abdad3e1dde5e1ed8149f4333

external/openglcts/modules/gl/gl4cEnhancedLayoutsTests.cpp
external/openglcts/modules/gl/gl4cEnhancedLayoutsTests.hpp

index 1924b72..85a92de 100644 (file)
@@ -5078,7 +5078,7 @@ tcu::TestNode::IterateResult TestBase::iterate()
  *
  * @return Last location index
  **/
-GLint TestBase::getLastInputLocation(Utils::Shader::STAGES stage, const Utils::Type& type, GLuint array_length)
+GLint TestBase::getLastInputLocation(Utils::Shader::STAGES stage, const Utils::Type& type, GLuint array_length, bool ignore_prev_stage)
 {
        GLint  divide           = 4; /* 4 components per location */
        GLint  param            = 0;
@@ -5126,7 +5126,7 @@ GLint TestBase::getLastInputLocation(Utils::Shader::STAGES stage, const Utils::T
        gl.getIntegerv(pname, &param);
        GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
 
-       if (pnamePrev) {
+       if (pnamePrev && !ignore_prev_stage) {
                gl.getIntegerv(pnamePrev, &paramPrev);
                GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
 
@@ -5158,7 +5158,7 @@ GLint TestBase::getLastInputLocation(Utils::Shader::STAGES stage, const Utils::T
  *
  * @return Last location index
  **/
-GLint TestBase::getLastOutputLocation(Utils::Shader::STAGES stage, const Utils::Type& type, GLuint array_length)
+GLint TestBase::getLastOutputLocation(Utils::Shader::STAGES stage, const Utils::Type& type, GLuint array_length, bool ignore_next_stage)
 {
        GLint  param            = 0;
        GLenum pname            = 0;
@@ -5201,9 +5201,6 @@ GLint TestBase::getLastOutputLocation(Utils::Shader::STAGES stage, const Utils::
        gl.getIntegerv(pname, &param);
        GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
 
-       gl.getIntegerv(pnameNext, &paramNext);
-       GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
-
 /* Calculate */
 #if WRKARD_VARYINGLOCATIONSTEST
 
@@ -5212,7 +5209,13 @@ GLint TestBase::getLastOutputLocation(Utils::Shader::STAGES stage, const Utils::
 #else
 
        /* Don't write to a location that doesn't exist in the next stage */
-       param = de::min(param, paramNext);
+       if (!ignore_next_stage)
+       {
+               gl.getIntegerv(pnameNext, &paramNext);
+               GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
+
+               param = de::min(param, paramNext);
+       }
 
        const GLint n_avl_locations = param / 4; /* 4 components per location */
 
@@ -12430,7 +12433,7 @@ void VaryingLocationsTest::prepareShaderStage(Utils::Shader::STAGES stage, const
        const GLuint array_length  = 1;
        const GLuint first_in_loc  = 0;
        const GLuint first_out_loc = 0;
-       const GLuint last_in_loc   = getLastInputLocation(stage, type, array_length);
+       const GLuint last_in_loc   = getLastInputLocation(stage, type, array_length, false);
        size_t           position         = 0;
 
        const GLchar* prefix_in = Utils::ProgramInterface::GetStagePrefix(stage, Utils::Variable::VARYING_INPUT);
@@ -12482,7 +12485,7 @@ void VaryingLocationsTest::prepareShaderStage(Utils::Shader::STAGES stage, const
 
        if (Utils::Shader::FRAGMENT != stage)
        {
-               const GLuint last_out_loc = getLastOutputLocation(stage, type, array_length);
+               const GLuint last_out_loc = getLastOutputLocation(stage, type, array_length, false);
 
                Utils::Variable* first_out =
                        si.Output(first_out_name.c_str(), qual_first_out /* qualifiers */, 0 /* expected_componenet */,
@@ -12800,7 +12803,7 @@ void VaryingArrayLocationsTest::prepareShaderStage(Utils::Shader::STAGES stage,
        const GLuint array_length  = 1u;
        const GLuint first_in_loc  = 0;
        const GLuint first_out_loc = 0;
-       const GLuint last_in_loc   = getLastInputLocation(stage, type, array_length);
+       const GLuint last_in_loc   = getLastInputLocation(stage, type, array_length, false);
        size_t           position         = 0;
 
        const GLchar* prefix_in = Utils::ProgramInterface::GetStagePrefix(stage, Utils::Variable::VARYING_INPUT);
@@ -12853,7 +12856,7 @@ void VaryingArrayLocationsTest::prepareShaderStage(Utils::Shader::STAGES stage,
 
        if (Utils::Shader::FRAGMENT != stage)
        {
-               const GLuint last_out_loc = getLastOutputLocation(stage, type, array_length);
+               const GLuint last_out_loc = getLastOutputLocation(stage, type, array_length, false);
 
                Utils::Variable* first_out =
                        si.Output(first_out_name.c_str(), qual_first_out /* qualifiers */, 0 /* expected_componenet */,
@@ -14592,7 +14595,7 @@ std::string VaryingLocationLimitTest::getShaderSource(GLuint test_case_index, Ut
                const GLchar*                    direction = "in ";
                const GLchar*                    flat     = "";
                const GLchar*                    index   = "";
-               GLuint                                   last     = getLastInputLocation(stage, test_case.m_type, 0);
+               GLuint                                   last     = getLastInputLocation(stage, test_case.m_type, 0, true);
                size_t                                   position  = 0;
                size_t                                   temp;
                const GLchar*                    type_name = test_case.m_type.GetGLSLTypeName();
@@ -14602,7 +14605,7 @@ std::string VaryingLocationLimitTest::getShaderSource(GLuint test_case_index, Ut
                if (false == test_case.m_is_input)
                {
                        direction = "out";
-                       last      = getLastOutputLocation(stage, test_case.m_type, 0);
+                       last      = getLastOutputLocation(stage, test_case.m_type, 0, true);
                        storage   = Utils::Variable::VARYING_OUTPUT;
                        var_use   = output_use;
                }
@@ -15009,7 +15012,7 @@ void VaryingComponentsTest::prepareShaderStage(Utils::Shader::STAGES stage, cons
        const GLuint                    first_in_loc  = 0;
        const GLuint                    first_out_loc = 0;
        const GLchar*                   interpolation = "";
-       const GLuint                    last_in_loc   = getLastInputLocation(stage, vector_type, array_length);
+       const GLuint                    last_in_loc   = getLastInputLocation(stage, vector_type, array_length, false);
        GLuint                                  last_out_loc  = 0;
        GLuint                                  n_desc            = 0;
        Utils::ShaderInterface& si                        = program_interface.GetShaderInterface(stage);
@@ -15022,7 +15025,7 @@ void VaryingComponentsTest::prepareShaderStage(Utils::Shader::STAGES stage, cons
 
        if (Utils::Shader::FRAGMENT != stage)
        {
-               last_out_loc = getLastOutputLocation(stage, vector_type, array_length);
+               last_out_loc = getLastOutputLocation(stage, vector_type, array_length, false);
        }
 
        switch (test_case.m_layout)
index fdfe45c..31d7982 100644 (file)
@@ -1018,9 +1018,9 @@ protected:
        glw::GLuint calculateStride(const Utils::Interface& interface) const;
        void generateData(const Utils::Interface& interface, glw::GLuint offset, std::vector<glw::GLubyte>& out_data) const;
 
-       glw::GLint getLastInputLocation(Utils::Shader::STAGES stage, const Utils::Type& type, glw::GLuint array_lenth);
+       glw::GLint getLastInputLocation(Utils::Shader::STAGES stage, const Utils::Type& type, glw::GLuint array_lenth, bool ignore_prev_stage);
 
-       glw::GLint getLastOutputLocation(Utils::Shader::STAGES stage, const Utils::Type& type, glw::GLuint array_lenth);
+       glw::GLint getLastOutputLocation(Utils::Shader::STAGES stage, const Utils::Type& type, glw::GLuint array_lenth, bool ignore_next_stage);
 
        Utils::Type getType(glw::GLuint index) const;
        std::string getTypeName(glw::GLuint index) const;