pipeline statistics test: Fix compute shader setup in !GL4.3 case.
authorEric Anholt <anholt@google.com>
Fri, 11 Dec 2020 20:17:44 +0000 (12:17 -0800)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 7 Jan 2021 09:52:49 +0000 (09:52 +0000)
The ARB_compute_shader spec states a requirement for GL4.2/GLSL 4.20
or better, but we were using "#version 430" regardless, causing a
compile failure on older versions.  Add a variant of the shader using
the ARB_compute_shader extension instead.

I picked GLSL 330 for the variant because the test is included in the
GL 3.3 test set, and Mesa's softpipe driver exposes ARB_compute_shader
on GL 3.3 -- the GLSL requirement in the spec seems to be more than is
actually necessary for compute shaders, assuming you have
ARB_shader_image_load_store and such as well.  Since we're doing this
pre-4.2, we have to add the dependency on ARB_shader_atomic_counters
as well.

VK-GL-CTS Issue: 2694
Components: OpenGL
Affects: KHR-GL33.pipeline_statistics_query_tests_ARB.functional_compute_shader_invocations

Change-Id: If37e0e10bed86281d07aed67394075844e88003d

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

index 3649088..2827f36 100644 (file)
@@ -85,6 +85,19 @@ const char* PipelineStatisticsQueryUtilities::dummy_cs_code =
        "{\n"
        "    atomicCounterIncrement(test_counter);\n"
        "}\n";
+const char* PipelineStatisticsQueryUtilities::dummy_cs_code_arb =
+       "#version 330\n"
+       "#extension GL_ARB_compute_shader : require\n"
+       "#extension GL_ARB_shader_atomic_counters : require\n"
+       "\n"
+       "layout(local_size_x=1, local_size_y = 1, local_size_z = 1) in;\n"
+       "\n"
+       "layout(binding = 0) uniform atomic_uint test_counter;\n"
+       "\n"
+       "void main()\n"
+       "{\n"
+       "    atomicCounterIncrement(test_counter);\n"
+       "}\n";
 const char* PipelineStatisticsQueryUtilities::dummy_fs_code = "#version 130\n"
                                                                                                                          "\n"
                                                                                                                          "out vec4 result;\n"
@@ -4322,15 +4335,25 @@ bool PipelineStatisticsQueryTestFunctional8::executeTest(glw::GLenum current_que
 void PipelineStatisticsQueryTestFunctional8::initObjects()
 {
        const glw::Functions& gl = m_context.getRenderContext().getFunctions();
+       const char*                       cs_code = NULL;
 
        /* This test should not execute if we don't have compute shaders */
-       if (!glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 3)) &&
-           !m_context.getContextInfo().isExtensionSupported("GL_ARB_compute_shader"))
+       if (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 3)))
+       {
+               cs_code = PipelineStatisticsQueryUtilities::dummy_cs_code;
+       }
+       else if (m_context.getContextInfo().isExtensionSupported("GL_ARB_compute_shader") &&
+       m_context.getContextInfo().isExtensionSupported("GL_ARB_shader_atomic_counters"))
+       {
+               cs_code = PipelineStatisticsQueryUtilities::dummy_cs_code_arb;
+       }
+       else
        {
-               throw tcu::NotSupportedError("OpenGL 4.3+ / compute shaders required to run this test.");
+               throw tcu::NotSupportedError("OpenGL 4.3+ / compute shaders and atomic counters required to run this test.");
        }
 
-       buildProgram(PipelineStatisticsQueryUtilities::dummy_cs_code, DE_NULL, /* fs_body */
+       buildProgram(cs_code,
+                                DE_NULL,                                                                                                  /* fs_body */
                                 DE_NULL,                                                                                                  /* gs_body */
                                 DE_NULL,                                                                                                  /* tc_body */
                                 DE_NULL,                                                                                                  /* te_body */
index 6bbb61b..af75940 100644 (file)
@@ -221,6 +221,7 @@ public:
         * GL_COMPUTE_SHADER_INVOCATIONS_ARB query works correctly.
         */
        static const char* dummy_cs_code;
+       static const char* dummy_cs_code_arb;
        /* Code of a fragment shader used by a number of functional tests */
        static const char* dummy_fs_code;
        /* Code of a tessellation control shader used by a functional test that verifies