• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * OpenGL Conformance Test Suite
3  * -----------------------------
4  *
5  * Copyright (c) 2016 Google Inc.
6  * Copyright (c) 2016 The Khronos Group Inc.
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */ /*!
21  * \file
22  * \brief OpenGL ES Extensions Test Package.
23  */ /*-------------------------------------------------------------------*/
24 
25 #include "esextcTestPackage.hpp"
26 
27 #include "disjoint_timer_query/esextcDisjointTimerQueryTests.hpp"
28 #include "draw_elements_base_vertex/esextcDrawElementsBaseVertexTests.hpp"
29 #include "fragment_shading_rate/esextcFragmentShadingRateTests.hpp"
30 #include "geometry_shader/esextcGeometryShaderTests.hpp"
31 #include "glcViewportArrayTests.hpp"
32 #include "gluStateReset.hpp"
33 #include "gpu_shader5/esextcGPUShader5Tests.hpp"
34 #include "tcuTestLog.hpp"
35 #include "tcuWaiverUtil.hpp"
36 #include "tessellation_shader/esextcTessellationShaderTests.hpp"
37 #include "texture_border_clamp/esextcTextureBorderClampTests.hpp"
38 #include "texture_buffer/esextcTextureBufferTests.hpp"
39 #include "texture_cube_map_array/esextcTextureCubeMapArrayTests.hpp"
40 #include "texture_shadow_lod/esextcTextureShadowLodFunctionsTest.hpp"
41 
42 namespace esextcts
43 {
44 
45 class TestCaseWrapper : public tcu::TestCaseExecutor
46 {
47 public:
48 	TestCaseWrapper(ESEXTTestPackage& package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism);
49 	~TestCaseWrapper(void);
50 
51 	void init(tcu::TestCase* testCase, const std::string& path);
52 	void deinit(tcu::TestCase* testCase);
53 	tcu::TestNode::IterateResult iterate(tcu::TestCase* testCase);
54 
55 private:
56 	ESEXTTestPackage& m_testPackage;
57 	de::SharedPtr<tcu::WaiverUtil> m_waiverMechanism;
58 };
59 
TestCaseWrapper(ESEXTTestPackage & package,de::SharedPtr<tcu::WaiverUtil> waiverMechanism)60 TestCaseWrapper::TestCaseWrapper(ESEXTTestPackage& package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism)
61 	: m_testPackage(package), m_waiverMechanism(waiverMechanism)
62 {
63 }
64 
~TestCaseWrapper(void)65 TestCaseWrapper::~TestCaseWrapper(void)
66 {
67 }
68 
init(tcu::TestCase * testCase,const std::string & path)69 void TestCaseWrapper::init(tcu::TestCase* testCase, const std::string& path)
70 {
71 	if (m_waiverMechanism->isOnWaiverList(path))
72 		throw tcu::TestException("Waived test", QP_TEST_RESULT_WAIVER);
73 
74 	glu::resetState(m_testPackage.getContext().getRenderContext(), m_testPackage.getContext().getContextInfo());
75 
76 	testCase->init();
77 }
78 
deinit(tcu::TestCase * testCase)79 void TestCaseWrapper::deinit(tcu::TestCase* testCase)
80 {
81 	testCase->deinit();
82 
83 	glu::resetState(m_testPackage.getContext().getRenderContext(), m_testPackage.getContext().getContextInfo());
84 }
85 
iterate(tcu::TestCase * testCase)86 tcu::TestNode::IterateResult TestCaseWrapper::iterate(tcu::TestCase* testCase)
87 {
88 	tcu::TestContext&			 testCtx   = m_testPackage.getContext().getTestContext();
89 	glu::RenderContext&			 renderCtx = m_testPackage.getContext().getRenderContext();
90 	tcu::TestCase::IterateResult result;
91 
92 	result = testCase->iterate();
93 
94 	// Call implementation specific post-iterate routine (usually handles native events and swaps buffers)
95 	try
96 	{
97 		renderCtx.postIterate();
98 		return result;
99 	}
100 	catch (const tcu::ResourceError&)
101 	{
102 		testCtx.getLog().endCase(QP_TEST_RESULT_RESOURCE_ERROR, "Resource error in context post-iteration routine");
103 		testCtx.setTerminateAfter(true);
104 		return tcu::TestNode::STOP;
105 	}
106 	catch (const std::exception&)
107 	{
108 		testCtx.getLog().endCase(QP_TEST_RESULT_FAIL, "Error in context post-iteration routine");
109 		return tcu::TestNode::STOP;
110 	}
111 }
112 
ESEXTTestPackage(tcu::TestContext & testCtx,const char * packageName)113 ESEXTTestPackage::ESEXTTestPackage(tcu::TestContext& testCtx, const char* packageName)
114 	: TestPackage(testCtx, packageName, "OpenGL ES Extensions Conformance Tests",
115 				  glu::ContextType(glu::ApiType::es(3, 1)), "gl_cts/data/")
116 {
117 }
118 
~ESEXTTestPackage(void)119 ESEXTTestPackage::~ESEXTTestPackage(void)
120 {
121 }
122 
init(void)123 void ESEXTTestPackage::init(void)
124 {
125 	// Call init() in parent - this creates context.
126 	TestPackage::init();
127 
128 	try
129 	{
130 		const glu::ContextType& context_type = getContext().getRenderContext().getType();
131 		glcts::ExtParameters	extParams(glu::GLSL_VERSION_310_ES, glcts::EXTENSIONTYPE_EXT);
132 		if (glu::contextSupports(context_type, glu::ApiType::es(3, 2)))
133 		{
134 			extParams.glslVersion = glu::GLSL_VERSION_320_ES;
135 			extParams.extType	 = glcts::EXTENSIONTYPE_NONE;
136 		}
137 
138 		addChild(new glcts::GeometryShaderTests(getContext(), extParams));
139 		addChild(new glcts::GPUShader5Tests(getContext(), extParams));
140 		addChild(new glcts::TessellationShaderTests(getContext(), extParams));
141 		addChild(new glcts::TextureCubeMapArrayTests(getContext(), extParams));
142 		addChild(new glcts::TextureBorderClampTests(getContext(), extParams));
143 		addChild(new glcts::TextureBufferTests(getContext(), extParams));
144 		addChild(new glcts::DrawElementsBaseVertexTests(getContext(), extParams));
145 		glcts::ExtParameters viewportParams(glu::GLSL_VERSION_310_ES, glcts::EXTENSIONTYPE_OES);
146 		addChild(new glcts::ViewportArrayTests(getContext(), viewportParams));
147 		addChild(new deqp::Functional::TextureShadowLodTest(getContext()));
148 		glcts::ExtParameters viewportParams2(glu::GLSL_VERSION_100_ES, glcts::EXTENSIONTYPE_OES);
149 		addChild(new glcts::DisjointTimerQueryTests(getContext(), viewportParams2));
150 		addChild(new glcts::FragmentShadingRateTests(getContext(), extParams));
151 	}
152 	catch (...)
153 	{
154 		// Destroy context.
155 		TestPackage::deinit();
156 		throw;
157 	}
158 }
159 
createExecutor(void) const160 tcu::TestCaseExecutor* ESEXTTestPackage::createExecutor(void) const
161 {
162 	return new TestCaseWrapper(const_cast<ESEXTTestPackage&>(*this), m_waiverMechanism);
163 }
164 
165 } // esextcts
166