Fix tests to work with pre-GL4 drivers
authorIlia Mirkin <imirkin@alum.mit.edu>
Sat, 1 Feb 2020 07:34:30 +0000 (02:34 -0500)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Fri, 16 Oct 2020 15:49:35 +0000 (11:49 -0400)
Components: OpenGL

Affects:
  KHR-GL33.cull_distance.*
  KHR-GL33.pipeline_statistics_query_tests_ARB.*
  KHR-GL33.gpu_shader5_gl.*
  KHR-GL33.transform_feedback.api_errors_test
(cherry picked from commit e14d294a7b773e90b350b41d4cc791ea01185b29)

Change-Id: Iab1400128c644214d224b6e15daf09dbfe88951f

external/openglcts/modules/gl/gl3cCullDistanceTests.cpp
external/openglcts/modules/gl/gl3cGPUShader5Tests.cpp
external/openglcts/modules/gl/gl3cTransformFeedbackTests.cpp
external/openglcts/modules/gl/gl4cPipelineStatisticsQueryTests.cpp

index 84bd8d3..3b82996 100644 (file)
@@ -508,12 +508,15 @@ tcu::TestNode::IterateResult CullDistance::APICoverageTest::iterate()
                GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2D() call failed.");
        }
 
-       gl.bindImageTexture(0,                     /* unit */
-                                               m_cs_to_id, 0, /* level */
-                                               GL_FALSE,         /* layered */
-                                               0,                         /* layer */
-                                               GL_WRITE_ONLY, GL_R32I);
-       GLU_EXPECT_NO_ERROR(gl.getError(), "glBindImageTexture() call failed.");
+       if (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 3)) ||
+           m_context.getContextInfo().isExtensionSupported("GL_ARB_compute_shader")) {
+               gl.bindImageTexture(0,                     /* unit */
+                                   m_cs_to_id, 0, /* level */
+                                   GL_FALSE,     /* layered */
+                                   0,                     /* layer */
+                                   GL_WRITE_ONLY, GL_R32I);
+                GLU_EXPECT_NO_ERROR(gl.getError(), "glBindImageTexture() call failed.");
+       }
 
        gl.bindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo_draw_id);
        GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer() call failed.");
@@ -1138,9 +1141,10 @@ void CullDistance::FunctionalTest::buildPO(glw::GLuint clipdistances_array_size,
 
        static const glw::GLchar* core_functionality = "#version 450\n";
 
-       static const glw::GLchar* extention_functionality = "#version 440\n"
+       static const glw::GLchar* extention_functionality = "#version 150\n"
                                                                                                                "\n"
                                                                                                                "#extension GL_ARB_cull_distance : require\n"
+                                                                                                               "TEMPLATE_EXTENSIONS\n"
                                                                                                                "\n"
                                                                                                                "#ifndef GL_ARB_cull_distance\n"
                                                                                                                "    #error GL_ARB_cull_distance is undefined\n"
@@ -1467,6 +1471,10 @@ void CullDistance::FunctionalTest::buildPO(glw::GLuint clipdistances_array_size,
                                        TCU_FAIL("Unknown primitive mode");
                                }
 
+                               CullDistance::Utilities::replaceAll(
+                                               shader_source,
+                                               std::string("TEMPLATE_EXTENSIONS"),
+                                               std::string("#extension GL_ARB_tessellation_shader: require"));
                                break;
                        }
 
@@ -1532,6 +1540,10 @@ void CullDistance::FunctionalTest::buildPO(glw::GLuint clipdistances_array_size,
                                        TCU_FAIL("Unknown primitive mode");
                                }
 
+                               CullDistance::Utilities::replaceAll(
+                                               shader_source,
+                                               std::string("TEMPLATE_EXTENSIONS"),
+                                               std::string("#extension GL_ARB_tessellation_shader: require"));
                                break;
                        }
 
