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 "tcuTestLog.hpp"
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuCompressedTexture.hpp"
3927b5856bb11af6bd900f11aeaf00d723a96783a5Jarkko Pöyry#include "tcuTextureUtil.hpp"
4027b5856bb11af6bd900f11aeaf00d723a96783a5Jarkko Pöyry
4127b5856bb11af6bd900f11aeaf00d723a96783a5Jarkko Pöyry#include "gluShaderProgram.hpp"
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluShaderUtil.hpp"
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4427b5856bb11af6bd900f11aeaf00d723a96783a5Jarkko Pöyry#include "deMath.h"
4527b5856bb11af6bd900f11aeaf00d723a96783a5Jarkko Pöyry#include "deInt32.h"
4627b5856bb11af6bd900f11aeaf00d723a96783a5Jarkko Pöyry
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <map>
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace tcu
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct LookupPrecision;
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct LodPrecision;
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct TexComparePrecision;
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gls
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace TextureTestUtil
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum TextureType
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TEXTURETYPE_2D = 0,
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TEXTURETYPE_CUBE,
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TEXTURETYPE_2D_ARRAY,
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TEXTURETYPE_3D,
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TEXTURETYPE_CUBE_ARRAY,
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TEXTURETYPE_1D,
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TEXTURETYPE_1D_ARRAY,
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TEXTURETYPE_BUFFER,
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TEXTURETYPE_LAST
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum SamplerType
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	SAMPLERTYPE_FLOAT,
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	SAMPLERTYPE_INT,
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	SAMPLERTYPE_UINT,
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	SAMPLERTYPE_SHADOW,
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	SAMPLERTYPE_FETCH_FLOAT,
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	SAMPLERTYPE_FETCH_INT,
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	SAMPLERTYPE_FETCH_UINT,
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	SAMPLERTYPE_LAST
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
913c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySamplerType		getSamplerType		(tcu::TextureFormat format);
923c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySamplerType		getFetchSamplerType	(tcu::TextureFormat format);
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct RenderParams
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enum Flags
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		PROJECTED		= (1<<0),
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		USE_BIAS		= (1<<1),
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LOG_PROGRAMS	= (1<<2),
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LOG_UNIFORMS	= (1<<3),
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LOG_ALL			= LOG_PROGRAMS|LOG_UNIFORMS
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	RenderParams (TextureType texType_)
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: texType		(texType_)
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, samplerType	(SAMPLERTYPE_FLOAT)
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, flags			(0)
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, w				(1.0f)
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, bias			(0.0f)
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, ref			(0.0f)
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, colorScale	(1.0f)
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, colorBias		(0.0f)
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureType		texType;		//!< Texture type.
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	SamplerType		samplerType;	//!< Sampler type.
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32		flags;			//!< Feature flags.
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Vec4		w;				//!< w coordinates for quad vertices.
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float			bias;			//!< User-supplied bias.
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float			ref;			//!< Reference value for shadow lookups.
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// color = lookup() * scale + bias
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Vec4		colorScale;		//!< Scale for texture color values.
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Vec4		colorBias;		//!< Bias for texture color values.
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum Program
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_2D_FLOAT = 0,
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_2D_INT,
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_2D_UINT,
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_2D_SHADOW,
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_2D_FLOAT_BIAS,
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_2D_INT_BIAS,
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_2D_UINT_BIAS,
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_2D_SHADOW_BIAS,
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_1D_FLOAT,
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_1D_INT,
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_1D_UINT,
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_1D_SHADOW,
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_1D_FLOAT_BIAS,
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_1D_INT_BIAS,
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_1D_UINT_BIAS,
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_1D_SHADOW_BIAS,
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_CUBE_FLOAT,
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_CUBE_INT,
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_CUBE_UINT,
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_CUBE_SHADOW,
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_CUBE_FLOAT_BIAS,
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_CUBE_INT_BIAS,
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_CUBE_UINT_BIAS,
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_CUBE_SHADOW_BIAS,
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_1D_ARRAY_FLOAT,
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_1D_ARRAY_INT,
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_1D_ARRAY_UINT,
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_1D_ARRAY_SHADOW,
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_2D_ARRAY_FLOAT,
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_2D_ARRAY_INT,
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_2D_ARRAY_UINT,
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_2D_ARRAY_SHADOW,
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_3D_FLOAT,
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_3D_INT,
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_3D_UINT,
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_3D_FLOAT_BIAS,
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_3D_INT_BIAS,
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_3D_UINT_BIAS,
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_CUBE_ARRAY_FLOAT,
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_CUBE_ARRAY_INT,
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_CUBE_ARRAY_UINT,
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_CUBE_ARRAY_SHADOW,
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_BUFFER_FLOAT,
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_BUFFER_INT,
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_BUFFER_UINT,
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PROGRAM_LAST
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ProgramLibrary
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
195469002caa1ccd58f59f53a1bf3dbac4cf6a5d817Jarkko Pöyry											ProgramLibrary			(const glu::RenderContext& context, tcu::TestLog& log, glu::GLSLVersion glslVersion, glu::Precision texCoordPrecision);
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											~ProgramLibrary			(void);
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram*						getProgram				(Program program);
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void									clear					(void);
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											ProgramLibrary			(const ProgramLibrary& other);
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ProgramLibrary&							operator=				(const ProgramLibrary& other);
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::RenderContext&				m_context;
206469002caa1ccd58f59f53a1bf3dbac4cf6a5d817Jarkko Pöyry	tcu::TestLog&							m_log;
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::GLSLVersion						m_glslVersion;
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::Precision							m_texCoordPrecision;
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::map<Program, glu::ShaderProgram*>	m_programs;
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureRenderer
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
215469002caa1ccd58f59f53a1bf3dbac4cf6a5d817Jarkko Pöyry								TextureRenderer			(const glu::RenderContext& context, tcu::TestLog& log, glu::GLSLVersion glslVersion, glu::Precision texCoordPrecision);
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								~TextureRenderer		(void);
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						clear					(void); //!< Frees allocated resources. Destructor will call clear() as well.
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						renderQuad				(int texUnit, const float* texCoord, TextureType texType);
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						renderQuad				(int texUnit, const float* texCoord, const RenderParams& params);
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								TextureRenderer			(const TextureRenderer& other);
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureRenderer&			operator=				(const TextureRenderer& other);
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::RenderContext&	m_renderCtx;
228469002caa1ccd58f59f53a1bf3dbac4cf6a5d817Jarkko Pöyry	tcu::TestLog&				m_log;
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ProgramLibrary				m_programLibrary;
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RandomViewport
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int		x;
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int		y;
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int		width;
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int		height;
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	RandomViewport (const tcu::RenderTarget& renderTarget, int preferredWidth, int preferredHeight, deUint32 seed);
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline tcu::RGBA toRGBAMasked (const tcu::Vec4& v, deUint8 mask)
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
24527b5856bb11af6bd900f11aeaf00d723a96783a5Jarkko Pöyry	return tcu::RGBA((mask&tcu::RGBA::RED_MASK)		? tcu::floatToU8(v.x()) : 0,
24627b5856bb11af6bd900f11aeaf00d723a96783a5Jarkko Pöyry					 (mask&tcu::RGBA::GREEN_MASK)	? tcu::floatToU8(v.y()) : 0,
24727b5856bb11af6bd900f11aeaf00d723a96783a5Jarkko Pöyry					 (mask&tcu::RGBA::BLUE_MASK)	? tcu::floatToU8(v.z()) : 0,
24835da00b47d81828e10c990e049314cac74195332Jarkko Pöyry					 (mask&tcu::RGBA::ALPHA_MASK)	? tcu::floatToU8(v.w()) : 0xFF); //!< \note Alpha defaults to full saturation when reading masked format
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
251fb4796914bfb9f7bef4d75312b9bce592e169b4bJarkko Pöyry// \todo[jarkko 2015-05-19] remove this
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline tcu::Vec4 toVec4 (const tcu::RGBA& c)
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
254fb4796914bfb9f7bef4d75312b9bce592e169b4bJarkko Pöyry	return c.toVec();
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline deUint8 getColorMask (const tcu::PixelFormat& format)
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
259c8e526bfc2141e1cb7a269483fb55dc2a8e77c11Jarkko Pöyry	return (deUint8)((format.redBits	? tcu::RGBA::RED_MASK	: 0) |
260c8e526bfc2141e1cb7a269483fb55dc2a8e77c11Jarkko Pöyry					 (format.greenBits	? tcu::RGBA::GREEN_MASK	: 0) |
261c8e526bfc2141e1cb7a269483fb55dc2a8e77c11Jarkko Pöyry					 (format.blueBits	? tcu::RGBA::BLUE_MASK	: 0) |
262c8e526bfc2141e1cb7a269483fb55dc2a8e77c11Jarkko Pöyry					 (format.alphaBits	? tcu::RGBA::ALPHA_MASK	: 0));
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline tcu::IVec4 getBitsVec (const tcu::PixelFormat& format)
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return tcu::IVec4(format.redBits, format.greenBits, format.blueBits, format.alphaBits);
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline tcu::BVec4 getCompareMask (const tcu::PixelFormat& format)
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return tcu::BVec4(format.redBits	> 0,
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					  format.greenBits	> 0,
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					  format.blueBits	> 0,
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					  format.alphaBits	> 0);
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// \todo [2012-02-09 pyry] Move to tcuSurfaceAccess?
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass SurfaceAccess
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							SurfaceAccess		(tcu::Surface& surface, const tcu::PixelFormat& colorFmt);
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							SurfaceAccess		(tcu::Surface& surface, const tcu::PixelFormat& colorFmt, int x, int y, int width, int height);
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							SurfaceAccess		(const SurfaceAccess& parent, int x, int y, int width, int height);
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						getWidth			(void) const	{ return m_width;	}
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						getHeight			(void) const	{ return m_height;	}
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					setPixel			(const tcu::Vec4& color, int x, int y) const;
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	mutable tcu::Surface*	m_surface;
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint8					m_colorMask;
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_x;
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_y;
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_width;
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_height;
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline void SurfaceAccess::setPixel (const tcu::Vec4& color, int x, int y) const
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(de::inBounds(x, 0, m_width) && de::inBounds(y, 0, m_height));
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_surface->setPixel(m_x+x, m_y+y, toRGBAMasked(color, m_colorMask));
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum LodMode
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LODMODE_EXACT = 0,		//!< Ideal lod computation.
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LODMODE_MIN_BOUND,		//!< Use estimation range minimum bound.
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LODMODE_MAX_BOUND,		//!< Use estimation range maximum bound.
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LODMODE_LAST
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct ReferenceParams : public RenderParams
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ReferenceParams (TextureType texType_)
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: RenderParams	(texType_)
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, sampler		()
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, lodMode		(LODMODE_EXACT)
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, minLod		(-1000.0f)
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, maxLod		(1000.0f)
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, baseLevel		(0)
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, maxLevel		(1000)
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ReferenceParams (TextureType texType_, const tcu::Sampler& sampler_, LodMode lodMode_ = LODMODE_EXACT)
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: RenderParams	(texType_)
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, sampler		(sampler_)
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, lodMode		(lodMode_)
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, minLod		(-1000.0f)
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, maxLod		(1000.0f)
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, baseLevel		(0)
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, maxLevel		(1000)
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Sampler		sampler;
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LodMode				lodMode;
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float				minLod;
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float				maxLod;
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int					baseLevel;
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int					maxLevel;
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Similar to sampleTexture() except uses texelFetch.
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			fetchTexture				(const SurfaceAccess& dst, const tcu::ConstPixelBufferAccess& src, const float* texCoord, const tcu::Vec4& colorScale, const tcu::Vec4& colorBias);
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			sampleTexture				(const SurfaceAccess& dst, const tcu::Texture2DView&		src, const float* texCoord, const ReferenceParams& params);
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			sampleTexture				(const SurfaceAccess& dst, const tcu::TextureCubeView&		src, const float* texCoord, const ReferenceParams& params);
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			sampleTexture				(const SurfaceAccess& dst, const tcu::Texture2DArrayView&	src, const float* texCoord, const ReferenceParams& params);
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			sampleTexture				(const SurfaceAccess& dst, const tcu::Texture3DView&		src, const float* texCoord, const ReferenceParams& params);
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			sampleTexture				(const SurfaceAccess& dst, const tcu::TextureCubeArrayView&	src, const float* texCoord, const ReferenceParams& params);
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			sampleTexture				(const SurfaceAccess& dst, const tcu::Texture1DView&		src, const float* texCoord, const ReferenceParams& params);
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			sampleTexture				(const SurfaceAccess& dst, const tcu::Texture1DArrayView&	src, const float* texCoord, const ReferenceParams& params);
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
358d6e176c7c08492db84cc8befcbb68e7d025500b4Jarkko Pöyryfloat			computeLodFromDerivates		(LodMode mode, float dudx, float dudy);
359d6e176c7c08492db84cc8befcbb68e7d025500b4Jarkko Pöyryfloat			computeLodFromDerivates		(LodMode mode, float dudx, float dvdx, float dudy, float dvdy);
360d6e176c7c08492db84cc8befcbb68e7d025500b4Jarkko Pöyryfloat			computeLodFromDerivates		(LodMode mode, float dudx, float dvdx, float dwdx, float dudy, float dvdy, float dwdy);
361d6e176c7c08492db84cc8befcbb68e7d025500b4Jarkko Pöyry
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			computeQuadTexCoord1D			(std::vector<float>& dst, float left, float right);
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			computeQuadTexCoord1DArray		(std::vector<float>& dst, int layerNdx, float left, float right);
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			computeQuadTexCoord2D			(std::vector<float>& dst, const tcu::Vec2& bottomLeft, const tcu::Vec2& topRight);
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			computeQuadTexCoord2DArray		(std::vector<float>& dst, int layerNdx, const tcu::Vec2& bottomLeft, const tcu::Vec2& topRight);
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			computeQuadTexCoord3D			(std::vector<float>& dst, const tcu::Vec3& p0, const tcu::Vec3& p1, const tcu::IVec3& dirSwz);
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			computeQuadTexCoordCube			(std::vector<float>& dst, tcu::CubeFace face);
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid			computeQuadTexCoordCube			(std::vector<float>& dst, tcu::CubeFace face, const tcu::Vec2& bottomLeft, const tcu::Vec2& topRight);
3698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid			computeQuadTexCoordCubeArray	(std::vector<float>& dst, tcu::CubeFace face, const tcu::Vec2& bottomLeft, const tcu::Vec2& topRight, const tcu::Vec2& layerRange);
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool			compareImages				(tcu::TestLog& log, const char* name, const char* desc, const tcu::Surface& reference, const tcu::Surface& rendered, tcu::RGBA threshold);
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool			compareImages				(tcu::TestLog& log, const tcu::Surface& reference, const tcu::Surface& rendered, tcu::RGBA threshold);
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint				measureAccuracy				(tcu::TestLog& log, const tcu::Surface& reference, const tcu::Surface& rendered, int bestScoreDiff, int worstScoreDiff);
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint				computeTextureLookupDiff	(const tcu::ConstPixelBufferAccess&	result,
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	reference,
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelBufferAccess&		errorMask,
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Texture1DView&			src,
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 qpWatchDog*						watchDog);
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint				computeTextureLookupDiff	(const tcu::ConstPixelBufferAccess&	result,
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	reference,
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelBufferAccess&		errorMask,
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Texture2DView&			src,
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 qpWatchDog*						watchDog);
3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint				computeTextureLookupDiff	(const tcu::ConstPixelBufferAccess&	result,
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	reference,
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelBufferAccess&		errorMask,
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::TextureCubeView&		src,
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 qpWatchDog*						watchDog);
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint				computeTextureLookupDiff	(const tcu::ConstPixelBufferAccess&	result,
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	reference,
4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelBufferAccess&		errorMask,
4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Texture1DArrayView&		src,
4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 qpWatchDog*						watchDog);
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint				computeTextureLookupDiff	(const tcu::ConstPixelBufferAccess&	result,
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	reference,
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelBufferAccess&		errorMask,
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Texture2DArrayView&		src,
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 qpWatchDog*						watchDog);
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint				computeTextureLookupDiff	(const tcu::ConstPixelBufferAccess&	result,
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	reference,
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelBufferAccess&		errorMask,
4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Texture3DView&			src,
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 qpWatchDog*						watchDog);
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4358852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryint				computeTextureLookupDiff	(const tcu::ConstPixelBufferAccess&	result,
4368852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	reference,
4378852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const tcu::PixelBufferAccess&		errorMask,
4388852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const tcu::TextureCubeArrayView&	src,
4398852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const float*						texCoord,
4408852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const ReferenceParams&				sampleParams,
4418852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
4428852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const tcu::IVec4&					coordBits,
4438852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
4448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 qpWatchDog*						watchDog);
4458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry
4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool			verifyTextureResult			(tcu::TestContext&					testCtx,
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	result,
4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Texture1DView&			src,
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelFormat&			pixelFormat);
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool			verifyTextureResult			(tcu::TestContext&					testCtx,
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	result,
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Texture2DView&			src,
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelFormat&			pixelFormat);
4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool			verifyTextureResult			(tcu::TestContext&					testCtx,
4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	result,
4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::TextureCubeView&		src,
4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelFormat&			pixelFormat);
4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool			verifyTextureResult			(tcu::TestContext&					testCtx,
4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	result,
4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Texture1DArrayView&		src,
4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelFormat&			pixelFormat);
4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool			verifyTextureResult			(tcu::TestContext&					testCtx,
4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	result,
4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Texture2DArrayView&		src,
4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelFormat&			pixelFormat);
4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool			verifyTextureResult			(tcu::TestContext&					testCtx,
4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	result,
4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Texture3DView&			src,
4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelFormat&			pixelFormat);
4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5008852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrybool			verifyTextureResult			(tcu::TestContext&					testCtx,
5018852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	result,
5028852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const tcu::TextureCubeArrayView&	src,
5038852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const float*						texCoord,
5048852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const ReferenceParams&				sampleParams,
5058852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const tcu::LookupPrecision&		lookupPrec,
5068852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const tcu::IVec4&					coordBits,
5078852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
5088852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry											 const tcu::PixelFormat&			pixelFormat);
5098852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry
5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint				computeTextureCompareDiff	(const tcu::ConstPixelBufferAccess&	result,
5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	reference,
5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelBufferAccess&		errorMask,
5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Texture2DView&			src,
5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::TexComparePrecision&	comparePrec,
5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Vec3&					nonShadowThreshold);
5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint				computeTextureCompareDiff	(const tcu::ConstPixelBufferAccess&	result,
5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	reference,
5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelBufferAccess&		errorMask,
5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::TextureCubeView&		src,
5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::TexComparePrecision&	comparePrec,
5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Vec3&					nonShadowThreshold);
5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint				computeTextureCompareDiff	(const tcu::ConstPixelBufferAccess&	result,
5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::ConstPixelBufferAccess&	reference,
5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::PixelBufferAccess&		errorMask,
5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Texture2DArrayView&		src,
5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const float*						texCoord,
5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const ReferenceParams&				sampleParams,
5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::TexComparePrecision&	comparePrec,
5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::LodPrecision&			lodPrec,
5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 const tcu::Vec3&					nonShadowThreshold);
5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Mipmap generation comparison.
5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct GenMipmapPrecision
5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::IVec3			filterBits;			//!< Bits in filtering parameters (fixed-point).
5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Vec4			colorThreshold;		//!< Threshold for color value comparison.
5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::BVec4			colorMask;			//!< Color channel comparison mask.
5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5493c827367444ee418f129b2c238299f49d3264554Jarkko PoyryqpTestResult	compareGenMipmapResult		(tcu::TestLog& log, const tcu::Texture2D& resultTexture, const tcu::Texture2D& level0Reference, const GenMipmapPrecision& precision);
5503c827367444ee418f129b2c238299f49d3264554Jarkko PoyryqpTestResult	compareGenMipmapResult		(tcu::TestLog& log, const tcu::TextureCube& resultTexture, const tcu::TextureCube& level0Reference, const GenMipmapPrecision& precision);
5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Utility for logging texture gradient ranges.
5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct LogGradientFmt
5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LogGradientFmt (const tcu::Vec4* min_, const tcu::Vec4* max_) : valueMin(min_), valueMax(max_) {}
5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::Vec4* valueMin;
5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::Vec4* valueMax;
5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::ostream&			operator<<		(std::ostream& str, const LogGradientFmt& fmt);
5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline LogGradientFmt	formatGradient	(const tcu::Vec4* minVal, const tcu::Vec4* maxVal) { return LogGradientFmt(minVal, maxVal); }
5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // TextureTestUtil
5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gls
5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _GLSTEXTURETESTUTIL_HPP
568