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 Texture completeness tests.
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es2fTextureCompletenessTests.hpp"
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsTextureTestUtil.hpp"
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuSurface.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuImageCompare.hpp"
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVector.hpp"
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTextureUtil.hpp"
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuRenderTarget.hpp"
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp"
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deMath.h"
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deInt32.h"
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deString.h"
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluTextureUtil.hpp"
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluPixelTransfer.hpp"
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluContextInfo.hpp"
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluRenderContext.hpp"
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glw.h"
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles2
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector;
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::string;
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog;
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TextureFormat;
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Sampler;
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::IVec2;
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::RGBA;
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing gls::TextureTestUtil::TextureRenderer;
61c4eb6f3271a0bcd54835e666e836e3e72beebbd2Peter Siketusing glu::TextureTestUtil::computeQuadTexCoord2D;
62c4eb6f3271a0bcd54835e666e836e3e72beebbd2Peter Siketusing glu::TextureTestUtil::computeQuadTexCoordCube;
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const GLenum s_cubeTargets[] =
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_TEXTURE_CUBE_MAP_POSITIVE_X,
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_TEXTURE_CUBE_MAP_POSITIVE_Z
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic bool isExtensionSupported (const glu::ContextInfo& ctxInfo, const char* extension)
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	vector<string> extensions = ctxInfo.getExtensions();
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (vector<string>::iterator iter = extensions.begin(); iter != extensions.end(); ++iter)
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (iter->compare(extension) == 0)
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return true;
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return false;
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic bool compareToConstantColor (TestLog& log, const char* imageSetName, const char* imageSetDesc, const tcu::Surface& result, tcu::CompareLogMode logMode, RGBA color)
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool isOk = true;
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int y = 0; y < result.getHeight(); y++)
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int x = 0; x < result.getWidth(); x++)
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (result.getPixel(x, y).getRed()		!= color.getRed()	||
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				result.getPixel(x, y).getGreen()	!= color.getGreen() ||
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				result.getPixel(x, y).getBlue()		!= color.getBlue()	||
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				result.getPixel(x, y).getAlpha()	!= color.getAlpha())
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				isOk = false;
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!isOk || logMode == tcu::COMPARE_LOG_EVERYTHING)
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!isOk)
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			log << TestLog::Message << "Image comparison failed" << TestLog::EndMessage;
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		log << TestLog::ImageSet(imageSetName, imageSetDesc)
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< TestLog::Image("Result",		"Result",		result)
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< TestLog::EndImageSet;
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else if (logMode == tcu::COMPARE_LOG_RESULT)
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		log << TestLog::ImageSet(imageSetName, imageSetDesc)
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< TestLog::Image("Result",		"Result",		result)
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< TestLog::EndImageSet;
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return isOk;
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Base classes.
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Tex2DCompletenessCase : public tcu::TestCase
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							Tex2DCompletenessCase	(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description);
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							~Tex2DCompletenessCase	(void) {};
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult			iterate					(void);
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			createTexture			(void) = 0;
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TestContext&		m_testCtx;
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::RenderContext&		m_renderCtx;
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	RGBA					m_compareColor;
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1383c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTex2DCompletenessCase::Tex2DCompletenessCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description)
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCase			(testCtx, name, description)
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_testCtx			(testCtx)
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_renderCtx		(renderCtx)
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_compareColor	(RGBA(0,0,0,255))
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1463c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTex2DCompletenessCase::IterateResult Tex2DCompletenessCase::iterate (void)
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int					viewportWidth	= de::min(64, m_renderCtx.getRenderTarget().getWidth());
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int					viewportHeight	= de::min(64, m_renderCtx.getRenderTarget().getHeight());
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TestLog&			log				= m_testCtx.getLog();
151469002caa1ccd58f59f53a1bf3dbac4cf6a5d817Jarkko Pöyry	TextureRenderer		renderer		(m_renderCtx, log, glu::GLSL_VERSION_100_ES, glu::PRECISION_MEDIUMP);
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Surface		renderedFrame	(viewportWidth, viewportHeight);
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	vector<float>		texCoord;
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	de::Random			random			(deStringHash(getName()));
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int					offsetX			= random.getInt(0, m_renderCtx.getRenderTarget().getWidth()		- viewportWidth	);
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int					offsetY			= random.getInt(0, m_renderCtx.getRenderTarget().getHeight()	- viewportHeight);
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	computeQuadTexCoord2D	(texCoord, tcu::Vec2(0.0f, 0.0f), tcu::Vec2(1.0f, 1.0f));
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glViewport				(offsetX, offsetY, viewportWidth, viewportHeight);
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	createTexture			();
164c4eb6f3271a0bcd54835e666e836e3e72beebbd2Peter Siket	renderer.renderQuad		(0, &texCoord[0], glu::TextureTestUtil::TEXTURETYPE_2D);
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::readPixels			(m_renderCtx, offsetX, offsetY, renderedFrame.getAccess());
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool isOk = compareToConstantColor(log, "Result", "Image comparison result", renderedFrame, tcu::COMPARE_LOG_RESULT, m_compareColor);
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_testCtx.setTestResult(isOk ? QP_TEST_RESULT_PASS	: QP_TEST_RESULT_FAIL,
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							isOk ? "Pass"				: "Image comparison failed");
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return STOP;
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexCubeCompletenessCase : public tcu::TestCase
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							TexCubeCompletenessCase		(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description);
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							~TexCubeCompletenessCase	(void) {};
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult			iterate						(void);
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			createTexture				(void) = 0;
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TestContext&		m_testCtx;
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::RenderContext&		m_renderCtx;
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	RGBA					m_compareColor;
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1903c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexCubeCompletenessCase::TexCubeCompletenessCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description)
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCase			(testCtx, name, description)
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_testCtx			(testCtx)
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_renderCtx		(renderCtx)
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_compareColor	(RGBA(0,0,0,255))
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1983c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexCubeCompletenessCase::IterateResult TexCubeCompletenessCase::iterate (void)
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int					viewportWidth	= de::min(64, m_renderCtx.getRenderTarget().getWidth());
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int					viewportHeight	= de::min(64, m_renderCtx.getRenderTarget().getHeight());
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool				allFacesOk		= true;
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TestLog&			log				= m_testCtx.getLog();
204469002caa1ccd58f59f53a1bf3dbac4cf6a5d817Jarkko Pöyry	TextureRenderer		renderer		(m_renderCtx, log, glu::GLSL_VERSION_100_ES, glu::PRECISION_MEDIUMP);
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Surface		renderedFrame	(viewportWidth, viewportHeight);
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	vector<float>		texCoord;
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	de::Random			random			(deStringHash(getName()));
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int					offsetX			= random.getInt(0, de::max(0,m_renderCtx.getRenderTarget().getWidth()	- 64));
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int					offsetY			= random.getInt(0, de::max(0,m_renderCtx.getRenderTarget().getHeight()	- 64));
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	createTexture();
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		computeQuadTexCoordCube	(texCoord, (tcu::CubeFace)face);
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glViewport				(offsetX, offsetY, viewportWidth, viewportHeight);
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
220c4eb6f3271a0bcd54835e666e836e3e72beebbd2Peter Siket		renderer.renderQuad		(0, &texCoord[0], glu::TextureTestUtil::TEXTURETYPE_CUBE);
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::readPixels			(m_renderCtx, offsetX, offsetY, renderedFrame.getAccess());
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool isOk = compareToConstantColor(log, "Result", "Image comparison result", renderedFrame, tcu::COMPARE_LOG_RESULT, m_compareColor);
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!isOk)
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			allFacesOk = false;
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_testCtx.setTestResult(allFacesOk ? QP_TEST_RESULT_PASS	: QP_TEST_RESULT_FAIL,
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							allFacesOk ? "Pass"					: "Image comparison failed");
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return STOP;
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Texture 2D tests.
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Incomplete2DSizeCase : public Tex2DCompletenessCase
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								Incomplete2DSizeCase	(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, IVec2 invalidLevelSize, int invalidLevelNdx, const glu::ContextInfo& ctxInfo);
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								~Incomplete2DSizeCase	(void) {}
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void				createTexture			(void);
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							m_invalidLevelNdx;
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IVec2						m_invalidLevelSize;
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::ContextInfo&		m_ctxInfo;
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IVec2						m_size;
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2513c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncomplete2DSizeCase::Incomplete2DSizeCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, IVec2 invalidLevelSize, int invalidLevelNdx, const glu::ContextInfo& ctxInfo)
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: Tex2DCompletenessCase		(testCtx, renderCtx, name, description)
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_invalidLevelNdx			(invalidLevelNdx)
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_invalidLevelSize		(invalidLevelSize)
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_ctxInfo					(ctxInfo)
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_size					(size)
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Incomplete2DSizeCase::createTexture (void)
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
262a2d05647ff9b7c7888d92d03084eb0b765ba1f60Jarkko Pöyry	static const char* const s_relaxingExtensions[] =
263a2d05647ff9b7c7888d92d03084eb0b765ba1f60Jarkko Pöyry	{
264a2d05647ff9b7c7888d92d03084eb0b765ba1f60Jarkko Pöyry		"GL_OES_texture_npot",
265a2d05647ff9b7c7888d92d03084eb0b765ba1f60Jarkko Pöyry		"GL_NV_texture_npot_2D_mipmap",
266a2d05647ff9b7c7888d92d03084eb0b765ba1f60Jarkko Pöyry	};
267a2d05647ff9b7c7888d92d03084eb0b765ba1f60Jarkko Pöyry
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureFormat		fmt				= glu::mapGLTransferFormat(GL_RGBA, GL_UNSIGNED_BYTE);
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureLevel		levelData		(fmt);
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TestLog&				log				= m_testCtx.getLog();
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint texture;
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glGenTextures	(1, &texture);
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glPixelStorei	(GL_UNPACK_ALIGNMENT, 1);
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glBindTexture	(GL_TEXTURE_2D, texture);
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,		GL_REPEAT);
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,		GL_REPEAT);
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,	GL_NEAREST_MIPMAP_NEAREST);
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,	GL_NEAREST);
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int numLevels = 1 + de::max(deLog2Floor32(m_size.x()), deLog2Floor32(m_size.y()));
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int levelNdx = 0; levelNdx < numLevels; levelNdx++)
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int	levelW = (levelNdx == m_invalidLevelNdx) ? m_invalidLevelSize.x() : de::max(1, m_size.x() >> levelNdx);
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int	levelH = (levelNdx == m_invalidLevelNdx) ? m_invalidLevelSize.y() : de::max(1, m_size.y() >> levelNdx);
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		levelData.setSize(m_size.x(), m_size.y());
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		clear(levelData.getAccess(), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f));
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexImage2D(GL_TEXTURE_2D, levelNdx, GL_RGBA, levelW, levelH, 0, GL_RGBA, GL_UNSIGNED_BYTE, levelData.getAccess().getDataPtr());
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_CHECK_MSG("Set texturing state");
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
297a2d05647ff9b7c7888d92d03084eb0b765ba1f60Jarkko Pöyry	// If size not allowed in core, search for relaxing extensions
298a2d05647ff9b7c7888d92d03084eb0b765ba1f60Jarkko Pöyry	if (!deIsPowerOfTwo32(m_size.x()) && !deIsPowerOfTwo32(m_size.y()))
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
300a2d05647ff9b7c7888d92d03084eb0b765ba1f60Jarkko Pöyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_relaxingExtensions); ++ndx)
301a2d05647ff9b7c7888d92d03084eb0b765ba1f60Jarkko Pöyry		{
302a2d05647ff9b7c7888d92d03084eb0b765ba1f60Jarkko Pöyry			if (isExtensionSupported(m_ctxInfo, s_relaxingExtensions[ndx]))
303a2d05647ff9b7c7888d92d03084eb0b765ba1f60Jarkko Pöyry			{
304a2d05647ff9b7c7888d92d03084eb0b765ba1f60Jarkko Pöyry				log << TestLog::Message << s_relaxingExtensions[ndx] << " supported, assuming completeness test to pass." << TestLog::EndMessage;
305a2d05647ff9b7c7888d92d03084eb0b765ba1f60Jarkko Pöyry				m_compareColor = RGBA(0,0,255,255);
306a2d05647ff9b7c7888d92d03084eb0b765ba1f60Jarkko Pöyry				break;
307a2d05647ff9b7c7888d92d03084eb0b765ba1f60Jarkko Pöyry			}
308a2d05647ff9b7c7888d92d03084eb0b765ba1f60Jarkko Pöyry		}
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Incomplete2DFormatCase : public Tex2DCompletenessCase
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							Incomplete2DFormatCase	(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, deUint32 format, deUint32 invalidFormat, int invalidLevelNdx);
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							~Incomplete2DFormatCase	(void) {}
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			createTexture			(void);
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_invalidLevelNdx;
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				m_format;
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				m_invalidFormat;
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IVec2					m_size;
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3273c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncomplete2DFormatCase::Incomplete2DFormatCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, deUint32 format, deUint32 invalidFormat, int invalidLevelNdx)
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: Tex2DCompletenessCase		(testCtx, renderCtx, name, description)
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_invalidLevelNdx			(invalidLevelNdx)
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_format					(format)
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_invalidFormat			(invalidFormat)
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_size					(size)
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Incomplete2DFormatCase::createTexture (void)
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureFormat	fmt			= glu::mapGLTransferFormat(m_format, GL_UNSIGNED_BYTE);
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureLevel	levelData	(fmt);
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint texture;
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glGenTextures	(1, &texture);
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glPixelStorei	(GL_UNPACK_ALIGNMENT, 1);
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glBindTexture	(GL_TEXTURE_2D, texture);
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,		GL_REPEAT);
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,		GL_REPEAT);
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,	GL_NEAREST_MIPMAP_NEAREST);
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,	GL_NEAREST);
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int numLevels = 1 + de::max(deLog2Floor32(m_size.x()), deLog2Floor32(m_size.y()));
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int levelNdx = 0; levelNdx < numLevels; levelNdx++)
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int	levelW = de::max(1, m_size.x() >> levelNdx);
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int	levelH = de::max(1, m_size.y() >> levelNdx);
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		levelData.setSize(m_size.x(), m_size.y());
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		clear(levelData.getAccess(), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f));
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32 format = levelNdx == m_invalidLevelNdx ? m_invalidFormat : m_format;
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexImage2D(GL_TEXTURE_2D, levelNdx, format, levelW, levelH, 0, format, GL_UNSIGNED_BYTE, levelData.getAccess().getDataPtr());
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_CHECK_MSG("Set texturing state");
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Incomplete2DMissingLevelCase : public Tex2DCompletenessCase
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						Incomplete2DMissingLevelCase	(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, int missingLevelNdx);
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						~Incomplete2DMissingLevelCase	(void) {}
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void		createTexture					(void);
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int					m_missingLevelNdx;
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IVec2				m_size;
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3823c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncomplete2DMissingLevelCase::Incomplete2DMissingLevelCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, int missingLevelNdx)
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: Tex2DCompletenessCase		(testCtx, renderCtx, name, description)
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_missingLevelNdx			(missingLevelNdx)
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_size					(size)
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Incomplete2DMissingLevelCase::createTexture (void)
3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureFormat	fmt			= glu::mapGLTransferFormat(GL_RGBA, GL_UNSIGNED_BYTE);
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureLevel	levelData	(fmt);
3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint texture;
3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glGenTextures	(1, &texture);
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glPixelStorei	(GL_UNPACK_ALIGNMENT, 1);
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glBindTexture	(GL_TEXTURE_2D, texture);
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,		GL_REPEAT);
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,		GL_REPEAT);
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,	GL_NEAREST_MIPMAP_NEAREST);
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,	GL_NEAREST);
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int numLevels = 1 + de::max(deLog2Floor32(m_size.x()), deLog2Floor32(m_size.y()));
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int levelNdx = 0; levelNdx < numLevels; levelNdx++)
4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		levelData.setSize(m_size.x(), m_size.y());
4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		clear(levelData.getAccess(), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f));
4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int	levelW = de::max(1, m_size.x() >> levelNdx);
4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int	levelH = de::max(1, m_size.y() >> levelNdx);
4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Skip specified level.
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (levelNdx != m_missingLevelNdx)
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage2D(GL_TEXTURE_2D, levelNdx, GL_RGBA, levelW, levelH, 0, GL_RGBA, GL_UNSIGNED_BYTE, levelData.getAccess().getDataPtr());
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_CHECK_MSG("Set texturing state");
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Incomplete2DWrapModeCase : public Tex2DCompletenessCase
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								Incomplete2DWrapModeCase	(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, deUint32 wrapT, deUint32 wrapS, const glu::ContextInfo& ctxInfo);
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								~Incomplete2DWrapModeCase	(void) {}
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void				createTexture				(void);
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					m_wrapT;
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					m_wrapS;
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::ContextInfo&		m_ctxInfo;
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IVec2						m_size;
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4373c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncomplete2DWrapModeCase::Incomplete2DWrapModeCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, deUint32 wrapT, deUint32 wrapS, const glu::ContextInfo& ctxInfo)
4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: Tex2DCompletenessCase		(testCtx, renderCtx, name, description)
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_wrapT					(wrapT)
4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_wrapS					(wrapS)
4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_ctxInfo					(ctxInfo)
4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_size					(size)
4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Incomplete2DWrapModeCase::createTexture (void)
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TestLog&			log			= m_testCtx.getLog();
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureFormat	fmt			= glu::mapGLTransferFormat(GL_RGBA, GL_UNSIGNED_BYTE);
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureLevel	levelData	(fmt);
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint texture;
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glGenTextures(1, &texture);
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glBindTexture(GL_TEXTURE_2D, texture);
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,		m_wrapS);
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,		m_wrapT);
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,	GL_NEAREST);
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,	GL_NEAREST);
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	levelData.setSize(m_size.x(), m_size.y());
4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	clear(levelData.getAccess(), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f));
4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_size.x(), m_size.y(), 0, GL_RGBA, GL_UNSIGNED_BYTE, levelData.getAccess().getDataPtr());
4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_CHECK_MSG("Set texturing state");
4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char* extension = "GL_OES_texture_npot";
4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (isExtensionSupported(m_ctxInfo, extension))
4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		log << TestLog::Message << extension << " supported, assuming completeness test to pass." << TestLog::EndMessage;
4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_compareColor = RGBA(0,0,255,255);
4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Complete2DExtraLevelCase : public Tex2DCompletenessCase
4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						Complete2DExtraLevelCase	(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size);
4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						~Complete2DExtraLevelCase	(void) {}
4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void		createTexture				(void);
4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IVec2				m_size;
4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4893c827367444ee418f129b2c238299f49d3264554Jarkko PoyryComplete2DExtraLevelCase::Complete2DExtraLevelCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size)
4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: Tex2DCompletenessCase		(testCtx, renderCtx, name, description)
4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_size					(size)
4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Complete2DExtraLevelCase::createTexture (void)
4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureFormat	fmt			= glu::mapGLTransferFormat(GL_RGBA, GL_UNSIGNED_BYTE);
4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureLevel	levelData	(fmt);
4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint texture;
5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glGenTextures	(1, &texture);
5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glPixelStorei	(GL_UNPACK_ALIGNMENT, 1);
5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glBindTexture	(GL_TEXTURE_2D, texture);
5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,		GL_REPEAT);
5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,		GL_REPEAT);
5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,	GL_NEAREST_MIPMAP_NEAREST);
5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,	GL_NEAREST);
5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int numLevels = 1 + de::max(deLog2Floor32(m_size.x()), deLog2Floor32(m_size.y()));
5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int levelNdx = 0; levelNdx < numLevels; levelNdx++)
5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int	levelW = de::max(1, m_size.x() >> levelNdx);
5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int	levelH = de::max(1, m_size.y() >> levelNdx);
5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		levelData.setSize(m_size.x(), m_size.y());
5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		clear(levelData.getAccess(), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f));
5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexImage2D(GL_TEXTURE_2D, levelNdx, GL_RGBA, levelW, levelH, 0, GL_RGBA, GL_UNSIGNED_BYTE, levelData.getAccess().getDataPtr());
5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Specify extra level.
5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexImage2D(GL_TEXTURE_2D, numLevels+1, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, levelData.getAccess().getDataPtr());
5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_compareColor = RGBA(0,0,255,255);
5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_CHECK_MSG("Set texturing state");
5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Incomplete2DEmptyObjectCase : public Tex2DCompletenessCase
5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						Incomplete2DEmptyObjectCase		(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size);
5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						~Incomplete2DEmptyObjectCase	(void) {}
5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void		createTexture					(void);
5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IVec2				m_size;
5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5423c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncomplete2DEmptyObjectCase::Incomplete2DEmptyObjectCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size)
5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: Tex2DCompletenessCase		(testCtx, renderCtx, name, description)
5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_size					(size)
5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Incomplete2DEmptyObjectCase::createTexture (void)
5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint texture;
5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glGenTextures	(1, &texture);
5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glPixelStorei	(GL_UNPACK_ALIGNMENT, 1);
5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glBindTexture	(GL_TEXTURE_2D, texture);
5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,		GL_REPEAT);
5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,		GL_REPEAT);
5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,	GL_NEAREST_MIPMAP_NEAREST);
5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,	GL_NEAREST);
5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_CHECK_MSG("Set texturing state");
5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Cube texture tests.
5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass IncompleteCubeSizeCase : public TexCubeCompletenessCase
5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							IncompleteCubeSizeCase	(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, IVec2 invalidLevelSize, int invalidLevelNdx);
5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							IncompleteCubeSizeCase	(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, IVec2 invalidLevelSize, int invalidLevelNdx, tcu::CubeFace invalidCubeFace);
5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							~IncompleteCubeSizeCase	(void) {}
5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			createTexture			(void);
5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_invalidLevelNdx;
5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IVec2					m_invalidLevelSize;
5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::CubeFace			m_invalidCubeFace;
5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IVec2					m_size;
5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5813c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncompleteCubeSizeCase::IncompleteCubeSizeCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, IVec2 invalidLevelSize, int invalidLevelNdx)
5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TexCubeCompletenessCase		(testCtx, renderCtx, name, description)
5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_invalidLevelNdx				(invalidLevelNdx)
5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_invalidLevelSize			(invalidLevelSize)
5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_invalidCubeFace				(tcu::CUBEFACE_LAST)
5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_size						(size)
5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5903c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncompleteCubeSizeCase::IncompleteCubeSizeCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, IVec2 invalidLevelSize, int invalidLevelNdx, tcu::CubeFace invalidCubeFace)
5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TexCubeCompletenessCase		(testCtx, renderCtx, name, description)
5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_invalidLevelNdx				(invalidLevelNdx)
5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_invalidLevelSize			(invalidLevelSize)
5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_invalidCubeFace				(invalidCubeFace)
5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_size						(size)
5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid IncompleteCubeSizeCase::createTexture (void)
6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureFormat	fmt			= glu::mapGLTransferFormat(GL_RGBA, GL_UNSIGNED_BYTE);
6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureLevel	levelData	(fmt);
6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint texture;
6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glGenTextures	(1, &texture);
6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glPixelStorei	(GL_UNPACK_ALIGNMENT, 1);
6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glBindTexture	(GL_TEXTURE_CUBE_MAP, texture);
6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri	(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S,		GL_REPEAT);
6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri	(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T,		GL_REPEAT);
6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri	(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER,	GL_NEAREST_MIPMAP_NEAREST);
6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri	(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER,	GL_NEAREST);
6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int numLevels = 1 + de::max(deLog2Floor32(m_size.x()), deLog2Floor32(m_size.y()));
6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int levelNdx = 0; levelNdx < numLevels; levelNdx++)
6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		levelData.setSize(m_size.x(), m_size.y());
6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		clear(levelData.getAccess(), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f));
6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int targetNdx = 0; targetNdx < DE_LENGTH_OF_ARRAY(s_cubeTargets); targetNdx++)
6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int levelW = de::max(1, m_size.x() >> levelNdx);
6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int levelH = de::max(1, m_size.y() >> levelNdx);
6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (levelNdx == m_invalidLevelNdx && (m_invalidCubeFace == tcu::CUBEFACE_LAST || m_invalidCubeFace == targetNdx))
6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				levelW =  m_invalidLevelSize.x();
6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				levelH =  m_invalidLevelSize.y();
6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage2D(s_cubeTargets[targetNdx], levelNdx, GL_RGBA, levelW, levelH, 0, GL_RGBA, GL_UNSIGNED_BYTE, levelData.getAccess().getDataPtr());
6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_CHECK_MSG("Set texturing state");
6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass IncompleteCubeFormatCase : public TexCubeCompletenessCase
6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							IncompleteCubeFormatCase	(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, deUint32 format, deUint32 invalidFormat);
6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							IncompleteCubeFormatCase	(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, deUint32 format, deUint32 invalidFormat, tcu::CubeFace invalidCubeFace);
6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							~IncompleteCubeFormatCase	(void) {}
6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			createTexture				(void);
6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				m_format;
6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				m_invalidFormat;
6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::CubeFace			m_invalidCubeFace;
6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IVec2					m_size;
6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6533c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncompleteCubeFormatCase::IncompleteCubeFormatCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, deUint32 format, deUint32 invalidFormat)
6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TexCubeCompletenessCase		(testCtx, renderCtx, name, description)
6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_format						(format)
6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_invalidFormat				(invalidFormat)
6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_invalidCubeFace				(tcu::CUBEFACE_LAST)
6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_size						(size)
6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6623c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncompleteCubeFormatCase::IncompleteCubeFormatCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, deUint32 format, deUint32 invalidFormat, tcu::CubeFace invalidCubeFace)
6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TexCubeCompletenessCase		(testCtx, renderCtx, name, description)
6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_format						(format)
6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_invalidFormat				(invalidFormat)
6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_invalidCubeFace				(invalidCubeFace)
6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_size						(size)
6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid IncompleteCubeFormatCase::createTexture (void)
6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureFormat	fmt			= glu::mapGLTransferFormat(GL_RGBA, GL_UNSIGNED_BYTE);
6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureLevel	levelData	(fmt);
6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint texture;
6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glGenTextures	(1, &texture);
6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glPixelStorei	(GL_UNPACK_ALIGNMENT, 1);
6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glBindTexture	(GL_TEXTURE_CUBE_MAP, texture);
6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri	(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S,		GL_REPEAT);
6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri	(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T,		GL_REPEAT);
6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri	(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER,	GL_NEAREST_MIPMAP_NEAREST);
6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri	(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER,	GL_NEAREST);
6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int numLevels = 1 + de::max(deLog2Floor32(m_size.x()), deLog2Floor32(m_size.y()));
6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int levelNdx = 0; levelNdx < numLevels; levelNdx++)
6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		levelData.setSize(m_size.x(), m_size.y());
6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		clear(levelData.getAccess(), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f));
6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int	levelW = de::max(1, m_size.x() >> levelNdx);
6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int	levelH = de::max(1, m_size.y() >> levelNdx);
6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int targetNdx = 0; targetNdx < DE_LENGTH_OF_ARRAY(s_cubeTargets); targetNdx++)
6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32 format = m_format;
6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (levelNdx == 0 && (m_invalidCubeFace == tcu::CUBEFACE_LAST || m_invalidCubeFace == targetNdx))
7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				format = m_invalidFormat;
7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage2D(s_cubeTargets[targetNdx], levelNdx, format, levelW, levelH, 0, format, GL_UNSIGNED_BYTE, levelData.getAccess().getDataPtr());
7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_CHECK_MSG("Set texturing state");
7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass IncompleteCubeMissingLevelCase : public TexCubeCompletenessCase
7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							IncompleteCubeMissingLevelCase	(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, int invalidLevelNdx);
7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							IncompleteCubeMissingLevelCase	(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, int invalidLevelNdx, tcu::CubeFace invalidCubeFace);
7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							~IncompleteCubeMissingLevelCase	(void) {}
7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			createTexture					(void);
7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_invalidLevelNdx;
7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::CubeFace			m_invalidCubeFace;
7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IVec2					m_size;
7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7243c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncompleteCubeMissingLevelCase::IncompleteCubeMissingLevelCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, int invalidLevelNdx)
7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TexCubeCompletenessCase		(testCtx, renderCtx, name, description)
7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_invalidLevelNdx				(invalidLevelNdx)
7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_invalidCubeFace				(tcu::CUBEFACE_LAST)
7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_size						(size)
7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7323c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncompleteCubeMissingLevelCase::IncompleteCubeMissingLevelCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, int invalidLevelNdx, tcu::CubeFace invalidCubeFace)
7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TexCubeCompletenessCase		(testCtx, renderCtx, name, description)
7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_invalidLevelNdx				(invalidLevelNdx)
7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_invalidCubeFace				(invalidCubeFace)
7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_size						(size)
7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid IncompleteCubeMissingLevelCase::createTexture (void)
7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureFormat	fmt			= glu::mapGLTransferFormat(GL_RGBA, GL_UNSIGNED_BYTE);
7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureLevel	levelData	(fmt);
7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint texture;
7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glGenTextures	(1, &texture);
7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glPixelStorei	(GL_UNPACK_ALIGNMENT, 1);
7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glBindTexture	(GL_TEXTURE_CUBE_MAP, texture);
7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri	(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S,		GL_REPEAT);
7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri	(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T,		GL_REPEAT);
7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri	(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER,	GL_NEAREST_MIPMAP_NEAREST);
7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri	(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER,	GL_NEAREST);
7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int numLevels = 1 + de::max(deLog2Floor32(m_size.x()), deLog2Floor32(m_size.y()));
7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int levelNdx = 0; levelNdx < numLevels; levelNdx++)
7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		levelData.setSize(m_size.x(), m_size.y());
7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		clear(levelData.getAccess(), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f));
7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int	levelW = (levelNdx == m_invalidLevelNdx) ? m_size.x() : de::max(1, m_size.x() >> levelNdx);
7633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int	levelH = (levelNdx == m_invalidLevelNdx) ? m_size.y() : de::max(1, m_size.y() >> levelNdx);
7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (levelNdx != m_invalidLevelNdx || m_invalidCubeFace != tcu::CUBEFACE_LAST)
7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
7673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int targetNdx = 0; targetNdx < DE_LENGTH_OF_ARRAY(s_cubeTargets); targetNdx++)
7683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
7693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				// If single cubeface is specified then skip only that one.
7703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (m_invalidCubeFace != targetNdx)
7713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					glTexImage2D(s_cubeTargets[targetNdx], levelNdx, GL_RGBA, levelW, levelH, 0, GL_RGBA, GL_UNSIGNED_BYTE, levelData.getAccess().getDataPtr());
7723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
7733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
7743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_CHECK_MSG("Set texturing state");
7773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7793c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass IncompleteCubeWrapModeCase : public TexCubeCompletenessCase
7803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7813c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
7823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								IncompleteCubeWrapModeCase	(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, deUint32 wrapT, deUint32 wrapS, const glu::ContextInfo& ctxInfo);
7833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								~IncompleteCubeWrapModeCase	(void) {}
7843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void				createTexture				(void);
7863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7873c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
7883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					m_wrapT;
7893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					m_wrapS;
7903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::ContextInfo&		m_ctxInfo;
7913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IVec2						m_size;
7923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
7933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7943c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncompleteCubeWrapModeCase::IncompleteCubeWrapModeCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, deUint32 wrapT, deUint32 wrapS, const glu::ContextInfo& ctxInfo)
7953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TexCubeCompletenessCase	(testCtx, renderCtx, name, description)
7963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_wrapT					(wrapT)
7973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_wrapS					(wrapS)
7983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_ctxInfo					(ctxInfo)
7993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_size					(size)
8003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8033c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid IncompleteCubeWrapModeCase::createTexture (void)
8043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TestLog&			log			= m_testCtx.getLog();
8063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureFormat	fmt			= glu::mapGLTransferFormat(GL_RGBA, GL_UNSIGNED_BYTE);
8073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureLevel	levelData	(fmt);
8083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint texture;
8103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glGenTextures(1, &texture);
8113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
8123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glBindTexture(GL_TEXTURE_2D, texture);
8133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S,		m_wrapS);
8153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T,		m_wrapT);
8163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER,	GL_NEAREST);
8173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER,	GL_NEAREST);
8183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	levelData.setSize(m_size.x(), m_size.y());
8203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	clear(levelData.getAccess(), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f));
8213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int targetNdx = 0; targetNdx < DE_LENGTH_OF_ARRAY(s_cubeTargets); targetNdx++)
8233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexImage2D(s_cubeTargets[targetNdx], 0, GL_RGBA, m_size.x(), m_size.y(), 0, GL_RGBA, GL_UNSIGNED_BYTE, levelData.getAccess().getDataPtr());
8243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_CHECK_MSG("Set texturing state");
8263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char* extension = "GL_OES_texture_npot";
8283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (isExtensionSupported(m_ctxInfo, extension))
8293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		log << TestLog::Message << extension << " supported, assuming completeness test to pass." << TestLog::EndMessage;
8313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_compareColor = RGBA(0,0,255,255);
8323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8353c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass CompleteCubeExtraLevelCase : public TexCubeCompletenessCase
8363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8373c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
8383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						CompleteCubeExtraLevelCase	(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size);
8393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						~CompleteCubeExtraLevelCase	(void) {}
8403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void		createTexture				(void);
8423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
8443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IVec2				m_size;
8453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
8463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8473c827367444ee418f129b2c238299f49d3264554Jarkko PoyryCompleteCubeExtraLevelCase::CompleteCubeExtraLevelCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size)
8483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TexCubeCompletenessCase	(testCtx, renderCtx, name, description)
8493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_size					(size)
8503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid CompleteCubeExtraLevelCase::createTexture (void)
8543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureFormat		fmt				= glu::mapGLTransferFormat(GL_RGBA, GL_UNSIGNED_BYTE);
8563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureLevel		levelData		(fmt);
8573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint texture;
8593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glGenTextures	(1, &texture);
8603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glPixelStorei	(GL_UNPACK_ALIGNMENT, 1);
8613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glBindTexture	(GL_TEXTURE_2D, texture);
8623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,		GL_REPEAT);
8643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,		GL_REPEAT);
8653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,	GL_NEAREST_MIPMAP_NEAREST);
8663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,	GL_NEAREST);
8673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int numLevels = 1 + de::max(deLog2Floor32(m_size.x()), deLog2Floor32(m_size.y()));
8693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	levelData.setSize(m_size.x(), m_size.y());
8713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	clear(levelData.getAccess(), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f));
8723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int levelNdx = 0; levelNdx < numLevels; levelNdx++)
8743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int	levelW = de::max(1, m_size.x() >> levelNdx);
8763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int	levelH = de::max(1, m_size.y() >> levelNdx);
8773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int targetNdx = 0; targetNdx < DE_LENGTH_OF_ARRAY(s_cubeTargets); targetNdx++)
8793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage2D(s_cubeTargets[targetNdx], levelNdx, GL_RGBA, levelW, levelH, 0, GL_RGBA, GL_UNSIGNED_BYTE, levelData.getAccess().getDataPtr());
8803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Specify extra level.
8833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int targetNdx = 0; targetNdx < DE_LENGTH_OF_ARRAY(s_cubeTargets); targetNdx++)
8843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexImage2D(s_cubeTargets[targetNdx], numLevels+1, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, levelData.getAccess().getDataPtr());
8853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_compareColor = RGBA(0,0,255,255);
8873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_CHECK_MSG("Set texturing state");
8893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8913c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass IncompleteCubeEmptyObjectCase : public TexCubeCompletenessCase
8923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8933c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
8943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							IncompleteCubeEmptyObjectCase	(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size);
8953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							~IncompleteCubeEmptyObjectCase	(void) {}
8963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			createTexture				(void);
8983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8993c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
9003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IVec2					m_size;
9013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
9023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9033c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncompleteCubeEmptyObjectCase::IncompleteCubeEmptyObjectCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size)
9043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TexCubeCompletenessCase	(testCtx, renderCtx, name, description)
9053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_size					(size)
9063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9093c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid IncompleteCubeEmptyObjectCase::createTexture (void)
9103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint texture;
9123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glGenTextures	(1, &texture);
9133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glPixelStorei	(GL_UNPACK_ALIGNMENT, 1);
9143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glBindTexture	(GL_TEXTURE_2D, texture);
9153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,		GL_REPEAT);
9173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,		GL_REPEAT);
9183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,	GL_NEAREST_MIPMAP_NEAREST);
9193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,	GL_NEAREST);
9203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_CHECK_MSG("Set texturing state");
9223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Texture completeness group.
9253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9263c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureCompletenessTests::TextureCompletenessTests (Context& context)
9273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCaseGroup(context, "completeness", "Completeness tests")
9283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9313c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureCompletenessTests::init (void)
9323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TestCaseGroup* tex2d = new tcu::TestCaseGroup(m_testCtx, "2d", "2D completeness");
9343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(tex2d);
9353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TestCaseGroup* cube = new tcu::TestCaseGroup(m_testCtx, "cube", "Cubemap completeness");
9363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(cube);
9373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Texture 2D size.
9393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tex2d->addChild(new Incomplete2DSizeCase(m_testCtx, m_context.getRenderContext(), "npot_size",				"", IVec2(255, 255), IVec2(255, 255), 0, m_context.getContextInfo()));
9403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tex2d->addChild(new Incomplete2DSizeCase(m_testCtx, m_context.getRenderContext(), "npot_size_level_0",		"", IVec2(256, 256), IVec2(255, 255), 0, m_context.getContextInfo()));
9413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tex2d->addChild(new Incomplete2DSizeCase(m_testCtx, m_context.getRenderContext(), "npot_size_level_1",		"", IVec2(256, 256), IVec2(127, 127), 1, m_context.getContextInfo()));
9423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tex2d->addChild(new Incomplete2DSizeCase(m_testCtx, m_context.getRenderContext(), "not_positive_level_0",	"", IVec2(256, 256), IVec2(0, 0),	  0, m_context.getContextInfo()));
9433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Texture 2D format.
9443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tex2d->addChild(new Incomplete2DFormatCase(m_testCtx, m_context.getRenderContext(), "format_mismatch_rgb_rgba",						"", IVec2(128, 128), GL_RGB,				GL_RGBA,			1));
9453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tex2d->addChild(new Incomplete2DFormatCase(m_testCtx, m_context.getRenderContext(), "format_mismatch_rgba_rgb",						"", IVec2(128, 128), GL_RGBA,				GL_RGB,				1));
9463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tex2d->addChild(new Incomplete2DFormatCase(m_testCtx, m_context.getRenderContext(), "format_mismatch_luminance_luminance_alpha",	"", IVec2(128, 128), GL_LUMINANCE,			GL_LUMINANCE_ALPHA,	1));
9473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tex2d->addChild(new Incomplete2DFormatCase(m_testCtx, m_context.getRenderContext(), "format_mismatch_luminance_alpha_luminance",	"", IVec2(128, 128), GL_LUMINANCE_ALPHA,	GL_LUMINANCE,		1));
9483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Texture 2D missing level.
9493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tex2d->addChild(new Incomplete2DMissingLevelCase(m_testCtx, m_context.getRenderContext(), "missing_level_1",			"", IVec2(128, 128),	1));
9503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tex2d->addChild(new Incomplete2DMissingLevelCase(m_testCtx, m_context.getRenderContext(), "missing_level_3",			"", IVec2(128, 128),	3));
9513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tex2d->addChild(new Incomplete2DMissingLevelCase(m_testCtx, m_context.getRenderContext(), "last_level_missing",			"", IVec2(128, 64),		de::max(deLog2Floor32(128), deLog2Floor32(64))));
9523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Texture 2D wrap modes.
9533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tex2d->addChild(new Incomplete2DWrapModeCase(m_testCtx, m_context.getRenderContext(), "npot_t_repeat",			"", IVec2(127, 127), GL_CLAMP_TO_EDGE,		GL_REPEAT,				m_context.getContextInfo()));
9543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tex2d->addChild(new Incomplete2DWrapModeCase(m_testCtx, m_context.getRenderContext(), "npot_s_repeat",			"", IVec2(127, 127), GL_REPEAT,				GL_CLAMP_TO_EDGE,		m_context.getContextInfo()));
9553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tex2d->addChild(new Incomplete2DWrapModeCase(m_testCtx, m_context.getRenderContext(), "npot_all_repeat",		"", IVec2(127, 127), GL_REPEAT,				GL_REPEAT,				m_context.getContextInfo()));
9563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tex2d->addChild(new Incomplete2DWrapModeCase(m_testCtx, m_context.getRenderContext(), "npot_mirrored_repeat",	"", IVec2(127, 127), GL_MIRRORED_REPEAT,	GL_MIRRORED_REPEAT,		m_context.getContextInfo()));
9573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tex2d->addChild(new Incomplete2DWrapModeCase(m_testCtx, m_context.getRenderContext(), "repeat_width_npot",		"", IVec2(127, 128), GL_REPEAT,				GL_REPEAT,				m_context.getContextInfo()));
9583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tex2d->addChild(new Incomplete2DWrapModeCase(m_testCtx, m_context.getRenderContext(), "repeat_height_npot",		"", IVec2(128, 127), GL_REPEAT,				GL_REPEAT,				m_context.getContextInfo()));
9593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Texture 2D extra level.
9603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tex2d->addChild(new Complete2DExtraLevelCase(m_testCtx, m_context.getRenderContext(), "extra_level", "", IVec2(64, 64)));
9613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Texture 2D empty object.
9623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tex2d->addChild(new Incomplete2DEmptyObjectCase(m_testCtx, m_context.getRenderContext(), "empty_object", "", IVec2(64, 64)));
9633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Cube size.
9653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	cube->addChild(new IncompleteCubeSizeCase(m_testCtx, m_context.getRenderContext(), "npot_size_level_0",			"", IVec2(64, 64), IVec2(63, 63), 0));
9663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	cube->addChild(new IncompleteCubeSizeCase(m_testCtx, m_context.getRenderContext(), "npot_size_level_1",			"", IVec2(64, 64), IVec2(31, 31), 1));
9673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	cube->addChild(new IncompleteCubeSizeCase(m_testCtx, m_context.getRenderContext(), "npot_size_level_0_pos_x",	"", IVec2(64, 64), IVec2(63, 63), 0, tcu::CUBEFACE_POSITIVE_X));
9683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	cube->addChild(new IncompleteCubeSizeCase(m_testCtx, m_context.getRenderContext(), "npot_size_level_1_neg_x",	"", IVec2(64, 64), IVec2(31, 31), 1, tcu::CUBEFACE_NEGATIVE_X));
9693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	cube->addChild(new IncompleteCubeSizeCase(m_testCtx, m_context.getRenderContext(), "not_positive_level_0",		"", IVec2(64, 64), IVec2(0,0)	, 0));
9703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Cube format.
9713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	cube->addChild(new IncompleteCubeFormatCase(m_testCtx, m_context.getRenderContext(), "format_mismatch_rgb_rgba_level_0",					"", IVec2(64, 64), GL_RGB,				GL_RGBA));
9723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	cube->addChild(new IncompleteCubeFormatCase(m_testCtx, m_context.getRenderContext(), "format_mismatch_rgba_rgb_level_0",					"", IVec2(64, 64), GL_RGBA,				GL_RGB));
9733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	cube->addChild(new IncompleteCubeFormatCase(m_testCtx, m_context.getRenderContext(), "format_mismatch_luminance_luminance_alpha_level_0",	"", IVec2(64, 64), GL_LUMINANCE,		GL_LUMINANCE_ALPHA));
9743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	cube->addChild(new IncompleteCubeFormatCase(m_testCtx, m_context.getRenderContext(), "format_mismatch_luminance_alpha_luminance_level_0",	"", IVec2(64, 64), GL_LUMINANCE_ALPHA,	GL_LUMINANCE));
9753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	cube->addChild(new IncompleteCubeFormatCase(m_testCtx, m_context.getRenderContext(), "format_mismatch_rgb_rgba_level_0_pos_z",				"", IVec2(64, 64), GL_RGB,				GL_RGBA,	tcu::CUBEFACE_POSITIVE_Z));
9763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	cube->addChild(new IncompleteCubeFormatCase(m_testCtx, m_context.getRenderContext(), "format_mismatch_rgba_rgb_level_0_neg_z",				"", IVec2(64, 64), GL_RGBA,				GL_RGB,		tcu::CUBEFACE_NEGATIVE_Z));
9773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Cube missing level.
9783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	cube->addChild(new IncompleteCubeMissingLevelCase(m_testCtx, m_context.getRenderContext(), "missing_level_1",		"", IVec2(64, 64), 1));
9793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	cube->addChild(new IncompleteCubeMissingLevelCase(m_testCtx, m_context.getRenderContext(), "missing_level_3",		"", IVec2(64, 64), 3));
9803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	cube->addChild(new IncompleteCubeMissingLevelCase(m_testCtx, m_context.getRenderContext(), "missing_level_1_pos_y",	"", IVec2(64, 64), 1, tcu::CUBEFACE_POSITIVE_Y));
9813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	cube->addChild(new IncompleteCubeMissingLevelCase(m_testCtx, m_context.getRenderContext(), "missing_level_3_neg_y",	"", IVec2(64, 64), 3, tcu::CUBEFACE_NEGATIVE_Y));
9823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Cube wrap modes.
9833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	cube->addChild(new IncompleteCubeWrapModeCase(m_testCtx, m_context.getRenderContext(), "npot_t_repeat",			"", IVec2(127, 127), GL_CLAMP_TO_EDGE,		GL_REPEAT,				m_context.getContextInfo()));
9843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	cube->addChild(new IncompleteCubeWrapModeCase(m_testCtx, m_context.getRenderContext(), "npot_s_repeat",			"", IVec2(127, 127), GL_REPEAT,				GL_CLAMP_TO_EDGE,		m_context.getContextInfo()));
9853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	cube->addChild(new IncompleteCubeWrapModeCase(m_testCtx, m_context.getRenderContext(), "npot_all_repeat",		"", IVec2(127, 127), GL_REPEAT,				GL_REPEAT,				m_context.getContextInfo()));
9863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	cube->addChild(new IncompleteCubeWrapModeCase(m_testCtx, m_context.getRenderContext(), "npot_mirrored_repeat",	"", IVec2(127, 127), GL_MIRRORED_REPEAT,	GL_MIRRORED_REPEAT,		m_context.getContextInfo()));
9873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Cube extra level.
9883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	cube->addChild(new CompleteCubeExtraLevelCase(m_testCtx, m_context.getRenderContext(), "extra_level", "", IVec2(64, 64)));
9893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Cube extra level.
9903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	cube->addChild(new IncompleteCubeEmptyObjectCase(m_testCtx, m_context.getRenderContext(), "empty_object", "", IVec2(64, 64)));
9913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional
9943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles2
9953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
996