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 Tests for mapping client coordinates to native surface coordinates
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "teglNativeCoordMappingTests.hpp"
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "teglSimpleConfigCase.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuSurface.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTexture.hpp"
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "egluNativeDisplay.hpp"
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "egluNativeWindow.hpp"
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "egluNativePixmap.hpp"
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "egluUnique.hpp"
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "egluUtil.hpp"
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
373c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos#include "eglwLibrary.hpp"
383c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos#include "eglwEnums.hpp"
393c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluDefs.hpp"
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp"
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp"
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuImageCompare.hpp"
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp"
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTexture.hpp"
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTextureUtil.hpp"
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deUniquePtr.hpp"
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp"
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deThread.hpp"
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deMath.h"
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <vector>
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <string>
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog;
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector;
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::string;
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
623c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulosusing namespace eglw;
633c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace egl
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
713c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry HaulosEGLContext createGLES2Context (const Library& egl, EGLDisplay display, EGLConfig config)
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
733c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	EGLContext		context			= EGL_NO_CONTEXT;
743c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	const EGLint	attribList[]	=
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		EGL_CONTEXT_CLIENT_VERSION, 2,
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		EGL_NONE
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
803c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	EGLU_CHECK_CALL(egl, bindAPI(EGL_OPENGL_ES_API));
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
823c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	context = egl.createContext(display, config, EGL_NO_CONTEXT, attribList);
833c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	EGLU_CHECK_MSG(egl, "eglCreateContext() failed");
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TCU_CHECK(context);
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return context;
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
893c827367444ee418f129b2c238299f49d3264554Jarkko PoyrydeUint32 createGLES2Program (const glw::Functions& gl, TestLog& log)
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char* const vertexShaderSource =
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"attribute highp vec2 a_pos;\n"
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"void main (void)\n"
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"{\n"
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"\tgl_Position = vec4(a_pos, 0.0, 1.0);\n"
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"}";
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char* const fragmentShaderSource =
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"void main (void)\n"
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"{\n"
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"\tgl_FragColor = vec4(1.0);\n"
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"}";
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	program			= 0;
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	vertexShader	= 0;
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	fragmentShader	= 0;
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deInt32		vertexCompileStatus;
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	string		vertexInfoLog;
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deInt32		fragmentCompileStatus;
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	string		fragmentInfoLog;
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deInt32		linkStatus;
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	string		programInfoLog;
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	try
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		program			= gl.createProgram();
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vertexShader	= gl.createShader(GL_VERTEX_SHADER);
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		fragmentShader	= gl.createShader(GL_FRAGMENT_SHADER);
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to create shaders and program");
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.shaderSource(vertexShader, 1, &vertexShaderSource, DE_NULL);
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.compileShader(vertexShader);
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to setup vertex shader");
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.shaderSource(fragmentShader, 1, &fragmentShaderSource, DE_NULL);
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.compileShader(fragmentShader);
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to setup fragment shader");
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deInt32		infoLogLength = 0;
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.getShaderiv(vertexShader, GL_COMPILE_STATUS, &vertexCompileStatus);
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.getShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &infoLogLength);
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			vertexInfoLog.resize(infoLogLength, '\0');
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.getShaderInfoLog(vertexShader, (glw::GLsizei)vertexInfoLog.length(), &infoLogLength, &(vertexInfoLog[0]));
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to get vertex shader compile info");
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			vertexInfoLog.resize(infoLogLength);
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deInt32		infoLogLength = 0;
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.getShaderiv(fragmentShader, GL_COMPILE_STATUS, &fragmentCompileStatus);
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.getShaderiv(fragmentShader, GL_INFO_LOG_LENGTH, &infoLogLength);
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			fragmentInfoLog.resize(infoLogLength, '\0');
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.getShaderInfoLog(fragmentShader, (glw::GLsizei)fragmentInfoLog.length(), &infoLogLength, &(fragmentInfoLog[0]));
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to get fragment shader compile info");
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			fragmentInfoLog.resize(infoLogLength);
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.attachShader(program, vertexShader);
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.attachShader(program, fragmentShader);
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.linkProgram(program);
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to setup program");
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deInt32		infoLogLength = 0;
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.getProgramiv(program, GL_LINK_STATUS, &linkStatus);
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.getProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength);
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			programInfoLog.resize(infoLogLength, '\0');
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.getProgramInfoLog(program, (glw::GLsizei)programInfoLog.length(), &infoLogLength, &(programInfoLog[0]));
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to get program link info");
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			programInfoLog.resize(infoLogLength);
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (linkStatus == 0 || vertexCompileStatus == 0 || fragmentCompileStatus == 0)
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			log.startShaderProgram(linkStatus != 0, programInfoLog.c_str());
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			log << TestLog::Shader(QP_SHADER_TYPE_VERTEX, vertexShaderSource, vertexCompileStatus != 0, vertexInfoLog);
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			log << TestLog::Shader(QP_SHADER_TYPE_FRAGMENT, fragmentShaderSource, fragmentCompileStatus != 0, fragmentInfoLog);
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			log.endShaderProgram();
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.deleteShader(vertexShader);
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.deleteShader(fragmentShader);
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to delete shaders");
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TCU_CHECK(linkStatus != 0 && vertexCompileStatus != 0 && fragmentCompileStatus != 0);
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	catch (...)
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (program)
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.deleteProgram(program);
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (vertexShader)
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.deleteShader(vertexShader);
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (fragmentShader)
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.deleteShader(fragmentShader);
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw;
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return program;
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid clear (const glw::Functions& gl, const tcu::Vec4& color, int x, int y, int width, int height)
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.enable(GL_SCISSOR_TEST);
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.scissor(x, y, width, height);
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.clearColor(color.x(), color.y(), color.z(), color.w());
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.clear(GL_COLOR_BUFFER_BIT);
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.getError(), "Color clear failed");
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytcu::Vec2 toGLCoord (int width, int height, int x, int y)
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
22335f4933c31a65a00084b6533e4a0deb098036d66Jarkko Pöyry	const float xf = ((2.0f * float(x)) / (float)width)  - 1.0f;
22435f4933c31a65a00084b6533e4a0deb098036d66Jarkko Pöyry	const float yf = ((2.0f * float(y)) / (float)height) - 1.0f;
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return tcu::Vec2(xf, yf);
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid render (const glw::Functions& gl, deUint32 program, int targetWidth, int targetHeight, int x, int y, int width, int height)
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::Vec2 positions[] =
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		toGLCoord(targetWidth, targetHeight, x,			y),
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		toGLCoord(targetWidth, targetHeight, x+width,	y),
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		toGLCoord(targetWidth, targetHeight, x+width,	y+height),
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		toGLCoord(targetWidth, targetHeight, x+width,	y+height),
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		toGLCoord(targetWidth, targetHeight, x,			y+height),
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		toGLCoord(targetWidth, targetHeight, x,			y)
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 posLocation;
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.useProgram(program);
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	posLocation	= gl.getAttribLocation(program, "a_pos");
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.enableVertexAttribArray(posLocation);
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.vertexAttribPointer(posLocation, 2, GL_FLOAT, GL_FALSE, 0, positions);
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to setup shader program for rendering");
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.viewport(0, 0, targetWidth, targetHeight);
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.drawArrays(GL_TRIANGLES, 0, 6);
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to render");
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool compareColor (const tcu::Vec4& a, const tcu::Vec4& b)
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const float threshold = 0.005f;
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return deFloatAbs(a.x() - b.x()) < threshold &&  deFloatAbs(a.y() - b.y()) < threshold && deFloatAbs(a.z() - b.z()) < threshold && deFloatAbs(a.w() - b.w()) < threshold;
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool validate (TestLog& log, const tcu::TextureLevel& result, int rectX, int rectY, int rectW, int rectH)
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::Vec4		black		(0.0f, 0.0f, 0.0f, 1.0f);
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::Vec4		white		(1.0f, 1.0f, 1.0f, 1.0f);
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Surface		errorMask	(result.getWidth(), result.getHeight());
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool				isOk		= true;
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int y = 0; y < result.getHeight(); y++)
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int x = 0; x < result.getWidth(); x++)
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::Vec4 resultColor = result.getAccess().getPixel(x, y);
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (x > rectX && x < rectX + rectW - 1 && y > rectY && y < rectY + rectH - 1)
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (!compareColor(resultColor, white))
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					errorMask.setPixel(x, y, tcu::RGBA(255, 0, 0, 255));
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					isOk = false;
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				else
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					errorMask.setPixel(x, y, tcu::RGBA(0, 255, 0, 255));
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			else if (x < rectX-1 || x > rectX + rectW || y < rectY-1 || y > rectY + rectH)
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (!compareColor(resultColor, black))
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					errorMask.setPixel(x, y, tcu::RGBA(255, 0, 0, 255));
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					isOk = false;
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				else
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					errorMask.setPixel(x, y, tcu::RGBA(0, 255, 0, 255));
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			else
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				// Pixel is close to edge of reference rectangle
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (!compareColor(resultColor, black) && !compareColor(resultColor, white))
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					errorMask.setPixel(x, y, tcu::RGBA(255, 0, 0, 255));
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					isOk = false;
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				else
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					errorMask.setPixel(x, y, tcu::RGBA(0, 255, 0, 255));
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::Image("Result", "Result of rendering", result.getAccess());
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!isOk)
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		log << TestLog::Image("Error Mask", "Error Mask", errorMask.getAccess());
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return isOk;
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass NativeCoordMappingCase : public SimpleConfigCase
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enum NativeType
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		NATIVETYPE_WINDOW = 0,
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		NATIVETYPE_PIXMAP,
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		NATIVETYPE_PBUFFER_COPY_TO_PIXMAP
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3283c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos				NativeCoordMappingCase	(EglTestContext& eglTestCtx, const char* name, const char* description, bool render, NativeType nativeType, const eglu::FilterList& filters);
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				~NativeCoordMappingCase	(void);
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
3323c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	void		executeForConfig		(EGLDisplay display, EGLConfig config);
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	NativeType	m_nativeType;
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool		m_render;
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3383c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry HaulosNativeCoordMappingCase::NativeCoordMappingCase (EglTestContext& eglTestCtx, const char* name, const char* description, bool render, NativeType nativeType, const eglu::FilterList& filters)
3393c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	: SimpleConfigCase	(eglTestCtx, name, description, filters)
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_nativeType		(nativeType)
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_render			(render)
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3453c827367444ee418f129b2c238299f49d3264554Jarkko PoyryNativeCoordMappingCase::~NativeCoordMappingCase	(void)
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deinit();
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3503c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulosvoid logConfigInfo (TestLog& log, const Library& egl, EGLDisplay display, EGLConfig config, NativeCoordMappingCase::NativeType nativeType, int waitFrames)
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3523c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	log << TestLog::Message << "EGL_RED_SIZE: "		<< eglu::getConfigAttribInt(egl, display, config, EGL_RED_SIZE)		<< TestLog::EndMessage;
3533c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	log << TestLog::Message << "EGL_GREEN_SIZE: "	<< eglu::getConfigAttribInt(egl, display, config, EGL_GREEN_SIZE)	<< TestLog::EndMessage;
3543c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	log << TestLog::Message << "EGL_BLUE_SIZE: "	<< eglu::getConfigAttribInt(egl, display, config, EGL_BLUE_SIZE)	<< TestLog::EndMessage;
3553c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	log << TestLog::Message << "EGL_ALPHA_SIZE: "	<< eglu::getConfigAttribInt(egl, display, config, EGL_ALPHA_SIZE)	<< TestLog::EndMessage;
3563c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	log << TestLog::Message << "EGL_DEPTH_SIZE: "	<< eglu::getConfigAttribInt(egl, display, config, EGL_DEPTH_SIZE)	<< TestLog::EndMessage;
3573c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	log << TestLog::Message << "EGL_STENCIL_SIZE: "	<< eglu::getConfigAttribInt(egl, display, config, EGL_STENCIL_SIZE)	<< TestLog::EndMessage;
3583c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	log << TestLog::Message << "EGL_SAMPLES: "		<< eglu::getConfigAttribInt(egl, display, config, EGL_SAMPLES)		<< TestLog::EndMessage;
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (nativeType == NativeCoordMappingCase::NATIVETYPE_WINDOW)
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		log << TestLog::Message << "Waiting " << waitFrames * 16 << "ms after eglSwapBuffers() and glFinish() for frame to become visible" << TestLog::EndMessage;
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool testNativeWindow (TestLog& log, eglu::NativeDisplay& nativeDisplay, eglu::NativeWindow& nativeWindow, EGLDisplay display, EGLContext context, EGLConfig config, const glw::Functions& gl, bool renderColor, int waitFrames)
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int			rectX		= 8;
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int			rectY		= 16;
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int			rectW		= 64;
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int			rectH		= 72;
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3713c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	const Library&		egl			= nativeDisplay.getLibrary();
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::IVec2	screenSize	= nativeWindow.getScreenSize();
3733c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	eglu::UniqueSurface	surface		(egl, display, eglu::createWindowSurface(nativeDisplay, nativeWindow, display, config, DE_NULL));
3743c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	const tcu::IVec2	surfaceSize = eglu::getSurfaceSize(egl, display, *surface);
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			program		= 0;
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool				isOk		= true;
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureLevel	result;
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	try
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3813c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		EGLU_CHECK_CALL(egl, makeCurrent(display, *surface, *surface, context));
3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (renderColor)
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			program = createGLES2Program(gl, log);
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		clear(gl, tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), 0, 0, surfaceSize.x(), surfaceSize.y());
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (renderColor)
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			render(gl, program, surfaceSize.x(), surfaceSize.y(), rectX, rectY, rectW, rectH);
3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		else
3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			clear(gl, tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f), rectX, rectY, rectW, rectH);
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3933c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		EGLU_CHECK_CALL(egl, swapBuffers(display, *surface));
3943c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		EGLU_CHECK_CALL(egl, waitClient());
3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deSleep(waitFrames*16);
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		nativeWindow.readScreenPixels(&result);
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!validate(log, result, rectX, screenSize.y() - rectY - rectH, rectW, rectH))
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			isOk = false;
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4013c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		EGLU_CHECK_CALL(egl, makeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	catch (...)
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (program)
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.deleteProgram(program);
4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw;
4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return isOk;
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool testNativePixmap (TestLog& log, eglu::NativeDisplay& nativeDisplay, eglu::NativePixmap& nativePixmap, int width, int height, EGLDisplay display, EGLContext context, EGLConfig config, const glw::Functions& gl, bool renderColor)
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int			rectX		= 8;
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int			rectY		= 16;
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int			rectW		= 64;
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int			rectH		= 72;
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4203c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	const Library&		egl			= nativeDisplay.getLibrary();
4213c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	eglu::UniqueSurface	surface		(egl, display, eglu::createPixmapSurface(nativeDisplay, nativePixmap, display, config, DE_NULL));
4223c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	deUint32			program		= 0;
4233c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	bool				isOk		= true;
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureLevel	result;
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	try
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4283c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		EGLU_CHECK_CALL(egl, makeCurrent(display, *surface, *surface, context));
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (renderColor)
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			program = createGLES2Program(gl, log);
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		clear(gl, tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), 0, 0, width, height);
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (renderColor)
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			render(gl, program, width, height, rectX, rectY, rectW, rectH);
4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		else
4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			clear(gl, tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f), rectX, rectY, rectW, rectH);
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4403c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		EGLU_CHECK_CALL(egl, waitClient());
4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		nativePixmap.readPixels(&result);
4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!validate(log, result, rectX, height - 1 - rectY - rectH, rectW, rectH))
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			isOk = false;
4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4463c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		EGLU_CHECK_CALL(egl, makeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	catch (...)
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (program)
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.deleteProgram(program);
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw;
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return isOk;
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4583c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulosbool testNativePixmapCopy (TestLog& log, const Library& egl, eglu::NativePixmap& nativePixmap, int width, int height, EGLDisplay display, EGLContext context, EGLConfig config, const glw::Functions& gl, bool renderColor)
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int			rectX		= 8;
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int			rectY		= 16;
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int			rectW		= 64;
4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int			rectH		= 72;
4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4653c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	eglu::UniqueSurface	surface		(egl, display, egl.createPbufferSurface(display, config, DE_NULL));
4663c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	deUint32			program		= 0;
4673c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	bool				isOk		= true;
4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureLevel	result;
4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	try
4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4723c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		EGLU_CHECK_CALL(egl, makeCurrent(display, *surface, *surface, context));
4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (renderColor)
4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			program = createGLES2Program(gl, log);
4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		clear(gl, tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), 0, 0, width, height);
4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (renderColor)
4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			render(gl, program, width, height, rectX, rectY, rectW, rectH);
4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		else
4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			clear(gl, tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f), rectX, rectY, rectW, rectH);
4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4843c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		EGLU_CHECK_CALL(egl, copyBuffers(display, *surface, nativePixmap.getLegacyNative()));
4853c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		EGLU_CHECK_CALL(egl, waitClient());
4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		nativePixmap.readPixels(&result);
4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!validate(log, result, rectX, height - 1 - rectY, rectW, rectH))
4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			isOk = false;
4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4913c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		EGLU_CHECK_CALL(egl, makeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	catch (...)
4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (program)
4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.deleteProgram(program);
4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw;
4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return isOk;
5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
503485844e764f2821545146b832726a36012f86238Mika Isojärvivoid NativeCoordMappingCase::executeForConfig (EGLDisplay display, EGLConfig config)
5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
505485844e764f2821545146b832726a36012f86238Mika Isojärvi	const Library&						egl				= m_eglTestCtx.getLibrary();
506485844e764f2821545146b832726a36012f86238Mika Isojärvi	const string						configIdStr		(de::toString(eglu::getConfigAttribInt(egl, display, config, EGL_CONFIG_ID)));
507485844e764f2821545146b832726a36012f86238Mika Isojärvi	tcu::ScopedLogSection				logSection		(m_testCtx.getLog(), ("Config ID " + configIdStr).c_str(), ("Config ID " + configIdStr).c_str());
508485844e764f2821545146b832726a36012f86238Mika Isojärvi	const int							waitFrames		= 5;
509485844e764f2821545146b832726a36012f86238Mika Isojärvi	const int							width			= 128;
510485844e764f2821545146b832726a36012f86238Mika Isojärvi	const int							height			= 128;
511485844e764f2821545146b832726a36012f86238Mika Isojärvi	const eglu::NativeWindowFactory*	windowFactory;
512485844e764f2821545146b832726a36012f86238Mika Isojärvi	const eglu::NativePixmapFactory*	pixmapFactory;
513485844e764f2821545146b832726a36012f86238Mika Isojärvi
514485844e764f2821545146b832726a36012f86238Mika Isojärvi	logConfigInfo(m_testCtx.getLog(), egl, display, config, m_nativeType, waitFrames);
515485844e764f2821545146b832726a36012f86238Mika Isojärvi
516485844e764f2821545146b832726a36012f86238Mika Isojärvi	try
5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
518485844e764f2821545146b832726a36012f86238Mika Isojärvi		windowFactory = &eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
5193c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos
520485844e764f2821545146b832726a36012f86238Mika Isojärvi		if ((windowFactory->getCapabilities() & eglu::NativeWindow::CAPABILITY_READ_SCREEN_PIXELS) == 0)
521485844e764f2821545146b832726a36012f86238Mika Isojärvi			TCU_THROW(NotSupportedError, "Native window doesn't support readPixels()");
522485844e764f2821545146b832726a36012f86238Mika Isojärvi	}
523485844e764f2821545146b832726a36012f86238Mika Isojärvi	catch (const tcu::NotSupportedError&)
524485844e764f2821545146b832726a36012f86238Mika Isojärvi	{
525485844e764f2821545146b832726a36012f86238Mika Isojärvi		if (m_nativeType == NATIVETYPE_WINDOW)
526485844e764f2821545146b832726a36012f86238Mika Isojärvi			throw;
527485844e764f2821545146b832726a36012f86238Mika Isojärvi		else
528485844e764f2821545146b832726a36012f86238Mika Isojärvi			windowFactory = DE_NULL;
529485844e764f2821545146b832726a36012f86238Mika Isojärvi	}
5303c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos
531485844e764f2821545146b832726a36012f86238Mika Isojärvi	try
532485844e764f2821545146b832726a36012f86238Mika Isojärvi	{
533485844e764f2821545146b832726a36012f86238Mika Isojärvi		pixmapFactory = &eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
535485844e764f2821545146b832726a36012f86238Mika Isojärvi		if (m_nativeType == NATIVETYPE_PIXMAP)
5363c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		{
5373c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos			if ((pixmapFactory->getCapabilities() & eglu::NativePixmap::CAPABILITY_READ_PIXELS) == 0)
5383c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos				TCU_THROW(NotSupportedError, "Native pixmap doesn't support readPixels()");
5393c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		}
540485844e764f2821545146b832726a36012f86238Mika Isojärvi		else if (m_nativeType == NATIVETYPE_PBUFFER_COPY_TO_PIXMAP)
5413c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		{
5423c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos			if ((pixmapFactory->getCapabilities() & eglu::NativePixmap::CAPABILITY_READ_PIXELS) == 0 ||
5433c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos				(pixmapFactory->getCapabilities() & eglu::NativePixmap::CAPABILITY_CREATE_SURFACE_LEGACY) == 0)
5443c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos				TCU_THROW(NotSupportedError, "Native pixmap doesn't support readPixels() or legacy create surface");
5453c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		}
5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
547485844e764f2821545146b832726a36012f86238Mika Isojärvi	catch (const tcu::NotSupportedError&)
548485844e764f2821545146b832726a36012f86238Mika Isojärvi	{
549485844e764f2821545146b832726a36012f86238Mika Isojärvi		if (m_nativeType == NATIVETYPE_PIXMAP || m_nativeType == NATIVETYPE_PBUFFER_COPY_TO_PIXMAP)
550485844e764f2821545146b832726a36012f86238Mika Isojärvi			throw;
551485844e764f2821545146b832726a36012f86238Mika Isojärvi		else
552485844e764f2821545146b832726a36012f86238Mika Isojärvi			pixmapFactory = DE_NULL;
553485844e764f2821545146b832726a36012f86238Mika Isojärvi	}
5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
555485844e764f2821545146b832726a36012f86238Mika Isojärvi	DE_ASSERT(m_nativeType != NATIVETYPE_WINDOW || windowFactory);
556485844e764f2821545146b832726a36012f86238Mika Isojärvi	DE_ASSERT((m_nativeType != NATIVETYPE_PIXMAP && m_nativeType != NATIVETYPE_PBUFFER_COPY_TO_PIXMAP) || pixmapFactory);
5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
558653ad0e8a4209754304cbd5b5ceb4fdc7b29c01aPyry Haulos	eglu::UniqueContext		context		(egl, display, createGLES2Context(egl, display, config));
5593c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	glw::Functions			gl;
5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5613c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	m_eglTestCtx.initGLFunctions(&gl, glu::ApiType::es(2,0));
5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	switch (m_nativeType)
5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case NATIVETYPE_WINDOW:
5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
5673c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos			de::UniquePtr<eglu::NativeWindow>	nativeWindow	(windowFactory->createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(width, height, eglu::WindowParams::VISIBILITY_VISIBLE)));
5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5693c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos			if (!testNativeWindow(m_testCtx.getLog(), m_eglTestCtx.getNativeDisplay(), *nativeWindow, display, *context, config, gl, m_render, waitFrames))
5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid color rendered");
5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			break;
5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case NATIVETYPE_PIXMAP:
5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
5773c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos			de::UniquePtr<eglu::NativePixmap> nativePixmap		(pixmapFactory->createPixmap(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, width, height));
5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5793c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos			if (!testNativePixmap(m_testCtx.getLog(), m_eglTestCtx.getNativeDisplay(), *nativePixmap, width, height, display, *context, config, gl, m_render))
5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid color rendered");
5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			break;
5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case NATIVETYPE_PBUFFER_COPY_TO_PIXMAP:
5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
5873c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos			de::UniquePtr<eglu::NativePixmap> nativePixmap		(pixmapFactory->createPixmap(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, width, height));
5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5893c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos			if (!testNativePixmapCopy(m_testCtx.getLog(), egl, *nativePixmap, width, height, display, *context, config, gl, m_render))
5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid color rendered");
5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			break;
5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		default:
5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			DE_ASSERT(DE_FALSE);
5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6003c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulostemplate <deUint32 Type>
6013c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulosstatic bool surfaceType (const eglu::CandidateConfig& c)
6023c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos{
6033c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	return (c.surfaceType() & Type) == Type;
6043c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos}
6053c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos
6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid addTestGroups (EglTestContext& eglTestCtx, TestCaseGroup* group, NativeCoordMappingCase::NativeType type)
6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6083c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	eglu::FilterList baseFilters;
6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	switch (type)
6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case NativeCoordMappingCase::NATIVETYPE_WINDOW:
6133c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos			baseFilters << surfaceType<EGL_WINDOW_BIT>;
6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			break;
6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case NativeCoordMappingCase::NATIVETYPE_PIXMAP:
6173c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos			baseFilters << surfaceType<EGL_PIXMAP_BIT>;
6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			break;
6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case NativeCoordMappingCase::NATIVETYPE_PBUFFER_COPY_TO_PIXMAP:
6213c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos			baseFilters << surfaceType<EGL_PBUFFER_BIT>;
6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			break;
6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		default:
6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			DE_ASSERT(DE_FALSE);
6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6283c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	vector<NamedFilterList> filterLists;
6293c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	getDefaultFilterLists(filterLists, baseFilters);
6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6313c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	for (vector<NamedFilterList>::iterator i = filterLists.begin(); i != filterLists.end(); i++)
6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6333c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		group->addChild(new NativeCoordMappingCase(eglTestCtx, (string(i->getName()) + "_clear").c_str(), i->getDescription(), false, type, *i));
6343c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos		group->addChild(new NativeCoordMappingCase(eglTestCtx, (string(i->getName()) + "_render").c_str(), i->getDescription(), true, type, *i));
6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // anonymous
6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6403c827367444ee418f129b2c238299f49d3264554Jarkko PoyryNativeCoordMappingTests::NativeCoordMappingTests (EglTestContext& eglTestCtx)
6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCaseGroup(eglTestCtx, "native_coord_mapping", "Tests for mapping client coordinates to native surface")
6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid NativeCoordMappingTests::init (void)
6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TestCaseGroup* windowGroup = new TestCaseGroup(m_eglTestCtx, "native_window", "Tests for mapping client color to native window");
6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addTestGroups(m_eglTestCtx, windowGroup, NativeCoordMappingCase::NATIVETYPE_WINDOW);
6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(windowGroup);
6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TestCaseGroup* pixmapGroup = new TestCaseGroup(m_eglTestCtx, "native_pixmap", "Tests for mapping client color to native pixmap");
6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addTestGroups(m_eglTestCtx, pixmapGroup, NativeCoordMappingCase::NATIVETYPE_PIXMAP);
6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(pixmapGroup);
6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TestCaseGroup* pbufferGroup = new TestCaseGroup(m_eglTestCtx, "pbuffer_to_native_pixmap", "Tests for mapping client color to native pixmap with eglCopyBuffers()");
6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addTestGroups(m_eglTestCtx, pbufferGroup, NativeCoordMappingCase::NATIVETYPE_PBUFFER_COPY_TO_PIXMAP);
6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(pbufferGroup);
6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // egl
6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
668