1e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------- 2e5c31af7Sopenharmony_ci * OpenGL Conformance Test Suite 3e5c31af7Sopenharmony_ci * ----------------------------- 4e5c31af7Sopenharmony_ci * 5e5c31af7Sopenharmony_ci * Copyright (c) 2016 Google Inc. 6e5c31af7Sopenharmony_ci * Copyright (c) 2016 The Khronos Group Inc. 7e5c31af7Sopenharmony_ci * 8e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 9e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License. 10e5c31af7Sopenharmony_ci * You may obtain a copy of the License at 11e5c31af7Sopenharmony_ci * 12e5c31af7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 13e5c31af7Sopenharmony_ci * 14e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 15e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 16e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and 18e5c31af7Sopenharmony_ci * limitations under the License. 19e5c31af7Sopenharmony_ci * 20e5c31af7Sopenharmony_ci */ /*! 21e5c31af7Sopenharmony_ci * \file 22e5c31af7Sopenharmony_ci * \brief OpenGL ES 2 Test Package. 23e5c31af7Sopenharmony_ci */ /*-------------------------------------------------------------------*/ 24e5c31af7Sopenharmony_ci 25e5c31af7Sopenharmony_ci#include "es2cTestPackage.hpp" 26e5c31af7Sopenharmony_ci#include "es2cTexture3DTests.hpp" 27e5c31af7Sopenharmony_ci#include "glcAggressiveShaderOptimizationsTests.hpp" 28e5c31af7Sopenharmony_ci#include "glcInfoTests.hpp" 29e5c31af7Sopenharmony_ci#include "glcInternalformatTests.hpp" 30e5c31af7Sopenharmony_ci#include "glcShaderNegativeTests.hpp" 31e5c31af7Sopenharmony_ci#include "gluRenderContext.hpp" 32e5c31af7Sopenharmony_ci#include "gluStateReset.hpp" 33e5c31af7Sopenharmony_ci#include "glwEnums.hpp" 34e5c31af7Sopenharmony_ci#include "glwFunctions.hpp" 35e5c31af7Sopenharmony_ci#include "tcuTestLog.hpp" 36e5c31af7Sopenharmony_ci#include "tcuWaiverUtil.hpp" 37e5c31af7Sopenharmony_ci 38e5c31af7Sopenharmony_cinamespace es2cts 39e5c31af7Sopenharmony_ci{ 40e5c31af7Sopenharmony_ci 41e5c31af7Sopenharmony_ciclass TestCaseWrapper : public tcu::TestCaseExecutor 42e5c31af7Sopenharmony_ci{ 43e5c31af7Sopenharmony_cipublic: 44e5c31af7Sopenharmony_ci TestCaseWrapper(TestPackage& package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism); 45e5c31af7Sopenharmony_ci ~TestCaseWrapper(void); 46e5c31af7Sopenharmony_ci 47e5c31af7Sopenharmony_ci void init(tcu::TestCase* testCase, const std::string& path); 48e5c31af7Sopenharmony_ci void deinit(tcu::TestCase* testCase); 49e5c31af7Sopenharmony_ci tcu::TestNode::IterateResult iterate(tcu::TestCase* testCase); 50e5c31af7Sopenharmony_ci 51e5c31af7Sopenharmony_ciprivate: 52e5c31af7Sopenharmony_ci es2cts::TestPackage& m_testPackage; 53e5c31af7Sopenharmony_ci de::SharedPtr<tcu::WaiverUtil> m_waiverMechanism; 54e5c31af7Sopenharmony_ci}; 55e5c31af7Sopenharmony_ci 56e5c31af7Sopenharmony_ciTestCaseWrapper::TestCaseWrapper(TestPackage& package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism) 57e5c31af7Sopenharmony_ci : m_testPackage(package) 58e5c31af7Sopenharmony_ci , m_waiverMechanism(waiverMechanism) 59e5c31af7Sopenharmony_ci{ 60e5c31af7Sopenharmony_ci} 61e5c31af7Sopenharmony_ci 62e5c31af7Sopenharmony_ciTestCaseWrapper::~TestCaseWrapper(void) 63e5c31af7Sopenharmony_ci{ 64e5c31af7Sopenharmony_ci} 65e5c31af7Sopenharmony_ci 66e5c31af7Sopenharmony_civoid TestCaseWrapper::init(tcu::TestCase* testCase, const std::string& path) 67e5c31af7Sopenharmony_ci{ 68e5c31af7Sopenharmony_ci if (m_waiverMechanism->isOnWaiverList(path)) 69e5c31af7Sopenharmony_ci throw tcu::TestException("Waived test", QP_TEST_RESULT_WAIVER); 70e5c31af7Sopenharmony_ci 71e5c31af7Sopenharmony_ci glu::resetState(m_testPackage.getContext().getRenderContext(), m_testPackage.getContext().getContextInfo()); 72e5c31af7Sopenharmony_ci 73e5c31af7Sopenharmony_ci testCase->init(); 74e5c31af7Sopenharmony_ci} 75e5c31af7Sopenharmony_ci 76e5c31af7Sopenharmony_civoid TestCaseWrapper::deinit(tcu::TestCase* testCase) 77e5c31af7Sopenharmony_ci{ 78e5c31af7Sopenharmony_ci testCase->deinit(); 79e5c31af7Sopenharmony_ci 80e5c31af7Sopenharmony_ci glu::resetState(m_testPackage.getContext().getRenderContext(), m_testPackage.getContext().getContextInfo()); 81e5c31af7Sopenharmony_ci} 82e5c31af7Sopenharmony_ci 83e5c31af7Sopenharmony_citcu::TestNode::IterateResult TestCaseWrapper::iterate(tcu::TestCase* testCase) 84e5c31af7Sopenharmony_ci{ 85e5c31af7Sopenharmony_ci tcu::TestContext& testCtx = m_testPackage.getContext().getTestContext(); 86e5c31af7Sopenharmony_ci glu::RenderContext& renderCtx = m_testPackage.getContext().getRenderContext(); 87e5c31af7Sopenharmony_ci tcu::TestCase::IterateResult result; 88e5c31af7Sopenharmony_ci 89e5c31af7Sopenharmony_ci // Clear to black 90e5c31af7Sopenharmony_ci { 91e5c31af7Sopenharmony_ci const glw::Functions& gl = renderCtx.getFunctions(); 92e5c31af7Sopenharmony_ci gl.clearColor(0.0f, 0.0f, 0.0f, 1.f); 93e5c31af7Sopenharmony_ci gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 94e5c31af7Sopenharmony_ci } 95e5c31af7Sopenharmony_ci 96e5c31af7Sopenharmony_ci result = testCase->iterate(); 97e5c31af7Sopenharmony_ci 98e5c31af7Sopenharmony_ci // Call implementation specific post-iterate routine (usually handles native events and swaps buffers) 99e5c31af7Sopenharmony_ci try 100e5c31af7Sopenharmony_ci { 101e5c31af7Sopenharmony_ci renderCtx.postIterate(); 102e5c31af7Sopenharmony_ci return result; 103e5c31af7Sopenharmony_ci } 104e5c31af7Sopenharmony_ci catch (const tcu::ResourceError& e) 105e5c31af7Sopenharmony_ci { 106e5c31af7Sopenharmony_ci testCtx.getLog() << e; 107e5c31af7Sopenharmony_ci testCtx.setTestResult(QP_TEST_RESULT_RESOURCE_ERROR, "Resource error in context post-iteration routine"); 108e5c31af7Sopenharmony_ci testCtx.setTerminateAfter(true); 109e5c31af7Sopenharmony_ci return tcu::TestNode::STOP; 110e5c31af7Sopenharmony_ci } 111e5c31af7Sopenharmony_ci catch (const std::exception& e) 112e5c31af7Sopenharmony_ci { 113e5c31af7Sopenharmony_ci testCtx.getLog() << e; 114e5c31af7Sopenharmony_ci testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Error in context post-iteration routine"); 115e5c31af7Sopenharmony_ci return tcu::TestNode::STOP; 116e5c31af7Sopenharmony_ci } 117e5c31af7Sopenharmony_ci} 118e5c31af7Sopenharmony_ci 119e5c31af7Sopenharmony_ciclass ShaderTests : public deqp::TestCaseGroup 120e5c31af7Sopenharmony_ci{ 121e5c31af7Sopenharmony_cipublic: 122e5c31af7Sopenharmony_ci ShaderTests(deqp::Context& context) : TestCaseGroup(context, "shaders", "Shading Language Tests") 123e5c31af7Sopenharmony_ci { 124e5c31af7Sopenharmony_ci } 125e5c31af7Sopenharmony_ci 126e5c31af7Sopenharmony_ci void init(void) 127e5c31af7Sopenharmony_ci { 128e5c31af7Sopenharmony_ci addChild(new deqp::ShaderNegativeTests(m_context, glu::GLSL_VERSION_100_ES)); 129e5c31af7Sopenharmony_ci addChild(new glcts::AggressiveShaderOptimizationsTests(m_context)); 130e5c31af7Sopenharmony_ci } 131e5c31af7Sopenharmony_ci}; 132e5c31af7Sopenharmony_ci 133e5c31af7Sopenharmony_ciTestPackage::TestPackage(tcu::TestContext& testCtx, const char* packageName) 134e5c31af7Sopenharmony_ci : deqp::TestPackage(testCtx, packageName, "OpenGL ES 2 Conformance Tests", glu::ContextType(glu::ApiType::es(2, 0)), 135e5c31af7Sopenharmony_ci "gl_cts/data/gles2/") 136e5c31af7Sopenharmony_ci{ 137e5c31af7Sopenharmony_ci} 138e5c31af7Sopenharmony_ci 139e5c31af7Sopenharmony_ciTestPackage::~TestPackage(void) 140e5c31af7Sopenharmony_ci{ 141e5c31af7Sopenharmony_ci} 142e5c31af7Sopenharmony_ci 143e5c31af7Sopenharmony_civoid TestPackage::init(void) 144e5c31af7Sopenharmony_ci{ 145e5c31af7Sopenharmony_ci // Call init() in parent - this creates context. 146e5c31af7Sopenharmony_ci deqp::TestPackage::init(); 147e5c31af7Sopenharmony_ci 148e5c31af7Sopenharmony_ci try 149e5c31af7Sopenharmony_ci { 150e5c31af7Sopenharmony_ci addChild(new ShaderTests(getContext())); 151e5c31af7Sopenharmony_ci addChild(new Texture3DTests(getContext())); 152e5c31af7Sopenharmony_ci tcu::TestCaseGroup* coreGroup = new tcu::TestCaseGroup(getTestContext(), "core", "core tests"); 153e5c31af7Sopenharmony_ci coreGroup->addChild(new glcts::InternalformatTests(getContext())); 154e5c31af7Sopenharmony_ci addChild(coreGroup); 155e5c31af7Sopenharmony_ci } 156e5c31af7Sopenharmony_ci catch (...) 157e5c31af7Sopenharmony_ci { 158e5c31af7Sopenharmony_ci // Destroy context. 159e5c31af7Sopenharmony_ci deqp::TestPackage::deinit(); 160e5c31af7Sopenharmony_ci throw; 161e5c31af7Sopenharmony_ci } 162e5c31af7Sopenharmony_ci} 163e5c31af7Sopenharmony_ci 164e5c31af7Sopenharmony_citcu::TestCaseExecutor* TestPackage::createExecutor(void) const 165e5c31af7Sopenharmony_ci{ 166e5c31af7Sopenharmony_ci return new TestCaseWrapper(const_cast<TestPackage&>(*this), m_waiverMechanism); 167e5c31af7Sopenharmony_ci} 168e5c31af7Sopenharmony_ci 169e5c31af7Sopenharmony_ci} // es2cts 170