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 Extensions Test Package.
23e5c31af7Sopenharmony_ci */ /*-------------------------------------------------------------------*/
24e5c31af7Sopenharmony_ci
25e5c31af7Sopenharmony_ci#include "esextcTestPackage.hpp"
26e5c31af7Sopenharmony_ci
27e5c31af7Sopenharmony_ci#include "disjoint_timer_query/esextcDisjointTimerQueryTests.hpp"
28e5c31af7Sopenharmony_ci#include "draw_elements_base_vertex/esextcDrawElementsBaseVertexTests.hpp"
29e5c31af7Sopenharmony_ci#include "fragment_shading_rate/esextcFragmentShadingRateTests.hpp"
30e5c31af7Sopenharmony_ci#include "geometry_shader/esextcGeometryShaderTests.hpp"
31e5c31af7Sopenharmony_ci#include "glcViewportArrayTests.hpp"
32e5c31af7Sopenharmony_ci#include "gluStateReset.hpp"
33e5c31af7Sopenharmony_ci#include "gpu_shader5/esextcGPUShader5Tests.hpp"
34e5c31af7Sopenharmony_ci#include "tcuTestLog.hpp"
35e5c31af7Sopenharmony_ci#include "tcuWaiverUtil.hpp"
36e5c31af7Sopenharmony_ci#include "tessellation_shader/esextcTessellationShaderTests.hpp"
37e5c31af7Sopenharmony_ci#include "texture_border_clamp/esextcTextureBorderClampTests.hpp"
38e5c31af7Sopenharmony_ci#include "texture_buffer/esextcTextureBufferTests.hpp"
39e5c31af7Sopenharmony_ci#include "texture_cube_map_array/esextcTextureCubeMapArrayTests.hpp"
40e5c31af7Sopenharmony_ci#include "texture_shadow_lod/esextcTextureShadowLodFunctionsTest.hpp"
41e5c31af7Sopenharmony_ci
42e5c31af7Sopenharmony_cinamespace esextcts
43e5c31af7Sopenharmony_ci{
44e5c31af7Sopenharmony_ci
45e5c31af7Sopenharmony_ciclass TestCaseWrapper : public tcu::TestCaseExecutor
46e5c31af7Sopenharmony_ci{
47e5c31af7Sopenharmony_cipublic:
48e5c31af7Sopenharmony_ci	TestCaseWrapper(ESEXTTestPackage& package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism);
49e5c31af7Sopenharmony_ci	~TestCaseWrapper(void);
50e5c31af7Sopenharmony_ci
51e5c31af7Sopenharmony_ci	void init(tcu::TestCase* testCase, const std::string& path);
52e5c31af7Sopenharmony_ci	void deinit(tcu::TestCase* testCase);
53e5c31af7Sopenharmony_ci	tcu::TestNode::IterateResult iterate(tcu::TestCase* testCase);
54e5c31af7Sopenharmony_ci
55e5c31af7Sopenharmony_ciprivate:
56e5c31af7Sopenharmony_ci	ESEXTTestPackage& m_testPackage;
57e5c31af7Sopenharmony_ci	de::SharedPtr<tcu::WaiverUtil> m_waiverMechanism;
58e5c31af7Sopenharmony_ci};
59e5c31af7Sopenharmony_ci
60e5c31af7Sopenharmony_ciTestCaseWrapper::TestCaseWrapper(ESEXTTestPackage& package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism)
61e5c31af7Sopenharmony_ci	: m_testPackage(package), m_waiverMechanism(waiverMechanism)
62e5c31af7Sopenharmony_ci{
63e5c31af7Sopenharmony_ci}
64e5c31af7Sopenharmony_ci
65e5c31af7Sopenharmony_ciTestCaseWrapper::~TestCaseWrapper(void)
66e5c31af7Sopenharmony_ci{
67e5c31af7Sopenharmony_ci}
68e5c31af7Sopenharmony_ci
69e5c31af7Sopenharmony_civoid TestCaseWrapper::init(tcu::TestCase* testCase, const std::string& path)
70e5c31af7Sopenharmony_ci{
71e5c31af7Sopenharmony_ci	if (m_waiverMechanism->isOnWaiverList(path))
72e5c31af7Sopenharmony_ci		throw tcu::TestException("Waived test", QP_TEST_RESULT_WAIVER);
73e5c31af7Sopenharmony_ci
74e5c31af7Sopenharmony_ci	glu::resetState(m_testPackage.getContext().getRenderContext(), m_testPackage.getContext().getContextInfo());
75e5c31af7Sopenharmony_ci
76e5c31af7Sopenharmony_ci	testCase->init();
77e5c31af7Sopenharmony_ci}
78e5c31af7Sopenharmony_ci
79e5c31af7Sopenharmony_civoid TestCaseWrapper::deinit(tcu::TestCase* testCase)
80e5c31af7Sopenharmony_ci{
81e5c31af7Sopenharmony_ci	testCase->deinit();
82e5c31af7Sopenharmony_ci
83e5c31af7Sopenharmony_ci	glu::resetState(m_testPackage.getContext().getRenderContext(), m_testPackage.getContext().getContextInfo());
84e5c31af7Sopenharmony_ci}
85e5c31af7Sopenharmony_ci
86e5c31af7Sopenharmony_citcu::TestNode::IterateResult TestCaseWrapper::iterate(tcu::TestCase* testCase)
87e5c31af7Sopenharmony_ci{
88e5c31af7Sopenharmony_ci	tcu::TestContext&			 testCtx   = m_testPackage.getContext().getTestContext();
89e5c31af7Sopenharmony_ci	glu::RenderContext&			 renderCtx = m_testPackage.getContext().getRenderContext();
90e5c31af7Sopenharmony_ci	tcu::TestCase::IterateResult result;
91e5c31af7Sopenharmony_ci
92e5c31af7Sopenharmony_ci	result = testCase->iterate();
93e5c31af7Sopenharmony_ci
94e5c31af7Sopenharmony_ci	// Call implementation specific post-iterate routine (usually handles native events and swaps buffers)
95e5c31af7Sopenharmony_ci	try
96e5c31af7Sopenharmony_ci	{
97e5c31af7Sopenharmony_ci		renderCtx.postIterate();
98e5c31af7Sopenharmony_ci		return result;
99e5c31af7Sopenharmony_ci	}
100e5c31af7Sopenharmony_ci	catch (const tcu::ResourceError&)
101e5c31af7Sopenharmony_ci	{
102e5c31af7Sopenharmony_ci		testCtx.getLog().endCase(QP_TEST_RESULT_RESOURCE_ERROR, "Resource error in context post-iteration routine");
103e5c31af7Sopenharmony_ci		testCtx.setTerminateAfter(true);
104e5c31af7Sopenharmony_ci		return tcu::TestNode::STOP;
105e5c31af7Sopenharmony_ci	}
106e5c31af7Sopenharmony_ci	catch (const std::exception&)
107e5c31af7Sopenharmony_ci	{
108e5c31af7Sopenharmony_ci		testCtx.getLog().endCase(QP_TEST_RESULT_FAIL, "Error in context post-iteration routine");
109e5c31af7Sopenharmony_ci		return tcu::TestNode::STOP;
110e5c31af7Sopenharmony_ci	}
111e5c31af7Sopenharmony_ci}
112e5c31af7Sopenharmony_ci
113e5c31af7Sopenharmony_ciESEXTTestPackage::ESEXTTestPackage(tcu::TestContext& testCtx, const char* packageName)
114e5c31af7Sopenharmony_ci	: TestPackage(testCtx, packageName, "OpenGL ES Extensions Conformance Tests",
115e5c31af7Sopenharmony_ci				  glu::ContextType(glu::ApiType::es(3, 1)), "gl_cts/data/")
116e5c31af7Sopenharmony_ci{
117e5c31af7Sopenharmony_ci}
118e5c31af7Sopenharmony_ci
119e5c31af7Sopenharmony_ciESEXTTestPackage::~ESEXTTestPackage(void)
120e5c31af7Sopenharmony_ci{
121e5c31af7Sopenharmony_ci}
122e5c31af7Sopenharmony_ci
123e5c31af7Sopenharmony_civoid ESEXTTestPackage::init(void)
124e5c31af7Sopenharmony_ci{
125e5c31af7Sopenharmony_ci	// Call init() in parent - this creates context.
126e5c31af7Sopenharmony_ci	TestPackage::init();
127e5c31af7Sopenharmony_ci
128e5c31af7Sopenharmony_ci	try
129e5c31af7Sopenharmony_ci	{
130e5c31af7Sopenharmony_ci		const glu::ContextType& context_type = getContext().getRenderContext().getType();
131e5c31af7Sopenharmony_ci		glcts::ExtParameters	extParams(glu::GLSL_VERSION_310_ES, glcts::EXTENSIONTYPE_EXT);
132e5c31af7Sopenharmony_ci		if (glu::contextSupports(context_type, glu::ApiType::es(3, 2)))
133e5c31af7Sopenharmony_ci		{
134e5c31af7Sopenharmony_ci			extParams.glslVersion = glu::GLSL_VERSION_320_ES;
135e5c31af7Sopenharmony_ci			extParams.extType	 = glcts::EXTENSIONTYPE_NONE;
136e5c31af7Sopenharmony_ci		}
137e5c31af7Sopenharmony_ci
138e5c31af7Sopenharmony_ci		addChild(new glcts::GeometryShaderTests(getContext(), extParams));
139e5c31af7Sopenharmony_ci		addChild(new glcts::GPUShader5Tests(getContext(), extParams));
140e5c31af7Sopenharmony_ci		addChild(new glcts::TessellationShaderTests(getContext(), extParams));
141e5c31af7Sopenharmony_ci		addChild(new glcts::TextureCubeMapArrayTests(getContext(), extParams));
142e5c31af7Sopenharmony_ci		addChild(new glcts::TextureBorderClampTests(getContext(), extParams));
143e5c31af7Sopenharmony_ci		addChild(new glcts::TextureBufferTests(getContext(), extParams));
144e5c31af7Sopenharmony_ci		addChild(new glcts::DrawElementsBaseVertexTests(getContext(), extParams));
145e5c31af7Sopenharmony_ci		glcts::ExtParameters viewportParams(glu::GLSL_VERSION_310_ES, glcts::EXTENSIONTYPE_OES);
146e5c31af7Sopenharmony_ci		addChild(new glcts::ViewportArrayTests(getContext(), viewportParams));
147e5c31af7Sopenharmony_ci		addChild(new deqp::Functional::TextureShadowLodTest(getContext()));
148e5c31af7Sopenharmony_ci		glcts::ExtParameters viewportParams2(glu::GLSL_VERSION_100_ES, glcts::EXTENSIONTYPE_OES);
149e5c31af7Sopenharmony_ci		addChild(new glcts::DisjointTimerQueryTests(getContext(), viewportParams2));
150e5c31af7Sopenharmony_ci		addChild(new glcts::FragmentShadingRateTests(getContext(), extParams));
151e5c31af7Sopenharmony_ci	}
152e5c31af7Sopenharmony_ci	catch (...)
153e5c31af7Sopenharmony_ci	{
154e5c31af7Sopenharmony_ci		// Destroy context.
155e5c31af7Sopenharmony_ci		TestPackage::deinit();
156e5c31af7Sopenharmony_ci		throw;
157e5c31af7Sopenharmony_ci	}
158e5c31af7Sopenharmony_ci}
159e5c31af7Sopenharmony_ci
160e5c31af7Sopenharmony_citcu::TestCaseExecutor* ESEXTTestPackage::createExecutor(void) const
161e5c31af7Sopenharmony_ci{
162e5c31af7Sopenharmony_ci	return new TestCaseWrapper(const_cast<ESEXTTestPackage&>(*this), m_waiverMechanism);
163e5c31af7Sopenharmony_ci}
164e5c31af7Sopenharmony_ci
165e5c31af7Sopenharmony_ci} // esextcts
166