13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 3.0 Module
33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * -------------------------------------------------
43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project
63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License");
83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License.
93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at
103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *      http://www.apache.org/licenses/LICENSE-2.0
123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software
143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS,
153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and
173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License.
183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*!
203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file
213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief OpenGL ES 3.0 Test Package
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tes3TestPackage.hpp"
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tes3InfoTests.hpp"
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es3fFunctionalTests.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es3aAccuracyTests.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es3sStressTests.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es3pPerformanceTests.hpp"
304e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos#include "tcuTestLog.hpp"
314e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos#include "gluRenderContext.hpp"
324e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos#include "gluStateReset.hpp"
334e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos#include "glwFunctions.hpp"
344e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos#include "glwEnums.hpp"
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles3
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
414e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulosclass TestCaseWrapper : public tcu::TestCaseExecutor
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
434e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulospublic:
444e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos									TestCaseWrapper		(TestPackage& package);
454e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos									~TestCaseWrapper	(void);
464e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos
474e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos	void							init				(tcu::TestCase* testCase, const std::string& path);
484e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos	void							deinit				(tcu::TestCase* testCase);
494e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos	tcu::TestNode::IterateResult	iterate				(tcu::TestCase* testCase);
504e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos
514e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulosprivate:
524e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos	TestPackage&					m_testPackage;
534e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos};
544e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos
554e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry HaulosTestCaseWrapper::TestCaseWrapper (TestPackage& package)
564e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos	: m_testPackage(package)
574e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos{
584e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos}
594e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos
604e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry HaulosTestCaseWrapper::~TestCaseWrapper (void)
614e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos{
624e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos}
634e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos
644e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulosvoid TestCaseWrapper::init (tcu::TestCase* testCase, const std::string&)
654e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos{
664e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos	testCase->init();
674e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos}
684e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos
694e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulosvoid TestCaseWrapper::deinit (tcu::TestCase* testCase)
704e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos{
714e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos	testCase->deinit();
724e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos
734e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos	DE_ASSERT(m_testPackage.getContext());
74344563b5b701bc65c4184ce9d1b13867a5cef81eMika Isojärvi	glu::resetState(m_testPackage.getContext()->getRenderContext(), m_testPackage.getContext()->getContextInfo());
754e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos}
764e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos
774e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulostcu::TestNode::IterateResult TestCaseWrapper::iterate (tcu::TestCase* testCase)
784e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos{
794e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos	tcu::TestContext&				testCtx		= m_testPackage.getContext()->getTestContext();
804e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos	glu::RenderContext&				renderCtx	= m_testPackage.getContext()->getRenderContext();
814e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos	tcu::TestCase::IterateResult	result;
824e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos
834e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos	// Clear to surrender-blue
844e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos	{
854e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos		const glw::Functions& gl = renderCtx.getFunctions();
864e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos		gl.clearColor(0.125f, 0.25f, 0.5f, 1.f);
874e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos		gl.clear(GL_COLOR_BUFFER_BIT);
884e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos	}
894e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos
904e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos	result = testCase->iterate();
914e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos
924e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos	// Call implementation specific post-iterate routine (usually handles native events and swaps buffers)
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	try
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
954e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos		renderCtx.postIterate();
964e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos		return result;
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
984e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos	catch (const tcu::ResourceError& e)
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1004e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos		testCtx.getLog() << e;
1014e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos		testCtx.setTestResult(QP_TEST_RESULT_RESOURCE_ERROR, "Resource error in context post-iteration routine");
1024e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos		testCtx.setTerminateAfter(true);
1034e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos		return tcu::TestNode::STOP;
1044e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos	}
1054e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos	catch (const std::exception& e)
1064e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos	{
1074e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos		testCtx.getLog() << e;
1084e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos		testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Error in context post-iteration routine");
1094e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos		return tcu::TestNode::STOP;
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1133c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestPackage::TestPackage (tcu::TestContext& testCtx)
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: tcu::TestPackage	(testCtx, "dEQP-GLES3", "dEQP OpenGL ES 3.0 Tests")
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_archive			(testCtx.getRootArchive(), "gles3/")
1164e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos	, m_context			(DE_NULL)
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1203c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestPackage::~TestPackage (void)
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Destroy children first since destructors may access context.
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TestNode::deinit();
1244e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos	delete m_context;
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TestPackage::init (void)
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	try
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Create context
1324e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos		m_context = new Context(m_testCtx);
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Add main test groups
1354e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos		addChild(new InfoTests						(*m_context));
1364e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos		addChild(new Functional::FunctionalTests	(*m_context));
1374e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos		addChild(new Accuracy::AccuracyTests		(*m_context));
1384e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos		addChild(new Performance::PerformanceTests	(*m_context));
1394e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos		addChild(new Stress::StressTests			(*m_context));
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	catch (...)
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1434e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos		delete m_context;
1444e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos		m_context = DE_NULL;
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw;
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TestPackage::deinit (void)
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TestNode::deinit();
1534e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos	delete m_context;
1544e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos	m_context = DE_NULL;
1554e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos}
1564e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos
1574e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulostcu::TestCaseExecutor* TestPackage::createExecutor (void) const
1584e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos{
1594e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos	return new TestCaseWrapper(const_cast<TestPackage&>(*this));
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles3
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
164