Use proper name for array-of-array varyings.
authorJuan A. Suarez Romero <jasuarez@igalia.com>
Mon, 30 Oct 2017 12:50:23 +0000 (12:50 +0000)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Fri, 10 Nov 2017 13:18:36 +0000 (08:18 -0500)
varying_structure_location tests have the piece of shader code:

```
struct Data {
    dvec2 single;
    dvec2 array[1];
};

layout (location = 0) flat in Data tes_gs_output[][1];
```

When test tries to verify "single" variable, it tries to access through
"tes_gs_output[0].single", which is not correct. Rather it must use
"tes_gs_output[0][0].single"

Affects:
* KHR-GL46.enhanced_layouts.varying_structure_locations

Components: OpenGL

VK-GL-CTS issue: 796

Change-Id: Ib1c2ac6877f46f0be8530156a184b8fa41349c40

external/openglcts/modules/gl/gl4cEnhancedLayoutsTests.cpp

index 60afa14..1924b72 100644 (file)
@@ -1057,7 +1057,7 @@ bool verifyVarying(Program& program, const std::string& parent_name, const Varia
  *
  * @return true if verification is positive, false otherwise
  **/
-bool checkVarying(Program& program, const Variable& variable, std::stringstream& stream, bool is_input)
+bool checkVarying(Program& program, Shader::STAGES stage, const Variable& variable, std::stringstream& stream, bool is_input)
 {
        bool result = true;
 
@@ -1091,6 +1091,17 @@ bool checkVarying(Program& program, const Variable& variable, std::stringstream&
                Utils::Interface* interface              = variable.m_descriptor.m_interface;
                const size_t      n_members              = interface->m_members.size();
                std::string               structVariable = variable.m_descriptor.m_name;
+
+               switch (Variable::GetFlavour(stage, is_input ? Variable::INPUT : Variable::OUTPUT))
+               {
+               case Variable::ARRAY:
+               case Variable::INDEXED_BY_INVOCATION_ID:
+                       structVariable.append("[0]");
+                       break;
+               default:
+                       break;
+               }
+
                // If struct variable is an array
                if (0 != variable.m_descriptor.m_n_array_elements)
                {
@@ -1319,7 +1330,7 @@ bool checkProgramStage(Program& program, const ProgramInterface& program_interfa
 
                for (const_iterator it = inputs.begin(); it != inputs.end(); ++it)
                {
-                       if (false == checkVarying(program, **it, stream, true))
+                       if (false == checkVarying(program, stage, **it, stream, true))
                        {
                                result = false;
                        }
@@ -1333,7 +1344,7 @@ bool checkProgramStage(Program& program, const ProgramInterface& program_interfa
 
                for (const_iterator it = outputs.begin(); it != outputs.end(); ++it)
                {
-                       if (false == checkVarying(program, **it, stream, false))
+                       if (false == checkVarying(program, stage, **it, stream, false))
                        {
                                result = false;
                        }