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 Sync tests.
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es3fSyncTests.hpp"
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVector.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluShaderProgram.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluCallLogWrapper.hpp"
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluRenderContext.hpp"
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp"
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp"
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp"
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deString.h"
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <vector>
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog;
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles3
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace glw; // GL types
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const int	NUM_CASE_ITERATIONS = 5;
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum WaitCommand
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	COMMAND_WAIT_SYNC			= 1 << 0,
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	COMMAND_CLIENT_WAIT_SYNC	= 1 << 1
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum CaseOptions
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	CASE_FLUSH_BEFORE_WAIT	= 1 << 0,
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	CASE_FINISH_BEFORE_WAIT	= 1 << 1
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass FenceSyncCase : public TestCase, private glu::CallLogWrapper
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						FenceSyncCase		(Context& context, const char* name, const char* description, int numPrimitives, deUint32 waitCommand, deUint32 waitFlags, deUint64 timeout, deUint32 options);
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						~FenceSyncCase		(void);
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void				init				(void);
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void				deinit				(void);
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult		iterate				(void);
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						FenceSyncCase		(const FenceSyncCase& other);
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FenceSyncCase&		operator=			(const FenceSyncCase& other);
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int					m_numPrimitives;
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			m_waitCommand;
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			m_waitFlags;
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint64			m_timeout;
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			m_caseOptions;
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram*	m_program;
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLsync				m_syncObject;
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int					m_iterNdx;
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	de::Random			m_rnd;
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
893c827367444ee418f129b2c238299f49d3264554Jarkko PoyryFenceSyncCase::FenceSyncCase (Context& context, const char* name, const char* description, int numPrimitives, deUint32 waitCommand, deUint32 waitFlags, deUint64 timeout, deUint32 options)
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCase				(context, name, description)
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, CallLogWrapper		(context.getRenderContext().getFunctions(), context.getTestContext().getLog())
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_numPrimitives		(numPrimitives)
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_waitCommand			(waitCommand)
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_waitFlags			(waitFlags)
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_timeout				(timeout)
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_caseOptions			(options)
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_program				(DE_NULL)
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_syncObject			(DE_NULL)
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_iterNdx				(0)
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_rnd					(deStringHash(name))
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1043c827367444ee418f129b2c238299f49d3264554Jarkko PoyryFenceSyncCase::~FenceSyncCase (void)
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FenceSyncCase::deinit();
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void generateVertices (std::vector<float>& dst, int numPrimitives, de::Random& rnd)
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int numVertices = 3*numPrimitives;
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	dst.resize(numVertices * 4);
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int i = 0; i < numVertices; i++)
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		dst[i*4    ] = rnd.getFloat(-1.0f, 1.0f);	// x
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		dst[i*4 + 1] = rnd.getFloat(-1.0f, 1.0f);	// y
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		dst[i*4 + 2] = rnd.getFloat( 0.0f, 1.0f);	// z
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		dst[i*4 + 3] = 1.0f;						// w
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid FenceSyncCase::init (void)
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char*	vertShaderSource =
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				"#version 300 es\n"
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				"layout(location = 0) in mediump vec4 a_position;\n"
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				"\n"
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				"void main (void)\n"
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				"{\n"
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				"	gl_Position = a_position;\n"
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				"}\n";
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char* fragShaderSource =
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				"#version 300 es\n"
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				"layout(location = 0) out mediump vec4 o_color;\n"
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				"\n"
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				"void main (void)\n"
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				"{\n"
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				"	o_color = vec4(0.25, 0.5, 0.75, 1.0);\n"
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				"}\n";
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(!m_program);
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_program = new glu::ShaderProgram(m_context.getRenderContext(), glu::makeVtxFragSources(vertShaderSource, fragShaderSource));
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!m_program->isOk())
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx.getLog() << *m_program;
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TCU_FAIL("Failed to compile shader program");
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); // Initialize test result to pass.
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_CHECK_MSG("Case initialization finished");
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid FenceSyncCase::deinit (void)
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_program)
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		delete m_program;
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_program = DE_NULL;
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_syncObject)
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteSync(m_syncObject);
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_syncObject = DE_NULL;
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1713c827367444ee418f129b2c238299f49d3264554Jarkko PoyryFenceSyncCase::IterateResult FenceSyncCase::iterate (void)
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1733e7f70ab65c0c3e797b1bcc73b874b113219c110Jarkko Pöyry	TestLog&					log			= m_testCtx.getLog();
1743e7f70ab65c0c3e797b1bcc73b874b113219c110Jarkko Pöyry	std::vector<float>			vertices;
1753e7f70ab65c0c3e797b1bcc73b874b113219c110Jarkko Pöyry	bool						testOk		= true;
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1773e7f70ab65c0c3e797b1bcc73b874b113219c110Jarkko Pöyry	std::string					header		= "Case iteration " + de::toString(m_iterNdx+1) + " / " + de::toString(NUM_CASE_ITERATIONS);
1783e7f70ab65c0c3e797b1bcc73b874b113219c110Jarkko Pöyry	const tcu::ScopedLogSection	section		(log, header, header);
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enableLogging(true);
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT		(m_program);
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glUseProgram	(m_program->getProgram());
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glEnable		(GL_DEPTH_TEST);
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glClearColor	(0.3f, 0.3f, 0.3f, 1.0f);
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glClearDepthf	(1.0f);
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glClear			(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Generate vertices
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glEnableVertexAttribArray (0);
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	generateVertices		  (vertices, m_numPrimitives, m_rnd);
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glVertexAttribPointer	  (0, 4, GL_FLOAT, GL_FALSE, 0, &vertices[0]);
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Draw
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glDrawArrays(GL_TRIANGLES, 0, (int)vertices.size() / 4);
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::Message << "// Primitives drawn." << TestLog::EndMessage;
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Create sync object
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_syncObject = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_CHECK_MSG ("Sync object created");
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::Message << "// Sync object created." << TestLog::EndMessage;
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_caseOptions & CASE_FLUSH_BEFORE_WAIT)
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glFlush();
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_caseOptions & CASE_FINISH_BEFORE_WAIT)
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glFinish();
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Wait for sync object
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLenum waitValue = 0;
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_waitCommand & COMMAND_WAIT_SYNC)
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_timeout == GL_TIMEOUT_IGNORED);
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_waitFlags == 0);
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glWaitSync(m_syncObject, m_waitFlags, m_timeout);
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_CHECK_MSG ("glWaitSync called");
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		log << TestLog::Message << "// Wait command glWaitSync called with GL_TIMEOUT_IGNORED." << TestLog::EndMessage;
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_waitCommand & COMMAND_CLIENT_WAIT_SYNC)
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		waitValue = glClientWaitSync(m_syncObject, m_waitFlags, m_timeout);
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_CHECK_MSG ("glClientWaitSync called");
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		log << TestLog::Message << "// glClientWaitSync return value:" << TestLog::EndMessage;
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		switch (waitValue)
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			case GL_ALREADY_SIGNALED:	 log << TestLog::Message << "// GL_ALREADY_SIGNALED"	<< TestLog::EndMessage; break;
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			case GL_TIMEOUT_EXPIRED:	 log << TestLog::Message << "// GL_TIMEOUT_EXPIRED"		<< TestLog::EndMessage; break;
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			case GL_CONDITION_SATISFIED: log << TestLog::Message << "// GL_CONDITION_SATISFIED"	<< TestLog::EndMessage; break;
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			case GL_WAIT_FAILED:		 log << TestLog::Message << "// GL_WAIT_FAILED"			<< TestLog::EndMessage; testOk = false; break;
2343e7f70ab65c0c3e797b1bcc73b874b113219c110Jarkko Pöyry			default:					 TCU_FAIL("// Illegal return value!");
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glFinish();
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_caseOptions & CASE_FINISH_BEFORE_WAIT && waitValue != GL_ALREADY_SIGNALED)
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testOk = false;
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		log << TestLog::Message << "// Expected glClientWaitSync to return GL_ALREADY_SIGNALED." << TestLog::EndMessage;
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Delete sync object
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_syncObject)
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteSync(m_syncObject);
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_syncObject = DE_NULL;
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_CHECK_MSG ("Sync object deleted");
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		log << TestLog::Message << "// Sync object deleted." << TestLog::EndMessage;
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Evaluate test result
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::Message << "// Test result: " << (testOk ? "Passed!" : "Failed!") << TestLog::EndMessage;
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!testOk)
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return STOP;
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2663e7f70ab65c0c3e797b1bcc73b874b113219c110Jarkko Pöyry	log << TestLog::Message << "// Sync objects created and deleted successfully." << TestLog::EndMessage;
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return (++m_iterNdx < NUM_CASE_ITERATIONS) ? CONTINUE : STOP;
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2713c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySyncTests::SyncTests (Context& context)
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCaseGroup(context, "fence_sync", "Fence Sync Tests")
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2763c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySyncTests::~SyncTests (void)
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid SyncTests::init (void)
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Fence sync tests.
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new FenceSyncCase(m_context, "wait_sync_smalldraw",	"",	10,		COMMAND_WAIT_SYNC,	0, GL_TIMEOUT_IGNORED,	0));
2856fe4621dfaa3d80deb71bbe63347d48ee9c2043eJarkko Pöyry	addChild(new FenceSyncCase(m_context, "wait_sync_largedraw",	"",	10000,	COMMAND_WAIT_SYNC,	0, GL_TIMEOUT_IGNORED,	0));
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new FenceSyncCase(m_context, "client_wait_sync_smalldraw",			"",	10,		COMMAND_CLIENT_WAIT_SYNC,	0, 0,	0));
2886fe4621dfaa3d80deb71bbe63347d48ee9c2043eJarkko Pöyry	addChild(new FenceSyncCase(m_context, "client_wait_sync_largedraw",			"",	10000,	COMMAND_CLIENT_WAIT_SYNC,	0, 0,	0));
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new FenceSyncCase(m_context, "client_wait_sync_timeout_smalldraw",	"",	10,		COMMAND_CLIENT_WAIT_SYNC,	0, 10,	0));
2906fe4621dfaa3d80deb71bbe63347d48ee9c2043eJarkko Pöyry	addChild(new FenceSyncCase(m_context, "client_wait_sync_timeout_largedraw",	"",	10000,	COMMAND_CLIENT_WAIT_SYNC,	0, 10,	0));
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2926fe4621dfaa3d80deb71bbe63347d48ee9c2043eJarkko Pöyry	addChild(new FenceSyncCase(m_context, "client_wait_sync_flush_auto",	"",	10000, COMMAND_CLIENT_WAIT_SYNC,	GL_SYNC_FLUSH_COMMANDS_BIT, 0,	0));
2936fe4621dfaa3d80deb71bbe63347d48ee9c2043eJarkko Pöyry	addChild(new FenceSyncCase(m_context, "client_wait_sync_flush_manual",	"",	10000, COMMAND_CLIENT_WAIT_SYNC,	0,							0,	CASE_FLUSH_BEFORE_WAIT));
2946fe4621dfaa3d80deb71bbe63347d48ee9c2043eJarkko Pöyry	addChild(new FenceSyncCase(m_context, "client_wait_sync_noflush",		"",	10000, COMMAND_CLIENT_WAIT_SYNC,	0,							0,	0));
2956fe4621dfaa3d80deb71bbe63347d48ee9c2043eJarkko Pöyry	addChild(new FenceSyncCase(m_context, "client_wait_sync_finish",		"",	10000, COMMAND_CLIENT_WAIT_SYNC,	0,							0,	CASE_FINISH_BEFORE_WAIT));
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles3
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
301