@@ -1559,6 +1571,12 @@ void CullDistance::FunctionalTest::buildPO(glw::GLuint clipdistances_array_size,
                                TCU_FAIL("Unknown shader type");
                        }
 
+                       /* Clear out in case no specific exts were needed */
+                       CullDistance::Utilities::replaceAll(
+                                       shader_source,
+                                       std::string("TEMPLATE_EXTENSIONS"),
+                                       std::string(""));
+
                        /* Adjust clipdistances declaration */
                        if (redeclare_clipdistances && clipdistances_array_size > 0)
                        {
index f4b22f1..cde0c85 100644 (file)
@@ -425,6 +425,11 @@ tcu::TestNode::IterateResult GPUShader5ImplicitConversionsTest::iterate()
        };
        static const size_t n_test_cases = sizeof(test_cases) / sizeof(test_cases[0]);
 
+       if (!m_context.getContextInfo().isExtensionSupported("GL_ARB_gpu_shader5"))
+       {
+               throw tcu::NotSupportedError("GL_ARB_gpu_shader5 is not supported.");
+       }
+
        testInit();
 
        /* Execute test cases */
@@ -729,6 +734,11 @@ tcu::TestNode::IterateResult GPUShader5FunctionOverloadingTest::iterate()
        static const glw::GLuint u2_data_1[4] = { 0xffff0000, 0x0000ffff, 0x00ffffff, 0xffffffff };
        static const glw::GLuint u2_data_2[4] = { 0xfff70000, 0x00007fff, 0x007fffff, 0xfffffff7 };
 
+       if (!m_context.getContextInfo().isExtensionSupported("GL_ARB_gpu_shader5"))
+       {
+               throw tcu::NotSupportedError("GL_ARB_gpu_shader5 is not supported.");
+       }
+
        testInit();
 
        /* Execute test case */
@@ -1017,6 +1027,11 @@ tcu::TestNode::IterateResult GPUShader5FloatEncodingTest::iterate()
        };
        static const size_t n_test_cases = sizeof(test_cases) / sizeof(test_cases[0]);
 
+       if (!m_context.getContextInfo().isExtensionSupported("GL_ARB_gpu_shader5"))
+       {
+               throw tcu::NotSupportedError("GL_ARB_gpu_shader5 is not supported.");
+       }
+
        testInit();
 
        /* Execute test case */
index 3189c37..a461ac4 100644 (file)
@@ -142,6 +142,7 @@ tcu::TestNode::IterateResult gl3cts::TransformFeedback::APIErrors::iterate(void)
        bool is_arb_tf_2                 = m_context.getContextInfo().isExtensionSupported("GL_ARB_transform_feedback2");
        bool is_arb_tf_3                 = m_context.getContextInfo().isExtensionSupported("GL_ARB_transform_feedback3");
        bool is_arb_tf_instanced = m_context.getContextInfo().isExtensionSupported("GL_ARB_transform_feedback_instanced");
+       bool is_tessellation = m_context.getContextInfo().isExtensionSupported("GL_ARB_tessellation_shader");
 
        if (is_ext_tf_1)
        {
@@ -229,13 +230,16 @@ tcu::TestNode::IterateResult gl3cts::TransformFeedback::APIErrors::iterate(void)
                        gl, m_context.getTestContext().getLog(), m_geometry_shader, NULL, NULL, s_vertex_shader_without_output,
                        s_fragment_shader, &m_varying_name, 1, GL_INTERLEAVED_ATTRIBS);
 
-               m_program_id_with_tessellation_shaders = gl3cts::TransformFeedback::Utilities::buildProgram(
-                       gl, m_context.getTestContext().getLog(), NULL, m_tessellation_control_shader,
-                       m_tessellation_evaluation_shader, s_vertex_shader_without_output, s_fragment_shader, &m_varying_name, 1,
-                       GL_INTERLEAVED_ATTRIBS);
-
                is_ok = is_ok && m_program_id_with_input_output && m_program_id_with_output && m_program_id_without_output &&
