Respect GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS
authorIago Toral Quiroga <itoral@igalia.com>
Tue, 17 Oct 2017 07:58:57 +0000 (09:58 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Tue, 31 Oct 2017 08:50:01 +0000 (04:50 -0400)
KHR-GL45.enhanced_layouts.xfb_override_qualifiers_with_api
generates shaders that capture XFB for varyings of all types.
For the cases of dmat4x3, dmat3x4 and dmat4, this requires
over 64 transform feedback components in total, which is larger
than the minimum value that implementations are required to
support for GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS,
which the OpenGL 4.6 spec sets in 64. For implementations that
support this minimum, the generated shaders are invalid and
expected to fail to link.

Check the required component size of the XFB for the generated
shaders and skip them if they exceed the implementation limit.
At worse, for implementations that only support the minimum
number of transform feedback components required by the spec
it would only skip the 3 largest types (out of 34 being tested).

Components: OpenGL
VK-GL-CTS issue: 776

Affects:
KHR-GL45.enhanced_layouts.xfb_override_qualifiers_with_api

Change-Id: I51c9da494f96a0746f74116f817d99afd070a9ee

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

index b4aedab..547ea44 100644 (file)
@@ -5609,7 +5609,8 @@ void BufferTestBase::getBufferDescriptors(glw::GLuint /* test_case_index */,
  * @param ignored
  **/
 void BufferTestBase::getCapturedVaryings(glw::GLuint /* test_case_index */,
-                                                                                Utils::Program::NameVector& /* captured_varyings */)
+                                                                                Utils::Program::NameVector& /* captured_varyings */,
+                                                                                GLint* /* xfb_components */)
 {
        /* Nothing to be done */
 }
@@ -5701,7 +5702,21 @@ bool BufferTestBase::testCase(GLuint test_case_index)
                Utils::VertexArray                 vao(m_context);
 
                /* Get captured varyings */
-               getCapturedVaryings(test_case_index, captured_varyings);
+               GLint xfb_components;
+               getCapturedVaryings(test_case_index, captured_varyings, &xfb_components);
+
+               /* Don't generate shaders that try to capture more XFB components than the implementation's limit */
+               if (captured_varyings.size() > 0)
+               {
+                       const Functions& gl     = m_context.getRenderContext().getFunctions();
+
+                       GLint max_xfb_components;
+                       gl.getIntegerv(GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, &max_xfb_components);
+                       GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
+
+                       if (xfb_components > max_xfb_components)
+                               return true;
+               }
 
                /* Get shader sources */
                const std::string& fragment_shader  = getShaderSource(test_case_index, Utils::Shader::FRAGMENT);
@@ -20441,9 +20456,11 @@ void XFBStrideOfEmptyListAndAPITest::getBufferDescriptors(glw::GLuint                          test_ca
  * @param captured_varyings Vector of varying names to be captured
  **/
 void XFBStrideOfEmptyListAndAPITest::getCapturedVaryings(glw::GLuint /* test_case_index */,
-                                                                                                                Utils::Program::NameVector& captured_varyings)
+                                                                                                                Utils::Program::NameVector& captured_varyings,
+                                                                                                                GLint* xfb_components)
 {
        captured_varyings.push_back("gs_fs");
+       *xfb_components = 4;
 }
 
 /** Get body of main function for given shader stage
@@ -22809,12 +22826,18 @@ void XFBOverrideQualifiersWithAPITest::getBufferDescriptors(glw::GLuint                                 tes
  * @param ignored
  * @param captured_varyings List of names
  **/
-void XFBOverrideQualifiersWithAPITest::getCapturedVaryings(glw::GLuint /* test_case_index */,
-                                                                                                                  Utils::Program::NameVector& captured_varyings)
+void XFBOverrideQualifiersWithAPITest::getCapturedVaryings(glw::GLuint test_case_index,
+                                                                                                                  Utils::Program::NameVector& captured_varyings,
+                                                                                                                  GLint* xfb_components)
 {
        captured_varyings.resize(1);
 
        captured_varyings[0] = "trunks";
+
+       /* The test captures 3 varyings of type 'type' */
+       Utils::Type     type            = getType(test_case_index);
+       GLint           type_size       = type.GetSize(false);
+       *xfb_components                 = 3 * type_size / 4;
 }
 
 /** Get body of main function for given shader stage
index 427b77c..f5d4225 100644 (file)
@@ -1081,7 +1081,7 @@ protected:
 
        virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector& out_descriptors);
 
-       virtual void getCapturedVaryings(glw::GLuint test_case_index, Utils::Program::NameVector& captured_varyings);
+       virtual void getCapturedVaryings(glw::GLuint test_case_index, Utils::Program::NameVector& captured_varyings, glw::GLint* xfb_components);
 
        virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string& out_assignments,
                                                           std::string& out_calculations);
@@ -3479,7 +3479,7 @@ protected:
        virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index);
        virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector& out_descriptors);
 
-       virtual void getCapturedVaryings(glw::GLuint test_case_index, Utils::Program::NameVector& captured_varyings);
+       virtual void getCapturedVaryings(glw::GLuint test_case_index, Utils::Program::NameVector& captured_varyings, glw::GLint* xfb_components);
 
        virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string& out_assignments,
                                                           std::string& out_calculations);
@@ -3924,7 +3924,7 @@ protected:
        /* Protected methods */
        virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector& out_descriptors);
 
-       virtual void getCapturedVaryings(glw::GLuint test_case_index, Utils::Program::NameVector& captured_varyings);
+       virtual void getCapturedVaryings(glw::GLuint test_case_index, Utils::Program::NameVector& captured_varyings, glw::GLint* xfb_components);
 
        virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string& out_assignments,
                                                           std::string& out_calculations);