13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 2.0 Module
33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * -------------------------------------------------
43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project
63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License");
83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License.
93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at
103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *      http://www.apache.org/licenses/LICENSE-2.0
123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software
143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS,
153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and
173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License.
183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*!
203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file
213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Mipmapping tests.
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es2fTextureMipmapTests.hpp"
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsTextureTestUtil.hpp"
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluTexture.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluStrUtil.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluTextureUtil.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluPixelTransfer.hpp"
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp"
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTextureUtil.hpp"
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVector.hpp"
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuMatrix.hpp"
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuMatrixUtil.hpp"
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTexLookupVerifier.hpp"
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVectorUtil.hpp"
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp"
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp"
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp"
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp"
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles2
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog;
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector;
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::string;
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Sampler;
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Vec2;
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Mat2;
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Vec4;
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::IVec2;
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::IVec4;
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace glu;
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace gls::TextureTestUtil;
60c4eb6f3271a0bcd54835e666e836e3e72beebbd2Peter Siketusing namespace glu::TextureTestUtil;
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum CoordType
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	COORDTYPE_BASIC,		//!< texCoord = translateScale(position).
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	COORDTYPE_BASIC_BIAS,	//!< Like basic, but with bias values.
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	COORDTYPE_AFFINE,		//!< texCoord = translateScaleRotateShear(position).
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	COORDTYPE_PROJECTED,	//!< Projected coordinates, w != 1
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	COORDTYPE_LAST
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Texture2DMipmapCase
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture2DMipmapCase : public tcu::TestCase
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								Texture2DMipmapCase			(tcu::TestContext&			testCtx,
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 glu::RenderContext&		renderCtx,
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 const glu::ContextInfo&	renderCtxInfo,
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 const char*				name,
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 const char*				desc,
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 CoordType					coordType,
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 deUint32					minFilter,
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 deUint32					wrapS,
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 deUint32					wrapT,
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 deUint32					format,
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 deUint32					dataType,
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 int						width,
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 int						height);
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								~Texture2DMipmapCase		(void);
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						init						(void);
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						deinit						(void);
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult				iterate						(void);
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								Texture2DMipmapCase			(const Texture2DMipmapCase& other);
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Texture2DMipmapCase&		operator=					(const Texture2DMipmapCase& other);
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::RenderContext&			m_renderCtx;
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::ContextInfo&		m_renderCtxInfo;
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	CoordType					m_coordType;
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					m_minFilter;
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					m_wrapS;
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					m_wrapT;
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					m_format;
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					m_dataType;
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							m_width;
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							m_height;
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::Texture2D*				m_texture;
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureRenderer				m_renderer;
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1173c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexture2DMipmapCase::Texture2DMipmapCase (tcu::TestContext&			testCtx,
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  glu::RenderContext&		renderCtx,
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  const glu::ContextInfo&	renderCtxInfo,
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  const char*				name,
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  const char*				desc,
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  CoordType					coordType,
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  deUint32					minFilter,
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  deUint32					wrapS,
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  deUint32					wrapT,
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  deUint32					format,
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  deUint32					dataType,
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  int						width,
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  int						height)
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCase			(testCtx, name, desc)
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_renderCtx		(renderCtx)
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_renderCtxInfo	(renderCtxInfo)
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_coordType		(coordType)
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_minFilter		(minFilter)
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_wrapS			(wrapS)
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_wrapT			(wrapT)
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_format			(format)
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_dataType		(dataType)
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_width			(width)
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_height			(height)
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_texture			(DE_NULL)
142469002caa1ccd58f59f53a1bf3dbac4cf6a5d817Jarkko Pöyry	, m_renderer		(renderCtx, testCtx.getLog(), glu::GLSL_VERSION_100_ES,
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						 renderCtxInfo.isFragmentHighPrecisionSupported() ? glu::PRECISION_HIGHP // Use highp if available.
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																		  : glu::PRECISION_MEDIUMP)
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1483c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexture2DMipmapCase::~Texture2DMipmapCase (void)
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deinit();
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Texture2DMipmapCase::init (void)
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!m_renderCtxInfo.isFragmentHighPrecisionSupported())
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx.getLog() << TestLog::Message << "Warning: High precision not supported in fragment shaders." << TestLog::EndMessage;
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_coordType == COORDTYPE_PROJECTED && m_renderCtx.getRenderTarget().getNumSamples() > 0)
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::NotSupportedError("Projected lookup validation not supported in multisample config");
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_texture = new Texture2D(m_renderCtx, m_format, m_dataType, m_width, m_height);
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int numLevels = deLog2Floor32(de::max(m_width, m_height))+1;
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Fill texture with colored grid.
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int levelNdx = 0; levelNdx < numLevels; levelNdx++)
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32	step		= 0xff / (numLevels-1);
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32	inc			= deClamp32(step*levelNdx, 0x00, 0xff);
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32	dec			= 0xff - inc;
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32	rgb			= (inc << 16) | (dec << 8) | 0xff;
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32	color		= 0xff000000 | rgb;
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_texture->getRefTexture().allocLevel(levelNdx);
175c4eb6f3271a0bcd54835e666e836e3e72beebbd2Peter Siket		tcu::clear(m_texture->getRefTexture().getLevel(levelNdx), tcu::RGBA(color).toVec());
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Texture2DMipmapCase::deinit (void)
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	delete m_texture;
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_texture = DE_NULL;
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_renderer.clear();
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void getBasicTexCoord2D (std::vector<float>& dst, int cellNdx)
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static const struct
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		Vec2 bottomLeft;
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		Vec2 topRight;
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	} s_basicCoords[] =
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ Vec2(-0.1f,  0.1f), Vec2( 0.8f,  1.0f) },
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ Vec2(-0.3f, -0.6f), Vec2( 0.7f,  0.4f) },
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ Vec2(-0.3f,  0.6f), Vec2( 0.7f, -0.9f) },
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ Vec2(-0.8f,  0.6f), Vec2( 0.7f, -0.9f) },
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ Vec2(-0.5f, -0.5f), Vec2( 1.5f,  1.5f) },
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ Vec2( 1.0f, -1.0f), Vec2(-1.3f,  1.0f) },
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ Vec2( 1.2f, -1.0f), Vec2(-1.3f,  1.6f) },
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ Vec2( 2.2f, -1.1f), Vec2(-1.3f,  0.8f) },
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ Vec2(-1.5f,  1.6f), Vec2( 1.7f, -1.4f) },
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ Vec2( 2.0f,  1.6f), Vec2( 2.3f, -1.4f) },
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ Vec2( 1.3f, -2.6f), Vec2(-2.7f,  2.9f) },
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ Vec2(-0.8f, -6.6f), Vec2( 6.0f, -0.9f) },
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ Vec2( -8.0f,   9.0f), Vec2(  8.3f,  -7.0f) },
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ Vec2(-16.0f,  10.0f), Vec2( 18.3f,  24.0f) },
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ Vec2( 30.2f,  55.0f), Vec2(-24.3f,  -1.6f) },
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ Vec2(-33.2f,  64.1f), Vec2( 32.1f, -64.1f) },
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(de::inBounds(cellNdx, 0, DE_LENGTH_OF_ARRAY(s_basicCoords)));
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const Vec2& bottomLeft	= s_basicCoords[cellNdx].bottomLeft;
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const Vec2& topRight	= s_basicCoords[cellNdx].topRight;
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	computeQuadTexCoord2D(dst, bottomLeft, topRight);
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void getAffineTexCoord2D (std::vector<float>& dst, int cellNdx)
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Use basic coords as base.
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	getBasicTexCoord2D(dst, cellNdx);
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Rotate based on cell index.
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float		angle		= 2.0f*DE_PI * ((float)cellNdx / 16.0f);
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Mat2	rotMatrix	= tcu::rotationMatrix(angle);
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Second and third row are sheared.
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float		shearX		= de::inRange(cellNdx, 4, 11) ? (float)(15-cellNdx) / 16.0f : 0.0f;
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Mat2	shearMatrix	= tcu::shearMatrix(tcu::Vec2(shearX, 0.0f));
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Mat2	transform	= rotMatrix * shearMatrix;
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec2		p0			= transform * Vec2(dst[0], dst[1]);
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec2		p1			= transform * Vec2(dst[2], dst[3]);
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec2		p2			= transform * Vec2(dst[4], dst[5]);
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec2		p3			= transform * Vec2(dst[6], dst[7]);
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	dst[0] = p0.x();	dst[1] = p0.y();
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	dst[2] = p1.x();	dst[3] = p1.y();
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	dst[4] = p2.x();	dst[5] = p2.y();
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	dst[6] = p3.x();	dst[7] = p3.y();
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2493c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexture2DMipmapCase::IterateResult Texture2DMipmapCase::iterate (void)
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glw::Functions&		gl					= m_renderCtx.getFunctions();
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::Texture2D&		refTexture			= m_texture->getRefTexture();
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32				magFilter			= GL_NEAREST;
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int					texWidth			= refTexture.getWidth();
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int					texHeight			= refTexture.getHeight();
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int					defViewportWidth	= texWidth*4;
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int					defViewportHeight	= texHeight*4;
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const RandomViewport		viewport			(m_renderCtx.getRenderTarget(), defViewportWidth, defViewportHeight, deStringHash(getName()));
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ReferenceParams				sampleParams		(TEXTURETYPE_2D);
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	vector<float>				texCoord;
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const bool					isProjected			= m_coordType == COORDTYPE_PROJECTED;
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const bool					useLodBias			= m_coordType == COORDTYPE_BASIC_BIAS;
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Surface				renderedFrame		(viewport.width, viewport.height);
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Viewport is divided into 4x4 grid.
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							gridWidth			= 4;
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							gridHeight			= 4;
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							cellWidth			= viewport.width / gridWidth;
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							cellHeight			= viewport.height / gridHeight;
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Bail out if rendertarget is too small.
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (viewport.width < defViewportWidth/2 || viewport.height < defViewportHeight/2)
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::NotSupportedError("Too small viewport", "", __FILE__, __LINE__);
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Sampling parameters.
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	sampleParams.sampler		= glu::mapGLSampler(m_wrapS, m_wrapT, m_minFilter, magFilter);
282c4eb6f3271a0bcd54835e666e836e3e72beebbd2Peter Siket	sampleParams.samplerType	= glu::TextureTestUtil::getSamplerType(m_texture->getRefTexture().getFormat());
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	sampleParams.flags			= (isProjected ? ReferenceParams::PROJECTED : 0) | (useLodBias ? ReferenceParams::USE_BIAS : 0);
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	sampleParams.lodMode		= LODMODE_EXACT; // Use ideal lod.
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Upload texture data.
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_texture->upload();
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Bind gradient texture and setup sampler parameters.
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.bindTexture	(GL_TEXTURE_2D, m_texture->getGLTexture());
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,		m_wrapS);
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,		m_wrapT);
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,	m_minFilter);
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,	magFilter);
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.getError(), "After texture setup");
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Bias values.
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static const float s_bias[] = { 1.0f, -2.0f, 0.8f, -0.5f, 1.5f, 0.9f, 2.0f, 4.0f };
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Projection values.
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static const Vec4 s_projections[] =
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		Vec4(1.2f, 1.0f, 0.7f, 1.0f),
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		Vec4(1.3f, 0.8f, 0.6f, 2.0f),
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		Vec4(0.8f, 1.0f, 1.7f, 0.6f),
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		Vec4(1.2f, 1.0f, 1.7f, 1.5f)
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Render cells.
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int gridY = 0; gridY < gridHeight; gridY++)
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int gridX = 0; gridX < gridWidth; gridX++)
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int		curX		= cellWidth*gridX;
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int		curY		= cellHeight*gridY;
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int		curW		= gridX+1 == gridWidth ? (viewport.width-curX) : cellWidth;
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int		curH		= gridY+1 == gridHeight ? (viewport.height-curY) : cellHeight;
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int		cellNdx		= gridY*gridWidth + gridX;
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// Compute texcoord.
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			switch (m_coordType)
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				case COORDTYPE_BASIC_BIAS:	// Fall-through.
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				case COORDTYPE_PROJECTED:
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				case COORDTYPE_BASIC:		getBasicTexCoord2D	(texCoord, cellNdx);	break;
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				case COORDTYPE_AFFINE:		getAffineTexCoord2D	(texCoord, cellNdx);	break;
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				default:					DE_ASSERT(DE_FALSE);
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (isProjected)
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				sampleParams.w = s_projections[cellNdx % DE_LENGTH_OF_ARRAY(s_projections)];
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (useLodBias)
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				sampleParams.bias = s_bias[cellNdx % DE_LENGTH_OF_ARRAY(s_bias)];
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// Render with GL.
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.viewport(viewport.x+curX, viewport.y+curY, curW, curH);
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_renderer.renderQuad(0, &texCoord[0], sampleParams);
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Read result.
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess());
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Compare and log.
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const tcu::PixelFormat&	pixelFormat		= m_renderCtx.getRenderTarget().getPixelFormat();
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const bool				isTrilinear		= m_minFilter == GL_NEAREST_MIPMAP_LINEAR || m_minFilter == GL_LINEAR_MIPMAP_LINEAR;
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::Surface			referenceFrame	(viewport.width, viewport.height);
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::Surface			errorMask		(viewport.width, viewport.height);
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::LookupPrecision	lookupPrec;
353433645782506cbdf8fa8b113ea0b5aa8ae761f0cPyry Haulos		tcu::LodPrecision		lodPrec;
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						numFailedPixels	= 0;
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		lookupPrec.coordBits		= tcu::IVec3(20, 20, 0);
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		lookupPrec.uvwBits			= tcu::IVec3(16, 16, 0); // Doesn't really matter since pixels are unicolored.
3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		lookupPrec.colorThreshold	= tcu::computeFixedPointThreshold(max(getBitsVec(pixelFormat) - (isTrilinear ? 2 : 1), tcu::IVec4(0)));
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		lookupPrec.colorMask		= getCompareMask(pixelFormat);
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		lodPrec.derivateBits		= 10;
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		lodPrec.lodBits				= isProjected ? 6 : 8;
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int gridY = 0; gridY < gridHeight; gridY++)
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int gridX = 0; gridX < gridWidth; gridX++)
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const int		curX		= cellWidth*gridX;
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const int		curY		= cellHeight*gridY;
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const int		curW		= gridX+1 == gridWidth ? (viewport.width-curX) : cellWidth;
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const int		curH		= gridY+1 == gridHeight ? (viewport.height-curY) : cellHeight;
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const int		cellNdx		= gridY*gridWidth + gridX;
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				// Compute texcoord.
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				switch (m_coordType)
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					case COORDTYPE_BASIC_BIAS:	// Fall-through.
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					case COORDTYPE_PROJECTED:
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					case COORDTYPE_BASIC:		getBasicTexCoord2D	(texCoord, cellNdx);	break;
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					case COORDTYPE_AFFINE:		getAffineTexCoord2D	(texCoord, cellNdx);	break;
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					default:					DE_ASSERT(DE_FALSE);
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (isProjected)
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					sampleParams.w = s_projections[cellNdx % DE_LENGTH_OF_ARRAY(s_projections)];
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (useLodBias)
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					sampleParams.bias = s_bias[cellNdx % DE_LENGTH_OF_ARRAY(s_bias)];
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				// Render ideal result
390c4eb6f3271a0bcd54835e666e836e3e72beebbd2Peter Siket				sampleTexture(tcu::SurfaceAccess(referenceFrame, pixelFormat, curX, curY, curW, curH),
3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							  refTexture, &texCoord[0], sampleParams);
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				// Compare this cell
3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				numFailedPixels += computeTextureLookupDiff(tcu::getSubregion(renderedFrame.getAccess(), curX, curY, curW, curH),
3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															tcu::getSubregion(referenceFrame.getAccess(), curX, curY, curW, curH),
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															tcu::getSubregion(errorMask.getAccess(), curX, curY, curW, curH),
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															m_texture->getRefTexture(), &texCoord[0], sampleParams,
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															lookupPrec, lodPrec, m_testCtx.getWatchDog());
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (numFailedPixels > 0)
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.getLog() << TestLog::Message << "ERROR: Image verification failed, found " << numFailedPixels << " invalid pixels!" << TestLog::EndMessage;
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx.getLog() << TestLog::ImageSet("Result", "Verification result")
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							<< TestLog::Image("Rendered", "Rendered image", renderedFrame);
4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (numFailedPixels > 0)
4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.getLog() << TestLog::Image("Reference", "Ideal reference", referenceFrame)
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								<< TestLog::Image("ErrorMask", "Error mask", errorMask);
4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx.getLog() << TestLog::EndImageSet;
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const bool isOk = numFailedPixels == 0;
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(isOk ? QP_TEST_RESULT_PASS	: QP_TEST_RESULT_FAIL,
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									isOk ? "Pass"				: "Image verification failed");
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return STOP;
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TextureCubeMipmapCase
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureCubeMipmapCase : public tcu::TestCase
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								TextureCubeMipmapCase		(tcu::TestContext&			testCtx,
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 glu::RenderContext&		renderCtx,
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 const glu::ContextInfo&	renderCtxInfo,
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 const char*				name,
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 const char*				desc,
4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 CoordType					coordType,
4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 deUint32					minFilter,
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 deUint32					wrapS,
4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 deUint32					wrapT,
4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 deUint32					format,
4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 deUint32					dataType,
4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 int						size);
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								~TextureCubeMipmapCase		(void);
4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						init						(void);
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						deinit						(void);
4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult				iterate						(void);
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								TextureCubeMipmapCase		(const TextureCubeMipmapCase& other);
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureCubeMipmapCase&		operator=					(const TextureCubeMipmapCase& other);
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::RenderContext&			m_renderCtx;
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::ContextInfo&		m_renderCtxInfo;
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	CoordType					m_coordType;
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					m_minFilter;
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					m_wrapS;
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					m_wrapT;
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					m_format;
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					m_dataType;
4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							m_size;
4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::TextureCube*			m_texture;
4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureRenderer				m_renderer;
4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4693c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureCubeMipmapCase::TextureCubeMipmapCase (tcu::TestContext&			testCtx,
4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											  glu::RenderContext&		renderCtx,
4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											  const glu::ContextInfo&	renderCtxInfo,
4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											  const char*				name,
4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											  const char*				desc,
4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											  CoordType					coordType,
4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											  deUint32					minFilter,
4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											  deUint32					wrapS,
4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											  deUint32					wrapT,
4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											  deUint32					format,
4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											  deUint32					dataType,
4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											  int						size)
4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCase			(testCtx, name, desc)
4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_renderCtx		(renderCtx)
4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_renderCtxInfo	(renderCtxInfo)
4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_coordType		(coordType)
4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_minFilter		(minFilter)
4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_wrapS			(wrapS)
4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_wrapT			(wrapT)
4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_format			(format)
4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_dataType		(dataType)
4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_size			(size)
4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_texture			(DE_NULL)
492469002caa1ccd58f59f53a1bf3dbac4cf6a5d817Jarkko Pöyry	, m_renderer		(renderCtx, testCtx.getLog(), glu::GLSL_VERSION_100_ES,
4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						 renderCtxInfo.isFragmentHighPrecisionSupported() ? glu::PRECISION_HIGHP // Use highp if available.
4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																		  : glu::PRECISION_MEDIUMP)
4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4983c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureCubeMipmapCase::~TextureCubeMipmapCase (void)
4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deinit();
5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureCubeMipmapCase::init (void)
5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!m_renderCtxInfo.isFragmentHighPrecisionSupported())
5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx.getLog() << TestLog::Message << "Warning: High precision not supported in fragment shaders." << TestLog::EndMessage;
5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_coordType == COORDTYPE_PROJECTED && m_renderCtx.getRenderTarget().getNumSamples() > 0)
5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::NotSupportedError("Projected lookup validation not supported in multisample config");
5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_texture = new TextureCube(m_renderCtx, m_format, m_dataType, m_size);
5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int numLevels = deLog2Floor32(m_size)+1;
5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Fill texture with colored grid.
5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int faceNdx = 0; faceNdx < tcu::CUBEFACE_LAST; faceNdx++)
5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int levelNdx = 0; levelNdx < numLevels; levelNdx++)
5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	step		= 0xff / (numLevels-1);
5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	inc			= deClamp32(step*levelNdx, 0x00, 0xff);
5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	dec			= 0xff - inc;
5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	rgb			= 0;
5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			switch (faceNdx)
5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				case 0: rgb = (inc << 16) | (dec << 8) | 255; break;
5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				case 1: rgb = (255 << 16) | (inc << 8) | dec; break;
5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				case 2: rgb = (dec << 16) | (255 << 8) | inc; break;
5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				case 3: rgb = (dec << 16) | (inc << 8) | 255; break;
5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				case 4: rgb = (255 << 16) | (dec << 8) | inc; break;
5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				case 5: rgb = (inc << 16) | (255 << 8) | dec; break;
5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	color		= 0xff000000 | rgb;
5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_texture->getRefTexture().allocLevel((tcu::CubeFace)faceNdx, levelNdx);
538c4eb6f3271a0bcd54835e666e836e3e72beebbd2Peter Siket			tcu::clear(m_texture->getRefTexture().getLevelFace(levelNdx, (tcu::CubeFace)faceNdx), tcu::RGBA(color).toVec());
5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureCubeMipmapCase::deinit (void)
5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	delete m_texture;
5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_texture = DE_NULL;
5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_renderer.clear();
5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void randomPartition (vector<IVec4>& dst, de::Random& rnd, int x, int y, int width, int height)
5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int minWidth	= 8;
5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int minHeight	= 8;
5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool	partition		= rnd.getFloat() > 0.4f;
5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool	partitionX		= partition && width > minWidth && rnd.getBool();
5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool	partitionY		= partition && height > minHeight && !partitionX;
5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (partitionX)
5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int split = width/2 + rnd.getInt(-width/4, +width/4);
5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		randomPartition(dst, rnd, x, y, split, height);
5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		randomPartition(dst, rnd, x+split, y, width-split, height);
5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else if (partitionY)
5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int split = height/2 + rnd.getInt(-height/4, +height/4);
5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		randomPartition(dst, rnd, x, y, width, split);
5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		randomPartition(dst, rnd, x, y+split, width, height-split);
5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else
5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		dst.push_back(IVec4(x, y, width, height));
5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void computeGridLayout (vector<IVec4>& dst, int width, int height)
5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	de::Random rnd(7);
5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	randomPartition(dst, rnd, 0, 0, width, height);
5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5823c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureCubeMipmapCase::IterateResult TextureCubeMipmapCase::iterate (void)
5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32			magFilter			= GL_NEAREST;
5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int				texWidth			= m_texture->getRefTexture().getSize();
5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int				texHeight			= m_texture->getRefTexture().getSize();
5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int				defViewportWidth	= texWidth*2;
5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int				defViewportHeight	= texHeight*2;
5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glw::Functions&	gl					= m_renderCtx.getFunctions();
5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const RandomViewport	viewport			(m_renderCtx.getRenderTarget(), defViewportWidth, defViewportHeight, deStringHash(getName()));
5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const bool				isProjected			= m_coordType == COORDTYPE_PROJECTED;
5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const bool				useLodBias			= m_coordType == COORDTYPE_BASIC_BIAS;
5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	vector<float>			texCoord;
5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Surface			renderedFrame		(viewport.width, viewport.height);
5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Bail out if rendertarget is too small.
6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (viewport.width < defViewportWidth/2 || viewport.height < defViewportHeight/2)
6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::NotSupportedError("Too small viewport", "", __FILE__, __LINE__);
6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Upload texture data.
6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_texture->upload();
6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Bind gradient texture and setup sampler parameters.
6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.bindTexture	(GL_TEXTURE_CUBE_MAP, m_texture->getGLTexture());
6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S,		m_wrapS);
6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T,		m_wrapT);
6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER,	m_minFilter);
6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER,	magFilter);
6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.getError(), "After texture setup");
6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Compute grid.
6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	vector<IVec4> gridLayout;
6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	computeGridLayout(gridLayout, viewport.width, viewport.height);
6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Bias values.
6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static const float s_bias[] = { 1.0f, -2.0f, 0.8f, -0.5f, 1.5f, 0.9f, 2.0f, 4.0f };
6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Projection values \note Less agressive than in 2D case due to smaller quads.
6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static const Vec4 s_projections[] =
6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		Vec4(1.2f, 1.0f, 0.7f, 1.0f),
6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		Vec4(1.3f, 0.8f, 0.6f, 1.1f),
6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		Vec4(0.8f, 1.0f, 1.2f, 0.8f),
6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		Vec4(1.2f, 1.0f, 1.3f, 0.9f)
6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Render with GL
6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int cellNdx = 0; cellNdx < (int)gridLayout.size(); cellNdx++)
6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int			curX		= gridLayout[cellNdx].x();
6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int			curY		= gridLayout[cellNdx].y();
6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int			curW		= gridLayout[cellNdx].z();
6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int			curH		= gridLayout[cellNdx].w();
6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const tcu::CubeFace	cubeFace	= (tcu::CubeFace)(cellNdx % tcu::CUBEFACE_LAST);
6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		RenderParams		params		(TEXTURETYPE_CUBE);
6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_coordType != COORDTYPE_AFFINE); // Not supported.
6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		computeQuadTexCoordCube(texCoord, cubeFace);
6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (isProjected)
6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			params.flags	|= ReferenceParams::PROJECTED;
6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			params.w		 = s_projections[cellNdx % DE_LENGTH_OF_ARRAY(s_projections)];
6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (useLodBias)
6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			params.flags	|= ReferenceParams::USE_BIAS;
6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			params.bias		 = s_bias[cellNdx % DE_LENGTH_OF_ARRAY(s_bias)];
6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Render with GL.
6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.viewport(viewport.x+curX, viewport.y+curY, curW, curH);
6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_renderer.renderQuad(0, &texCoord[0], params);
6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.getError(), "Draw");
6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Read result.
6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess());
6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.getError(), "Read pixels");
6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Render reference and compare
6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::Surface			referenceFrame		(viewport.width, viewport.height);
6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::Surface			errorMask			(viewport.width, viewport.height);
6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						numFailedPixels		= 0;
6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ReferenceParams			params				(TEXTURETYPE_CUBE);
6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::LookupPrecision	lookupPrec;
673433645782506cbdf8fa8b113ea0b5aa8ae761f0cPyry Haulos		tcu::LodPrecision		lodPrec;
6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Params for rendering reference
6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		params.sampler					= glu::mapGLSampler(m_wrapS, m_wrapT, m_minFilter, magFilter);
6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		params.sampler.seamlessCubeMap	= false;
6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		params.lodMode					= LODMODE_EXACT;
6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Comparison parameters
6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		lookupPrec.colorMask			= getCompareMask(m_renderCtx.getRenderTarget().getPixelFormat());
6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		lookupPrec.colorThreshold		= tcu::computeFixedPointThreshold(max(getBitsVec(m_renderCtx.getRenderTarget().getPixelFormat())-2, IVec4(0)));
6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		lookupPrec.coordBits			= isProjected ? tcu::IVec3(8) : tcu::IVec3(10);
6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		lookupPrec.uvwBits				= tcu::IVec3(5,5,0);
6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		lodPrec.derivateBits			= 10;
6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		lodPrec.lodBits					= isProjected ? 4 : 6;
6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int cellNdx = 0; cellNdx < (int)gridLayout.size(); cellNdx++)
6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int				curX		= gridLayout[cellNdx].x();
6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int				curY		= gridLayout[cellNdx].y();
6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int				curW		= gridLayout[cellNdx].z();
6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int				curH		= gridLayout[cellNdx].w();
6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::CubeFace		cubeFace	= (tcu::CubeFace)(cellNdx % tcu::CUBEFACE_LAST);
6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			DE_ASSERT(m_coordType != COORDTYPE_AFFINE); // Not supported.
6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			computeQuadTexCoordCube(texCoord, cubeFace);
6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (isProjected)
7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				params.flags	|= ReferenceParams::PROJECTED;
7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				params.w		 = s_projections[cellNdx % DE_LENGTH_OF_ARRAY(s_projections)];
7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (useLodBias)
7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				params.flags	|= ReferenceParams::USE_BIAS;
7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				params.bias		 = s_bias[cellNdx % DE_LENGTH_OF_ARRAY(s_bias)];
7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// Render ideal reference.
7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
713c4eb6f3271a0bcd54835e666e836e3e72beebbd2Peter Siket				tcu::SurfaceAccess idealDst(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat(), curX, curY, curW, curH);
7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				sampleTexture(idealDst, m_texture->getRefTexture(), &texCoord[0], params);
7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// Compare this cell
7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			numFailedPixels += computeTextureLookupDiff(tcu::getSubregion(renderedFrame.getAccess(), curX, curY, curW, curH),
7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														tcu::getSubregion(referenceFrame.getAccess(), curX, curY, curW, curH),
7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														tcu::getSubregion(errorMask.getAccess(), curX, curY, curW, curH),
7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														m_texture->getRefTexture(), &texCoord[0], params,
7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														lookupPrec, lodPrec, m_testCtx.getWatchDog());
7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (numFailedPixels > 0)
7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.getLog() << TestLog::Message << "ERROR: Image verification failed, found " << numFailedPixels << " invalid pixels!" << TestLog::EndMessage;
7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx.getLog() << TestLog::ImageSet("Result", "Verification result")
7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						   << TestLog::Image("Rendered", "Rendered image", renderedFrame);
7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (numFailedPixels > 0)
7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.getLog() << TestLog::Image("Reference", "Ideal reference", referenceFrame)
7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   << TestLog::Image("ErrorMask", "Error mask", errorMask);
7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx.getLog() << TestLog::EndImageSet;
7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const bool isOk = numFailedPixels == 0;
7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(isOk ? QP_TEST_RESULT_PASS	: QP_TEST_RESULT_FAIL,
7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									isOk ? "Pass"				: "Image verification failed");
7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return STOP;
7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Texture2DGenMipmapCase
7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture2DGenMipmapCase : public tcu::TestCase
7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								Texture2DGenMipmapCase		(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 hint, int width, int height);
7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								~Texture2DGenMipmapCase		(void);
7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						init						(void);
7593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						deinit						(void);
7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult				iterate						(void);
7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7623c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
7633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								Texture2DGenMipmapCase		(const Texture2DGenMipmapCase& other);
7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Texture2DGenMipmapCase&		operator=					(const Texture2DGenMipmapCase& other);
7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::RenderContext&			m_renderCtx;
7673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					m_format;
7693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					m_dataType;
7703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					m_hint;
7713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							m_width;
7723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							m_height;
7733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::Texture2D*				m_texture;
7753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureRenderer				m_renderer;
7763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
7773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7783c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexture2DGenMipmapCase::Texture2DGenMipmapCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 hint, int width, int height)
7793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCase			(testCtx, name, desc)
7803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_renderCtx		(renderCtx)
7813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_format			(format)
7823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_dataType		(dataType)
7833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_hint			(hint)
7843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_width			(width)
7853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_height			(height)
7863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_texture			(DE_NULL)
787469002caa1ccd58f59f53a1bf3dbac4cf6a5d817Jarkko Pöyry	, m_renderer		(renderCtx, testCtx.getLog(), glu::GLSL_VERSION_100_ES, glu::PRECISION_MEDIUMP)
7883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7913c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexture2DGenMipmapCase::~Texture2DGenMipmapCase (void)
7923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deinit();
7943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7963c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Texture2DGenMipmapCase::init (void)
7973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(!m_texture);
7993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_texture = new Texture2D(m_renderCtx, m_format, m_dataType, m_width, m_height);
8003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8023c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Texture2DGenMipmapCase::deinit (void)
8033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	delete m_texture;
8053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_texture = DE_NULL;
8063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_renderer.clear();
8083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8103c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexture2DGenMipmapCase::IterateResult Texture2DGenMipmapCase::iterate (void)
8113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glw::Functions&	gl					= m_renderCtx.getFunctions();
8133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32			minFilter			= GL_NEAREST_MIPMAP_NEAREST;
8153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32			magFilter			= GL_NEAREST;
8163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32			wrapS				= GL_CLAMP_TO_EDGE;
8173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32			wrapT				= GL_CLAMP_TO_EDGE;
8183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int				numLevels			= deLog2Floor32(de::max(m_width, m_height))+1;
8203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Texture2D			resultTexture		(tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), m_texture->getRefTexture().getWidth(), m_texture->getRefTexture().getHeight());
8223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	vector<float>			texCoord;
8243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Initialize texture level 0 with colored grid.
8263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_texture->getRefTexture().allocLevel(0);
8273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::fillWithGrid(m_texture->getRefTexture().getLevel(0), 8, tcu::Vec4(1.0f, 0.5f, 0.0f, 0.5f), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f));
8283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Upload data and setup params.
8303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_texture->upload();
8313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.bindTexture	(GL_TEXTURE_2D, m_texture->getGLTexture());
8333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,		wrapS);
8343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,		wrapT);
8353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,	minFilter);
8363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,	magFilter);
8373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.getError(), "After texture setup");
8383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Generate mipmap.
8403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.hint(GL_GENERATE_MIPMAP_HINT, m_hint);
8413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.generateMipmap(GL_TEXTURE_2D);
8423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.getError(), "glGenerateMipmap()");
8433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Use (0, 0) -> (1, 1) texture coordinates.
8453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	computeQuadTexCoord2D(texCoord, Vec2(0.0f, 0.0f), Vec2(1.0f, 1.0f));
8463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Fetch resulting texture by rendering.
8483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int levelNdx = 0; levelNdx < numLevels; levelNdx++)
8493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int				levelWidth		= de::max(1, m_width >> levelNdx);
8513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int				levelHeight		= de::max(1, m_height >> levelNdx);
8523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const RandomViewport	viewport		(m_renderCtx.getRenderTarget(), levelWidth, levelHeight, deStringHash(getName()) + levelNdx);
8533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
8553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_renderer.renderQuad(0, &texCoord[0], TEXTURETYPE_2D);
8563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		resultTexture.allocLevel(levelNdx);
8583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::readPixels(m_renderCtx, viewport.x, viewport.y, resultTexture.getLevel(levelNdx));
8593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Compare results
8623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const IVec4			framebufferBits		= max(getBitsVec(m_renderCtx.getRenderTarget().getPixelFormat())-2, IVec4(0));
8653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const IVec4			formatBits			= tcu::getTextureFormatBitDepth(glu::mapGLTransferFormat(m_format, m_dataType));
8663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const tcu::BVec4	formatMask			= greaterThan(formatBits, IVec4(0));
8673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const IVec4			cmpBits				= select(min(framebufferBits, formatBits), framebufferBits, formatMask);
8683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GenMipmapPrecision	comparePrec;
8693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		comparePrec.colorMask		= getCompareMask(m_renderCtx.getRenderTarget().getPixelFormat());
8713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		comparePrec.colorThreshold	= tcu::computeFixedPointThreshold(cmpBits);
8723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		comparePrec.filterBits		= tcu::IVec3(4, 4, 0);
8733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const qpTestResult compareResult = compareGenMipmapResult(m_testCtx.getLog(), resultTexture, m_texture->getRefTexture(), comparePrec);
8753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx.setTestResult(compareResult, compareResult == QP_TEST_RESULT_PASS				? "Pass" :
8773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											   compareResult == QP_TEST_RESULT_QUALITY_WARNING	? "Low-quality method used"	:
8783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											   compareResult == QP_TEST_RESULT_FAIL				? "Image comparison failed"	: "");
8793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return STOP;
8823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TextureCubeGenMipmapCase
8853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8863c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureCubeGenMipmapCase : public tcu::TestCase
8873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8883c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
8893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								TextureCubeGenMipmapCase		(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 hint, int size);
8913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								~TextureCubeGenMipmapCase		(void);
8923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						init							(void);
8943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						deinit							(void);
8953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult				iterate							(void);
8963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8973c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
8983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								TextureCubeGenMipmapCase		(const TextureCubeGenMipmapCase& other);
8993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureCubeGenMipmapCase&	operator=						(const TextureCubeGenMipmapCase& other);
9003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::RenderContext&			m_renderCtx;
9023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					m_format;
9043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					m_dataType;
9053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					m_hint;
9063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							m_size;
9073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::TextureCube*			m_texture;
9093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureRenderer				m_renderer;
9103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
9113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9123c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureCubeGenMipmapCase::TextureCubeGenMipmapCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 hint, int size)
9133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCase			(testCtx, name, desc)
9143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_renderCtx		(renderCtx)
9153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_format			(format)
9163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_dataType		(dataType)
9173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_hint			(hint)
9183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_size			(size)
9193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_texture			(DE_NULL)
920469002caa1ccd58f59f53a1bf3dbac4cf6a5d817Jarkko Pöyry	, m_renderer		(renderCtx, testCtx.getLog(), glu::GLSL_VERSION_100_ES, glu::PRECISION_MEDIUMP)
9213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9243c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureCubeGenMipmapCase::~TextureCubeGenMipmapCase (void)
9253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deinit();
9273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9293c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureCubeGenMipmapCase::init (void)
9303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_renderCtx.getRenderTarget().getWidth() < 3*m_size || m_renderCtx.getRenderTarget().getHeight() < 2*m_size)
9323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::NotSupportedError("Render target size must be at least (" + de::toString(3*m_size) + ", " + de::toString(2*m_size) + ")");
9333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(!m_texture);
9353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_texture = new TextureCube(m_renderCtx, m_format, m_dataType, m_size);
9363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureCubeGenMipmapCase::deinit (void)
9393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	delete m_texture;
9413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_texture = DE_NULL;
9423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_renderer.clear();
9443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9463c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureCubeGenMipmapCase::IterateResult TextureCubeGenMipmapCase::iterate (void)
9473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glw::Functions&	gl					= m_renderCtx.getFunctions();
9493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32			minFilter			= GL_NEAREST_MIPMAP_NEAREST;
9513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32			magFilter			= GL_NEAREST;
9523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32			wrapS				= GL_CLAMP_TO_EDGE;
9533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32			wrapT				= GL_CLAMP_TO_EDGE;
9543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureCube		resultTexture		(tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), m_size);
9563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int				numLevels			= deLog2Floor32(m_size)+1;
9583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	vector<float>			texCoord;
9593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Initialize texture level 0 with colored grid.
9613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
9623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		Vec4 ca, cb; // Grid colors.
9643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		switch (face)
9663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
9673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			case 0: ca = Vec4(1.0f, 0.3f, 0.0f, 0.7f); cb = Vec4(0.0f, 0.0f, 1.0f, 1.0f); break;
9683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			case 1: ca = Vec4(0.0f, 1.0f, 0.5f, 0.5f); cb = Vec4(1.0f, 0.0f, 0.0f, 1.0f); break;
9693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			case 2: ca = Vec4(0.7f, 0.0f, 1.0f, 0.3f); cb = Vec4(0.0f, 1.0f, 0.0f, 1.0f); break;
9703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			case 3: ca = Vec4(0.0f, 0.3f, 1.0f, 1.0f); cb = Vec4(1.0f, 0.0f, 0.0f, 0.7f); break;
9713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			case 4: ca = Vec4(1.0f, 0.0f, 0.5f, 1.0f); cb = Vec4(0.0f, 1.0f, 0.0f, 0.5f); break;
9723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			case 5: ca = Vec4(0.7f, 1.0f, 0.0f, 1.0f); cb = Vec4(0.0f, 0.0f, 1.0f, 0.3f); break;
9733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
9743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_texture->getRefTexture().allocLevel((tcu::CubeFace)face, 0);
9763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		fillWithGrid(m_texture->getRefTexture().getLevelFace(0, (tcu::CubeFace)face), 8, ca, cb);
9773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Upload data and setup params.
9803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_texture->upload();
9813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.bindTexture	(GL_TEXTURE_CUBE_MAP, m_texture->getGLTexture());
9833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S,		wrapS);
9843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T,		wrapT);
9853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER,	minFilter);
9863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER,	magFilter);
9873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.getError(), "After texture setup");
9883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Generate mipmap.
9903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.hint(GL_GENERATE_MIPMAP_HINT, m_hint);
9913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.generateMipmap(GL_TEXTURE_CUBE_MAP);
9923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.getError(), "glGenerateMipmap()");
9933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Render all levels.
9953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int levelNdx = 0; levelNdx < numLevels; levelNdx++)
9963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int	levelWidth	= de::max(1, m_size >> levelNdx);
9983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int	levelHeight	= de::max(1, m_size >> levelNdx);
9993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int faceNdx = 0; faceNdx < tcu::CUBEFACE_LAST; faceNdx++)
10013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
10023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const RandomViewport	viewport	(m_renderCtx.getRenderTarget(), levelWidth*3, levelHeight*2, deStringHash(getName()) ^ deInt32Hash(levelNdx + faceNdx));
10033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::CubeFace		face		= tcu::CubeFace(faceNdx);
10043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			computeQuadTexCoordCube(texCoord, face);
10063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			gl.viewport(viewport.x, viewport.y, levelWidth, levelHeight);
10083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_renderer.renderQuad(0, &texCoord[0], TEXTURETYPE_CUBE);
10093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			resultTexture.allocLevel(face, levelNdx);
10113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glu::readPixels(m_renderCtx, viewport.x, viewport.y, resultTexture.getLevelFace(levelNdx, face));
10123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
10133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
10143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Compare results
10163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const IVec4			framebufferBits		= max(getBitsVec(m_renderCtx.getRenderTarget().getPixelFormat())-2, IVec4(0));
10183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const IVec4			formatBits			= tcu::getTextureFormatBitDepth(glu::mapGLTransferFormat(m_format, m_dataType));
10193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const tcu::BVec4	formatMask			= greaterThan(formatBits, IVec4(0));
10203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const IVec4			cmpBits				= select(min(framebufferBits, formatBits), framebufferBits, formatMask);
10213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GenMipmapPrecision	comparePrec;
10223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		comparePrec.colorMask		= getCompareMask(m_renderCtx.getRenderTarget().getPixelFormat());
10243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		comparePrec.colorThreshold	= tcu::computeFixedPointThreshold(cmpBits);
10253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		comparePrec.filterBits		= tcu::IVec3(4, 4, 0);
10263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const qpTestResult compareResult = compareGenMipmapResult(m_testCtx.getLog(), resultTexture, m_texture->getRefTexture(), comparePrec);
10283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx.setTestResult(compareResult, compareResult == QP_TEST_RESULT_PASS				? "Pass" :
10303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											   compareResult == QP_TEST_RESULT_QUALITY_WARNING	? "Low-quality method used"	:
10313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											   compareResult == QP_TEST_RESULT_FAIL				? "Image comparison failed"	: "");
10323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
10333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return STOP;
10353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
10363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10373c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureMipmapTests::TextureMipmapTests (Context& context)
10383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCaseGroup(context, "mipmap", "Mipmapping tests")
10393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
10413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10423c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureMipmapTests::~TextureMipmapTests (void)
10433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
10453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureMipmapTests::init (void)
10473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TestCaseGroup* group2D		= new tcu::TestCaseGroup(m_testCtx, "2d",	"2D Texture Mipmapping");
10493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TestCaseGroup*	groupCube	= new tcu::TestCaseGroup(m_testCtx, "cube",	"Cube Map Filtering");
10503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(group2D);
10513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(groupCube);
10523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static const struct
10543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char*		name;
10563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32		mode;
10573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	} wrapModes[] =
10583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "clamp",		GL_CLAMP_TO_EDGE },
10603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "repeat",		GL_REPEAT },
10613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "mirror",		GL_MIRRORED_REPEAT }
10623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
10633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static const struct
10653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char*		name;
10673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32		mode;
10683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	} minFilterModes[] =
10693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "nearest_nearest",	GL_NEAREST_MIPMAP_NEAREST	},
10713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "linear_nearest",		GL_LINEAR_MIPMAP_NEAREST	},
10723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "nearest_linear",		GL_NEAREST_MIPMAP_LINEAR	},
10733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "linear_linear",		GL_LINEAR_MIPMAP_LINEAR		}
10743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
10753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static const struct
10773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		CoordType		type;
10793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char*		name;
10803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char*		desc;
10813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	} coordTypes[] =
10823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ COORDTYPE_BASIC,		"basic",		"Mipmapping with translated and scaled coordinates" },
10843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ COORDTYPE_AFFINE,		"affine",		"Mipmapping with affine coordinate transform"		},
10853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ COORDTYPE_PROJECTED,	"projected",	"Mipmapping with perspective projection"			}
10863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
10873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static const struct
10893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char*		name;
10913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32		format;
10923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32		dataType;
10933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	} formats[] =
10943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "a8",			GL_ALPHA,			GL_UNSIGNED_BYTE },
10963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "l8",			GL_LUMINANCE,		GL_UNSIGNED_BYTE },
10973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "la88",		GL_LUMINANCE_ALPHA,	GL_UNSIGNED_BYTE },
10983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb565",		GL_RGB,				GL_UNSIGNED_SHORT_5_6_5 },
10993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb888",		GL_RGB,				GL_UNSIGNED_BYTE },
11003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba4444",	GL_RGBA,			GL_UNSIGNED_SHORT_4_4_4_4 },
11013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba5551",	GL_RGBA,			GL_UNSIGNED_SHORT_5_5_5_1 },
11023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba8888",	GL_RGBA,			GL_UNSIGNED_BYTE }
11033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
11043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static const struct
11063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
11073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char*		name;
11083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32		hint;
11093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	} genHints[] =
11103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
11113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "fastest",	GL_FASTEST },
11123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "nicest",		GL_NICEST }
11133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
11143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static const struct
11163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
11173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char*		name;
11183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int				width;
11193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int				height;
11203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	} tex2DSizes[] =
11213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
11223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ DE_NULL,		64, 64 }, // Default.
11233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "non_square",	32, 64 }
11243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
11253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// 2D cases.
11273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int coordType = 0; coordType < DE_LENGTH_OF_ARRAY(coordTypes); coordType++)
11283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
11293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* coordTypeGroup = new tcu::TestCaseGroup(m_testCtx, coordTypes[coordType].name, coordTypes[coordType].desc);
11303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		group2D->addChild(coordTypeGroup);
11313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int minFilter = 0; minFilter < DE_LENGTH_OF_ARRAY(minFilterModes); minFilter++)
11333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
11343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int wrapMode = 0; wrapMode < DE_LENGTH_OF_ARRAY(wrapModes); wrapMode++)
11353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
11363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				// Add non_square variants to basic cases only.
11373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int sizeEnd = coordTypes[coordType].type == COORDTYPE_BASIC ? DE_LENGTH_OF_ARRAY(tex2DSizes) : 1;
11383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				for (int size = 0; size < sizeEnd; size++)
11403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
11413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					std::ostringstream name;
11423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					name << minFilterModes[minFilter].name
11433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						 << "_" << wrapModes[wrapMode].name;
11443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (tex2DSizes[size].name)
11463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						name << "_" << tex2DSizes[size].name;
11473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					coordTypeGroup->addChild(new Texture2DMipmapCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(),
11493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																	 name.str().c_str(), "",
11503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																	 coordTypes[coordType].type,
11513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																	 minFilterModes[minFilter].mode,
11523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																	 wrapModes[wrapMode].mode,
11533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																	 wrapModes[wrapMode].mode,
11543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																	 GL_RGBA, GL_UNSIGNED_BYTE,
11553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																	 tex2DSizes[size].width, tex2DSizes[size].height));
11563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
11573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
11583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
11593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
11603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// 2D bias variants.
11623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
11633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* biasGroup = new tcu::TestCaseGroup(m_testCtx, "bias", "User-supplied bias value");
11643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		group2D->addChild(biasGroup);
11653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int minFilter = 0; minFilter < DE_LENGTH_OF_ARRAY(minFilterModes); minFilter++)
11673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			biasGroup->addChild(new Texture2DMipmapCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(),
11683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														minFilterModes[minFilter].name, "",
11693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														COORDTYPE_BASIC_BIAS,
11703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														minFilterModes[minFilter].mode,
11713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														GL_REPEAT, GL_REPEAT,
11723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														GL_RGBA, GL_UNSIGNED_BYTE,
11733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														tex2DSizes[0].width, tex2DSizes[0].height));
11743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
11753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// 2D mipmap generation variants.
11773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
11783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* genMipmapGroup = new tcu::TestCaseGroup(m_testCtx, "generate", "Mipmap generation tests");
11793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		group2D->addChild(genMipmapGroup);
11803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int format = 0; format < DE_LENGTH_OF_ARRAY(formats); format++)
11823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
11833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int size = 0; size < DE_LENGTH_OF_ARRAY(tex2DSizes); size++)
11843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
11853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				for (int hint = 0; hint < DE_LENGTH_OF_ARRAY(genHints); hint++)
11863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
11873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					std::ostringstream name;
11883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					name << formats[format].name;
11893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (tex2DSizes[size].name)
11913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						name << "_" << tex2DSizes[size].name;
11923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					name << "_" << genHints[hint].name;
11943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					genMipmapGroup->addChild(new Texture2DGenMipmapCase(m_testCtx, m_context.getRenderContext(), name.str().c_str(), "",
11963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																		formats[format].format, formats[format].dataType, genHints[hint].hint,
11973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																		tex2DSizes[size].width, tex2DSizes[size].height));
11983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
11993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
12003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
12013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
12023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int cubeMapSize = 64;
12043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static const struct
12063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
12073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		CoordType		type;
12083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char*		name;
12093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char*		desc;
12103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	} cubeCoordTypes[] =
12113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
12123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ COORDTYPE_BASIC,		"basic",		"Mipmapping with translated and scaled coordinates" },
12133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ COORDTYPE_PROJECTED,	"projected",	"Mipmapping with perspective projection"			},
12143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ COORDTYPE_BASIC_BIAS,	"bias",			"User-supplied bias value"							}
12153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
12163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Cubemap cases.
12183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int coordType = 0; coordType < DE_LENGTH_OF_ARRAY(cubeCoordTypes); coordType++)
12193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
12203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* coordTypeGroup = new tcu::TestCaseGroup(m_testCtx, cubeCoordTypes[coordType].name, cubeCoordTypes[coordType].desc);
12213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		groupCube->addChild(coordTypeGroup);
12223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int minFilter = 0; minFilter < DE_LENGTH_OF_ARRAY(minFilterModes); minFilter++)
12243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
12253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			coordTypeGroup->addChild(new TextureCubeMipmapCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(),
12263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															   minFilterModes[minFilter].name, "",
12273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															   cubeCoordTypes[coordType].type,
12283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															   minFilterModes[minFilter].mode,
12293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															   GL_CLAMP_TO_EDGE,
12303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															   GL_CLAMP_TO_EDGE,
12313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															   GL_RGBA, GL_UNSIGNED_BYTE, cubeMapSize));
12323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
12333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
12343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Cubemap mipmap generation variants.
12363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
12373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* genMipmapGroup = new tcu::TestCaseGroup(m_testCtx, "generate", "Mipmap generation tests");
12383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		groupCube->addChild(genMipmapGroup);
12393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int format = 0; format < DE_LENGTH_OF_ARRAY(formats); format++)
12413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
12423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int hint = 0; hint < DE_LENGTH_OF_ARRAY(genHints); hint++)
12433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
12443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				std::ostringstream name;
12453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				name << formats[format].name
12463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					 << "_" << genHints[hint].name;
12473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				genMipmapGroup->addChild(new TextureCubeGenMipmapCase(m_testCtx, m_context.getRenderContext(), name.str().c_str(), "", formats[format].format, formats[format].dataType, genHints[hint].hint, cubeMapSize));
12493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
12503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
12513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
12523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
12533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional
12553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles2
12563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
1257