-                               m_program_id_with_geometry_shader && m_program_id_with_tessellation_shaders;
+                               m_program_id_with_geometry_shader;
+
+                if (is_at_least_gl_40 || is_tessellation) {
+                       m_program_id_with_tessellation_shaders = gl3cts::TransformFeedback::Utilities::buildProgram(
+                                       gl, m_context.getTestContext().getLog(), NULL, m_tessellation_control_shader,
+                                       m_tessellation_evaluation_shader, s_vertex_shader_without_output, s_fragment_shader, &m_varying_name, 1,
+                                       GL_INTERLEAVED_ATTRIBS);
+                       is_ok = is_ok && m_program_id_with_tessellation_shaders;
+               }
        }
        catch (...)
        {
@@ -1357,6 +1361,11 @@ bool gl3cts::TransformFeedback::APIErrors::testInstanced(void)
        /* Functions handler */
        const glw::Functions& gl = m_context.getRenderContext().getFunctions();
 
+       bool is_at_least_gl_40 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 0)));
+       bool is_tessellation = m_context.getContextInfo().isExtensionSupported("GL_ARB_tessellation_shader");
+
+       bool has_patches = is_at_least_gl_40 || is_tessellation;
+
        /*  INVALID_ENUM is generated by DrawTransformFeedbackInstanced and
         DrawTransformFeedbackStreamInstanced if <mode> is invalid */
 
@@ -1374,7 +1383,7 @@ bool gl3cts::TransformFeedback::APIErrors::testInstanced(void)
                                                                          GL_PATCHES };
 
        std::set<glw::GLenum> supported_mode(_supported_mode,
-                                                                                _supported_mode + sizeof(_supported_mode) / sizeof(_supported_mode[0]));
+                                                                                _supported_mode + sizeof(_supported_mode) / sizeof(_supported_mode[0]) - (has_patches ? 0 : 1));
 
        int mode = 0;
 
@@ -1459,6 +1468,13 @@ bool gl3cts::TransformFeedback::APIErrors::testInstanced(void)
                return false;
        }
 
+       /* All of the below tests concern themselves with GL_PATCHES and
+        * tessellation shaders */
+       if (!has_patches)
+       {
+               return true;
+       }
+
        /*  INVALID_OPERATION is generated by DrawTransformFeedbackInstanced and
         DrawTransformFeedbackStreamInstanced if <mode> does not match tessellation */
 
