Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 1 | /*------------------------------------------------------------------------- |
| 2 | * drawElements Quality Program OpenGL ES 3.0 Module |
| 3 | * ------------------------------------------------- |
| 4 | * |
| 5 | * Copyright 2014 The Android Open Source Project |
| 6 | * |
| 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
| 10 | * |
| 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | * |
| 13 | * Unless required by applicable law or agreed to in writing, software |
| 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | * See the License for the specific language governing permissions and |
| 17 | * limitations under the License. |
| 18 | * |
| 19 | *//*! |
| 20 | * \file |
| 21 | * \brief OpenGL ES 3.0 Test Package |
| 22 | *//*--------------------------------------------------------------------*/ |
| 23 | |
| 24 | #include "tes3TestPackage.hpp" |
| 25 | #include "tes3InfoTests.hpp" |
| 26 | #include "es3fFunctionalTests.hpp" |
| 27 | #include "es3aAccuracyTests.hpp" |
| 28 | #include "es3sStressTests.hpp" |
| 29 | #include "es3pPerformanceTests.hpp" |
Pyry Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 30 | #include "tcuTestLog.hpp" |
| 31 | #include "gluRenderContext.hpp" |
| 32 | #include "gluStateReset.hpp" |
| 33 | #include "glwFunctions.hpp" |
| 34 | #include "glwEnums.hpp" |
Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 35 | |
| 36 | namespace deqp |
| 37 | { |
| 38 | namespace gles3 |
| 39 | { |
| 40 | |
Pyry Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 41 | class TestCaseWrapper : public tcu::TestCaseExecutor |
Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 42 | { |
Pyry Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 43 | public: |
| 44 | TestCaseWrapper (TestPackage& package); |
| 45 | ~TestCaseWrapper (void); |
Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 46 | |
Pyry Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 47 | void init (tcu::TestCase* testCase, const std::string& path); |
| 48 | void deinit (tcu::TestCase* testCase); |
| 49 | tcu::TestNode::IterateResult iterate (tcu::TestCase* testCase); |
| 50 | |
| 51 | private: |
| 52 | TestPackage& m_testPackage; |
| 53 | }; |
| 54 | |
| 55 | TestCaseWrapper::TestCaseWrapper (TestPackage& package) |
| 56 | : m_testPackage(package) |
| 57 | { |
Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 58 | } |
| 59 | |
Pyry Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 60 | TestCaseWrapper::~TestCaseWrapper (void) |
Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 61 | { |
Pyry Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | void TestCaseWrapper::init (tcu::TestCase* testCase, const std::string&) |
| 65 | { |
| 66 | testCase->init(); |
| 67 | } |
| 68 | |
| 69 | void TestCaseWrapper::deinit (tcu::TestCase* testCase) |
| 70 | { |
| 71 | testCase->deinit(); |
| 72 | |
| 73 | DE_ASSERT(m_testPackage.getContext()); |
Mika Isojärvi | 344563b | 2016-03-10 13:56:54 -0800 | [diff] [blame] | 74 | glu::resetState(m_testPackage.getContext()->getRenderContext(), m_testPackage.getContext()->getContextInfo()); |
Pyry Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | tcu::TestNode::IterateResult TestCaseWrapper::iterate (tcu::TestCase* testCase) |
| 78 | { |
| 79 | tcu::TestContext& testCtx = m_testPackage.getContext()->getTestContext(); |
| 80 | glu::RenderContext& renderCtx = m_testPackage.getContext()->getRenderContext(); |
| 81 | tcu::TestCase::IterateResult result; |
| 82 | |
| 83 | // Clear to surrender-blue |
| 84 | { |
| 85 | const glw::Functions& gl = renderCtx.getFunctions(); |
| 86 | gl.clearColor(0.125f, 0.25f, 0.5f, 1.f); |
| 87 | gl.clear(GL_COLOR_BUFFER_BIT); |
| 88 | } |
| 89 | |
| 90 | result = testCase->iterate(); |
| 91 | |
| 92 | // Call implementation specific post-iterate routine (usually handles native events and swaps buffers) |
| 93 | try |
| 94 | { |
| 95 | renderCtx.postIterate(); |
| 96 | return result; |
| 97 | } |
| 98 | catch (const tcu::ResourceError& e) |
| 99 | { |
| 100 | testCtx.getLog() << e; |
| 101 | testCtx.setTestResult(QP_TEST_RESULT_RESOURCE_ERROR, "Resource error in context post-iteration routine"); |
| 102 | testCtx.setTerminateAfter(true); |
| 103 | return tcu::TestNode::STOP; |
| 104 | } |
| 105 | catch (const std::exception& e) |
| 106 | { |
| 107 | testCtx.getLog() << e; |
| 108 | testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Error in context post-iteration routine"); |
| 109 | return tcu::TestNode::STOP; |
| 110 | } |
Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | TestPackage::TestPackage (tcu::TestContext& testCtx) |
| 114 | : tcu::TestPackage (testCtx, "dEQP-GLES3", "dEQP OpenGL ES 3.0 Tests") |
Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 115 | , m_archive (testCtx.getRootArchive(), "gles3/") |
Pyry Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 116 | , m_context (DE_NULL) |
Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 117 | { |
| 118 | } |
| 119 | |
| 120 | TestPackage::~TestPackage (void) |
| 121 | { |
| 122 | // Destroy children first since destructors may access context. |
| 123 | TestNode::deinit(); |
Pyry Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 124 | delete m_context; |
Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | void TestPackage::init (void) |
| 128 | { |
| 129 | try |
| 130 | { |
| 131 | // Create context |
Pyry Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 132 | m_context = new Context(m_testCtx); |
Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 133 | |
| 134 | // Add main test groups |
Pyry Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 135 | addChild(new InfoTests (*m_context)); |
| 136 | addChild(new Functional::FunctionalTests (*m_context)); |
| 137 | addChild(new Accuracy::AccuracyTests (*m_context)); |
| 138 | addChild(new Performance::PerformanceTests (*m_context)); |
| 139 | addChild(new Stress::StressTests (*m_context)); |
Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 140 | } |
| 141 | catch (...) |
| 142 | { |
Pyry Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 143 | delete m_context; |
| 144 | m_context = DE_NULL; |
Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 145 | |
| 146 | throw; |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | void TestPackage::deinit (void) |
| 151 | { |
| 152 | TestNode::deinit(); |
Pyry Haulos | 4e3ea87 | 2015-03-20 11:06:41 -0700 | [diff] [blame] | 153 | delete m_context; |
| 154 | m_context = DE_NULL; |
| 155 | } |
| 156 | |
| 157 | tcu::TestCaseExecutor* TestPackage::createExecutor (void) const |
| 158 | { |
| 159 | return new TestCaseWrapper(const_cast<TestPackage&>(*this)); |
Jarkko Poyry | 3c82736 | 2014-09-02 11:48:52 +0300 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | } // gles3 |
| 163 | } // deqp |