13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _GLSTEXTURETESTUTIL_HPP
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _GLSTEXTURETESTUTIL_HPP
33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL (ES) Module
53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * -----------------------------------------------
63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project
83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License");
103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License.
113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at
123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *      http://www.apache.org/licenses/LICENSE-2.0
143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software
163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS,
173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and
193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License.
203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*!
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Texture test utilities.
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * About coordinates:
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  + Quads consist of 2 triangles, rendered using explicit indices.
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  + All TextureTestUtil functions and classes expect texture coordinates
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *    for quads to be specified in order (-1, -1), (-1, 1), (1, -1), (1, 1).
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuDefs.hpp"
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTexture.hpp"
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuSurface.hpp"
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuPixelFormat.hpp"
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuRenderTarget.hpp"
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestContext.hpp"
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deMath.h"
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deInt32.h"
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluShaderProgram.hpp"
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp"
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuCompressedTexture.hpp"
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluShaderUtil.hpp"
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <map>
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace tcu
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct LookupPrecision;
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct LodPrecision;
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct TexComparePrecision;
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gls
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace TextureTestUtil
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum TextureType
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TEXTURETYPE_2D = 0,
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TEXTURETYPE_CUBE,
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TEXTURETYPE_2D_ARRAY,
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TEXTURETYPE_3D,
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TEXTURETYPE_CUBE_ARRAY,
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TEXTURETYPE_1D,
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TEXTURETYPE_1D_ARRAY,
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TEXTURETYPE_BUFFER,
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TEXTURETYPE_LAST
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum SamplerType
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	SAMPLERTYPE_FLOAT,
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	SAMPLERTYPE_INT,
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	SAMPLERTYPE_UINT,
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	SAMPLERTYPE_SHADOW,
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	SAMPLERTYPE_FETCH_FLOAT,
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	SAMPLERTYPE_FETCH_INT,
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	SAMPLERTYPE_FETCH_UINT,
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	SAMPLERTYPE_LAST
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
883c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySamplerType		getSamplerType		(tcu::TextureFormat format);
893c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySamplerType		getFetchSamplerType	(tcu::TextureFormat format);
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct RenderParams
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enum Flags
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		PROJECTED		= (1<<0),
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		USE_BIAS		= (1<<1),
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LOG_PROGRAMS	= (1<<2),
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LOG_UNIFORMS	= (1<<3),
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LOG_ALL			= LOG_PROGRAMS|LOG_UNIFORMS
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	RenderParams (TextureType texType_)
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: texType		(texType_)
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, samplerType	(SAMPLERTYPE_FLOAT)
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, flags			(0)
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, w				(1.0f)
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, bias			(0.0f)
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, ref			(0.0f)
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, colorScale	(1.0f)
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, colorBias		(0.0f)
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureType		texType;		//!< Texture type.
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	SamplerType		samplerType;	//!< Sampler type.
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32		flags;			//!< Feature flags.
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Vec4		w;				//!< w coordinates for quad vertices.
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float			bias;			//!< User-supplied bias.
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float			ref;			//!< Reference value for shadow lookups.
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// color = lookup() * scale + bias
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Vec4		colorScale;		//!< Scale for texture color values.
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Vec4		colorBias;		//!< Bias for texture color values.
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum Program
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_2D_FLOAT = 0,
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_2D_INT,
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_2D_UINT,
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_2D_SHADOW,
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_2D_FLOAT_BIAS,
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_2D_INT_BIAS,
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_2D_UINT_BIAS,
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_2D_SHADOW_BIAS,
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_1D_FLOAT,
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_1D_INT,
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_1D_UINT,
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_1D_SHADOW,
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_1D_FLOAT_BIAS,
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_1D_INT_BIAS,
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_1D_UINT_BIAS,
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_1D_SHADOW_BIAS,
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_CUBE_FLOAT,
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_CUBE_INT,
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_CUBE_UINT,
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_CUBE_SHADOW,
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_CUBE_FLOAT_BIAS,
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_CUBE_INT_BIAS,
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_CUBE_UINT_BIAS,
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_CUBE_SHADOW_BIAS,
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_1D_ARRAY_FLOAT,
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_1D_ARRAY_INT,
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_1D_ARRAY_UINT,
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_1D_ARRAY_SHADOW,
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_2D_ARRAY_FLOAT,
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_2D_ARRAY_INT,
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_2D_ARRAY_UINT,
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_2D_ARRAY_SHADOW,
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_3D_FLOAT,
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_3D_INT,
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_3D_UINT,
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_3D_FLOAT_BIAS,
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_3D_INT_BIAS,
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_3D_UINT_BIAS,
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_CUBE_ARRAY_FLOAT,
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_CUBE_ARRAY_INT,
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_CUBE_ARRAY_UINT,
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_CUBE_ARRAY_SHADOW,
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_BUFFER_FLOAT,
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_BUFFER_INT,
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_BUFFER_UINT,
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_LAST
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ProgramLibrary
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											ProgramLibrary			(const glu::RenderContext& context, tcu::TestContext& testCtx, glu::GLSLVersion glslVersion, glu::Precision texCoordPrecision);
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											~ProgramLibrary			(void);
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram*						getProgram				(Program program);
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void									clear					(void);
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											ProgramLibrary			(const ProgramLibrary& other);
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ProgramLibrary&							operator=				(const ProgramLibrary& other);
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::RenderContext&				m_context;
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TestContext&						m_testCtx;
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::GLSLVersion						m_glslVersion;
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::Precision							m_texCoordPrecision;
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::map<Program, glu::ShaderProgram*>	m_programs;
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureRenderer
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								TextureRenderer			(const glu::RenderContext& context, tcu::TestContext& testCtx, glu::GLSLVersion glslVersion, glu::Precision texCoordPrecision);
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								~TextureRenderer		(void);
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						clear					(void); //!< Frees allocated resources. Destructor will call clear() as well.
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						renderQuad				(int texUnit, const float* texCoord, TextureType texType);
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						renderQuad				(int texUnit, const float* texCoord, const RenderParams& params);
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								TextureRenderer			(const TextureRenderer& other);
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureRenderer&			operator=				(const TextureRenderer& other);
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::RenderContext&	m_renderCtx;
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TestContext&			m_testCtx;
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ProgramLibrary				m_programLibrary;
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RandomViewport
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int		x;
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int		y;
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int		width;
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int		height;
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	RandomViewport (const tcu::RenderTarget& renderTarget, int preferredWidth, int preferredHeight, deUint32 seed);
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline tcu::RGBA toRGBA (const tcu::Vec4& v)
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// \todo [2011-10-24 pyry] Rounding mode?
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return tcu::RGBA(deClamp32(deRoundFloatToInt32(v.x()*255.0f), 0, 255),
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					 deClamp32(deRoundFloatToInt32(v.y()*255.0f), 0, 255),
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					 deClamp32(deRoundFloatToInt32(v.z()*255.0f), 0, 255),
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					 deClamp32(deRoundFloatToInt32(v.w()*255.0f), 0, 255));
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline tcu::RGBA toRGBAMasked (const tcu::Vec4& v, deUint8 mask)
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// \todo [2011-10-24 pyry] Rounding mode?
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return tcu::RGBA((mask&tcu::RGBA::RED_MASK)		? deClamp32(deRoundFloatToInt32(v.x()*255.0f), 0, 255) : 0,
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					 (mask&tcu::RGBA::GREEN_MASK)	? deClamp32(deRoundFloatToInt32(v.y()*255.0f), 0, 255) : 0,
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					 (mask&tcu::RGBA::BLUE_MASK)	? deClamp32(deRoundFloatToInt32(v.z()*255.0f), 0, 255) : 0,
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					 (mask&tcu::RGBA::ALPHA_MASK)	? deClamp32(deRoundFloatToInt32(v.w()*255.0f), 0, 255) : 0xff);
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline tcu::Vec4 toVec4 (const tcu::RGBA& c)
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return tcu::Vec4(c.getRed()		/ 255.0f,
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					 c.getGreen()	/ 255.0f,
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					 c.getBlue()	/ 255.0f,
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					 c.getAlpha()	/ 255.0f);
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline deUint8 getColorMask (const tcu::PixelFormat& format)
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return (format.redBits		? tcu::RGBA::RED_MASK	: 0) |
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		   (format.greenBits	? tcu::RGBA::GREEN_MASK	: 0) |
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		   (format.blueBits		? tcu::RGBA::BLUE_MASK	: 0) |
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		   (format.alphaBits	? tcu::RGBA::ALPHA_MASK	: 0);
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline tcu::IVec4 getBitsVec (const tcu::PixelFormat& format)
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return tcu::IVec4(format.redBits, format.greenBits, format.blueBits, format.alphaBits);
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline tcu::BVec4 getCompareMask (const tcu::PixelFormat& format)
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return tcu::BVec4(format.redBits	> 0,
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					  format.greenBits	> 0,
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					  format.blueBits	> 0,
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					  format.alphaBits	> 0);
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// \todo [2012-02-09 pyry] Move to tcuSurfaceAccess?
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass SurfaceAccess
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							SurfaceAccess		(tcu::Surface& surface, const tcu::PixelFormat& colorFmt);
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							SurfaceAccess		(tcu::Surface& surface, const tcu::PixelFormat& colorFmt, int x, int y, int width, int height);
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							SurfaceAccess		(const SurfaceAccess& parent, int x, int y, int width, int height);
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						getWidth			(void) const	{ return m_width;	}
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						getHeight			(void) const	{ return m_height;	}
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					setPixel			(const tcu::Vec4& color, int x, int y) const;
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	mutable tcu::Surface*	m_surface;
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint8					m_colorMask;
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_x;
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_y;
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_width;
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_height;
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline void SurfaceAccess::setPixel (const tcu::Vec4& color, int x, int y) const
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(de::inBounds(x, 0, m_width) && de::inBounds(y, 0, m_height));
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_surface->setPixel(m_x+x, m_y+y, toRGBAMasked(color, m_colorMask));
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum LodMode
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LODMODE_EXACT = 0,		//!< Ideal lod computation.
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LODMODE_MIN_BOUND,		//!< Use estimation range minimum bound.
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LODMODE_MAX_BOUND,		//!< Use estimation range maximum bound.
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LODMODE_LAST
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct ReferenceParams : public RenderParams
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ReferenceParams (TextureType texType_)
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: RenderParams	(texType_)
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, sampler		()
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, lodMode		(LODMODE_EXACT)
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, minLod		(-1000.0f)
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, maxLod		(1000.0f)
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, baseLevel		(0)
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, maxLevel		(1000)
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ReferenceParams (TextureType texType_, const tcu::Sampler& sampler_, LodMode lodMode_ = LODMODE_EXACT)
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: RenderParams	(texType_)
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, sampler		(sampler_)
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, lodMode		(lodMode_)
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, minLod		(-1000.0f)
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, maxLod		(1000.0f)
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, baseLevel		(0)
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, maxLevel		(1000)
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Sampler		sampler;
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LodMode				lodMode;
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float				minLod;
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float				maxLod;
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int					baseLevel;
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int					maxLevel;
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			clear						(const SurfaceAccess& dst, const tcu::Vec4& color);
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Similar to sampleTexture() except uses texelFetch.
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			fetchTexture				(const SurfaceAccess& dst, const tcu::ConstPixelBufferAccess& src, const float* texCoord, const tcu::Vec4& colorScale, const tcu::Vec4& colorBias);
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			sampleTexture				(const SurfaceAccess& dst, const tcu::Texture2DView&		src, const float* texCoord, const ReferenceParams& params);
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			sampleTexture				(const SurfaceAccess& dst, const tcu::TextureCubeView&		src, const float* texCoord, const ReferenceParams& params);
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			sampleTextureMultiFace		(const SurfaceAccess& dst, const tcu::TextureCubeView&		src, const float* texCoord, const ReferenceParams& params);
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			sampleTexture				(const SurfaceAccess& dst, const tcu::Texture2DArrayView&	src, const float* texCoord, const ReferenceParams& params);
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			sampleTexture				(const SurfaceAccess& dst, const tcu::Texture3DView&		src, const float* texCoord, const ReferenceParams& params);
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			sampleTexture				(const SurfaceAccess& dst, const tcu::TextureCubeArrayView&	src, const float* texCoord, const ReferenceParams& params);
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			sampleTexture				(const SurfaceAccess& dst, const tcu::Texture1DView&		src, const float* texCoord, const ReferenceParams& params);
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			sampleTexture				(const SurfaceAccess& dst, const tcu::Texture1DArrayView&	src, const float* texCoord, const ReferenceParams& params);
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			computeQuadTexCoord1D			(std::vector<float>& dst, float left, float right);
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			computeQuadTexCoord1DArray		(std::vector<float>& dst, int layerNdx, float left, float right);
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			computeQuadTexCoord2D			(std::vector<float>& dst, const tcu::Vec2& bottomLeft, const tcu::Vec2& topRight);
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			computeQuadTexCoord2DArray		(std::vector<float>& dst, int layerNdx, const tcu::Vec2& bottomLeft, const tcu::Vec2& topRight);
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			computeQuadTexCoord3D			(std::vector<float>& dst, const tcu::Vec3& p0, const tcu::Vec3& p1, const tcu::IVec3& dirSwz);
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			computeQuadTexCoordCube			(std::vector<float>& dst, tcu::CubeFace face);
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			computeQuadTexCoordCube			(std::vector<float>& dst, tcu::CubeFace face, const tcu::Vec2& bottomLeft, const tcu::Vec2& topRight);
3778852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid			computeQuadTexCoordCubeArray	(std::vector<float>& dst, tcu::CubeFace face, const tcu::Vec2& bottomLeft, const tcu::Vec2& topRight, const tcu::Vec2& layerRange);
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool			compareImages				(tcu::TestLog& log, const char* name, const char* desc, const tcu::Surface& reference, const tcu::Surface& rendered, tcu::RGBA threshold);
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool			compareImages				(tcu::TestLog& log, const tcu::Surface& reference, const tcu::Surface& rendered, tcu::RGBA threshold);
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint				measureAccuracy				(tcu::TestLog& log, const tcu::Surface& reference, const tcu::Surface& rendered, int bestScoreDiff, int worstScoreDiff);
3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint				computeTextureLookupDiff	(const tcu::ConstPixelBufferAccess&	result,
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	reference,
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelBufferAccess&		errorMask,
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Texture1DView&			src,
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 qpWatchDog*						watchDog);
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint				computeTextureLookupDiff	(const tcu::ConstPixelBufferAccess&	result,
3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	reference,
3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelBufferAccess&		errorMask,
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Texture2DView&			src,
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 qpWatchDog*						watchDog);
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint				computeTextureLookupDiff	(const tcu::ConstPixelBufferAccess&	result,
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	reference,
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelBufferAccess&		errorMask,
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::TextureCubeView&		src,
4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 qpWatchDog*						watchDog);
4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint				computeTextureLookupDiff	(const tcu::ConstPixelBufferAccess&	result,
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	reference,
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelBufferAccess&		errorMask,
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Texture1DArrayView&		src,
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 qpWatchDog*						watchDog);
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint				computeTextureLookupDiff	(const tcu::ConstPixelBufferAccess&	result,
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	reference,
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelBufferAccess&		errorMask,
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Texture2DArrayView&		src,
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 qpWatchDog*						watchDog);
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint				computeTextureLookupDiff	(const tcu::ConstPixelBufferAccess&	result,
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	reference,
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelBufferAccess&		errorMask,
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Texture3DView&			src,
4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 qpWatchDog*						watchDog);
4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4438852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryint				computeTextureLookupDiff	(const tcu::ConstPixelBufferAccess&	result,
4448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	reference,
4458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const tcu::PixelBufferAccess&		errorMask,
4468852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const tcu::TextureCubeArrayView&	src,
4478852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const float*						texCoord,
4488852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const ReferenceParams&				sampleParams,
4498852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
4508852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const tcu::IVec4&					coordBits,
4518852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
4528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 qpWatchDog*						watchDog);
4538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool			verifyTextureResult			(tcu::TestContext&					testCtx,
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	result,
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Texture1DView&			src,
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelFormat&			pixelFormat);
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool			verifyTextureResult			(tcu::TestContext&					testCtx,
4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	result,
4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Texture2DView&			src,
4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelFormat&			pixelFormat);
4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool			verifyTextureResult			(tcu::TestContext&					testCtx,
4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	result,
4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::TextureCubeView&		src,
4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelFormat&			pixelFormat);
4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool			verifyTextureResult			(tcu::TestContext&					testCtx,
4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	result,
4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Texture1DArrayView&		src,
4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelFormat&			pixelFormat);
4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool			verifyTextureResult			(tcu::TestContext&					testCtx,
4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	result,
4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Texture2DArrayView&		src,
4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelFormat&			pixelFormat);
4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool			verifyTextureResult			(tcu::TestContext&					testCtx,
5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	result,
5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Texture3DView&			src,
5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelFormat&			pixelFormat);
5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5088852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrybool			verifyTextureResult			(tcu::TestContext&					testCtx,
5098852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	result,
5108852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const tcu::TextureCubeArrayView&	src,
5118852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const float*						texCoord,
5128852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const ReferenceParams&				sampleParams,
5138852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
5148852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const tcu::IVec4&					coordBits,
5158852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
5168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const tcu::PixelFormat&			pixelFormat);
5178852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry
5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint				computeTextureCompareDiff	(const tcu::ConstPixelBufferAccess&	result,
5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	reference,
5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelBufferAccess&		errorMask,
5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Texture2DView&			src,
5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::TexComparePrecision&	comparePrec,
5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Vec3&					nonShadowThreshold);
5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint				computeTextureCompareDiff	(const tcu::ConstPixelBufferAccess&	result,
5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	reference,
5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelBufferAccess&		errorMask,
5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::TextureCubeView&		src,
5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::TexComparePrecision&	comparePrec,
5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Vec3&					nonShadowThreshold);
5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint				computeTextureCompareDiff	(const tcu::ConstPixelBufferAccess&	result,
5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	reference,
5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelBufferAccess&		errorMask,
5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Texture2DArrayView&		src,
5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::TexComparePrecision&	comparePrec,
5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Vec3&					nonShadowThreshold);
5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Mipmap generation comparison.
5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct GenMipmapPrecision
5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::IVec3			filterBits;			//!< Bits in filtering parameters (fixed-point).
5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Vec4			colorThreshold;		//!< Threshold for color value comparison.
5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::BVec4			colorMask;			//!< Color channel comparison mask.
5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5573c827367444ee418f129b2c238299f49d3264554Jarkko PoyryqpTestResult	compareGenMipmapResult		(tcu::TestLog& log, const tcu::Texture2D& resultTexture, const tcu::Texture2D& level0Reference, const GenMipmapPrecision& precision);
5583c827367444ee418f129b2c238299f49d3264554Jarkko PoyryqpTestResult	compareGenMipmapResult		(tcu::TestLog& log, const tcu::TextureCube& resultTexture, const tcu::TextureCube& level0Reference, const GenMipmapPrecision& precision);
5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Utility for logging texture gradient ranges.
5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct LogGradientFmt
5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LogGradientFmt (const tcu::Vec4* min_, const tcu::Vec4* max_) : valueMin(min_), valueMax(max_) {}
5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::Vec4* valueMin;
5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::Vec4* valueMax;
5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::ostream&			operator<<		(std::ostream& str, const LogGradientFmt& fmt);
5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline LogGradientFmt	formatGradient	(const tcu::Vec4* minVal, const tcu::Vec4* maxVal) { return LogGradientFmt(minVal, maxVal); }
5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // TextureTestUtil
5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gls
5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _GLSTEXTURETESTUTIL_HPP
576