index 172e0af..3649088 100644 (file)
@@ -444,7 +444,7 @@ bool PipelineStatisticsQueryUtilities::executeQuery(glw::GLenum query_type, glw:
                {
                        gl.bindBuffer(GL_QUERY_BUFFER, qo_bo_id);
                }
-               else
+               else if (qo_bo_id != 0)
                {
                        gl.bindBuffer(GL_QUERY_BUFFER, 0 /* buffer */);
                }
@@ -2067,6 +2067,7 @@ void PipelineStatisticsQueryTestFunctionalBase::initVBO(
        unsigned int indirect_draw_bo_first_argument, unsigned int indirect_draw_bo_basevertex_argument)
 {
        const glw::Functions& gl = m_context.getRenderContext().getFunctions();
+       glu::ContextType contextType = m_context.getRenderContext().getType();
 
        /* If we already have initialized a VBO, delete it before we continue */
        if (m_vbo_id != 0)
@@ -2119,7 +2120,11 @@ void PipelineStatisticsQueryTestFunctionalBase::initVBO(
        GLU_EXPECT_NO_ERROR(gl.getError(), "glGenBuffers() call failed.");
 
        gl.bindBuffer(GL_ARRAY_BUFFER, m_vbo_id);
-       gl.bindBuffer(GL_DRAW_INDIRECT_BUFFER, m_vbo_id);
+       if (glu::contextSupports(contextType, glu::ApiType::core(4, 0)) ||
+           m_context.getContextInfo().isExtensionSupported("GL_ARB_draw_indirect"))
+       {
+               gl.bindBuffer(GL_DRAW_INDIRECT_BUFFER, m_vbo_id);
+       }
        gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_vbo_id);
        GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer() call(s) failed.");
 
@@ -2171,6 +2176,12 @@ tcu::TestNode::IterateResult PipelineStatisticsQueryTestFunctionalBase::iterate(
        {
                glw::GLenum current_query_target = PipelineStatisticsQueryUtilities::query_targets[n_query_target];
 
+               /* Make sure the query is supported */
+               if (!PipelineStatisticsQueryUtilities::isQuerySupported(current_query_target, m_context.getContextInfo(), m_context.getRenderContext()))
+               {
+                       continue;
+               }
+
                if (shouldExecuteForQueryTarget(current_query_target))
                {
                        /* Initialize the query object */
@@ -2433,7 +2444,7 @@ bool PipelineStatisticsQueryTestFunctional1::executeTest(glw::GLenum current_que
                const glw::GLuint64 expected_value = 0;
 
                result &= PipelineStatisticsQueryUtilities::verifyResultValues(
-                       run_result, 1, &expected_value, m_qo_id != 0, /* should_check_qo_bo_values */
+                       run_result, 1, &expected_value, m_bo_qo_id != 0, /* should_check_qo_bo_values */
                        current_query_target, DE_NULL, DE_NULL,
                        false, /* is_primitive_restart_enabled */
                        m_testCtx, PipelineStatisticsQueryUtilities::VERIFICATION_TYPE_EXACT_MATCH);
@@ -2864,7 +2875,7 @@ bool PipelineStatisticsQueryTestFunctional2::executeTest(glw::GLenum current_que
                                bool                            has_passed       = true;
 
                                has_passed = PipelineStatisticsQueryUtilities::verifyResultValues(
-                                       run_result, 1, &expected_value, m_qo_id != 0,  /* should_check_qo_bo_values */
+                                       run_result, 1, &expected_value, m_bo_qo_id != 0,  /* should_check_qo_bo_values */
                                        current_query_target, DE_NULL, DE_NULL, false, /* is_primitive_restart_enabled */
                                        m_testCtx, PipelineStatisticsQueryUtilities::VERIFICATION_TYPE_EXACT_MATCH);
 
@@ -3102,7 +3113,7 @@ bool PipelineStatisticsQueryTestFunctional3::executeTest(glw::GLenum current_que
                                        }
 
                                        result &= PipelineStatisticsQueryUtilities::verifyResultValues(
-                                               run_result, n_expected_values, expected_values, m_qo_id != 0, /* should_check_qo_bo_values */
+                                               run_result, n_expected_values, expected_values, m_bo_qo_id != 0, /* should_check_qo_bo_values */
                                                current_query_target, &m_current_draw_call_type, &m_current_primitive_type,
                                                m_is_primitive_restart_enabled, m_testCtx, verification_type);
 
@@ -3638,7 +3649,7 @@ bool PipelineStatisticsQueryTestFunctional4::executeTest(glw::GLenum current_que
 
                                        /* Compare it against query result values */
                                        result &= PipelineStatisticsQueryUtilities::verifyResultValues(
-                                               run_result, 1, &expected_value, m_qo_id != 0, /* should_check_qo_bo_values */
+                                               run_result, 1, &expected_value, m_bo_qo_id != 0, /* should_check_qo_bo_values */
                                                current_query_target, &m_current_draw_call_type, &m_current_primitive_type,
                                                false, /* is_primitive_restart_enabled */
                                                m_testCtx, PipelineStatisticsQueryUtilities::VERIFICATION_TYPE_EQUAL_OR_GREATER);
@@ -3776,7 +3787,7 @@ bool PipelineStatisticsQueryTestFunctional5::executeTest(glw::GLenum current_que
 
                        /* Compare it against query result values */
                        result &= PipelineStatisticsQueryUtilities::verifyResultValues(
-                               run_result, 1, &expected_value, m_qo_id != 0, /* should_check_qo_bo_values */
+                               run_result, 1, &expected_value, m_bo_qo_id != 0, /* should_check_qo_bo_values */
                                current_query_target, &m_current_draw_call_type, &m_current_primitive_type,
                                false, /* is_primitive_restart_enabled */
                                m_testCtx, PipelineStatisticsQueryUtilities::VERIFICATION_TYPE_EQUAL_OR_GREATER);
@@ -3917,8 +3928,9 @@ bool PipelineStatisticsQueryTestFunctional6::executeTest(glw::GLenum current_que
                         *
                         * For GL_GEOMETRY_SHADER_INVOCATIONS, we only need a single iteration.
                         **/
+                       const bool streams_supported = glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 0));
                        const unsigned int n_internal_iterations =
-                               (current_query_target == GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB) ? 2 : 1;
+                               (current_query_target == GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB && streams_supported) ? 2 : 1;
 
                        for (unsigned int n_internal_iteration = 0; n_internal_iteration < n_internal_iterations;
                                 ++n_internal_iteration)
@@ -4024,7 +4036,7 @@ bool PipelineStatisticsQueryTestFunctional6::executeTest(glw::GLenum current_que
                                                /* Compare it against query result values */
                                                result &= PipelineStatisticsQueryUtilities::verifyResultValues(
                                                        run_result, n_expected_values, expected_values,
-                                                       m_qo_id != 0, /* should_check_qo_bo_values */
+                                                       m_bo_qo_id != 0, /* should_check_qo_bo_values */
                                                        current_query_target, &m_current_draw_call_type, &m_current_primitive_type,
                                                        false, /* is_primitive_restart_enabled */
                                                        m_testCtx, verification_type);
@@ -4187,7 +4199,7 @@ bool PipelineStatisticsQueryTestFunctional7::executeTest(glw::GLenum current_que
 
                                /* Compare it against query result values */
                                result &= PipelineStatisticsQueryUtilities::verifyResultValues(
-                                       run_result, 1, &expected_value, m_qo_id != 0, /* should_check_qo_bo_values */
+                                       run_result, 1, &expected_value, m_bo_qo_id != 0, /* should_check_qo_bo_values */
                                        current_query_target, &m_current_draw_call_type, &m_current_primitive_type,
                                        false, /* is_primitive_restart_enabled */
                                        m_testCtx, PipelineStatisticsQueryUtilities::VERIFICATION_TYPE_EQUAL_OR_GREATER);
@@ -4297,7 +4309,7 @@ bool PipelineStatisticsQueryTestFunctional8::executeTest(glw::GLenum current_que
 
                        /* Compare it against query result values */
                        result &= PipelineStatisticsQueryUtilities::verifyResultValues(
-                               run_result, 1, &expected_value, m_qo_id != 0,  /* should_check_qo_bo_values */
+                               run_result, 1, &expected_value, m_bo_qo_id != 0,  /* should_check_qo_bo_values */
                                current_query_target, DE_NULL, DE_NULL, false, /* is_primitive_restart_enabled */
                                m_testCtx, PipelineStatisticsQueryUtilities::VERIFICATION_TYPE_EQUAL_OR_GREATER);
                } /* if (run results were obtained successfully) */
@@ -4311,6 +4323,13 @@ void PipelineStatisticsQueryTestFunctional8::initObjects()
 {
        const glw::Functions& gl = m_context.getRenderContext().getFunctions();
 
+       /* 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"))
+       {
+               throw tcu::NotSupportedError("OpenGL 4.3+ / compute shaders required to run this test.");
+       }
+
        buildProgram(PipelineStatisticsQueryUtilities::dummy_cs_code, DE_NULL, /* fs_body */
                                 DE_NULL,                                                                                                  /* gs_body */
                                 DE_NULL,                                                                                                  /* tc_body */