13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program EGL 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 Test eglSwapBuffers() interaction with native window.
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "teglSwapBuffersTests.hpp"
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "teglSimpleConfigCase.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "egluNativeWindow.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "egluUtil.hpp"
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "egluUnique.hpp"
313c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos#include "eglwLibrary.hpp"
323c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos#include "eglwEnums.hpp"
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluDefs.hpp"
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp"
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp"
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp"
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuSurface.hpp"
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTexture.hpp"
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTextureUtil.hpp"
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuImageCompare.hpp"
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVector.hpp"
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVectorUtil.hpp"
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deUniquePtr.hpp"
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deThread.hpp"
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <string>
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <vector>
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <sstream>
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace egl
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
583c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulosusing tcu::TestLog;
593c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulosusing std::string;
603c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulosusing std::vector;
613c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulosusing namespace eglw;
623c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
663c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry HaulosEGLContext createGLES2Context (const Library& egl, EGLDisplay display, EGLConfig config)
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	EGLContext		context = EGL_NO_CONTEXT;
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const EGLint	attribList[] =
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		EGL_CONTEXT_CLIENT_VERSION, 2,
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		EGL_NONE
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
763c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	EGLU_CHECK_CALL(egl, bindAPI(EGL_OPENGL_ES_API));
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
783c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	context = egl.createContext(display, config, EGL_NO_CONTEXT, attribList);
793c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	EGLU_CHECK_MSG(egl, "eglCreateContext() failed");
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TCU_CHECK(context);
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return context;
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass SwapBuffersTest : public SimpleConfigCase
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
883c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos						SwapBuffersTest		(EglTestContext& eglTestCtx, const NamedFilterList& filters);
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						~SwapBuffersTest	(void);
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
923c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	void				executeForConfig	(EGLDisplay display, EGLConfig config);
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Not allowed
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						SwapBuffersTest		(const SwapBuffersTest&);
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	SwapBuffersTest&	operator=			(const SwapBuffersTest&);
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1003c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry HaulosSwapBuffersTest::SwapBuffersTest (EglTestContext& eglTestCtx, const NamedFilterList& filters)
1013c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	: SimpleConfigCase(eglTestCtx, filters.getName(), filters.getDescription(), filters)
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1053c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySwapBuffersTest::~SwapBuffersTest (void)
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1093c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulosstring getConfigIdString (const Library& egl, EGLDisplay display, EGLConfig config)
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::ostringstream	stream;
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	EGLint				id;
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1143c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	EGLU_CHECK_CALL(egl, getConfigAttrib(display, config , EGL_CONFIG_ID, &id));
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	stream << id;
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return stream.str();
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1213c827367444ee418f129b2c238299f49d3264554Jarkko PoyrydeUint32 createGLES2Program (const glw::Functions& gl, TestLog& log)
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char* const vertexShaderSource =
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"attribute highp vec2 a_pos;\n"
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"void main (void)\n"
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"{\n"
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"\tgl_Position = vec4(a_pos, 0.0, 1.0);\n"
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"}";
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char* const fragmentShaderSource =
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"void main (void)\n"
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"{\n"
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"\tgl_FragColor = vec4(0.9, 0.1, 0.4, 1.0);\n"
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"}";
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	program			= 0;
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	vertexShader	= 0;
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	fragmentShader	= 0;
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deInt32		vertexCompileStatus;
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	string		vertexInfoLog;
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deInt32		fragmentCompileStatus;
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	string		fragmentInfoLog;
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deInt32		linkStatus;
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	string		programInfoLog;
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	try
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		program			= gl.createProgram();
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vertexShader	= gl.createShader(GL_VERTEX_SHADER);
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		fragmentShader	= gl.createShader(GL_FRAGMENT_SHADER);
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to create shaders and program");
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.shaderSource(vertexShader, 1, &vertexShaderSource, DE_NULL);
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.compileShader(vertexShader);
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to setup vertex shader");
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.shaderSource(fragmentShader, 1, &fragmentShaderSource, DE_NULL);
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.compileShader(fragmentShader);
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to setup fragment shader");
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deInt32		infoLogLength = 0;
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.getShaderiv(vertexShader, GL_COMPILE_STATUS, &vertexCompileStatus);
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.getShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &infoLogLength);
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			vertexInfoLog.resize(infoLogLength, '\0');
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.getShaderInfoLog(vertexShader, (glw::GLsizei)vertexInfoLog.length(), &infoLogLength, &(vertexInfoLog[0]));
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to get vertex shader compile info");
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			vertexInfoLog.resize(infoLogLength);
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deInt32		infoLogLength = 0;
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.getShaderiv(fragmentShader, GL_COMPILE_STATUS, &fragmentCompileStatus);
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.getShaderiv(fragmentShader, GL_INFO_LOG_LENGTH, &infoLogLength);
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			fragmentInfoLog.resize(infoLogLength, '\0');
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.getShaderInfoLog(fragmentShader, (glw::GLsizei)fragmentInfoLog.length(), &infoLogLength, &(fragmentInfoLog[0]));
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to get fragment shader compile info");
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			fragmentInfoLog.resize(infoLogLength);
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.attachShader(program, vertexShader);
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.attachShader(program, fragmentShader);
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.linkProgram(program);
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to setup program");
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deInt32		infoLogLength = 0;
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.getProgramiv(program, GL_LINK_STATUS, &linkStatus);
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.getProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength);
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			programInfoLog.resize(infoLogLength, '\0');
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.getProgramInfoLog(program, (glw::GLsizei)programInfoLog.length(), &infoLogLength, &(programInfoLog[0]));
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to get program link info");
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			programInfoLog.resize(infoLogLength);
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (linkStatus == 0 || vertexCompileStatus == 0 || fragmentCompileStatus == 0)
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			log.startShaderProgram(linkStatus != 0, programInfoLog.c_str());
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			log << TestLog::Shader(QP_SHADER_TYPE_VERTEX, vertexShaderSource, vertexCompileStatus != 0, vertexInfoLog);
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			log << TestLog::Shader(QP_SHADER_TYPE_FRAGMENT, fragmentShaderSource, fragmentCompileStatus != 0, fragmentInfoLog);
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			log.endShaderProgram();
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.deleteShader(vertexShader);
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.deleteShader(fragmentShader);
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to delete shaders");
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TCU_CHECK(linkStatus != 0 && vertexCompileStatus != 0 && fragmentCompileStatus != 0);
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	catch (...)
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (program)
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.deleteProgram(program);
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (vertexShader)
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.deleteShader(vertexShader);
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (fragmentShader)
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.deleteShader(fragmentShader);
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw;
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return program;
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool checkColor (tcu::TestLog& log, const tcu::TextureLevel& screen, const tcu::Vec4& color)
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::Vec4 threshold(0.01f, 0.01f, 0.01f, 1.00f);
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int y = 0; y < screen.getHeight(); y++)
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int x = 0; x < screen.getWidth(); x++)
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::Vec4	pixel(screen.getAccess().getPixel(x, y));
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::Vec4	diff(abs(pixel - color));
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (!boolAll(lessThanEqual(diff, threshold)))
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				log << TestLog::Message << "Unexpected color values read from screen expected: " << color << TestLog::EndMessage;
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				log << TestLog::Image("Screen", "Screen", screen.getAccess());
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				return false;
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return true;
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2673c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulosvoid SwapBuffersTest::executeForConfig (EGLDisplay display, EGLConfig config)
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2693c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	const Library&						egl			= m_eglTestCtx.getLibrary();
2703c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	const string						configIdStr	(getConfigIdString(egl, display, config));
2713c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	tcu::ScopedLogSection				logSection	(m_testCtx.getLog(), ("Config ID " + configIdStr).c_str(), ("Config ID " + configIdStr).c_str());
2723c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	const int							waitFrames	= 5;
273485844e764f2821545146b832726a36012f86238Mika Isojärvi	const eglu::NativeWindowFactory&	factory		= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
2743c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos
275485844e764f2821545146b832726a36012f86238Mika Isojärvi	if ((factory.getCapabilities() & eglu::NativeWindow::CAPABILITY_READ_SCREEN_PIXELS) == 0)
2763c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		TCU_THROW(NotSupportedError, "eglu::NativeWindow doesn't support readScreenPixels()");
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TestLog& log = m_testCtx.getLog();
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2813c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		log << TestLog::Message << "EGL_RED_SIZE: "		<< eglu::getConfigAttribInt(egl, display, config, EGL_RED_SIZE)		<< TestLog::EndMessage;
2823c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		log << TestLog::Message << "EGL_GREEN_SIZE: "	<< eglu::getConfigAttribInt(egl, display, config, EGL_GREEN_SIZE)	<< TestLog::EndMessage;
2833c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		log << TestLog::Message << "EGL_BLUE_SIZE: "	<< eglu::getConfigAttribInt(egl, display, config, EGL_BLUE_SIZE)	<< TestLog::EndMessage;
2843c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		log << TestLog::Message << "EGL_ALPHA_SIZE: "	<< eglu::getConfigAttribInt(egl, display, config, EGL_ALPHA_SIZE)	<< TestLog::EndMessage;
2853c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		log << TestLog::Message << "EGL_DEPTH_SIZE: "	<< eglu::getConfigAttribInt(egl, display, config, EGL_DEPTH_SIZE)	<< TestLog::EndMessage;
2863c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		log << TestLog::Message << "EGL_STENCIL_SIZE: "	<< eglu::getConfigAttribInt(egl, display, config, EGL_STENCIL_SIZE)	<< TestLog::EndMessage;
2873c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		log << TestLog::Message << "EGL_SAMPLES: "		<< eglu::getConfigAttribInt(egl, display, config, EGL_SAMPLES)		<< TestLog::EndMessage;
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		log << TestLog::Message << "Waiting " << waitFrames * 16 << "ms after eglSwapBuffers() and glFinish() for frame to become visible" << TestLog::EndMessage;
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
292485844e764f2821545146b832726a36012f86238Mika Isojärvi	de::UniquePtr<eglu::NativeWindow>	window	(factory.createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(128, 128, eglu::WindowParams::VISIBILITY_VISIBLE)));
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2943c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	eglu::UniqueSurface					surface	(egl, display, eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, display, config, DE_NULL));
2953c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	eglu::UniqueContext					context	(egl, display, createGLES2Context(egl, display, config));
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glw::Functions						gl;
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32							program = 0;
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureLevel					whiteFrame;
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureLevel					blackFrame;
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureLevel					frameBegin;
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureLevel					frameEnd;
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3043c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	m_eglTestCtx.initGLFunctions(&gl, glu::ApiType::es(2,0));
3053c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	EGLU_CHECK_CALL(egl, makeCurrent(display, *surface, *surface, *context));
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	try
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const float positions1[] = {
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			 0.00f,  0.00f,
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			 0.75f,  0.00f,
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			 0.75f,  0.75f,
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			 0.75f,  0.75f,
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			 0.00f,  0.75f,
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			 0.00f,  0.00f
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const float positions2[] = {
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			-0.75f, -0.75f,
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			 0.00f, -0.75f,
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			 0.00f,  0.00f,
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			 0.00f,  0.00f,
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			-0.75f,  0.00f,
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			-0.75f, -0.75f
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32 posLocation;
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		program	= createGLES2Program(gl, m_testCtx.getLog());
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.useProgram(program);
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		posLocation	= gl.getAttribLocation(program, "a_pos");
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.enableVertexAttribArray(posLocation);
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to setup shader program for rendering");
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Clear screen to white and check that sceen is white
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.clearColor(1.0f, 1.0f, 1.0f, 1.0f);
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.clear(GL_COLOR_BUFFER_BIT);
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to clear surface");
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3433c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		EGLU_CHECK_CALL(egl, swapBuffers(display, *surface));
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.finish();
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "glFinish() failed");
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deSleep(waitFrames * 16);
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		window->processEvents();
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		window->readScreenPixels(&whiteFrame);
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!checkColor(m_testCtx.getLog(), whiteFrame, tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f)))
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Couldn't reliably read pixels from screen");
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return;
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Clear screen to black and check that sceen is black
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.clear(GL_COLOR_BUFFER_BIT);
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to clear surface");
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3613c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		EGLU_CHECK_CALL(egl, swapBuffers(display, *surface));
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.finish();
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "glFinish() failed");
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deSleep(waitFrames * 16);
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		window->processEvents();
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		window->readScreenPixels(&blackFrame);
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!checkColor(m_testCtx.getLog(), blackFrame, tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f)))
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Couldn't reliably read pixels from screen");
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return;
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.clearColor(0.7f, 1.0f, 0.3f, 1.0f);
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.clear(GL_COLOR_BUFFER_BIT);
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to clear surface");
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.vertexAttribPointer(posLocation, 2, GL_FLOAT, GL_FALSE, 0, positions1);
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.drawArrays(GL_TRIANGLES, 0, 6);
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to render");
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3823c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		EGLU_CHECK_CALL(egl, swapBuffers(display, *surface));
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.finish();
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "glFinish() failed");
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deSleep(waitFrames * 16);
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		window->processEvents();
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		window->readScreenPixels(&frameBegin);
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.clearColor(0.7f, 0.7f, 1.0f, 1.0f);
3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.clear(GL_COLOR_BUFFER_BIT);
3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to clear surface");
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.vertexAttribPointer(posLocation, 2, GL_FLOAT, GL_FALSE, 0, positions2);
3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.drawArrays(GL_TRIANGLES, 0, 6);
3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to render");
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.finish();
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "glFinish() failed");
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deSleep(waitFrames * 16);
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		window->readScreenPixels(&frameEnd);
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4023c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		EGLU_CHECK_CALL(egl, swapBuffers(display, *surface));
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.finish();
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "glFinish() failed");
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deSleep(waitFrames * 16);
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		window->processEvents();
4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.disableVertexAttribArray(posLocation);
4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.useProgram(0);
4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to release program state");
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.deleteProgram(program);
4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		program = 0;
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "glDeleteProgram()");
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!tcu::intThresholdCompare(m_testCtx.getLog(), "Compare end of frame against beginning of frame" , "Compare end of frame against beginning of frame", frameBegin.getAccess(), frameEnd.getAccess(), tcu::UVec4(0, 0, 0, 0), tcu::COMPARE_LOG_RESULT))
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Screen pixels changed during frame");
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	catch (...)
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (program != 0)
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.deleteProgram(program);
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4243c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		EGLU_CHECK_CALL(egl, makeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw;
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4283c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	EGLU_CHECK_CALL(egl, makeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // anonymous
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4333c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySwapBuffersTests::SwapBuffersTests (EglTestContext& eglTestCtx)
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCaseGroup(eglTestCtx, "swap_buffers", "Swap buffers tests")
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4385f78b1323b6ef28d8b9cdce6fefcbbb61a0477a9Pyry Haulosstatic bool isWindow (const eglu::CandidateConfig& c) { return (c.surfaceType() & EGL_WINDOW_BIT) != 0; }
4393c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos
4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid SwapBuffersTests::init (void)
4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4423c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	eglu::FilterList baseFilters;
4433c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	baseFilters << isWindow;
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4453c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	vector<NamedFilterList> filterLists;
4463c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	getDefaultFilterLists(filterLists, baseFilters);
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4483c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	for (vector<NamedFilterList>::iterator i = filterLists.begin(); i != filterLists.end(); i++)
4493c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		addChild(new SwapBuffersTest(m_eglTestCtx, *i));
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // egl
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
454