13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 3.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 specification tests.
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \todo [pyry] Following tests are missing:
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  - Specify mipmap incomplete texture, use without mipmaps, re-specify
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *    as complete and render.
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  - Randomly re-specify levels to eventually reach mipmap-complete texture.
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es3fTextureSpecificationTests.hpp"
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp"
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuImageCompare.hpp"
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTextureUtil.hpp"
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVectorUtil.hpp"
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluStrUtil.hpp"
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluTexture.hpp"
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluTextureUtil.hpp"
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "sglrContextUtil.hpp"
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "sglrContextWrapper.hpp"
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "sglrGLContext.hpp"
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "sglrReferenceContext.hpp"
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsTextureTestUtil.hpp"
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp"
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp"
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// \todo [2012-04-29 pyry] Should be named SglrUtil
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es3fFboTestUtil.hpp"
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp"
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles3
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::string;
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector;
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::pair;
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog;
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Vec4;
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::IVec4;
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::UVec4;
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace FboTestUtil;
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytcu::TextureFormat mapGLUnsizedInternalFormat (deUint32 internalFormat)
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TextureFormat;
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	switch (internalFormat)
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case GL_ALPHA:				return TextureFormat(TextureFormat::A,		TextureFormat::UNORM_INT8);
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case GL_LUMINANCE:			return TextureFormat(TextureFormat::L,		TextureFormat::UNORM_INT8);
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case GL_LUMINANCE_ALPHA:	return TextureFormat(TextureFormat::LA,		TextureFormat::UNORM_INT8);
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case GL_RGB:				return TextureFormat(TextureFormat::RGB,	TextureFormat::UNORM_INT8);
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case GL_RGBA:				return TextureFormat(TextureFormat::RGBA,	TextureFormat::UNORM_INT8);
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		default:
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			throw tcu::InternalError(string("Can't map GL unsized internal format (") + tcu::toHex(internalFormat).toString() + ") to texture format");
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VIEWPORT_WIDTH	= 256,
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VIEWPORT_HEIGHT	= 256
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic inline int maxLevelCount (int width, int height)
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return (int)deLog2Floor32(de::max(width, height))+1;
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic inline int maxLevelCount (int width, int height, int depth)
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return (int)deLog2Floor32(de::max(width, de::max(height, depth)))+1;
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <int Size>
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic tcu::Vector<float, Size> randomVector (de::Random& rnd, const tcu::Vector<float, Size>& minVal = tcu::Vector<float, Size>(0.0f), const tcu::Vector<float, Size>& maxVal = tcu::Vector<float, Size>(1.0f))
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Vector<float, Size> res;
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int ndx = 0; ndx < Size; ndx++)
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		res[ndx] = rnd.getFloat(minVal[ndx], maxVal[ndx]);
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return res;
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const deUint32 s_cubeMapFaces[] =
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic tcu::IVec4 getPixelFormatCompareDepth (const tcu::PixelFormat& pixelFormat, tcu::TextureFormat textureFormat)
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	switch (textureFormat.order)
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case tcu::TextureFormat::L:
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case tcu::TextureFormat::LA:
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return tcu::IVec4(pixelFormat.redBits, pixelFormat.redBits, pixelFormat.redBits, pixelFormat.alphaBits);
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		default:
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return tcu::IVec4(pixelFormat.redBits, pixelFormat.greenBits, pixelFormat.blueBits, pixelFormat.alphaBits);
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1285a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyrystatic IVec4 getEffectiveTextureFormatBitDepth (tcu::TextureFormat textureFormat)
1295a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyry{
1305a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyry	if (textureFormat.order == tcu::TextureFormat::DS)
1315a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyry	{
1325a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyry		// When sampling depth-stencil texture, we actually sample just
1335a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyry		// the depth component.
1345a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyry		return tcu::getTextureFormatBitDepth(tcu::getEffectiveDepthStencilTextureFormat(textureFormat, tcu::Sampler::MODE_DEPTH));
1355a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyry	}
1365a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyry	else
1375a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyry		return tcu::getTextureFormatBitDepth(textureFormat);
1385a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyry}
1395a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyry
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic tcu::UVec4 computeCompareThreshold (const tcu::PixelFormat& pixelFormat, tcu::TextureFormat textureFormat)
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1425a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyry	const IVec4		texFormatBits		= getEffectiveTextureFormatBitDepth(textureFormat);
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const IVec4		pixelFormatBits		= getPixelFormatCompareDepth(pixelFormat, textureFormat);
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const IVec4		accurateFmtBits		= min(pixelFormatBits, texFormatBits);
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const IVec4		compareBits			= select(accurateFmtBits, IVec4(8), greaterThan(accurateFmtBits, IVec4(0))) - 1;
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return (IVec4(1) << (8-compareBits)).asUint();
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureSpecCase : public TestCase, public sglr::ContextWrapper
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							TextureSpecCase		(Context& context, const char* name, const char* desc);
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							~TextureSpecCase	(void);
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult			iterate				(void);
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			createTexture		(void)																	= DE_NULL;
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			verifyTexture		(sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext)	= DE_NULL;
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Utilities.
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					renderTex			(tcu::Surface& dst, deUint32 program, int width, int height);
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					readPixels			(tcu::Surface& dst, int x, int y, int width, int height);
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							TextureSpecCase		(const TextureSpecCase& other);
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureSpecCase&		operator=			(const TextureSpecCase& other);
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1713c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureSpecCase::TextureSpecCase (Context& context, const char* name, const char* desc)
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCase(context, name, desc)
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1763c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureSpecCase::~TextureSpecCase (void)
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1803c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureSpecCase::IterateResult TextureSpecCase::iterate (void)
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::RenderContext&			renderCtx				= TestCase::m_context.getRenderContext();
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::RenderTarget&	renderTarget			= renderCtx.getRenderTarget();
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TestLog&				log						= m_testCtx.getLog();
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (renderTarget.getWidth() < VIEWPORT_WIDTH || renderTarget.getHeight() < VIEWPORT_HEIGHT)
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::NotSupportedError("Too small viewport", "", __FILE__, __LINE__);
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Context size, and viewport for GLES3
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	de::Random		rnd			(deStringHash(getName()));
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				width		= deMin32(renderTarget.getWidth(),	VIEWPORT_WIDTH);
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				height		= deMin32(renderTarget.getHeight(),	VIEWPORT_HEIGHT);
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				x			= rnd.getInt(0, renderTarget.getWidth()		- width);
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				y			= rnd.getInt(0, renderTarget.getHeight()	- height);
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Contexts.
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	sglr::GLContext					gles3Context	(renderCtx, log, sglr::GLCONTEXT_LOG_CALLS, tcu::IVec4(x, y, width, height));
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	sglr::ReferenceContextBuffers	refBuffers		(tcu::PixelFormat(8,8,8,renderTarget.getPixelFormat().alphaBits?8:0), 0 /* depth */, 0 /* stencil */, width, height);
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	sglr::ReferenceContext			refContext		(sglr::ReferenceContextLimits(renderCtx), refBuffers.getColorbuffer(), refBuffers.getDepthbuffer(), refBuffers.getStencilbuffer());
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Clear color buffer.
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int ndx = 0; ndx < 2; ndx++)
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		setContext(ndx ? (sglr::Context*)&refContext : (sglr::Context*)&gles3Context);
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glClearColor(0.125f, 0.25f, 0.5f, 1.0f);
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Construct texture using both GLES3 and reference contexts.
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int ndx = 0; ndx < 2; ndx++)
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		setContext(ndx ? (sglr::Context*)&refContext : (sglr::Context*)&gles3Context);
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		createTexture();
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TCU_CHECK(glGetError() == GL_NO_ERROR);
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Initialize case result to pass.
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Disable logging.
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gles3Context.enableLogging(0);
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Verify results.
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	verifyTexture(gles3Context, refContext);
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return STOP;
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureSpecCase::renderTex (tcu::Surface& dst, deUint32 program, int width, int height)
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int		targetW		= getWidth();
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int		targetH		= getHeight();
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float	w			= (float)width	/ (float)targetW;
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float	h			= (float)height	/ (float)targetH;
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	sglr::drawQuad(*getCurrentContext(), program, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(-1.0f + w*2.0f, -1.0f + h*2.0f, 0.0f));
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Read pixels back.
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	readPixels(dst, 0, 0, width, height);
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureSpecCase::readPixels (tcu::Surface& dst, int x, int y, int width, int height)
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	dst.setSize(width, height);
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, dst.getAccess().getDataPtr());
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture2DSpecCase : public TextureSpecCase
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							Texture2DSpecCase	(Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int width, int height, int numLevels);
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							~Texture2DSpecCase	(void);
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			verifyTexture		(sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext);
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureFormat		m_texFormat;
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureFormatInfo	m_texFormatInfo;
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_width;
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_height;
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_numLevels;
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2653c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexture2DSpecCase::Texture2DSpecCase (Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int width, int height, int numLevels)
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TextureSpecCase		(context, name, desc)
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_texFormat			(format)
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_texFormatInfo		(tcu::getTextureFormatInfo(format))
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_width				(width)
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_height				(height)
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_numLevels			(numLevels)
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2753c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexture2DSpecCase::~Texture2DSpecCase (void)
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Texture2DSpecCase::verifyTexture (sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext)
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Texture2DShader shader			(DataTypes() << glu::getSampler2DType(m_texFormat), glu::TYPE_FLOAT_VEC4);
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32		shaderIDgles	= gles3Context.createProgram(&shader);
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32		shaderIDRef		= refContext.createProgram(&shader);
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	shader.setTexScaleBias(0, m_texFormatInfo.lookupScale, m_texFormatInfo.lookupBias);
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Set state.
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int ndx = 0; ndx < 2; ndx++)
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		sglr::Context* ctx = ndx ? static_cast<sglr::Context*>(&refContext) : static_cast<sglr::Context*>(&gles3Context);
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		setContext(ctx);
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,	GL_NEAREST_MIPMAP_NEAREST);
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,	GL_NEAREST);
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,		GL_CLAMP_TO_EDGE);
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,		GL_CLAMP_TO_EDGE);
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL,	m_numLevels-1);
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int levelNdx = 0; levelNdx < m_numLevels; levelNdx++)
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int				levelW		= de::max(1, m_width >> levelNdx);
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int				levelH		= de::max(1, m_height >> levelNdx);
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::Surface	reference;
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::Surface	result;
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < 2; ndx++)
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::Surface&	dst			= ndx ? reference									: result;
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			sglr::Context*	ctx			= ndx ? static_cast<sglr::Context*>(&refContext)	: static_cast<sglr::Context*>(&gles3Context);
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32		shaderID	= ndx ? shaderIDRef									: shaderIDgles;
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			setContext(ctx);
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			shader.setUniforms(*ctx, shaderID);
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			renderTex(dst, shaderID, levelW, levelH);
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UVec4			threshold	= computeCompareThreshold(m_context.getRenderTarget().getPixelFormat(), m_texFormat);
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		string			levelStr	= de::toString(levelNdx);
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		string			name		= string("Level") + levelStr;
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		string			desc		= string("Level ") + levelStr;
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool			isOk		= tcu::intThresholdCompare(m_testCtx.getLog(), name.c_str(), desc.c_str(), reference.getAccess(), result.getAccess(), threshold,
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															   levelNdx == 0 ? tcu::COMPARE_LOG_RESULT : tcu::COMPARE_LOG_ON_ERROR);
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!isOk)
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed");
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			break;
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureCubeSpecCase : public TextureSpecCase
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							TextureCubeSpecCase		(Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int size, int numLevels);
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							~TextureCubeSpecCase	(void);
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			verifyTexture			(sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext);
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureFormat		m_texFormat;
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureFormatInfo	m_texFormatInfo;
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_size;
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_numLevels;
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3493c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureCubeSpecCase::TextureCubeSpecCase (Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int size, int numLevels)
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TextureSpecCase		(context, name, desc)
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_texFormat			(format)
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_texFormatInfo		(tcu::getTextureFormatInfo(format))
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_size				(size)
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_numLevels			(numLevels)
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3583c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureCubeSpecCase::~TextureCubeSpecCase (void)
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureCubeSpecCase::verifyTexture (sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext)
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureCubeShader	shader			(glu::getSamplerCubeType(m_texFormat), glu::TYPE_FLOAT_VEC4);
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			shaderIDgles	= gles3Context.createProgram(&shader);
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			shaderIDRef		= refContext.createProgram(&shader);
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	shader.setTexScaleBias(m_texFormatInfo.lookupScale, m_texFormatInfo.lookupBias);
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Set state.
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int ndx = 0; ndx < 2; ndx++)
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		sglr::Context* ctx = ndx ? static_cast<sglr::Context*>(&refContext) : static_cast<sglr::Context*>(&gles3Context);
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		setContext(ctx);
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER,	GL_NEAREST_MIPMAP_NEAREST);
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER,	GL_NEAREST);
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S,		GL_CLAMP_TO_EDGE);
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T,		GL_CLAMP_TO_EDGE);
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL,	m_numLevels-1);
3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int levelNdx = 0; levelNdx < m_numLevels; levelNdx++)
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int		levelSize	= de::max(1, m_size >> levelNdx);
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool	isOk		= true;
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::Surface	reference;
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::Surface	result;
3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (levelSize <= 2)
3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				continue; // Fuzzy compare doesn't work for images this small.
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			shader.setFace((tcu::CubeFace)face);
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int ndx = 0; ndx < 2; ndx++)
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				tcu::Surface&	dst			= ndx ? reference									: result;
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				sglr::Context*	ctx			= ndx ? static_cast<sglr::Context*>(&refContext)	: static_cast<sglr::Context*>(&gles3Context);
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				deUint32		shaderID	= ndx ? shaderIDRef									: shaderIDgles;
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				setContext(ctx);
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				shader.setUniforms(*ctx, shaderID);
4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				renderTex(dst, shaderID, levelSize, levelSize);
4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const float		threshold	= 0.02f;
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			string			faceStr		= de::toString((tcu::CubeFace)face);
4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			string			levelStr	= de::toString(levelNdx);
4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			string			name		= string("Level") + levelStr;
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			string			desc		= string("Level ") + levelStr + ", face " + faceStr;
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			bool			isFaceOk	= tcu::fuzzyCompare(m_testCtx.getLog(), name.c_str(), desc.c_str(), reference, result, threshold,
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															levelNdx == 0 ? tcu::COMPARE_LOG_RESULT : tcu::COMPARE_LOG_ON_ERROR);
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (!isFaceOk)
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed");
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				isOk = false;
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				break;
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!isOk)
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			break;
4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture2DArraySpecCase : public TextureSpecCase
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							Texture2DArraySpecCase	(Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int width, int height, int numLayers, int numLevels);
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							~Texture2DArraySpecCase	(void);
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			verifyTexture			(sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext);
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureFormat		m_texFormat;
4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureFormatInfo	m_texFormatInfo;
4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_width;
4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_height;
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_numLayers;
4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_numLevels;
4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4483c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexture2DArraySpecCase::Texture2DArraySpecCase (Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int width, int height, int numLayers, int numLevels)
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TextureSpecCase		(context, name, desc)
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_texFormat			(format)
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_texFormatInfo		(tcu::getTextureFormatInfo(format))
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_width				(width)
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_height				(height)
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_numLayers			(numLayers)
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_numLevels			(numLevels)
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4593c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexture2DArraySpecCase::~Texture2DArraySpecCase (void)
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Texture2DArraySpecCase::verifyTexture (sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext)
4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Texture2DArrayShader	shader			(glu::getSampler2DArrayType(m_texFormat), glu::TYPE_FLOAT_VEC4);
4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				shaderIDgles	= gles3Context.createProgram(&shader);
4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				shaderIDRef		= refContext.createProgram(&shader);
4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	shader.setTexScaleBias(m_texFormatInfo.lookupScale, m_texFormatInfo.lookupBias);
4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Set state.
4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int ndx = 0; ndx < 2; ndx++)
4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		sglr::Context* ctx = ndx ? static_cast<sglr::Context*>(&refContext) : static_cast<sglr::Context*>(&gles3Context);
4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		setContext(ctx);
4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER,	GL_NEAREST_MIPMAP_NEAREST);
4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER,	GL_NEAREST);
4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S,		GL_CLAMP_TO_EDGE);
4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T,		GL_CLAMP_TO_EDGE);
4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_R,		GL_CLAMP_TO_EDGE);
4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LEVEL,	m_numLevels-1);
4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int layerNdx = 0; layerNdx < m_numLayers; layerNdx++)
4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool layerOk = true;
4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		shader.setLayer(layerNdx);
4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int levelNdx = 0; levelNdx < m_numLevels; levelNdx++)
4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int				levelW		= de::max(1, m_width	>> levelNdx);
4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int				levelH		= de::max(1, m_height	>> levelNdx);
4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::Surface	reference;
4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::Surface	result;
4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int ndx = 0; ndx < 2; ndx++)
5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				tcu::Surface&	dst			= ndx ? reference									: result;
5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				sglr::Context*	ctx			= ndx ? static_cast<sglr::Context*>(&refContext)	: static_cast<sglr::Context*>(&gles3Context);
5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				deUint32		shaderID	= ndx ? shaderIDRef									: shaderIDgles;
5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				setContext(ctx);
5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				shader.setUniforms(*ctx, shaderID);
5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				renderTex(dst, shaderID, levelW, levelH);
5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			UVec4			threshold	= computeCompareThreshold(m_context.getRenderTarget().getPixelFormat(), m_texFormat);
5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			string			levelStr	= de::toString(levelNdx);
5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			string			layerStr	= de::toString(layerNdx);
5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			string			name		= string("Layer") + layerStr + "Level" + levelStr;
5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			string			desc		= string("Layer ") + layerStr + ", Level " + levelStr;
5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			bool			depthOk		= tcu::intThresholdCompare(m_testCtx.getLog(), name.c_str(), desc.c_str(), reference.getAccess(), result.getAccess(), threshold,
5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																   (levelNdx == 0 && layerNdx == 0) ? tcu::COMPARE_LOG_RESULT : tcu::COMPARE_LOG_ON_ERROR);
5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (!depthOk)
5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed");
5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				layerOk = false;
5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				break;
5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!layerOk)
5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			break;
5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture3DSpecCase : public TextureSpecCase
5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							Texture3DSpecCase	(Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int width, int height, int depth, int numLevels);
5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							~Texture3DSpecCase	(void);
5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			verifyTexture		(sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext);
5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureFormat		m_texFormat;
5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureFormatInfo	m_texFormatInfo;
5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_width;
5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_height;
5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_depth;
5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_numLevels;
5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5483c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexture3DSpecCase::Texture3DSpecCase (Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int width, int height, int depth, int numLevels)
5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TextureSpecCase		(context, name, desc)
5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_texFormat			(format)
5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_texFormatInfo		(tcu::getTextureFormatInfo(format))
5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_width				(width)
5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_height				(height)
5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_depth				(depth)
5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_numLevels			(numLevels)
5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5593c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexture3DSpecCase::~Texture3DSpecCase (void)
5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Texture3DSpecCase::verifyTexture (sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext)
5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Texture3DShader shader			(glu::getSampler3DType(m_texFormat), glu::TYPE_FLOAT_VEC4);
5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32		shaderIDgles	= gles3Context.createProgram(&shader);
5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32		shaderIDRef		= refContext.createProgram(&shader);
5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	shader.setTexScaleBias(m_texFormatInfo.lookupScale, m_texFormatInfo.lookupBias);
5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Set state.
5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int ndx = 0; ndx < 2; ndx++)
5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		sglr::Context* ctx = ndx ? static_cast<sglr::Context*>(&refContext) : static_cast<sglr::Context*>(&gles3Context);
5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		setContext(ctx);
5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER,	GL_NEAREST_MIPMAP_NEAREST);
5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER,	GL_NEAREST);
5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S,		GL_CLAMP_TO_EDGE);
5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T,		GL_CLAMP_TO_EDGE);
5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R,		GL_CLAMP_TO_EDGE);
5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_LEVEL,	m_numLevels-1);
5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int levelNdx = 0; levelNdx < m_numLevels; levelNdx++)
5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int		levelW		= de::max(1, m_width	>> levelNdx);
5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int		levelH		= de::max(1, m_height	>> levelNdx);
5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int		levelD		= de::max(1, m_depth	>> levelNdx);
5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool	levelOk		= true;
5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int depth = 0; depth < levelD; depth++)
5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::Surface	reference;
5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::Surface	result;
5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			shader.setDepth(((float)depth + 0.5f) / (float)levelD);
5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int ndx = 0; ndx < 2; ndx++)
6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				tcu::Surface&	dst			= ndx ? reference									: result;
6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				sglr::Context*	ctx			= ndx ? static_cast<sglr::Context*>(&refContext)	: static_cast<sglr::Context*>(&gles3Context);
6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				deUint32		shaderID	= ndx ? shaderIDRef									: shaderIDgles;
6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				setContext(ctx);
6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				shader.setUniforms(*ctx, shaderID);
6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				renderTex(dst, shaderID, levelW, levelH);
6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			UVec4			threshold	= computeCompareThreshold(m_context.getRenderTarget().getPixelFormat(), m_texFormat);
6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			string			levelStr	= de::toString(levelNdx);
6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			string			sliceStr	= de::toString(depth);
6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			string			name		= string("Level") + levelStr + "Slice" + sliceStr;
6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			string			desc		= string("Level ") + levelStr + ", Slice " + sliceStr;
6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			bool			depthOk		= tcu::intThresholdCompare(m_testCtx.getLog(), name.c_str(), desc.c_str(), reference.getAccess(), result.getAccess(), threshold,
6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																   (levelNdx == 0 && depth == 0) ? tcu::COMPARE_LOG_RESULT : tcu::COMPARE_LOG_ON_ERROR);
6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (!depthOk)
6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed");
6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				levelOk = false;
6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				break;
6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!levelOk)
6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			break;
6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Basic TexImage2D() with 2D texture usage
6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicTexImage2DCase : public Texture2DSpecCase
6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Unsized internal format.
6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicTexImage2DCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int width, int height)
6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DSpecCase	(context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height, maxLevelCount(width, height))
6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(format)
6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(format)
6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(dataType)
6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Sized internal format.
6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicTexImage2DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height)
6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, maxLevelCount(width, height))
6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(internalFormat)
6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(GL_NONE)
6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(GL_NONE)
6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_format	= fmt.format;
6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_dataType	= fmt.dataType;
6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel	levelData	(m_texFormat);
6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random			rnd			(deStringHash(getName()));
6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D, tex);
6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMin		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMax		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levelData.setSize(levelW, levelH);
6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, levelW, levelH, 0, m_format, m_dataType, levelData.getAccess().getDataPtr());
6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Basic TexImage2D() with cubemap usage
6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicTexImageCubeCase : public TextureCubeSpecCase
6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Unsized formats.
6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicTexImageCubeCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int size)
6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCubeSpecCase	(context, name, desc, glu::mapGLTransferFormat(format, dataType), size, deLog2Floor32(size)+1)
6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat		(format)
6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format				(format)
6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType			(dataType)
6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Sized internal formats.
7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicTexImageCubeCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size)
7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCubeSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), size, deLog2Floor32(size)+1)
7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat		(internalFormat)
7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format				(GL_NONE)
7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType			(GL_NONE)
7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_format	= fmt.format;
7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_dataType	= fmt.dataType;
7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel	levelData	(m_texFormat);
7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random			rnd			(deStringHash(getName()));
7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int levelSize = de::max(1, m_size >> ndx);
7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levelData.setSize(levelSize, levelSize);
7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glTexImage2D(s_cubeMapFaces[face], ndx, m_internalFormat, levelSize, levelSize, 0, m_format, m_dataType, levelData.getAccess().getDataPtr());
7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Basic TexImage3D() with 2D array texture usage
7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicTexImage2DArrayCase : public Texture2DArraySpecCase
7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicTexImage2DArrayCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int numLayers)
7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DArraySpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, numLayers, maxLevelCount(width, height))
7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat			(internalFormat)
7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				tex			= 0;
7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel		levelData	(m_texFormat);
7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random				rnd			(deStringHash(getName()));
7623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat		transferFmt	= glu::getTransferFormat(m_texFormat);
7633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
7673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
7693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
7703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width	>> ndx);
7713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height	>> ndx);
7723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMin		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
7733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMax		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
7743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levelData.setSize(levelW, levelH, m_numLayers);
7763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
7773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage3D(GL_TEXTURE_2D_ARRAY, ndx, m_internalFormat, levelW, levelH, m_numLayers, 0, transferFmt.format, transferFmt.dataType, levelData.getAccess().getDataPtr());
7793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
7803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 m_internalFormat;
7833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
7843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Basic TexImage3D() with 3D texture usage
7863c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicTexImage3DCase : public Texture3DSpecCase
7873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7883c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
7893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicTexImage3DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int depth)
7903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture3DSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, maxLevelCount(width, height, depth))
7913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(internalFormat)
7923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7953c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
7963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
7973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				tex			= 0;
7993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel		levelData	(m_texFormat);
8003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random				rnd			(deStringHash(getName()));
8013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat		transferFmt	= glu::getTransferFormat(m_texFormat);
8023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
8043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_3D, tex);
8053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
8063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
8083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
8093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width	>> ndx);
8103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height	>> ndx);
8113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelD		= de::max(1, m_depth	>> ndx);
8123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMin		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
8133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMax		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
8143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levelData.setSize(levelW, levelH, levelD);
8163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
8173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage3D(GL_TEXTURE_3D, ndx, m_internalFormat, levelW, levelH, levelD, 0, transferFmt.format, transferFmt.dataType, levelData.getAccess().getDataPtr());
8193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
8203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 m_internalFormat;
8233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
8243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Randomized 2D texture specification using TexImage2D
8263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RandomOrderTexImage2DCase : public Texture2DSpecCase
8273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8283c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
8293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	RandomOrderTexImage2DCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int width, int height)
8303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DSpecCase	(context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height, maxLevelCount(width, height))
8313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(format)
8323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(format)
8333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(dataType)
8343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	RandomOrderTexImage2DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height)
8383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, maxLevelCount(width, height))
8393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(internalFormat)
8403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(GL_NONE)
8413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(GL_NONE)
8423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
8443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_format	= fmt.format;
8453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_dataType	= fmt.dataType;
8463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
8493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
8503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
8523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel	levelData	(m_texFormat);
8533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random			rnd			(deStringHash(getName()));
8543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
8563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D, tex);
8573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
8583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<int>			levels		(m_numLevels);
8603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int i = 0; i < m_numLevels; i++)
8623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levels[i] = i;
8633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		rnd.shuffle(levels.begin(), levels.end());
8643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
8663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
8673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelNdx	= levels[ndx];
8683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width	>> levelNdx);
8693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height	>> levelNdx);
8703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMin		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
8713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMax		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
8723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levelData.setSize(levelW, levelH);
8743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
8753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage2D(GL_TEXTURE_2D, levelNdx, m_internalFormat, levelW, levelH, 0, m_format, m_dataType, levelData.getAccess().getDataPtr());
8773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
8783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
8813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
8823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
8833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
8843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Randomized cubemap texture specification using TexImage2D
8863c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RandomOrderTexImageCubeCase : public TextureCubeSpecCase
8873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8883c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
8893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	RandomOrderTexImageCubeCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int size)
8903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCubeSpecCase	(context, name, desc, glu::mapGLTransferFormat(format, dataType), size, deLog2Floor32(size)+1)
8913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat		(GL_NONE)
8923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format				(format)
8933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType			(dataType)
8943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	RandomOrderTexImageCubeCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size)
8983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCubeSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), size, deLog2Floor32(size)+1)
8993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat		(internalFormat)
9003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format				(GL_NONE)
9013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType			(GL_NONE)
9023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
9043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_format	= fmt.format;
9053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_dataType	= fmt.dataType;
9063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9083c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
9093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
9103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
9123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel	levelData	(m_texFormat);
9133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random			rnd			(deStringHash(getName()));
9143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
9163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
9173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
9183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Level-face pairs.
9203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<pair<int, tcu::CubeFace> >	images	(m_numLevels*6);
9213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
9233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
9243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				images[ndx*6 + face] = std::make_pair(ndx, (tcu::CubeFace)face);
9253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		rnd.shuffle(images.begin(), images.end());
9273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < (int)images.size(); ndx++)
9293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
9303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int				levelNdx	= images[ndx].first;
9313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::CubeFace	face		= images[ndx].second;
9323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int				levelSize	= de::max(1, m_size >> levelNdx);
9333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4			gMin		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
9343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4			gMax		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
9353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levelData.setSize(levelSize, levelSize);
9373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
9383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage2D(s_cubeMapFaces[face], levelNdx, m_internalFormat, levelSize, levelSize, 0, m_format, m_dataType, levelData.getAccess().getDataPtr());
9403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
9413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
9443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
9453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
9463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
9473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexImage2D() unpack alignment case.
9493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexImage2DAlignCase : public Texture2DSpecCase
9503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9513c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
9523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexImage2DAlignCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int width, int height, int numLevels, int alignment)
9533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DSpecCase	(context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height, numLevels)
9543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(format)
9553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(format)
9563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(dataType)
9573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment		(alignment)
9583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexImage2DAlignCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int numLevels, int alignment)
9623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, numLevels)
9633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(internalFormat)
9643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(GL_NONE)
9653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(GL_NONE)
9663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment		(alignment)
9673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
9693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_format	= fmt.format;
9703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_dataType	= fmt.dataType;
9713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9733c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
9743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
9753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
9773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<deUint8>		data;
9783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
9803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D, tex);
9813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
9823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
9843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
9853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
9863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
9873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorA		= Vec4(1.0f, 0.0f, 0.0f, 1.0f)*(m_texFormatInfo.valueMax-m_texFormatInfo.valueMin) + m_texFormatInfo.valueMin;
9883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorB		= Vec4(0.0f, 1.0f, 0.0f, 1.0f)*(m_texFormatInfo.valueMax-m_texFormatInfo.valueMin) + m_texFormatInfo.valueMin;
9893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		rowPitch	= deAlign32(levelW*m_texFormat.getPixelSize(), m_alignment);
9903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		cellSize	= de::max(1, de::min(levelW >> 2, levelH >> 2));
9913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.resize(rowPitch*levelH);
9933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, levelW, levelH, 1, rowPitch, 0, &data[0]), cellSize, colorA, colorB);
9943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, levelW, levelH, 0, m_format, m_dataType, &data[0]);
9963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
9973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
10003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
10013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
10023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_alignment;
10033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
10043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexImage2D() unpack alignment case.
10063c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexImageCubeAlignCase : public TextureCubeSpecCase
10073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10083c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
10093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexImageCubeAlignCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int size, int numLevels, int alignment)
10103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCubeSpecCase	(context, name, desc, glu::mapGLTransferFormat(format, dataType), size, numLevels)
10113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat		(format)
10123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format				(format)
10133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType			(dataType)
10143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment			(alignment)
10153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
10173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexImageCubeAlignCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size, int numLevels, int alignment)
10193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCubeSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), size, numLevels)
10203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat		(internalFormat)
10213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format				(GL_NONE)
10223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType			(GL_NONE)
10233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment			(alignment)
10243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
10263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_format	= fmt.format;
10273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_dataType	= fmt.dataType;
10283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
10293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10303c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
10313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
10323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
10343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<deUint8>		data;
10353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
10373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
10383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
10393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
10413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
10423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelSize	= de::max(1, m_size >> ndx);
10433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		rowPitch	= deAlign32(m_texFormat.getPixelSize()*levelSize, m_alignment);
10443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorA		= Vec4(1.0f, 0.0f, 0.0f, 1.0f)*(m_texFormatInfo.valueMax-m_texFormatInfo.valueMin) + m_texFormatInfo.valueMin;
10453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorB		= Vec4(0.0f, 1.0f, 0.0f, 1.0f)*(m_texFormatInfo.valueMax-m_texFormatInfo.valueMin) + m_texFormatInfo.valueMin;
10463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		cellSize	= de::max(1, levelSize >> 2);
10473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.resize(rowPitch*levelSize);
10493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, levelSize, levelSize, 1, rowPitch, 0, &data[0]), cellSize, colorA, colorB);
10503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
10523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glTexImage2D(s_cubeMapFaces[face], ndx, m_internalFormat, levelSize, levelSize, 0, m_format, m_dataType, &data[0]);
10533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
10543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
10553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
10573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
10583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
10593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_alignment;
10603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
10613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexImage2D() unpack parameters case.
10633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexImage2DParamsCase : public Texture2DSpecCase
10643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10653c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
10663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexImage2DParamsCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int rowLength, int skipRows, int skipPixels, int alignment)
10673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, 1)
10683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(internalFormat)
10693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_rowLength		(rowLength)
10703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipRows		(skipRows)
10713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipPixels		(skipPixels)
10723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment		(alignment)
10733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
10753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10763c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
10773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
10783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat		transferFmt		= glu::getTransferFormat(m_texFormat);
10803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						pixelSize		= m_texFormat.getPixelSize();
10813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						rowLength		= m_rowLength > 0 ? m_rowLength : m_width;
10823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						rowPitch		= deAlign32(rowLength*pixelSize, m_alignment);
10833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						height			= m_height + m_skipRows;
10843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				tex				= 0;
10853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<deUint8>			data;
10863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_numLevels == 1);
10883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill data with grid.
10903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		data.resize(rowPitch*height);
10913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
10923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cScale		= m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
10933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cBias		= m_texFormatInfo.valueMin;
10943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorA		= Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias;
10953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorB		= Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias;
10963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, 1, rowPitch, 0, &data[0] + m_skipRows*rowPitch + m_skipPixels*pixelSize), 4, colorA, colorB);
10983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
10993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ROW_LENGTH,		m_rowLength);
11013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_ROWS,		m_skipRows);
11023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_PIXELS,	m_skipPixels);
11033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT,		m_alignment);
11043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
11063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D, tex);
11073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexImage2D(GL_TEXTURE_2D, 0, m_internalFormat, m_width, m_height, 0, transferFmt.format, transferFmt.dataType, &data[0]);
11083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
11093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
11113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_rowLength;
11123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipRows;
11133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipPixels;
11143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_alignment;
11153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
11163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexImage3D() unpack parameters case.
11183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexImage3DParamsCase : public Texture3DSpecCase
11193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
11203c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
11213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexImage3DParamsCase (Context&		context,
11223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						   const char*	name,
11233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						   const char*	desc,
11243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						   deUint32		internalFormat,
11253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						   int			width,
11263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						   int			height,
11273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						   int			depth,
11283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						   int			imageHeight,
11293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						   int			rowLength,
11303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						   int			skipImages,
11313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						   int			skipRows,
11323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						   int			skipPixels,
11333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						   int			alignment)
11343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture3DSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, 1)
11353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(internalFormat)
11363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_imageHeight		(imageHeight)
11373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_rowLength		(rowLength)
11383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipImages		(skipImages)
11393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipRows		(skipRows)
11403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipPixels		(skipPixels)
11413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment		(alignment)
11423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
11433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
11443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
11463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
11473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
11483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat		transferFmt		= glu::getTransferFormat(m_texFormat);
11493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						pixelSize		= m_texFormat.getPixelSize();
11503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						rowLength		= m_rowLength > 0 ? m_rowLength : m_width;
11513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						rowPitch		= deAlign32(rowLength*pixelSize, m_alignment);
11523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						imageHeight		= m_imageHeight > 0 ? m_imageHeight : m_height;
11533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						slicePitch		= imageHeight*rowPitch;
11543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				tex				= 0;
11553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<deUint8>			data;
11563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_numLevels == 1);
11583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill data with grid.
11603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		data.resize(slicePitch*(m_depth+m_skipImages));
11613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
11623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cScale		= m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
11633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cBias		= m_texFormatInfo.valueMin;
11643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorA		= Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias;
11653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorB		= Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias;
11663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, m_depth, rowPitch, slicePitch, &data[0] + m_skipImages*slicePitch + m_skipRows*rowPitch + m_skipPixels*pixelSize), 4, colorA, colorB);
11683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
11693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_IMAGE_HEIGHT,	m_imageHeight);
11713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ROW_LENGTH,		m_rowLength);
11723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_IMAGES,	m_skipImages);
11733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_ROWS,		m_skipRows);
11743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_PIXELS,	m_skipPixels);
11753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT,		m_alignment);
11763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
11783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_3D, tex);
11793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexImage3D(GL_TEXTURE_3D, 0, m_internalFormat, m_width, m_height, m_depth, 0, transferFmt.format, transferFmt.dataType, &data[0]);
11803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
11813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
11833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_imageHeight;
11843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_rowLength;
11853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipImages;
11863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipRows;
11873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipPixels;
11883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_alignment;
11893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
11903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Basic TexSubImage2D() with 2D texture usage
11923c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicTexSubImage2DCase : public Texture2DSpecCase
11933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
11943c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
11953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicTexSubImage2DCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int width, int height)
11963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DSpecCase	(context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height, maxLevelCount(width, height))
11973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(format)
11983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(format)
11993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(dataType)
12003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
12013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
12023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicTexSubImage2DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height)
12043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, maxLevelCount(width, height))
12053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(internalFormat)
12063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(GL_NONE)
12073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(GL_NONE)
12083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
12093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
12103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_format	= fmt.format;
12113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_dataType	= fmt.dataType;
12123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
12133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12143c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
12153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
12163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
12173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
12183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel	data		(m_texFormat);
12193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random			rnd			(deStringHash(getName()));
12203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
12223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D, tex);
12233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
12243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// First specify full texture.
12263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
12273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
12283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
12293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
12303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMin		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
12313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMax		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
12323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.setSize(levelW, levelH);
12343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
12353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, levelW, levelH, 0, m_format, m_dataType, data.getAccess().getDataPtr());
12373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
12383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Re-specify parts of each level.
12403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
12413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
12423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
12433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
12443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		w			= rnd.getInt(1, levelW);
12463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		h			= rnd.getInt(1, levelH);
12473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		x			= rnd.getInt(0, levelW-w);
12483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		y			= rnd.getInt(0, levelH-h);
12493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorA		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
12513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorB		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
12523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		cellSize	= rnd.getInt(2, 16);
12533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.setSize(w, h);
12553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
12563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexSubImage2D(GL_TEXTURE_2D, ndx, x, y, w, h, m_format, m_dataType, data.getAccess().getDataPtr());
12583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
12593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
12603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
12623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
12633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
12643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
12653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Basic TexSubImage2D() with cubemap usage
12673c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicTexSubImageCubeCase : public TextureCubeSpecCase
12683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
12693c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
12703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicTexSubImageCubeCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int size)
12713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCubeSpecCase	(context, name, desc, glu::mapGLTransferFormat(format, dataType), size, deLog2Floor32(size)+1)
12723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat		(format)
12733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format				(format)
12743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType			(dataType)
12753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
12763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
12773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicTexSubImageCubeCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size)
12793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCubeSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), size, deLog2Floor32(size)+1)
12803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat		(internalFormat)
12813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format				(GL_NONE)
12823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType			(GL_NONE)
12833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
12843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
12853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_format	= fmt.format;
12863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_dataType	= fmt.dataType;
12873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
12883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12893c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
12903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
12913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
12923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
12933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel	data		(m_texFormat);
12943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random			rnd			(deStringHash(getName()));
12953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
12973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
12983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
12993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
13013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
13023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int levelSize = de::max(1, m_size >> ndx);
13033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.setSize(levelSize, levelSize);
13053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
13073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
13083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
13093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
13103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
13123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glTexImage2D(s_cubeMapFaces[face], ndx, m_internalFormat, levelSize, levelSize, 0, m_format, m_dataType, data.getAccess().getDataPtr());
13143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
13153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
13163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Re-specify parts of each face and level.
13183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
13193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
13203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int levelSize = de::max(1, m_size >> ndx);
13213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
13233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
13243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int		w			= rnd.getInt(1, levelSize);
13253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int		h			= rnd.getInt(1, levelSize);
13263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int		x			= rnd.getInt(0, levelSize-w);
13273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int		y			= rnd.getInt(0, levelSize-h);
13283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				Vec4	colorA		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
13303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				Vec4	colorB		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
13313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int		cellSize	= rnd.getInt(2, 16);
13323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				data.setSize(w, h);
13343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
13353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glTexSubImage2D(s_cubeMapFaces[face], ndx, x, y, w, h, m_format, m_dataType, data.getAccess().getDataPtr());
13373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
13383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
13393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
13403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
13423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
13433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
13443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
13453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexSubImage2D() unpack parameters case.
13473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexSubImage2DParamsCase : public Texture2DSpecCase
13483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
13493c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
13503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexSubImage2DParamsCase (Context&		context,
13513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 const char*	name,
13523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 const char*	desc,
13533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 deUint32		internalFormat,
13543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			width,
13553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			height,
13563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			subX,
13573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			subY,
13583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			subW,
13593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			subH,
13603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			rowLength,
13613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			skipRows,
13623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			skipPixels,
13633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			alignment)
13643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, 1)
13653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(internalFormat)
13663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subX			(subX)
13673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subY			(subY)
13683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subW			(subW)
13693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subH			(subH)
13703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_rowLength		(rowLength)
13713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipRows		(skipRows)
13723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipPixels		(skipPixels)
13733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment		(alignment)
13743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
13753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
13763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13773c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
13783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
13793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
13803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat		transferFmt		= glu::getTransferFormat(m_texFormat);
13813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						pixelSize		= m_texFormat.getPixelSize();
13823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				tex				= 0;
13833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<deUint8>			data;
13843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_numLevels == 1);
13863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
13883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D, tex);
13893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// First fill texture with gradient.
13913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		data.resize(deAlign32(m_width*pixelSize, 4)*m_height);
13923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, 1, deAlign32(m_width*pixelSize, 4), 0, &data[0]), m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
13933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexImage2D(GL_TEXTURE_2D, 0, m_internalFormat, m_width, m_height, 0, transferFmt.format, transferFmt.dataType, &data[0]);
13943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill data with grid.
13963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
13973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		rowLength	= m_rowLength > 0 ? m_rowLength : m_subW;
13983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		rowPitch	= deAlign32(rowLength*pixelSize, m_alignment);
13993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		height		= m_subH + m_skipRows;
14003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cScale		= m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
14013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cBias		= m_texFormatInfo.valueMin;
14023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorA		= Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias;
14033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorB		= Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias;
14043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.resize(rowPitch*height);
14063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_subW, m_subH, 1, rowPitch, 0, &data[0] + m_skipRows*rowPitch + m_skipPixels*pixelSize), 4, colorA, colorB);
14073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
14083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ROW_LENGTH,		m_rowLength);
14103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_ROWS,		m_skipRows);
14113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_PIXELS,	m_skipPixels);
14123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT,		m_alignment);
14133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexSubImage2D(GL_TEXTURE_2D, 0, m_subX, m_subY, m_subW, m_subH, transferFmt.format, transferFmt.dataType, &data[0]);
14143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
14153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
14173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subX;
14183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subY;
14193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subW;
14203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subH;
14213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_rowLength;
14223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipRows;
14233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipPixels;
14243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_alignment;
14253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
14263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Basic TexSubImage3D() with 3D texture usage
14283c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicTexSubImage3DCase : public Texture3DSpecCase
14293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
14303c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
14313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicTexSubImage3DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int depth)
14323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture3DSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, maxLevelCount(width, height, depth))
14333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(internalFormat)
14343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
14353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
14363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14373c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
14383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
14393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
14403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				tex				= 0;
14413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel		data			(m_texFormat);
14423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random				rnd				(deStringHash(getName()));
14433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat		transferFmt		= glu::getTransferFormat(m_texFormat);
14443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
14463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_3D, tex);
14473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
14483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// First specify full texture.
14503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
14513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
14523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
14533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
14543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelD		= de::max(1, m_depth >> ndx);
14553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMin		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
14563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMax		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
14573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.setSize(levelW, levelH, levelD);
14593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
14603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage3D(GL_TEXTURE_3D, ndx, m_internalFormat, levelW, levelH, levelD, 0, transferFmt.format, transferFmt.dataType, data.getAccess().getDataPtr());
14623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
14633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Re-specify parts of each level.
14653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
14663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
14673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
14683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
14693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelD		= de::max(1, m_depth >> ndx);
14703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		w			= rnd.getInt(1, levelW);
14723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		h			= rnd.getInt(1, levelH);
14733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		d			= rnd.getInt(1, levelD);
14743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		x			= rnd.getInt(0, levelW-w);
14753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		y			= rnd.getInt(0, levelH-h);
14763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		z			= rnd.getInt(0, levelD-d);
14773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorA		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
14793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorB		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
14803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		cellSize	= rnd.getInt(2, 16);
14813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.setSize(w, h, d);
14833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
14843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexSubImage3D(GL_TEXTURE_3D, ndx, x, y, z, w, h, d, transferFmt.format, transferFmt.dataType, data.getAccess().getDataPtr());
14863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
14873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
14883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 m_internalFormat;
14903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
14913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexSubImage2D() to texture initialized with empty data
14933c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexSubImage2DEmptyTexCase : public Texture2DSpecCase
14943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
14953c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
14963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexSubImage2DEmptyTexCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int width, int height)
14973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DSpecCase	(context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height, maxLevelCount(width, height))
14983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(format)
14993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(format)
15003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(dataType)
15013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
15023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
15033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexSubImage2DEmptyTexCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height)
15053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, maxLevelCount(width, height))
15063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(internalFormat)
15073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(GL_NONE)
15083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(GL_NONE)
15093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
15103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
15113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_format	= fmt.format;
15123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_dataType	= fmt.dataType;
15133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
15143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15153c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
15163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
15173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
15183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
15193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel	data		(m_texFormat);
15203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random			rnd			(deStringHash(getName()));
15213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
15233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D, tex);
15243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
15253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// First allocate storage for each level.
15273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
15283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
15293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
15303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
15313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, levelW, levelH, 0, m_format, m_dataType, DE_NULL);
15333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
15343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Specify pixel data to all levels using glTexSubImage2D()
15363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
15373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
15383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
15393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
15403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMin		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
15413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMax		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
15423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.setSize(levelW, levelH);
15443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
15453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexSubImage2D(GL_TEXTURE_2D, ndx, 0, 0, levelW, levelH, m_format, m_dataType, data.getAccess().getDataPtr());
15473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
15483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
15493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
15513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
15523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
15533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
15543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexSubImage2D() to empty cubemap texture
15563c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexSubImageCubeEmptyTexCase : public TextureCubeSpecCase
15573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
15583c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
15593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexSubImageCubeEmptyTexCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int size)
15603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCubeSpecCase	(context, name, desc, glu::mapGLTransferFormat(format, dataType), size, deLog2Floor32(size)+1)
15613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat		(format)
15623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format				(format)
15633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType			(dataType)
15643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
15653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
15663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexSubImageCubeEmptyTexCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size)
15683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCubeSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), size, deLog2Floor32(size)+1)
15693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat		(internalFormat)
15703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format				(GL_NONE)
15713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType			(GL_NONE)
15723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
15733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
15743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_format	= fmt.format;
15753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_dataType	= fmt.dataType;
15763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
15773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15783c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
15793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
15803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
15813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
15823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel	data		(m_texFormat);
15833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random			rnd			(deStringHash(getName()));
15843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
15863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
15873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
15883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Specify storage for each level.
15903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
15913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
15923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int levelSize = de::max(1, m_size >> ndx);
15933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
15953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glTexImage2D(s_cubeMapFaces[face], ndx, m_internalFormat, levelSize, levelSize, 0, m_format, m_dataType, DE_NULL);
15963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
15973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Specify data using glTexSubImage2D()
15993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
16003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
16013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int levelSize = de::max(1, m_size >> ndx);
16023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.setSize(levelSize, levelSize);
16043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
16063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
16073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
16083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
16093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
16113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glTexSubImage2D(s_cubeMapFaces[face], ndx, 0, 0, levelSize, levelSize, m_format, m_dataType, data.getAccess().getDataPtr());
16133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
16143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
16153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
16163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
16183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
16193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
16203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
16213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexSubImage2D() unpack alignment with 2D texture
16233c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexSubImage2DAlignCase : public Texture2DSpecCase
16243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
16253c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
16263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexSubImage2DAlignCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int width, int height, int subX, int subY, int subW, int subH, int alignment)
16273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DSpecCase	(context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height, 1)
16283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(format)
16293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(format)
16303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(dataType)
16313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subX			(subX)
16323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subY			(subY)
16333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subW			(subW)
16343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subH			(subH)
16353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment		(alignment)
16363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
16373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
16383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexSubImage2DAlignCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int subX, int subY, int subW, int subH, int alignment)
16403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, 1)
16413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(internalFormat)
16423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(GL_NONE)
16433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(GL_NONE)
16443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subX			(subX)
16453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subY			(subY)
16463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subW			(subW)
16473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subH			(subH)
16483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment		(alignment)
16493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
16503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
16513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_format	= fmt.format;
16523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_dataType	= fmt.dataType;
16533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
16543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
16563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
16573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
16583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
16593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<deUint8>		data;
16603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
16623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D, tex);
16633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Specify base level.
16653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		data.resize(m_texFormat.getPixelSize()*m_width*m_height);
16663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, 1, &data[0]), Vec4(0.0f), Vec4(1.0f));
16673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
16693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexImage2D(GL_TEXTURE_2D, 0, m_internalFormat, m_width, m_height, 0, m_format, m_dataType, &data[0]);
16703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Re-specify subrectangle.
16723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int rowPitch = deAlign32(m_texFormat.getPixelSize()*m_subW, m_alignment);
16733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		data.resize(rowPitch*m_subH);
16743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_subW, m_subH, 1, rowPitch, 0, &data[0]), 4, Vec4(1.0f, 0.0f, 0.0f, 1.0f), Vec4(0.0f, 1.0f, 0.0f, 1.0f));
16753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
16773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexSubImage2D(GL_TEXTURE_2D, 0, m_subX, m_subY, m_subW, m_subH, m_format, m_dataType, &data[0]);
16783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
16793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
16813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
16823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
16833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subX;
16843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subY;
16853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subW;
16863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subH;
16873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_alignment;
16883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
16893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexSubImage2D() unpack alignment with cubemap texture
16913c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexSubImageCubeAlignCase : public TextureCubeSpecCase
16923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
16933c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
16943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexSubImageCubeAlignCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int size, int subX, int subY, int subW, int subH, int alignment)
16953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCubeSpecCase	(context, name, desc, glu::mapGLTransferFormat(format, dataType), size, 1)
16963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat		(format)
16973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format				(format)
16983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType			(dataType)
16993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subX				(subX)
17003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subY				(subY)
17013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subW				(subW)
17023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subH				(subH)
17033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment			(alignment)
17043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
17053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
17063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexSubImageCubeAlignCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size, int subX, int subY, int subW, int subH, int alignment)
17083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCubeSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), size, 1)
17093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat		(internalFormat)
17103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format				(GL_NONE)
17113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType			(GL_NONE)
17123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subX				(subX)
17133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subY				(subY)
17143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subW				(subW)
17153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subH				(subH)
17163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment			(alignment)
17173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
17183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
17193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_format	= fmt.format;
17203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_dataType	= fmt.dataType;
17213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
17223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17233c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
17243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
17253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
17263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
17273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<deUint8>		data;
17283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
17303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
17313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Specify base level.
17333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		data.resize(m_texFormat.getPixelSize()*m_size*m_size);
17343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_size, m_size, 1, &data[0]), Vec4(0.0f), Vec4(1.0f));
17353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
17373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
17383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage2D(s_cubeMapFaces[face], 0, m_internalFormat, m_size, m_size, 0, m_format, m_dataType, &data[0]);
17393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Re-specify subrectangle.
17413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int rowPitch = deAlign32(m_texFormat.getPixelSize()*m_subW, m_alignment);
17423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		data.resize(rowPitch*m_subH);
17433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_subW, m_subH, 1, rowPitch, 0, &data[0]), 4, Vec4(1.0f, 0.0f, 0.0f, 1.0f), Vec4(0.0f, 1.0f, 0.0f, 1.0f));
17443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
17463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
17473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexSubImage2D(s_cubeMapFaces[face], 0, m_subX, m_subY, m_subW, m_subH, m_format, m_dataType, &data[0]);
17483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
17493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
17513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
17523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
17533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subX;
17543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subY;
17553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subW;
17563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subH;
17573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_alignment;
17583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
17593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexSubImage3D() unpack parameters case.
17613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexSubImage3DParamsCase : public Texture3DSpecCase
17623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
17633c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
17643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexSubImage3DParamsCase (Context&		context,
17653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 const char*	name,
17663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 const char*	desc,
17673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 deUint32		internalFormat,
17683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			width,
17693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			height,
17703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			depth,
17713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			subX,
17723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			subY,
17733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			subZ,
17743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			subW,
17753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			subH,
17763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			subD,
17773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			imageHeight,
17783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			rowLength,
17793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			skipImages,
17803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			skipRows,
17813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			skipPixels,
17823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			alignment)
17833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture3DSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, 1)
17843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(internalFormat)
17853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subX			(subX)
17863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subY			(subY)
17873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subZ			(subZ)
17883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subW			(subW)
17893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subH			(subH)
17903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subD			(subD)
17913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_imageHeight		(imageHeight)
17923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_rowLength		(rowLength)
17933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipImages		(skipImages)
17943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipRows		(skipRows)
17953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipPixels		(skipPixels)
17963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment		(alignment)
17973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
17983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
17993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18003c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
18013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
18023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
18033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat		transferFmt		= glu::getTransferFormat(m_texFormat);
18043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						pixelSize		= m_texFormat.getPixelSize();
18053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				tex				= 0;
18063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<deUint8>			data;
18073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_numLevels == 1);
18093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
18113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_3D, tex);
18123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill with gradient.
18143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
18153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		rowPitch		= deAlign32(pixelSize*m_width,  4);
18163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		slicePitch		= rowPitch*m_height;
18173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.resize(slicePitch*m_depth);
18193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, m_depth, rowPitch, slicePitch, &data[0]), m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
18203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
18213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexImage3D(GL_TEXTURE_3D, 0, m_internalFormat, m_width, m_height, m_depth, 0, transferFmt.format, transferFmt.dataType, &data[0]);
18233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill data with grid.
18253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
18263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		rowLength		= m_rowLength > 0 ? m_rowLength : m_subW;
18273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		rowPitch		= deAlign32(rowLength*pixelSize, m_alignment);
18283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		imageHeight		= m_imageHeight > 0 ? m_imageHeight : m_subH;
18293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		slicePitch		= imageHeight*rowPitch;
18303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cScale			= m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
18313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cBias			= m_texFormatInfo.valueMin;
18323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorA			= Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias;
18333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorB			= Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias;
18343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.resize(slicePitch*(m_depth+m_skipImages));
18363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_subW, m_subH, m_subD, rowPitch, slicePitch, &data[0] + m_skipImages*slicePitch + m_skipRows*rowPitch + m_skipPixels*pixelSize), 4, colorA, colorB);
18373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
18383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_IMAGE_HEIGHT,	m_imageHeight);
18403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ROW_LENGTH,		m_rowLength);
18413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_IMAGES,	m_skipImages);
18423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_ROWS,		m_skipRows);
18433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_PIXELS,	m_skipPixels);
18443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT,		m_alignment);
18453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexSubImage3D(GL_TEXTURE_3D, 0, m_subX, m_subY, m_subZ, m_subW, m_subH, m_subD, transferFmt.format, transferFmt.dataType, &data[0]);
18463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
18473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
18493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subX;
18503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subY;
18513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subZ;
18523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subW;
18533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subH;
18543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subD;
18553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_imageHeight;
18563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_rowLength;
18573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipImages;
18583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipRows;
18593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipPixels;
18603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_alignment;
18613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
18623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Basic CopyTexImage2D() with 2D texture usage
18643c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicCopyTexImage2DCase : public Texture2DSpecCase
18653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
18663c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
18673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicCopyTexImage2DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height)
18683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DSpecCase	(context, name, desc, glu::mapGLTransferFormat(internalFormat, GL_UNSIGNED_BYTE), width, height, maxLevelCount(width, height))
18693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(internalFormat)
18703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
18713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
18723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18733c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
18743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
18753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
18763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const tcu::RenderTarget&	renderTarget	= TestCase::m_context.getRenderContext().getRenderTarget();
18773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						targetHasRGB	= renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 && renderTarget.getPixelFormat().blueBits > 0;
18783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						targetHasAlpha	= renderTarget.getPixelFormat().alphaBits > 0;
18793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureFormat			fmt				= mapGLUnsizedInternalFormat(m_internalFormat);
18803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						texHasRGB		= fmt.order != tcu::TextureFormat::A;
18813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						texHasAlpha		= fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA || fmt.order == tcu::TextureFormat::A;
18823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32					tex				= 0;
18833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random					rnd				(deStringHash(getName()));
18843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GradientShader				shader			(glu::TYPE_FLOAT_VEC4);
18853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32					shaderID		= getCurrentContext()->createProgram(&shader);
18863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha))
18883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__);
18893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill render target with gradient.
18913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		shader.setGradient(*getCurrentContext(), shaderID, Vec4(0.0f), Vec4(1.0f));
18923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f));
18933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
18953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D, tex);
18963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
18973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
18983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
18993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
19003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
19013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		x			= rnd.getInt(0, getWidth()	- levelW);
19023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		y			= rnd.getInt(0, getHeight()	- levelH);
19033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glCopyTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, x, y, levelW, levelH, 0);
19053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
19063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
19073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 m_internalFormat;
19093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
19103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Basic CopyTexImage2D() with cubemap usage
19123c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicCopyTexImageCubeCase : public TextureCubeSpecCase
19133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
19143c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
19153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicCopyTexImageCubeCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size)
19163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCubeSpecCase	(context, name, desc, glu::mapGLTransferFormat(internalFormat, GL_UNSIGNED_BYTE), size, deLog2Floor32(size)+1)
19173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat		(internalFormat)
19183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
19193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
19203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19213c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
19223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
19233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
19243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const tcu::RenderTarget&	renderTarget	= TestCase::m_context.getRenderContext().getRenderTarget();
19253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						targetHasRGB	= renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 && renderTarget.getPixelFormat().blueBits > 0;
19263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						targetHasAlpha	= renderTarget.getPixelFormat().alphaBits > 0;
19273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureFormat			fmt				= mapGLUnsizedInternalFormat(m_internalFormat);
19283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						texHasRGB		= fmt.order != tcu::TextureFormat::A;
19293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						texHasAlpha		= fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA || fmt.order == tcu::TextureFormat::A;
19303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32					tex				= 0;
19313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random					rnd				(deStringHash(getName()));
19323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GradientShader				shader			(glu::TYPE_FLOAT_VEC4);
19333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32					shaderID		= getCurrentContext()->createProgram(&shader);
19343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha))
19363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__);
19373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill render target with gradient.
19393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		shader.setGradient(*getCurrentContext(), shaderID, Vec4(0.0f), Vec4(1.0f));
19403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f));
19413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
19433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
19443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
19463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
19473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int levelSize = de::max(1, m_size >> ndx);
19483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
19503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
19513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int x = rnd.getInt(0, getWidth()	- levelSize);
19523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int y = rnd.getInt(0, getHeight()	- levelSize);
19533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glCopyTexImage2D(s_cubeMapFaces[face], ndx, m_internalFormat, x, y, levelSize, levelSize, 0);
19553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
19563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
19573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
19583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 m_internalFormat;
19603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
19613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Basic CopyTexSubImage2D() with 2D texture usage
19633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicCopyTexSubImage2DCase : public Texture2DSpecCase
19643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
19653c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
19663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicCopyTexSubImage2DCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int width, int height)
19673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DSpecCase	(context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height, maxLevelCount(width, height))
19683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(format)
19693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(dataType)
19703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
19713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
19723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19733c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
19743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
19753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
19763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const tcu::RenderTarget&	renderTarget	= TestCase::m_context.getRenderContext().getRenderTarget();
19773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						targetHasRGB	= renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 && renderTarget.getPixelFormat().blueBits > 0;
19783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						targetHasAlpha	= renderTarget.getPixelFormat().alphaBits > 0;
19793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureFormat			fmt				= glu::mapGLTransferFormat(m_format, m_dataType);
19803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						texHasRGB		= fmt.order != tcu::TextureFormat::A;
19813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						texHasAlpha		= fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA || fmt.order == tcu::TextureFormat::A;
19823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32					tex				= 0;
19833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel			data			(fmt);
19843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random					rnd				(deStringHash(getName()));
19853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GradientShader				shader			(glu::TYPE_FLOAT_VEC4);
19863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32					shaderID		= getCurrentContext()->createProgram(&shader);
19873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha))
19893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__);
19903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
19923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D, tex);
19933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
19943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
19953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// First specify full texture.
19963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
19973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
19983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
19993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
20003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorA		= randomVector<4>(rnd);
20023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorB		= randomVector<4>(rnd);
20033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		cellSize	= rnd.getInt(2, 16);
20043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.setSize(levelW, levelH);
20063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
20073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage2D(GL_TEXTURE_2D, ndx, m_format, levelW, levelH, 0, m_format, m_dataType, data.getAccess().getDataPtr());
20093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
20103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill render target with gradient.
20123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		shader.setGradient(*getCurrentContext(), shaderID, Vec4(0.0f), Vec4(1.0f));
20133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f));
20143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Re-specify parts of each level.
20163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
20173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
20183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
20193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
20203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		w			= rnd.getInt(1, levelW);
20223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		h			= rnd.getInt(1, levelH);
20233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		xo			= rnd.getInt(0, levelW-w);
20243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		yo			= rnd.getInt(0, levelH-h);
20253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		x			= rnd.getInt(0, getWidth() - w);
20273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		y			= rnd.getInt(0, getHeight() - h);
20283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glCopyTexSubImage2D(GL_TEXTURE_2D, ndx, xo, yo, x, y, w, h);
20303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
20313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
20323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
20343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
20353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
20363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Basic CopyTexSubImage2D() with cubemap usage
20383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicCopyTexSubImageCubeCase : public TextureCubeSpecCase
20393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
20403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
20413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicCopyTexSubImageCubeCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int size)
20423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCubeSpecCase	(context, name, desc, glu::mapGLTransferFormat(format, dataType), size, deLog2Floor32(size)+1)
20433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format				(format)
20443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType			(dataType)
20453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
20463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
20473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
20493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
20503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
20513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const tcu::RenderTarget&	renderTarget	= TestCase::m_context.getRenderContext().getRenderTarget();
20523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						targetHasRGB	= renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 && renderTarget.getPixelFormat().blueBits > 0;
20533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						targetHasAlpha	= renderTarget.getPixelFormat().alphaBits > 0;
20543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureFormat			fmt				= glu::mapGLTransferFormat(m_format, m_dataType);
20553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						texHasRGB		= fmt.order != tcu::TextureFormat::A;
20563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						texHasAlpha		= fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA || fmt.order == tcu::TextureFormat::A;
20573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32					tex				= 0;
20583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel			data			(fmt);
20593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random					rnd				(deStringHash(getName()));
20603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GradientShader				shader			(glu::TYPE_FLOAT_VEC4);
20613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32					shaderID		= getCurrentContext()->createProgram(&shader);
20623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha))
20643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__);
20653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
20673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
20683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
20693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
20713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
20723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int levelSize = de::max(1, m_size >> ndx);
20733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.setSize(levelSize, levelSize);
20753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
20773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
20783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				Vec4	colorA		= randomVector<4>(rnd);
20793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				Vec4	colorB		= randomVector<4>(rnd);
20803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int		cellSize	= rnd.getInt(2, 16);
20813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
20833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glTexImage2D(s_cubeMapFaces[face], ndx, m_format, levelSize, levelSize, 0, m_format, m_dataType, data.getAccess().getDataPtr());
20843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
20853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
20863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill render target with gradient.
20883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		shader.setGradient(*getCurrentContext(), shaderID, Vec4(0.0f), Vec4(1.0f));
20893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f));
20903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Re-specify parts of each face and level.
20923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
20933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
20943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int levelSize = de::max(1, m_size >> ndx);
20953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
20963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
20973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
20983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int		w			= rnd.getInt(1, levelSize);
20993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int		h			= rnd.getInt(1, levelSize);
21003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int		xo			= rnd.getInt(0, levelSize-w);
21013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int		yo			= rnd.getInt(0, levelSize-h);
21023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int		x			= rnd.getInt(0, getWidth() - w);
21043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int		y			= rnd.getInt(0, getHeight() - h);
21053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glCopyTexSubImage2D(s_cubeMapFaces[face], ndx, xo, yo, x, y, w, h);
21073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
21083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
21093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
21103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
21123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
21133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
21143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Basic glTexStorage2D() with 2D texture usage
21163c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicTexStorage2DCase : public Texture2DSpecCase
21173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
21183c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
21193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicTexStorage2DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int numLevels)
21203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, numLevels)
21213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(internalFormat)
21223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
21233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
21243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21253c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
21263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
21273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
21283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureFormat		fmt				= glu::mapGLInternalFormat(m_internalFormat);
21293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat		transferFmt		= glu::getTransferFormat(fmt);
21303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				tex				= 0;
21313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel		levelData		(fmt);
21323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random				rnd				(deStringHash(getName()));
21333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
21353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D, tex);
21363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexStorage2D(GL_TEXTURE_2D, m_numLevels, m_internalFormat, m_width, m_height);
21373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
21393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
21413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
21423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
21433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
21443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMin		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
21453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMax		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
21463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levelData.setSize(levelW, levelH);
21483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
21493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexSubImage2D(GL_TEXTURE_2D, ndx, 0, 0, levelW, levelH, transferFmt.format, transferFmt.dataType, levelData.getAccess().getDataPtr());
21513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
21523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
21533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 m_internalFormat;
21553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
21563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Basic glTexStorage2D() with cubemap usage
21583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicTexStorageCubeCase : public TextureCubeSpecCase
21593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
21603c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
21613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicTexStorageCubeCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size, int numLevels)
21623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCubeSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), size, numLevels)
21633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat		(internalFormat)
21643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
21653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
21663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21673c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
21683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
21693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
21703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureFormat		fmt				= glu::mapGLInternalFormat(m_internalFormat);
21713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat		transferFmt		= glu::getTransferFormat(fmt);
21723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				tex				= 0;
21733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel		levelData		(fmt);
21743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random				rnd				(deStringHash(getName()));
21753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
21773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
21783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexStorage2D(GL_TEXTURE_CUBE_MAP, m_numLevels, m_internalFormat, m_size, m_size);
21793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
21813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
21833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
21843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int levelSize = de::max(1, m_size >> ndx);
21853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levelData.setSize(levelSize, levelSize);
21873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
21893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
21903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
21913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
21923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
21943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glTexSubImage2D(s_cubeMapFaces[face], ndx, 0, 0, levelSize, levelSize, transferFmt.format, transferFmt.dataType, levelData.getAccess().getDataPtr());
21963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
21973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
21983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
21993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 m_internalFormat;
22013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
22023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Basic glTexStorage3D() with 2D array texture usage
22043c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicTexStorage2DArrayCase : public Texture2DArraySpecCase
22053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
22063c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
22073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicTexStorage2DArrayCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int numLayers, int numLevels)
22083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DArraySpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, numLayers, numLevels)
22093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat			(internalFormat)
22103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
22113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
22123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22133c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
22143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
22153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
22163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				tex			= 0;
22173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel		levelData	(m_texFormat);
22183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random				rnd			(deStringHash(getName()));
22193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat		transferFmt	= glu::getTransferFormat(m_texFormat);
22203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures	(1, &tex);
22223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture	(GL_TEXTURE_2D_ARRAY, tex);
22233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexStorage3D	(GL_TEXTURE_2D_ARRAY, m_numLevels, m_internalFormat, m_width, m_height, m_numLayers);
22243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei	(GL_UNPACK_ALIGNMENT, 1);
22263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
22283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
22293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width	>> ndx);
22303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height	>> ndx);
22313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMin		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
22323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMax		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
22333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levelData.setSize(levelW, levelH, m_numLayers);
22353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
22363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexSubImage3D(GL_TEXTURE_2D_ARRAY, ndx, 0, 0, 0, levelW, levelH, m_numLayers, transferFmt.format, transferFmt.dataType, levelData.getAccess().getDataPtr());
22383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
22393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
22403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 m_internalFormat;
22423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
22433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Basic TexStorage3D() with 3D texture usage
22453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicTexStorage3DCase : public Texture3DSpecCase
22463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
22473c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
22483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicTexStorage3DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int depth, int numLevels)
22493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture3DSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, numLevels)
22503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(internalFormat)
22513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
22523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
22533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22543c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
22553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
22563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
22573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				tex			= 0;
22583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel		levelData	(m_texFormat);
22593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random				rnd			(deStringHash(getName()));
22603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat		transferFmt	= glu::getTransferFormat(m_texFormat);
22613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures	(1, &tex);
22633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture	(GL_TEXTURE_3D, tex);
22643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexStorage3D	(GL_TEXTURE_3D, m_numLevels, m_internalFormat, m_width, m_height, m_depth);
22653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei	(GL_UNPACK_ALIGNMENT, 1);
22673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
22693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
22703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width	>> ndx);
22713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height	>> ndx);
22723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelD		= de::max(1, m_depth	>> ndx);
22733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMin		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
22743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMax		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
22753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levelData.setSize(levelW, levelH, levelD);
22773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
22783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexSubImage3D(GL_TEXTURE_3D, ndx, 0, 0, 0, levelW, levelH, levelD, transferFmt.format, transferFmt.dataType, levelData.getAccess().getDataPtr());
22803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
22813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
22823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 m_internalFormat;
22843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
22853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Pixel buffer object cases.
22873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
22883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexImage2D() from pixel buffer object.
22893c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexImage2DBufferCase : public Texture2DSpecCase
22903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
22913c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
22923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexImage2DBufferCase (Context&		context,
22933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						  const char*	name,
22943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						  const char*	desc,
22953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						  deUint32		internalFormat,
22963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						  int			width,
22973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						  int			height,
22983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						  int			rowLength,
22993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						  int			skipRows,
23003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						  int			skipPixels,
23013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						  int			alignment,
23023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						  int			offset)
23033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, 1)
23043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(internalFormat)
23053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_rowLength		(rowLength)
23063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipRows		(skipRows)
23073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipPixels		(skipPixels)
23083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment		(alignment)
23093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_offset			(offset)
23103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
23113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
23123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23133c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
23143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
23153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
23163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat		transferFmt		= glu::getTransferFormat(m_texFormat);
23173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						pixelSize		= m_texFormat.getPixelSize();
23183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						rowLength		= m_rowLength > 0 ? m_rowLength : m_width + m_skipPixels;
23193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						rowPitch		= deAlign32(rowLength*pixelSize, m_alignment);
23203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						height			= m_height + m_skipRows;
23213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				buf				= 0;
23223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				tex				= 0;
23233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<deUint8>			data;
23243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_numLevels == 1);
23263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill data with grid.
23283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		data.resize(rowPitch*height + m_offset);
23293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
23303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cScale		= m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
23313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cBias		= m_texFormatInfo.valueMin;
23323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorA		= Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias;
23333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorB		= Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias;
23343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, 1, rowPitch, 0, &data[0] + m_skipRows*rowPitch + m_skipPixels*pixelSize + m_offset), 4, colorA, colorB);
23363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
23373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Create buffer and upload.
23393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenBuffers(1, &buf);
23403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
23413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW);
23423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ROW_LENGTH,		m_rowLength);
23443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_ROWS,		m_skipRows);
23453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_PIXELS,	m_skipPixels);
23463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT,		m_alignment);
23473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
23493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D, tex);
23503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexImage2D(GL_TEXTURE_2D, 0, m_internalFormat, m_width, m_height, 0, transferFmt.format, transferFmt.dataType, (const void*)(deUintptr)m_offset);
23513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
23523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
23543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_rowLength;
23553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipRows;
23563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipPixels;
23573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_alignment;
23583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_offset;
23593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
23603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexImage2D() cubemap from pixel buffer object case
23623c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexImageCubeBufferCase : public TextureCubeSpecCase
23633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
23643c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
23653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexImageCubeBufferCase (Context&	context,
23663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							const char*	name,
23673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							const char*	desc,
23683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							deUint32	internalFormat,
23693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							int			size,
23703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							int			rowLength,
23713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							int			skipRows,
23723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							int			skipPixels,
23733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							int			alignment,
23743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							int			offset)
23753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCubeSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), size, 1)
23763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat		(internalFormat)
23773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_rowLength			(rowLength)
23783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipRows			(skipRows)
23793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipPixels			(skipPixels)
23803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment			(alignment)
23813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_offset				(offset)
23823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
23833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
23843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23853c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
23863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
23873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
23883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random					rnd			(deStringHash(getName()));
23893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32					tex			= 0;
23903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat			fmt			= glu::getTransferFormat(m_texFormat);
23913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					pixelSize	= m_texFormat.getPixelSize();
23923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					rowLength	= m_rowLength > 0 ? m_rowLength : m_size + m_skipPixels;
23933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					rowPitch	= deAlign32(rowLength*pixelSize, m_alignment);
23943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int					height		= m_size + m_skipRows;
23953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<vector<deUint8> >	data		(DE_LENGTH_OF_ARRAY(s_cubeMapFaces));
23963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_numLevels == 1);
23983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
23993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
24003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
24013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
24023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
24043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
24053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32 buf = 0;
24063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
24083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
24093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
24103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				data[face].resize(rowPitch*height + m_offset);
24123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_size, m_size, 1, rowPitch, 0, &data[face][0] + m_skipRows*rowPitch + m_skipPixels*pixelSize + m_offset), gMin, gMax);
24133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
24143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// Create buffer and upload.
24163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGenBuffers(1, &buf);
24173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
24183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data[face].size(), &data[face][0], GL_STATIC_DRAW);
24193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glPixelStorei(GL_UNPACK_ROW_LENGTH,		m_rowLength);
24213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glPixelStorei(GL_UNPACK_SKIP_ROWS,		m_skipRows);
24223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glPixelStorei(GL_UNPACK_SKIP_PIXELS,	m_skipPixels);
24233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glPixelStorei(GL_UNPACK_ALIGNMENT,		m_alignment);
24243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage2D(s_cubeMapFaces[face], 0, m_internalFormat, m_size, m_size, 0, fmt.format, fmt.dataType, (const void*)(deUintptr)m_offset);
24263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
24273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
24283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
24303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_rowLength;
24313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipRows;
24323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipPixels;
24333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_alignment;
24343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_offset;
24353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
24363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexImage3D() 2D array from pixel buffer object.
24383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexImage2DArrayBufferCase : public Texture2DArraySpecCase
24393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
24403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
24413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexImage2DArrayBufferCase (Context&		context,
24423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   const char*	name,
24433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   const char*	desc,
24443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   deUint32		internalFormat,
24453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   int			width,
24463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   int			height,
24473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   int			depth,
24483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   int			imageHeight,
24493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   int			rowLength,
24503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   int			skipImages,
24513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   int			skipRows,
24523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   int			skipPixels,
24533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   int			alignment,
24543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   int			offset)
24553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DArraySpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, 1)
24563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat			(internalFormat)
24573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_imageHeight				(imageHeight)
24583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_rowLength				(rowLength)
24593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipImages				(skipImages)
24603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipRows				(skipRows)
24613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipPixels				(skipPixels)
24623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment				(alignment)
24633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_offset					(offset)
24643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
24653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
24663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24673c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
24683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
24693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
24703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat		transferFmt		= glu::getTransferFormat(m_texFormat);
24713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						pixelSize		= m_texFormat.getPixelSize();
24723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						rowLength		= m_rowLength > 0 ? m_rowLength : m_width;
24733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						rowPitch		= deAlign32(rowLength*pixelSize, m_alignment);
24743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						imageHeight		= m_imageHeight > 0 ? m_imageHeight : m_height;
24753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						slicePitch		= imageHeight*rowPitch;
24763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				tex				= 0;
24773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				buf				= 0;
24783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<deUint8>			data;
24793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_numLevels == 1);
24813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill data with grid.
24833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		data.resize(slicePitch*(m_numLayers+m_skipImages) + m_offset);
24843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
24853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cScale		= m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
24863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cBias		= m_texFormatInfo.valueMin;
24873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorA		= Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias;
24883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorB		= Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias;
24893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, m_numLayers, rowPitch, slicePitch, &data[0] + m_skipImages*slicePitch + m_skipRows*rowPitch + m_skipPixels*pixelSize + m_offset), 4, colorA, colorB);
24913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
24923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenBuffers(1, &buf);
24943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
24953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW);
24963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
24973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_IMAGE_HEIGHT,	m_imageHeight);
24983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ROW_LENGTH,		m_rowLength);
24993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_IMAGES,	m_skipImages);
25003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_ROWS,		m_skipRows);
25013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_PIXELS,	m_skipPixels);
25023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT,		m_alignment);
25033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
25053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
25063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, m_internalFormat, m_width, m_height, m_numLayers, 0, transferFmt.format, transferFmt.dataType, (const void*)(deUintptr)m_offset);
25073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
25083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
25103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_imageHeight;
25113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_rowLength;
25123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipImages;
25133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipRows;
25143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipPixels;
25153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_alignment;
25163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_offset;
25173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
25183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexImage3D() from pixel buffer object.
25203c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexImage3DBufferCase : public Texture3DSpecCase
25213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
25223c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
25233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexImage3DBufferCase (Context&		context,
25243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						  const char*	name,
25253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						  const char*	desc,
25263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						  deUint32		internalFormat,
25273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						  int			width,
25283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						  int			height,
25293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						  int			depth,
25303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						  int			imageHeight,
25313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						  int			rowLength,
25323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						  int			skipImages,
25333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						  int			skipRows,
25343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						  int			skipPixels,
25353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						  int			alignment,
25363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						  int			offset)
25373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture3DSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, 1)
25383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(internalFormat)
25393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_imageHeight		(imageHeight)
25403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_rowLength		(rowLength)
25413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipImages		(skipImages)
25423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipRows		(skipRows)
25433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipPixels		(skipPixels)
25443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment		(alignment)
25453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_offset			(offset)
25463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
25473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
25483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
25503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
25513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
25523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat		transferFmt		= glu::getTransferFormat(m_texFormat);
25533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						pixelSize		= m_texFormat.getPixelSize();
25543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						rowLength		= m_rowLength > 0 ? m_rowLength : m_width;
25553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						rowPitch		= deAlign32(rowLength*pixelSize, m_alignment);
25563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						imageHeight		= m_imageHeight > 0 ? m_imageHeight : m_height;
25573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						slicePitch		= imageHeight*rowPitch;
25583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				tex				= 0;
25593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				buf				= 0;
25603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<deUint8>			data;
25613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_numLevels == 1);
25633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill data with grid.
25653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		data.resize(slicePitch*(m_depth+m_skipImages) + m_offset);
25663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
25673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cScale		= m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
25683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cBias		= m_texFormatInfo.valueMin;
25693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorA		= Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias;
25703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorB		= Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias;
25713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, m_depth, rowPitch, slicePitch, &data[0] + m_skipImages*slicePitch + m_skipRows*rowPitch + m_skipPixels*pixelSize + m_offset), 4, colorA, colorB);
25733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
25743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenBuffers(1, &buf);
25763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
25773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW);
25783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_IMAGE_HEIGHT,	m_imageHeight);
25803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ROW_LENGTH,		m_rowLength);
25813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_IMAGES,	m_skipImages);
25823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_ROWS,		m_skipRows);
25833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_PIXELS,	m_skipPixels);
25843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT,		m_alignment);
25853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
25873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_3D, tex);
25883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexImage3D(GL_TEXTURE_3D, 0, m_internalFormat, m_width, m_height, m_depth, 0, transferFmt.format, transferFmt.dataType, (const void*)(deUintptr)m_offset);
25893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
25903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
25913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
25923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_imageHeight;
25933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_rowLength;
25943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipImages;
25953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipRows;
25963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipPixels;
25973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_alignment;
25983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_offset;
25993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
26003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexSubImage2D() PBO case.
26023c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexSubImage2DBufferCase : public Texture2DSpecCase
26033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
26043c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
26053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexSubImage2DBufferCase (Context&		context,
26063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 const char*	name,
26073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 const char*	desc,
26083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 deUint32		internalFormat,
26093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			width,
26103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			height,
26113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			subX,
26123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			subY,
26133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			subW,
26143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			subH,
26153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			rowLength,
26163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			skipRows,
26173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			skipPixels,
26183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			alignment,
26193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			offset)
26203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, 1)
26213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(internalFormat)
26223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subX			(subX)
26233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subY			(subY)
26243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subW			(subW)
26253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subH			(subH)
26263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_rowLength		(rowLength)
26273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipRows		(skipRows)
26283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipPixels		(skipPixels)
26293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment		(alignment)
26303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_offset			(offset)
26313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
26323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
26333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26343c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
26353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
26363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
26373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat		transferFmt		= glu::getTransferFormat(m_texFormat);
26383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						pixelSize		= m_texFormat.getPixelSize();
26393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				tex				= 0;
26403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				buf				= 0;
26413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<deUint8>			data;
26423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_numLevels == 1);
26443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
26463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D, tex);
26473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// First fill texture with gradient.
26493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		data.resize(deAlign32(m_width*pixelSize, 4)*m_height);
26503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, 1, deAlign32(m_width*pixelSize, 4), 0, &data[0]), m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
26513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexImage2D(GL_TEXTURE_2D, 0, m_internalFormat, m_width, m_height, 0, transferFmt.format, transferFmt.dataType, &data[0]);
26523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill data with grid.
26543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
26553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		rowLength	= m_rowLength > 0 ? m_rowLength : m_subW;
26563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		rowPitch	= deAlign32(rowLength*pixelSize, m_alignment);
26573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		height		= m_subH + m_skipRows;
26583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cScale		= m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
26593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cBias		= m_texFormatInfo.valueMin;
26603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorA		= Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias;
26613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorB		= Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias;
26623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.resize(rowPitch*height + m_offset);
26643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_subW, m_subH, 1, rowPitch, 0, &data[0] + m_skipRows*rowPitch + m_skipPixels*pixelSize + m_offset), 4, colorA, colorB);
26653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
26663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenBuffers(1, &buf);
26683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindBuffer(GL_PIXEL_UNPACK_BUFFER,	buf);
26693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBufferData(GL_PIXEL_UNPACK_BUFFER,	(int)data.size(), &data[0], GL_STATIC_DRAW);
26703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ROW_LENGTH,		m_rowLength);
26723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_ROWS,		m_skipRows);
26733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_PIXELS,	m_skipPixels);
26743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT,		m_alignment);
26753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexSubImage2D(GL_TEXTURE_2D, 0, m_subX, m_subY, m_subW, m_subH, transferFmt.format, transferFmt.dataType, (const void*)(deUintptr)m_offset);
26763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
26773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
26793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subX;
26803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subY;
26813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subW;
26823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subH;
26833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_rowLength;
26843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipRows;
26853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipPixels;
26863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_alignment;
26873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_offset;
26883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
26893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
26903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexSubImage2D() cubemap PBO case.
26913c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexSubImageCubeBufferCase : public TextureCubeSpecCase
26923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
26933c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
26943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexSubImageCubeBufferCase	(Context&		context,
26953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 const char*	name,
26963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 const char*	desc,
26973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 deUint32		internalFormat,
26983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			size,
26993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			subX,
27003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			subY,
27013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			subW,
27023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			subH,
27033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			rowLength,
27043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			skipRows,
27053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			skipPixels,
27063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			alignment,
27073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			offset)
27083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCubeSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), size, 1)
27093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat		(internalFormat)
27103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subX				(subX)
27113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subY				(subY)
27123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subW				(subW)
27133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subH				(subH)
27143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_rowLength			(rowLength)
27153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipRows			(skipRows)
27163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipPixels			(skipPixels)
27173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment			(alignment)
27183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_offset				(offset)
27193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
27203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
27213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27223c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
27233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
27243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
27253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random				rnd				(deStringHash(getName()));
27263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat		transferFmt		= glu::getTransferFormat(m_texFormat);
27273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						pixelSize		= m_texFormat.getPixelSize();
27283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				tex				= 0;
27293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				buf				= 0;
27303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<deUint8>			data;
27313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_numLevels == 1);
27333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
27353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
27363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill faces with different gradients.
27383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		data.resize(deAlign32(m_size*pixelSize, 4)*m_size);
27403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
27413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
27433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
27443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
27453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
27463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_size, m_size, 1, deAlign32(m_size*pixelSize, 4), 0, &data[0]), gMin, gMax);
27483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage2D(s_cubeMapFaces[face], 0, m_internalFormat, m_size, m_size, 0, transferFmt.format, transferFmt.dataType, &data[0]);
27503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
27513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill data with grid.
27533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
27543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		rowLength	= m_rowLength > 0 ? m_rowLength : m_subW;
27553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		rowPitch	= deAlign32(rowLength*pixelSize, m_alignment);
27563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		height		= m_subH + m_skipRows;
27573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cScale		= m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
27583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cBias		= m_texFormatInfo.valueMin;
27593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorA		= Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias;
27603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorB		= Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias;
27613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.resize(rowPitch*height + m_offset);
27633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_subW, m_subH, 1, rowPitch, 0, &data[0] + m_skipRows*rowPitch + m_skipPixels*pixelSize + m_offset), 4, colorA, colorB);
27643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
27653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenBuffers(1, &buf);
27673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindBuffer(GL_PIXEL_UNPACK_BUFFER,	buf);
27683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBufferData(GL_PIXEL_UNPACK_BUFFER,	(int)data.size(), &data[0], GL_STATIC_DRAW);
27693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ROW_LENGTH,		m_rowLength);
27713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_ROWS,		m_skipRows);
27723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_PIXELS,	m_skipPixels);
27733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT,		m_alignment);
27743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
27763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexSubImage2D(s_cubeMapFaces[face], 0, m_subX, m_subY, m_subW, m_subH, transferFmt.format, transferFmt.dataType, (const void*)(deUintptr)m_offset);
27773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
27783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
27803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subX;
27813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subY;
27823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subW;
27833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subH;
27843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_rowLength;
27853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipRows;
27863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipPixels;
27873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_alignment;
27883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_offset;
27893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
27903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
27913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexSubImage3D() 2D array PBO case.
27923c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexSubImage2DArrayBufferCase : public Texture2DArraySpecCase
27933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
27943c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
27953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexSubImage2DArrayBufferCase (Context&		context,
27963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 const char*	name,
27973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 const char*	desc,
27983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 deUint32		internalFormat,
27993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			width,
28003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			height,
28013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			depth,
28023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			subX,
28033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			subY,
28043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			subZ,
28053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			subW,
28063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			subH,
28073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			subD,
28083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			imageHeight,
28093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			rowLength,
28103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			skipImages,
28113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			skipRows,
28123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			skipPixels,
28133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			alignment,
28143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			offset)
28153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DArraySpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, 1)
28163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat			(internalFormat)
28173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subX					(subX)
28183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subY					(subY)
28193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subZ					(subZ)
28203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subW					(subW)
28213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subH					(subH)
28223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subD					(subD)
28233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_imageHeight				(imageHeight)
28243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_rowLength				(rowLength)
28253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipImages				(skipImages)
28263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipRows				(skipRows)
28273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipPixels				(skipPixels)
28283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment				(alignment)
28293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_offset					(offset)
28303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
28313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
28323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28333c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
28343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
28353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
28363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat		transferFmt		= glu::getTransferFormat(m_texFormat);
28373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						pixelSize		= m_texFormat.getPixelSize();
28383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				tex				= 0;
28393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				buf				= 0;
28403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<deUint8>			data;
28413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_numLevels == 1);
28433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
28453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
28463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill with gradient.
28483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
28493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		rowPitch		= deAlign32(pixelSize*m_width,  4);
28503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		slicePitch		= rowPitch*m_height;
28513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.resize(slicePitch*m_numLayers);
28533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, m_numLayers, rowPitch, slicePitch, &data[0]), m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
28543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
28553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, m_internalFormat, m_width, m_height, m_numLayers, 0, transferFmt.format, transferFmt.dataType, &data[0]);
28573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill data with grid.
28593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
28603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		rowLength		= m_rowLength > 0 ? m_rowLength : m_subW;
28613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		rowPitch		= deAlign32(rowLength*pixelSize, m_alignment);
28623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		imageHeight		= m_imageHeight > 0 ? m_imageHeight : m_subH;
28633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		slicePitch		= imageHeight*rowPitch;
28643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cScale			= m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
28653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cBias			= m_texFormatInfo.valueMin;
28663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorA			= Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias;
28673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorB			= Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias;
28683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.resize(slicePitch*(m_numLayers+m_skipImages) + m_offset);
28703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_subW, m_subH, m_subD, rowPitch, slicePitch, &data[0] + m_skipImages*slicePitch + m_skipRows*rowPitch + m_skipPixels*pixelSize + m_offset), 4, colorA, colorB);
28713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
28723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenBuffers(1, &buf);
28743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindBuffer(GL_PIXEL_UNPACK_BUFFER,	buf);
28753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBufferData(GL_PIXEL_UNPACK_BUFFER,	(int)data.size(), &data[0], GL_STATIC_DRAW);
28763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_IMAGE_HEIGHT,	m_imageHeight);
28783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ROW_LENGTH,		m_rowLength);
28793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_IMAGES,	m_skipImages);
28803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_ROWS,		m_skipRows);
28813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_PIXELS,	m_skipPixels);
28823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT,		m_alignment);
28833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, m_subX, m_subY, m_subZ, m_subW, m_subH, m_subD, transferFmt.format, transferFmt.dataType, (const void*)(deIntptr)m_offset);
28843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
28853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
28863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
28873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subX;
28883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subY;
28893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subZ;
28903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subW;
28913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subH;
28923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subD;
28933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_imageHeight;
28943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_rowLength;
28953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipImages;
28963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipRows;
28973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipPixels;
28983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_alignment;
28993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_offset;
29003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
29013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexSubImage3D() PBO case.
29033c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexSubImage3DBufferCase : public Texture3DSpecCase
29043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
29053c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
29063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexSubImage3DBufferCase (Context&		context,
29073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 const char*	name,
29083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 const char*	desc,
29093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 deUint32		internalFormat,
29103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			width,
29113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			height,
29123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			depth,
29133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			subX,
29143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			subY,
29153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			subZ,
29163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			subW,
29173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			subH,
29183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			subD,
29193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			imageHeight,
29203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			rowLength,
29213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			skipImages,
29223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			skipRows,
29233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			skipPixels,
29243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			alignment,
29253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							 int			offset)
29263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture3DSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, 1)
29273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(internalFormat)
29283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subX			(subX)
29293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subY			(subY)
29303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subZ			(subZ)
29313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subW			(subW)
29323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subH			(subH)
29333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subD			(subD)
29343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_imageHeight		(imageHeight)
29353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_rowLength		(rowLength)
29363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipImages		(skipImages)
29373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipRows		(skipRows)
29383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipPixels		(skipPixels)
29393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment		(alignment)
29403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_offset			(offset)
29413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
29423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
29433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
29453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
29463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
29473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat		transferFmt		= glu::getTransferFormat(m_texFormat);
29483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						pixelSize		= m_texFormat.getPixelSize();
29493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				tex				= 0;
29503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				buf				= 0;
29513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<deUint8>			data;
29523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_numLevels == 1);
29543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
29563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_3D, tex);
29573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill with gradient.
29593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
29603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		rowPitch		= deAlign32(pixelSize*m_width,  4);
29613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		slicePitch		= rowPitch*m_height;
29623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.resize(slicePitch*m_depth);
29643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, m_depth, rowPitch, slicePitch, &data[0]), m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
29653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
29663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexImage3D(GL_TEXTURE_3D, 0, m_internalFormat, m_width, m_height, m_depth, 0, transferFmt.format, transferFmt.dataType, &data[0]);
29683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill data with grid.
29703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
29713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		rowLength		= m_rowLength > 0 ? m_rowLength : m_subW;
29723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		rowPitch		= deAlign32(rowLength*pixelSize, m_alignment);
29733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		imageHeight		= m_imageHeight > 0 ? m_imageHeight : m_subH;
29743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		slicePitch		= imageHeight*rowPitch;
29753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cScale			= m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
29763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cBias			= m_texFormatInfo.valueMin;
29773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorA			= Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias;
29783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorB			= Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias;
29793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.resize(slicePitch*(m_depth+m_skipImages) + m_offset);
29813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_subW, m_subH, m_subD, rowPitch, slicePitch, &data[0] + m_skipImages*slicePitch + m_skipRows*rowPitch + m_skipPixels*pixelSize + m_offset), 4, colorA, colorB);
29823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
29833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenBuffers(1, &buf);
29853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindBuffer(GL_PIXEL_UNPACK_BUFFER,	buf);
29863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBufferData(GL_PIXEL_UNPACK_BUFFER,	(int)data.size(), &data[0], GL_STATIC_DRAW);
29873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_IMAGE_HEIGHT,	m_imageHeight);
29893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ROW_LENGTH,		m_rowLength);
29903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_IMAGES,	m_skipImages);
29913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_ROWS,		m_skipRows);
29923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_PIXELS,	m_skipPixels);
29933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT,		m_alignment);
29943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexSubImage3D(GL_TEXTURE_3D, 0, m_subX, m_subY, m_subZ, m_subW, m_subH, m_subD, transferFmt.format, transferFmt.dataType, (const void*)(deIntptr)m_offset);
29953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
29963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
29973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
29983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subX;
29993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subY;
30003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subZ;
30013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subW;
30023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subH;
30033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subD;
30043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_imageHeight;
30053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_rowLength;
30063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipImages;
30073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipRows;
30083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipPixels;
30093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_alignment;
30103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_offset;
30113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
30123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexImage2D() depth case.
30143c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexImage2DDepthCase : public Texture2DSpecCase
30153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
30163c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
30173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexImage2DDepthCase (Context&		context,
30183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						 const char*	name,
30193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						 const char*	desc,
30203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						 deUint32		internalFormat,
30213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						 int			imageWidth,
30223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						 int			imageHeight)
30233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), imageWidth, imageHeight, maxLevelCount(imageWidth, imageHeight))
30243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(internalFormat)
30253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
30263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// we are interested in the behavior near [-2, 2], map it to visible range [0, 1]
30273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_texFormatInfo.lookupBias = Vec4(0.25f, 0.0f, 0.0f, 1.0f);
30283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_texFormatInfo.lookupScale = Vec4(0.5f, 1.0f, 1.0f, 0.0f);
30293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
30303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
30323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
30333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat	fmt			= glu::getTransferFormat(m_texFormat);
30343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
30353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel	levelData	(m_texFormat);
30363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
30383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D, tex);
30393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
30403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_CHECK();
30413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
30433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
30443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int   levelW		= de::max(1, m_width >> ndx);
30453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int   levelH		= de::max(1, m_height >> ndx);
30463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4  gMin		= Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
30473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4  gMax		= Vec4(2.0f, 1.5f, -1.0f, 2.0f);
30483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levelData.setSize(levelW, levelH);
30503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
30513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, levelW, levelH, 0, fmt.format, fmt.dataType, levelData.getAccess().getDataPtr());
30533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
30543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
30553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32 m_internalFormat;
30573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
30583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexImage3D() depth case.
30603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexImage2DArrayDepthCase : public Texture2DArraySpecCase
30613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
30623c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
30633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexImage2DArrayDepthCase (Context&		context,
30643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							  const char*	name,
30653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							  const char*	desc,
30663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							  deUint32		internalFormat,
30673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							  int			imageWidth,
30683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							  int			imageHeight,
30693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							  int			numLayers)
30703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DArraySpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), imageWidth, imageHeight, numLayers, maxLevelCount(imageWidth, imageHeight))
30713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat		(internalFormat)
30723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
30733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// we are interested in the behavior near [-2, 2], map it to visible range [0, 1]
30743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_texFormatInfo.lookupBias = Vec4(0.25f, 0.0f, 0.0f, 1.0f);
30753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_texFormatInfo.lookupScale = Vec4(0.5f, 1.0f, 1.0f, 0.0f);
30763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
30773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
30793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
30803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat	fmt			= glu::getTransferFormat(m_texFormat);
30813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
30823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel	levelData	(m_texFormat);
30833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
30853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
30863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
30873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_CHECK();
30883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
30903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
30913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int   levelW		= de::max(1, m_width >> ndx);
30923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int   levelH		= de::max(1, m_height >> ndx);
30933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4  gMin		= Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
30943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4  gMax		= Vec4(2.0f, 1.5f, -1.0f, 2.0f);
30953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levelData.setSize(levelW, levelH, m_numLayers);
30973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
30983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage3D(GL_TEXTURE_2D_ARRAY, ndx, m_internalFormat, levelW, levelH, m_numLayers, 0, fmt.format, fmt.dataType, levelData.getAccess().getDataPtr());
31003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
31013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
31023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32 m_internalFormat;
31043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
31053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexSubImage2D() depth case.
31073c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexSubImage2DDepthCase : public Texture2DSpecCase
31083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
31093c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
31103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexSubImage2DDepthCase (Context&	context,
31113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							const char*	name,
31123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							const char*	desc,
31133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							deUint32	internalFormat,
31143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							int			imageWidth,
31153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							int			imageHeight)
31163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), imageWidth, imageHeight, maxLevelCount(imageWidth, imageHeight))
31173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(internalFormat)
31183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
31193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// we are interested in the behavior near [-2, 2], map it to visible range [0, 1]
31203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_texFormatInfo.lookupBias = Vec4(0.25f, 0.0f, 0.0f, 1.0f);
31213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_texFormatInfo.lookupScale = Vec4(0.5f, 1.0f, 1.0f, 0.0f);
31223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
31233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
31253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
31263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat	fmt			= glu::getTransferFormat(m_texFormat);
31273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random			rnd			(deStringHash(getName()));
31283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
31293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel	levelData	(m_texFormat);
31303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
31323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D, tex);
31333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
31343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_CHECK();
31353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// First specify full texture.
31373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
31383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
31393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int   levelW		= de::max(1, m_width >> ndx);
31403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int   levelH		= de::max(1, m_height >> ndx);
31413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4  gMin		= Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
31423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4  gMax		= Vec4(2.0f, 1.5f, -1.0f, 2.0f);
31433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levelData.setSize(levelW, levelH);
31453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
31463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, levelW, levelH, 0, fmt.format, fmt.dataType, levelData.getAccess().getDataPtr());
31483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
31493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Re-specify parts of each level.
31513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
31523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
31533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	levelW		= de::max(1, m_width >> ndx);
31543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	levelH		= de::max(1, m_height >> ndx);
31553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	w			= rnd.getInt(1, levelW);
31573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	h			= rnd.getInt(1, levelH);
31583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	x			= rnd.getInt(0, levelW-w);
31593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	y			= rnd.getInt(0, levelH-h);
31603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4	colorA		= Vec4(2.0f, 1.5f, -1.0f, 2.0f);
31623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4	colorB		= Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
31633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	cellSize	= rnd.getInt(2, 16);
31643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levelData.setSize(w, h);
31663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithGrid(levelData.getAccess(), cellSize, colorA, colorB);
31673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexSubImage2D(GL_TEXTURE_2D, ndx, x, y, w, h, fmt.format, fmt.dataType, levelData.getAccess().getDataPtr());
31693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
31703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
31713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32 m_internalFormat;
31733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
31743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexSubImage3D() depth case.
31763c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexSubImage2DArrayDepthCase : public Texture2DArraySpecCase
31773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
31783c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
31793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexSubImage2DArrayDepthCase (Context&		context,
31803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 const char*	name,
31813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 const char*	desc,
31823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 deUint32		internalFormat,
31833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			imageWidth,
31843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			imageHeight,
31853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			numLayers)
31863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DArraySpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), imageWidth, imageHeight, numLayers, maxLevelCount(imageWidth, imageHeight))
31873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat		(internalFormat)
31883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
31893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// we are interested in the behavior near [-2, 2], map it to visible range [0, 1]
31903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_texFormatInfo.lookupBias = Vec4(0.25f, 0.0f, 0.0f, 1.0f);
31913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_texFormatInfo.lookupScale = Vec4(0.5f, 1.0f, 1.0f, 0.0f);
31923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
31933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
31943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
31953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
31963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat	fmt			= glu::getTransferFormat(m_texFormat);
31973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random			rnd			(deStringHash(getName()));
31983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
31993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel	levelData	(m_texFormat);
32003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
32023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
32033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
32043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_CHECK();
32053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// First specify full texture.
32073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
32083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
32093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int   levelW		= de::max(1, m_width >> ndx);
32103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int   levelH		= de::max(1, m_height >> ndx);
32113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4  gMin		= Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
32123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4  gMax		= Vec4(2.0f, 1.5f, -1.0f, 2.0f);
32133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levelData.setSize(levelW, levelH, m_numLayers);
32153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
32163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage3D(GL_TEXTURE_2D_ARRAY, ndx, m_internalFormat, levelW, levelH, m_numLayers, 0, fmt.format, fmt.dataType, levelData.getAccess().getDataPtr());
32183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
32193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Re-specify parts of each level.
32213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
32223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
32233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	levelW		= de::max(1, m_width >> ndx);
32243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	levelH		= de::max(1, m_height >> ndx);
32253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	w			= rnd.getInt(1, levelW);
32273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	h			= rnd.getInt(1, levelH);
32283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	d			= rnd.getInt(1, m_numLayers);
32293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	x			= rnd.getInt(0, levelW-w);
32303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	y			= rnd.getInt(0, levelH-h);
32313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	z			= rnd.getInt(0, m_numLayers-d);
32323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4	colorA		= Vec4(2.0f, 1.5f, -1.0f, 2.0f);
32343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4	colorB		= Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
32353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	cellSize	= rnd.getInt(2, 16);
32363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levelData.setSize(w, h, d);
32383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithGrid(levelData.getAccess(), cellSize, colorA, colorB);
32393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexSubImage3D(GL_TEXTURE_2D_ARRAY, ndx, x, y, z, w, h, d, fmt.format, fmt.dataType, levelData.getAccess().getDataPtr());
32413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
32423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
32433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32 m_internalFormat;
32453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
32463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexImage2D() depth case with pbo.
32483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexImage2DDepthBufferCase : public Texture2DSpecCase
32493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
32503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
32513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexImage2DDepthBufferCase (Context&		context,
32523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   const char*	name,
32533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   const char*	desc,
32543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   deUint32		internalFormat,
32553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   int			imageWidth,
32563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   int			imageHeight)
32573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DSpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), imageWidth, imageHeight, 1)
32583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(internalFormat)
32593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
32603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// we are interested in the behavior near [-2, 2], map it to visible range [0, 1]
32613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_texFormatInfo.lookupBias = Vec4(0.25f, 0.0f, 0.0f, 1.0f);
32623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_texFormatInfo.lookupScale = Vec4(0.5f, 1.0f, 1.0f, 0.0f);
32633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
32643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
32663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
32673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat		transferFmt		= glu::getTransferFormat(m_texFormat);
32683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						pixelSize		= m_texFormat.getPixelSize();
32693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						rowLength		= m_width;
32703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						alignment		= 4;
32713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						rowPitch		= deAlign32(rowLength*pixelSize, alignment);
32723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						height			= m_height;
32733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				buf				= 0;
32743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				tex				= 0;
32753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<deUint8>			data;
32763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_numLevels == 1);
32783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill data with gradient
32803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		data.resize(rowPitch*height);
32813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
32823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4 gMin = Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
32833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4 gMax = Vec4(2.0f, 1.5f, -1.0f, 2.0f);
32843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, 1, rowPitch, 0, &data[0]), gMin, gMax);
32863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
32873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Create buffer and upload.
32893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenBuffers(1, &buf);
32903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
32913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW);
32923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ROW_LENGTH,		rowLength);
32943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_ROWS,		0);
32953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_PIXELS,	0);
32963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT,		alignment);
32973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
32993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D, tex);
33003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexImage2D(GL_TEXTURE_2D, 0, m_internalFormat, m_width, m_height, 0, transferFmt.format, transferFmt.dataType, DE_NULL);
33013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteBuffers(1, &buf);
33023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
33033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32 m_internalFormat;
33053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
33063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexImage3D() depth case with pbo.
33083c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexImage2DArrayDepthBufferCase : public Texture2DArraySpecCase
33093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
33103c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
33113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexImage2DArrayDepthBufferCase (Context&	context,
33123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									const char*	name,
33133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									const char*	desc,
33143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									deUint32	internalFormat,
33153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									int			imageWidth,
33163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									int			imageHeight,
33173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									int			numLayers)
33183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: Texture2DArraySpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), imageWidth, imageHeight, numLayers, 1)
33193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat		(internalFormat)
33203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
33213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// we are interested in the behavior near [-2, 2], map it to visible range [0, 1]
33223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_texFormatInfo.lookupBias = Vec4(0.25f, 0.0f, 0.0f, 1.0f);
33233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_texFormatInfo.lookupScale = Vec4(0.5f, 1.0f, 1.0f, 0.0f);
33243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
33253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
33273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
33283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat		transferFmt		= glu::getTransferFormat(m_texFormat);
33293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						pixelSize		= m_texFormat.getPixelSize();
33303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						rowLength		= m_width;
33313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						alignment		= 4;
33323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						rowPitch		= deAlign32(rowLength*pixelSize, alignment);
33333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						imageHeight		= m_height;
33343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						slicePitch		= imageHeight*rowPitch;
33353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				tex				= 0;
33363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				buf				= 0;
33373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<deUint8>			data;
33383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_numLevels == 1);
33403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill data with grid.
33423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		data.resize(slicePitch*m_numLayers);
33433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
33443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4 gMin = Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
33453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4 gMax = Vec4(2.0f, 1.5f, -1.0f, 2.0f);
33463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, m_numLayers, rowPitch, slicePitch, &data[0]), gMin, gMax);
33483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
33493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenBuffers(1, &buf);
33513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
33523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW);
33533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_IMAGE_HEIGHT,	imageHeight);
33553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ROW_LENGTH,		rowLength);
33563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_IMAGES,	0);
33573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_ROWS,		0);
33583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_PIXELS,	0);
33593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT,		alignment);
33603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
33623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
33633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, m_internalFormat, m_width, m_height, m_numLayers, 0, transferFmt.format, transferFmt.dataType, DE_NULL);
33643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteBuffers(1, &buf);
33653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
33663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32 m_internalFormat;
33683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
33693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33703c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureSpecificationTests::TextureSpecificationTests (Context& context)
33713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCaseGroup(context, "specification", "Texture Specification Tests")
33723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
33733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
33743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33753c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureSpecificationTests::~TextureSpecificationTests (void)
33763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
33773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
33783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33793c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureSpecificationTests::init (void)
33803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
33813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	struct
33823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
33833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char*	name;
33843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32	format;
33853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32	dataType;
33863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	} unsizedFormats[] =
33873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
33883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "alpha_unsigned_byte",			GL_ALPHA,			GL_UNSIGNED_BYTE },
33893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "luminance_unsigned_byte",		GL_LUMINANCE,		GL_UNSIGNED_BYTE },
33903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "luminance_alpha_unsigned_byte",	GL_LUMINANCE_ALPHA,	GL_UNSIGNED_BYTE },
33913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb_unsigned_short_5_6_5",		GL_RGB,				GL_UNSIGNED_SHORT_5_6_5 },
33923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb_unsigned_byte",				GL_RGB,				GL_UNSIGNED_BYTE },
33933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba_unsigned_short_4_4_4_4",	GL_RGBA,			GL_UNSIGNED_SHORT_4_4_4_4 },
33943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba_unsigned_short_5_5_5_1",	GL_RGBA,			GL_UNSIGNED_SHORT_5_5_5_1 },
33953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba_unsigned_byte",				GL_RGBA,			GL_UNSIGNED_BYTE }
33963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
33973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	struct
33993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
34003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char*	name;
34013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32	internalFormat;
34023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	} colorFormats[] =
34033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
34043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba32f",			GL_RGBA32F,			},
34053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba32i",			GL_RGBA32I,			},
34063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba32ui",			GL_RGBA32UI,		},
34073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba16f",			GL_RGBA16F,			},
34083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba16i",			GL_RGBA16I,			},
34093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba16ui",			GL_RGBA16UI,		},
34103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba8",				GL_RGBA8,			},
34113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba8i",				GL_RGBA8I,			},
34123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba8ui",			GL_RGBA8UI,			},
34133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "srgb8_alpha8",		GL_SRGB8_ALPHA8,	},
34143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb10_a2",			GL_RGB10_A2,		},
34153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb10_a2ui",			GL_RGB10_A2UI,		},
34163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba4",				GL_RGBA4,			},
34173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb5_a1",			GL_RGB5_A1,			},
34183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba8_snorm",		GL_RGBA8_SNORM,		},
34193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb8",				GL_RGB8,			},
34203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb565",				GL_RGB565,			},
34213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "r11f_g11f_b10f",		GL_R11F_G11F_B10F,	},
34223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb32f",				GL_RGB32F,			},
34233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb32i",				GL_RGB32I,			},
34243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb32ui",			GL_RGB32UI,			},
34253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb16f",				GL_RGB16F,			},
34263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb16i",				GL_RGB16I,			},
34273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb16ui",			GL_RGB16UI,			},
34283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb8_snorm",			GL_RGB8_SNORM,		},
34293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb8i",				GL_RGB8I,			},
34303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb8ui",				GL_RGB8UI,			},
34313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "srgb8",				GL_SRGB8,			},
34323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb9_e5",			GL_RGB9_E5,			},
34333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rg32f",				GL_RG32F,			},
34343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rg32i",				GL_RG32I,			},
34353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rg32ui",				GL_RG32UI,			},
34363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rg16f",				GL_RG16F,			},
34373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rg16i",				GL_RG16I,			},
34383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rg16ui",				GL_RG16UI,			},
34393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rg8",				GL_RG8,				},
34403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rg8i",				GL_RG8I,			},
34413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rg8ui",				GL_RG8UI,			},
34423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rg8_snorm",			GL_RG8_SNORM,		},
34433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "r32f",				GL_R32F,			},
34443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "r32i",				GL_R32I,			},
34453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "r32ui",				GL_R32UI,			},
34463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "r16f",				GL_R16F,			},
34473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "r16i",				GL_R16I,			},
34483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "r16ui",				GL_R16UI,			},
34493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "r8",					GL_R8,				},
34503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "r8i",				GL_R8I,				},
34513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "r8ui",				GL_R8UI,			},
34523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "r8_snorm",			GL_R8_SNORM,		}
34533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
34543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static const struct
34563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
34573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char*	name;
34583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32	internalFormat;
34593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	} depthStencilFormats[] =
34603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
34613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Depth and stencil formats
34623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "depth_component32f",	GL_DEPTH_COMPONENT32F	},
34633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "depth_component24",	GL_DEPTH_COMPONENT24	},
34643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "depth_component16",	GL_DEPTH_COMPONENT16	},
34653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "depth32f_stencil8",	GL_DEPTH32F_STENCIL8	},
34663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "depth24_stencil8",	GL_DEPTH24_STENCIL8		}
34673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
34683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Basic TexImage2D usage.
34703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
34713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* basicTexImageGroup = new tcu::TestCaseGroup(m_testCtx, "basic_teximage2d", "Basic glTexImage2D() usage");
34723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(basicTexImageGroup);
34733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
34743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
34753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	fmtName		= colorFormats[formatNdx].name;
34763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	format		= colorFormats[formatNdx].internalFormat;
34773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DWidth	= 64;
34783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DHeight	= 128;
34793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	texCubeSize	= 64;
34803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			basicTexImageGroup->addChild(new BasicTexImage2DCase	(m_context,	(string(fmtName) + "_2d").c_str(),		"",	format, tex2DWidth, tex2DHeight));
34823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			basicTexImageGroup->addChild(new BasicTexImageCubeCase	(m_context,	(string(fmtName) + "_cube").c_str(),	"",	format, texCubeSize));
34833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
34843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
34853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Randomized TexImage2D order.
34873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
34883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* randomTexImageGroup = new tcu::TestCaseGroup(m_testCtx, "random_teximage2d", "Randomized glTexImage2D() usage");
34893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(randomTexImageGroup);
34903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random rnd(9);
34923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
34933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// 2D cases.
34943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < 10; ndx++)
34953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
34963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		formatNdx	= rnd.getInt(0, DE_LENGTH_OF_ARRAY(colorFormats)-1);
34973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		width		= 1 << rnd.getInt(2, 8);
34983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		height		= 1 << rnd.getInt(2, 8);
34993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			randomTexImageGroup->addChild(new RandomOrderTexImage2DCase(m_context, (string("2d_") + de::toString(ndx)).c_str(), "", colorFormats[formatNdx].internalFormat, width, height));
35013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
35023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Cubemap cases.
35043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < 10; ndx++)
35053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
35063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		formatNdx	= rnd.getInt(0, DE_LENGTH_OF_ARRAY(colorFormats)-1);
35073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		size		= 1 << rnd.getInt(2, 8);
35083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			randomTexImageGroup->addChild(new RandomOrderTexImageCubeCase(m_context, (string("cube_") + de::toString(ndx)).c_str(), "", colorFormats[formatNdx].internalFormat, size));
35103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
35113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
35123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// TexImage2D unpack alignment.
35143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
35153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* alignGroup = new tcu::TestCaseGroup(m_testCtx, "teximage2d_align", "glTexImage2D() unpack alignment tests");
35163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(alignGroup);
35173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_r8_4_8",			"",	GL_R8,			 4,  8, 4, 8));
35193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_r8_63_1",			"",	GL_R8,			63, 30, 1, 1));
35203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_r8_63_2",			"",	GL_R8,			63, 30, 1, 2));
35213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_r8_63_4",			"",	GL_R8,			63, 30, 1, 4));
35223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_r8_63_8",			"",	GL_R8,			63, 30, 1, 8));
35233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_rgba4_51_1",		"",	GL_RGBA4,		51, 30, 1, 1));
35243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_rgba4_51_2",		"",	GL_RGBA4,		51, 30, 1, 2));
35253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_rgba4_51_4",		"",	GL_RGBA4,		51, 30, 1, 4));
35263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_rgba4_51_8",		"",	GL_RGBA4,		51, 30, 1, 8));
35273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_rgb8_39_1",			"",	GL_RGB8,		39, 43, 1, 1));
35283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_rgb8_39_2",			"",	GL_RGB8,		39, 43, 1, 2));
35293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_rgb8_39_4",			"",	GL_RGB8,		39, 43, 1, 4));
35303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_rgb8_39_8",			"",	GL_RGB8,		39, 43, 1, 8));
35313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_rgba8_47_1",		"",	GL_RGBA8,		47, 27, 1, 1));
35323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_rgba8_47_2",		"",	GL_RGBA8,		47, 27, 1, 2));
35333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_rgba8_47_4",		"",	GL_RGBA8,		47, 27, 1, 4));
35343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_rgba8_47_8",		"",	GL_RGBA8,		47, 27, 1, 8));
35353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_r8_4_8",			"",	GL_R8,			 4, 3, 8));
35373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_r8_63_1",			"",	GL_R8,			63, 1, 1));
35383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_r8_63_2",			"",	GL_R8,			63, 1, 2));
35393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_r8_63_4",			"",	GL_R8,			63, 1, 4));
35403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_r8_63_8",			"",	GL_R8,			63, 1, 8));
35413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_rgba4_51_1",		"",	GL_RGBA4,		51, 1, 1));
35423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_rgba4_51_2",		"",	GL_RGBA4,		51, 1, 2));
35433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_rgba4_51_4",		"",	GL_RGBA4,		51, 1, 4));
35443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_rgba4_51_8",		"",	GL_RGBA4,		51, 1, 8));
35453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_rgb8_39_1",		"",	GL_RGB8,		39, 1, 1));
35463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_rgb8_39_2",		"",	GL_RGB8,		39, 1, 2));
35473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_rgb8_39_4",		"",	GL_RGB8,		39, 1, 4));
35483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_rgb8_39_8",		"",	GL_RGB8,		39, 1, 8));
35493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_rgba8_47_1",		"",	GL_RGBA8,		47, 1, 1));
35503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_rgba8_47_2",		"",	GL_RGBA8,		47, 1, 2));
35513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_rgba8_47_4",		"",	GL_RGBA8,		47, 1, 4));
35523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_rgba8_47_8",		"",	GL_RGBA8,		47, 1, 8));
35533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
35543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// glTexImage2D() unpack parameter cases.
35563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
35573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* paramGroup = new tcu::TestCaseGroup(m_testCtx, "teximage2d_unpack_params", "glTexImage2D() pixel transfer mode cases");
35583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(paramGroup);
35593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const struct
35613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
35623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	name;
35633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	format;
35643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			width;
35653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			height;
35663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			rowLength;
35673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipRows;
35683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipPixels;
35693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			alignment;
35703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} cases[] =
35713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
35723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_alignment",		GL_RGB8,	31,	30,	0,	0,	0,	2 },
35733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_row_length",	GL_RGB8,	31,	30,	50,	0,	0,	4 },
35743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_rows",		GL_RGB8,	31,	30,	0,	3,	0,	4 },
35753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_pixels",	GL_RGB8,	31,	30,	36,	0,	5,	4 },
35763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "r8_complex1",		GL_R8,		31, 30, 64, 1,	3,	1 },
35773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "r8_complex2",		GL_R8,		31, 30, 64, 1,	3,	2 },
35783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "r8_complex3",		GL_R8,		31, 30, 64, 1,	3,	4 },
35793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "r8_complex4",		GL_R8,		31, 30, 64, 1,	3,	8 },
35803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgba8_complex1",		GL_RGBA8,	56,	61,	69,	0,	0,	8 },
35813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgba8_complex2",		GL_RGBA8,	56,	61,	69,	0,	7,	8 },
35823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgba8_complex3",		GL_RGBA8,	56,	61,	69,	3,	0,	8 },
35833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgba8_complex4",		GL_RGBA8,	56,	61,	69,	3,	7,	8 },
35843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgba32f_complex",	GL_RGBA32F,	19,	10,	27,	1,	7,	8 }
35853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
35863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(cases); ndx++)
35883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			paramGroup->addChild(new TexImage2DParamsCase(m_context, cases[ndx].name, "",
35893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														  cases[ndx].format,
35903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														  cases[ndx].width,
35913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														  cases[ndx].height,
35923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														  cases[ndx].rowLength,
35933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														  cases[ndx].skipRows,
35943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														  cases[ndx].skipPixels,
35953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														  cases[ndx].alignment));
35963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
35973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
35983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// glTexImage2D() pbo cases.
35993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
36003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* pboGroup = new tcu::TestCaseGroup(m_testCtx, "teximage2d_pbo", "glTexImage2D() from PBO");
36013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(pboGroup);
36023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Parameter cases
36043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const struct
36053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
36063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	name;
36073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	format;
36083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			width;
36093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			height;
36103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			rowLength;
36113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipRows;
36123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipPixels;
36133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			alignment;
36143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			offset;
36153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} parameterCases[] =
36163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
36173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_offset",		GL_RGB8,	31,	30,	0,	0,	0,	4,	67 },
36183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_alignment",		GL_RGB8,	31,	30,	0,	0,	0,	2,	0 },
36193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_row_length",	GL_RGB8,	31,	30,	50,	0,	0,	4,	0 },
36203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_rows",		GL_RGB8,	31,	30,	0,	3,	0,	4,	0 },
36213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_pixels",	GL_RGB8,	31,	30,	36,	0,	5,	4,	0 }
36223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
36233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
36253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
36263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const string	fmtName		= colorFormats[formatNdx].name;
36273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const deUint32	format		= colorFormats[formatNdx].internalFormat;
36283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int		tex2DWidth	= 65;
36293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int		tex2DHeight	= 37;
36303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int		texCubeSize	= 64;
36313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			pboGroup->addChild(new TexImage2DBufferCase		(m_context,	(fmtName + "_2d").c_str(),		"", format, tex2DWidth, tex2DHeight, 0, 0, 0, 4, 0));
36333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			pboGroup->addChild(new TexImageCubeBufferCase	(m_context,	(fmtName + "_cube").c_str(),	"", format, texCubeSize, 0, 0, 0, 4, 0));
36343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
36353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(parameterCases); ndx++)
36373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
36383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			pboGroup->addChild(new TexImage2DBufferCase(m_context, (string(parameterCases[ndx].name) + "_2d").c_str(), "",
36393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].format,
36403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].width,
36413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].height,
36423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].rowLength,
36433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].skipRows,
36443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].skipPixels,
36453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].alignment,
36463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].offset));
36473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			pboGroup->addChild(new TexImageCubeBufferCase(m_context, (string(parameterCases[ndx].name) + "_cube").c_str(), "",
36483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].format,
36493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].width,
36503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].rowLength,
36513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].skipRows,
36523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].skipPixels,
36533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].alignment,
36543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].offset));
36553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
36563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
36573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// glTexImage2D() depth cases.
36593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
36603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* shadow2dGroup = new tcu::TestCaseGroup(m_testCtx, "teximage2d_depth", "glTexImage2D() with depth or depth/stencil format");
36613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(shadow2dGroup);
36623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthStencilFormats); ndx++)
36643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
36653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int tex2DWidth	= 64;
36663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int tex2DHeight	= 128;
36673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			shadow2dGroup->addChild(new TexImage2DDepthCase(m_context, depthStencilFormats[ndx].name, "", depthStencilFormats[ndx].internalFormat, tex2DWidth, tex2DHeight));
36693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
36703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
36713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// glTexImage2D() depth cases with pbo.
36733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
36743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* shadow2dGroup = new tcu::TestCaseGroup(m_testCtx, "teximage2d_depth_pbo", "glTexImage2D() with depth or depth/stencil format with pbo");
36753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(shadow2dGroup);
36763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthStencilFormats); ndx++)
36783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
36793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int tex2DWidth	= 64;
36803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int tex2DHeight	= 128;
36813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			shadow2dGroup->addChild(new TexImage2DDepthBufferCase(m_context, depthStencilFormats[ndx].name, "", depthStencilFormats[ndx].internalFormat, tex2DWidth, tex2DHeight));
36833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
36843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
36853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Basic TexSubImage2D usage.
36873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
36883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* basicTexSubImageGroup = new tcu::TestCaseGroup(m_testCtx, "basic_texsubimage2d", "Basic glTexSubImage2D() usage");
36893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(basicTexSubImageGroup);
36903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
36913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
36923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	fmtName		= colorFormats[formatNdx].name;
36933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	format		= colorFormats[formatNdx].internalFormat;
36943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DWidth	= 64;
36953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DHeight	= 128;
36963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	texCubeSize	= 64;
36973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
36983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			basicTexSubImageGroup->addChild(new BasicTexSubImage2DCase		(m_context,	(string(fmtName) + "_2d").c_str(),		"",	format, tex2DWidth, tex2DHeight));
36993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			basicTexSubImageGroup->addChild(new BasicTexSubImageCubeCase	(m_context,	(string(fmtName) + "_cube").c_str(),	"",	format, texCubeSize));
37003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
37013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
37023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
37033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// TexSubImage2D to empty texture.
37043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
37053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* texSubImageEmptyTexGroup = new tcu::TestCaseGroup(m_testCtx, "texsubimage2d_empty_tex", "glTexSubImage2D() to texture that has storage but no data");
37063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(texSubImageEmptyTexGroup);
37073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(unsizedFormats); formatNdx++)
37083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
37093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	fmtName		= unsizedFormats[formatNdx].name;
37103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	format		= unsizedFormats[formatNdx].format;
37113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	dataType	= unsizedFormats[formatNdx].dataType;
37123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DWidth	= 64;
37133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DHeight	= 32;
37143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	texCubeSize	= 32;
37153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
37163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			texSubImageEmptyTexGroup->addChild(new TexSubImage2DEmptyTexCase	(m_context,	(string(fmtName) + "_2d").c_str(),		"",	format, dataType, tex2DWidth, tex2DHeight));
37173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			texSubImageEmptyTexGroup->addChild(new TexSubImageCubeEmptyTexCase	(m_context,	(string(fmtName) + "_cube").c_str(),	"",	format, dataType, texCubeSize));
37183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
37193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
37203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
37213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// TexSubImage2D alignment cases.
37223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
37233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* alignGroup = new tcu::TestCaseGroup(m_testCtx, "texsubimage2d_align", "glTexSubImage2D() unpack alignment tests");
37243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(alignGroup);
37253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
37263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_r8_1_1",			"",	GL_R8,			64, 64, 13, 17,  1,  6, 1));
37273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_r8_1_2",			"",	GL_R8,			64, 64, 13, 17,  1,  6, 2));
37283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_r8_1_4",			"",	GL_R8,			64, 64, 13, 17,  1,  6, 4));
37293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_r8_1_8",			"",	GL_R8,			64, 64, 13, 17,  1,  6, 8));
37303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_r8_63_1",			"",	GL_R8,			64, 64,  1,  9, 63, 30, 1));
37313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_r8_63_2",			"",	GL_R8,			64, 64,  1,  9, 63, 30, 2));
37323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_r8_63_4",			"",	GL_R8,			64, 64,  1,  9, 63, 30, 4));
37333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_r8_63_8",			"",	GL_R8,			64, 64,  1,  9, 63, 30, 8));
37343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_rgba4_51_1",		"",	GL_RGBA4,		64, 64,  7, 29, 51, 30, 1));
37353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_rgba4_51_2",		"",	GL_RGBA4,		64, 64,  7, 29, 51, 30, 2));
37363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_rgba4_51_4",		"",	GL_RGBA4,		64, 64,  7, 29, 51, 30, 4));
37373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_rgba4_51_8",		"",	GL_RGBA4,		64, 64,  7, 29, 51, 30, 8));
37383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_rgb8_39_1",			"",	GL_RGB8,		64, 64, 11,  8, 39, 43, 1));
37393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_rgb8_39_2",			"",	GL_RGB8,		64, 64, 11,  8, 39, 43, 2));
37403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_rgb8_39_4",			"",	GL_RGB8,		64, 64, 11,  8, 39, 43, 4));
37413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_rgb8_39_8",			"",	GL_RGB8,		64, 64, 11,  8, 39, 43, 8));
37423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_rgba8_47_1",		"",	GL_RGBA8,		64, 64, 10,  1, 47, 27, 1));
37433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_rgba8_47_2",		"",	GL_RGBA8,		64, 64, 10,  1, 47, 27, 2));
37443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_rgba8_47_4",		"",	GL_RGBA8,		64, 64, 10,  1, 47, 27, 4));
37453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_rgba8_47_8",		"",	GL_RGBA8,		64, 64, 10,  1, 47, 27, 8));
37463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
37473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_r8_1_1",			"",	GL_R8,			64, 13, 17,  1,  6, 1));
37483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_r8_1_2",			"",	GL_R8,			64, 13, 17,  1,  6, 2));
37493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_r8_1_4",			"",	GL_R8,			64, 13, 17,  1,  6, 4));
37503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_r8_1_8",			"",	GL_R8,			64, 13, 17,  1,  6, 8));
37513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_r8_63_1",			"",	GL_R8,			64,  1,  9, 63, 30, 1));
37523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_r8_63_2",			"",	GL_R8,			64,  1,  9, 63, 30, 2));
37533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_r8_63_4",			"",	GL_R8,			64,  1,  9, 63, 30, 4));
37543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_r8_63_8",			"",	GL_R8,			64,  1,  9, 63, 30, 8));
37553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_rgba4_51_1",		"",	GL_RGBA4,		64,  7, 29, 51, 30, 1));
37563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_rgba4_51_2",		"",	GL_RGBA4,		64,  7, 29, 51, 30, 2));
37573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_rgba4_51_4",		"",	GL_RGBA4,		64,  7, 29, 51, 30, 4));
37583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_rgba4_51_8",		"",	GL_RGBA4,		64,  7, 29, 51, 30, 8));
37593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_rgb8_39_1",		"",	GL_RGB8,		64, 11,  8, 39, 43, 1));
37603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_rgb8_39_2",		"",	GL_RGB8,		64, 11,  8, 39, 43, 2));
37613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_rgb8_39_4",		"",	GL_RGB8,		64, 11,  8, 39, 43, 4));
37623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_rgb8_39_8",		"",	GL_RGB8,		64, 11,  8, 39, 43, 8));
37633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_rgba8_47_1",		"",	GL_RGBA8,		64, 10,  1, 47, 27, 1));
37643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_rgba8_47_2",		"",	GL_RGBA8,		64, 10,  1, 47, 27, 2));
37653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_rgba8_47_4",		"",	GL_RGBA8,		64, 10,  1, 47, 27, 4));
37663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_rgba8_47_8",		"",	GL_RGBA8,		64, 10,  1, 47, 27, 8));
37673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
37683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
37693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// glTexSubImage2D() pixel transfer mode cases.
37703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
37713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* paramGroup = new tcu::TestCaseGroup(m_testCtx, "texsubimage2d_unpack_params", "glTexSubImage2D() pixel transfer mode cases");
37723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(paramGroup);
37733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
37743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const struct
37753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
37763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	name;
37773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	format;
37783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			width;
37793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			height;
37803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subX;
37813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subY;
37823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subW;
37833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subH;
37843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			rowLength;
37853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipRows;
37863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipPixels;
37873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			alignment;
37883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} cases[] =
37893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
37903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_alignment",		GL_RGB8,	54,	60,	11,	7,	31,	30,	0,	0,	0,	2 },
37913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_row_length",	GL_RGB8,	54,	60,	11,	7,	31,	30,	50,	0,	0,	4 },
37923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_rows",		GL_RGB8,	54,	60,	11,	7,	31,	30,	0,	3,	0,	4 },
37933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_pixels",	GL_RGB8,	54,	60,	11,	7,	31,	30,	36,	0,	5,	4 },
37943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "r8_complex1",		GL_R8,		54,	60,	11,	7,	31, 30, 64, 1,	3,	1 },
37953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "r8_complex2",		GL_R8,		54,	60,	11,	7,	31, 30, 64, 1,	3,	2 },
37963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "r8_complex3",		GL_R8,		54,	60,	11,	7,	31, 30, 64, 1,	3,	4 },
37973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "r8_complex4",		GL_R8,		54,	60,	11,	7,	31, 30, 64, 1,	3,	8 },
37983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgba8_complex1",		GL_RGBA8,	92,	84,	13,	19,	56,	61,	69,	0,	0,	8 },
37993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgba8_complex2",		GL_RGBA8,	92,	84,	13,	19,	56,	61,	69,	0,	7,	8 },
38003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgba8_complex3",		GL_RGBA8,	92,	84,	13,	19,	56,	61,	69,	3,	0,	8 },
38013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgba8_complex4",		GL_RGBA8,	92,	84,	13,	19,	56,	61,	69,	3,	7,	8 },
38023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgba32f_complex",	GL_RGBA32F,	92,	84,	13,	19,	56,	61,	69,	3,	7,	8 }
38033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
38043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
38053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(cases); ndx++)
38063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			paramGroup->addChild(new TexSubImage2DParamsCase(m_context, cases[ndx].name, "",
38073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].format,
38083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].width,
38093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].height,
38103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].subX,
38113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].subY,
38123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].subW,
38133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].subH,
38143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].rowLength,
38153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].skipRows,
38163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].skipPixels,
38173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].alignment));
38183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
38193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
38203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// glTexSubImage2D() PBO cases.
38213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
38223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* pboGroup = new tcu::TestCaseGroup(m_testCtx, "texsubimage2d_pbo", "glTexSubImage2D() pixel buffer object tests");
38233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(pboGroup);
38243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
38253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const struct
38263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
38273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	name;
38283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	format;
38293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			width;
38303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			height;
38313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subX;
38323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subY;
38333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subW;
38343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subH;
38353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			rowLength;
38363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipRows;
38373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipPixels;
38383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			alignment;
38393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			offset;
38403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} paramCases[] =
38413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
38423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_offset",		GL_RGB8,	54,	60,	11,	7,	31,	30,	0,	0,	0,	4,	67 },
38433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_alignment",		GL_RGB8,	54,	60,	11,	7,	31,	30,	0,	0,	0,	2,	0 },
38443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_row_length",	GL_RGB8,	54,	60,	11,	7,	31,	30,	50,	0,	0,	4,	0 },
38453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_rows",		GL_RGB8,	54,	60,	11,	7,	31,	30,	0,	3,	0,	4,	0 },
38463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_pixels",	GL_RGB8,	54,	60,	11,	7,	31,	30,	36,	0,	5,	4,	0 }
38473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
38483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
38493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(colorFormats); ndx++)
38503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
38513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			pboGroup->addChild(new TexSubImage2DBufferCase(m_context, (std::string(colorFormats[ndx].name) + "_2d").c_str(), "",
38523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   colorFormats[ndx].internalFormat,
38533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   54,	// Width
38543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   60,	// Height
38553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   11,	// Sub X
38563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   7,	// Sub Y
38573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   31,	// Sub W
38583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   30,	// Sub H
38593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0,	// Row len
38603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0,	// Skip rows
38613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0,	// Skip pixels
38623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   4,	// Alignment
38633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0	/* offset */));
38643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			pboGroup->addChild(new TexSubImageCubeBufferCase(m_context, (std::string(colorFormats[ndx].name) + "_cube").c_str(), "",
38653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   colorFormats[ndx].internalFormat,
38663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   64,	// Size
38673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   11,	// Sub X
38683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   7,	// Sub Y
38693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   31,	// Sub W
38703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   30,	// Sub H
38713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0,	// Row len
38723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0,	// Skip rows
38733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0,	// Skip pixels
38743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   4,	// Alignment
38753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0	/* offset */));
38763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
38773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
38783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(paramCases); ndx++)
38793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
38803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			pboGroup->addChild(new TexSubImage2DBufferCase(m_context, (std::string(paramCases[ndx].name) + "_2d").c_str(), "",
38813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].format,
38823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].width,
38833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].height,
38843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subX,
38853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subY,
38863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subW,
38873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subH,
38883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].rowLength,
38893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].skipRows,
38903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].skipPixels,
38913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].alignment,
38923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].offset));
38933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			pboGroup->addChild(new TexSubImageCubeBufferCase(m_context, (std::string(paramCases[ndx].name) + "_cube").c_str(), "",
38943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].format,
38953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].width,
38963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subX,
38973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subY,
38983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subW,
38993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subH,
39003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].rowLength,
39013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].skipRows,
39023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].skipPixels,
39033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].alignment,
39043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].offset));
39053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
39063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
39073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
39083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// glTexSubImage2D() depth cases.
39093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
39103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* shadow2dGroup = new tcu::TestCaseGroup(m_testCtx, "texsubimage2d_depth", "glTexSubImage2D() with depth or depth/stencil format");
39113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(shadow2dGroup);
39123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
39133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthStencilFormats); ndx++)
39143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
39153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DWidth	= 64;
39163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DHeight	= 32;
39173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
39183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			shadow2dGroup->addChild(new TexSubImage2DDepthCase(m_context, depthStencilFormats[ndx].name, "", depthStencilFormats[ndx].internalFormat, tex2DWidth, tex2DHeight));
39193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
39203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
39213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
39223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Basic glCopyTexImage2D() cases
39233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
39243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* copyTexImageGroup = new tcu::TestCaseGroup(m_testCtx, "basic_copyteximage2d", "Basic glCopyTexImage2D() usage");
39253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(copyTexImageGroup);
39263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
39273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexImageGroup->addChild(new BasicCopyTexImage2DCase		(m_context, "2d_alpha",				"",	GL_ALPHA,			128, 64));
39283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexImageGroup->addChild(new BasicCopyTexImage2DCase		(m_context, "2d_luminance",			"",	GL_LUMINANCE,		128, 64));
39293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexImageGroup->addChild(new BasicCopyTexImage2DCase		(m_context, "2d_luminance_alpha",	"",	GL_LUMINANCE_ALPHA,	128, 64));
39303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexImageGroup->addChild(new BasicCopyTexImage2DCase		(m_context, "2d_rgb",				"",	GL_RGB,				128, 64));
39313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexImageGroup->addChild(new BasicCopyTexImage2DCase		(m_context, "2d_rgba",				"",	GL_RGBA,			128, 64));
39323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
39333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexImageGroup->addChild(new BasicCopyTexImageCubeCase	(m_context, "cube_alpha",			"",	GL_ALPHA,			64));
39343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexImageGroup->addChild(new BasicCopyTexImageCubeCase	(m_context, "cube_luminance",		"",	GL_LUMINANCE,		64));
39353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexImageGroup->addChild(new BasicCopyTexImageCubeCase	(m_context, "cube_luminance_alpha",	"",	GL_LUMINANCE_ALPHA,	64));
39363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexImageGroup->addChild(new BasicCopyTexImageCubeCase	(m_context, "cube_rgb",				"",	GL_RGB,				64));
39373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexImageGroup->addChild(new BasicCopyTexImageCubeCase	(m_context, "cube_rgba",			"",	GL_RGBA,			64));
39383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
39393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
39403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Basic glCopyTexSubImage2D() cases
39413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
39423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* copyTexSubImageGroup = new tcu::TestCaseGroup(m_testCtx, "basic_copytexsubimage2d", "Basic glCopyTexSubImage2D() usage");
39433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(copyTexSubImageGroup);
39443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
39453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexSubImageGroup->addChild(new BasicCopyTexSubImage2DCase	(m_context, "2d_alpha",				"",	GL_ALPHA,			GL_UNSIGNED_BYTE, 128, 64));
39463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexSubImageGroup->addChild(new BasicCopyTexSubImage2DCase	(m_context, "2d_luminance",			"",	GL_LUMINANCE,		GL_UNSIGNED_BYTE, 128, 64));
39473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexSubImageGroup->addChild(new BasicCopyTexSubImage2DCase	(m_context, "2d_luminance_alpha",	"",	GL_LUMINANCE_ALPHA,	GL_UNSIGNED_BYTE, 128, 64));
39483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexSubImageGroup->addChild(new BasicCopyTexSubImage2DCase	(m_context, "2d_rgb",				"",	GL_RGB,				GL_UNSIGNED_BYTE, 128, 64));
39493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexSubImageGroup->addChild(new BasicCopyTexSubImage2DCase	(m_context, "2d_rgba",				"",	GL_RGBA,			GL_UNSIGNED_BYTE, 128, 64));
39503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
39513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexSubImageGroup->addChild(new BasicCopyTexSubImageCubeCase	(m_context, "cube_alpha",			"",	GL_ALPHA,			GL_UNSIGNED_BYTE, 64));
39523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexSubImageGroup->addChild(new BasicCopyTexSubImageCubeCase	(m_context, "cube_luminance",		"",	GL_LUMINANCE,		GL_UNSIGNED_BYTE, 64));
39533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexSubImageGroup->addChild(new BasicCopyTexSubImageCubeCase	(m_context, "cube_luminance_alpha",	"",	GL_LUMINANCE_ALPHA,	GL_UNSIGNED_BYTE, 64));
39543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexSubImageGroup->addChild(new BasicCopyTexSubImageCubeCase	(m_context, "cube_rgb",				"",	GL_RGB,				GL_UNSIGNED_BYTE, 64));
39553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexSubImageGroup->addChild(new BasicCopyTexSubImageCubeCase	(m_context, "cube_rgba",			"",	GL_RGBA,			GL_UNSIGNED_BYTE, 64));
39563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
39573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
39583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Basic TexImage3D usage.
39593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
39603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* basicTexImageGroup = new tcu::TestCaseGroup(m_testCtx, "basic_teximage3d", "Basic glTexImage3D() usage");
39613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(basicTexImageGroup);
39623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
39633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
39643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	fmtName				= colorFormats[formatNdx].name;
39653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	format				= colorFormats[formatNdx].internalFormat;
39663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DArrayWidth		= 57;
39673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DArrayHeight	= 44;
39683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DArrayLevels	= 5;
39693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex3DWidth			= 63;
39703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex3DHeight			= 29;
39713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex3DDepth			= 11;
39723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
39733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			basicTexImageGroup->addChild(new BasicTexImage2DArrayCase	(m_context,	(string(fmtName) + "_2d_array").c_str(),	"",	format, tex2DArrayWidth, tex2DArrayHeight, tex2DArrayLevels));
39743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			basicTexImageGroup->addChild(new BasicTexImage3DCase		(m_context,	(string(fmtName) + "_3d").c_str(),			"",	format, tex3DWidth, tex3DHeight, tex3DDepth));
39753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
39763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
39773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
39783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// glTexImage3D() unpack params cases.
39793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
39803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* paramGroup = new tcu::TestCaseGroup(m_testCtx, "teximage3d_unpack_params", "glTexImage3D() unpack parameters");
39813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(paramGroup);
39823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
39833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const struct
39843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
39853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	name;
39863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	format;
39873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			width;
39883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			height;
39893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			depth;
39903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			imageHeight;
39913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			rowLength;
39923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipImages;
39933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipRows;
39943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipPixels;
39953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			alignment;
39963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} cases[] =
39973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
39983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_image_height",	GL_RGB8,	23,	19,	8,	26,	0,	0,	0,	0,	4 },
39993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_row_length",	GL_RGB8,	23,	19,	8,	0,	27,	0,	0,	0,	4 },
40003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_images",	GL_RGB8,	23,	19,	8,	0,	0,	3,	0,	0,	4 },
40013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_rows",		GL_RGB8,	23,	19,	8,	22,	0,	0,	3,	0,	4 },
40023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_pixels",	GL_RGB8,	23,	19,	8,	0,	25,	0,	0,	2,	4 },
40033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "r8_complex1",		GL_R8,		13, 17, 11,	23,	15,	2,	3,	1,	1 },
40043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "r8_complex2",		GL_R8,		13, 17, 11,	23,	15,	2,	3,	1,	2 },
40053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "r8_complex3",		GL_R8,		13, 17, 11,	23,	15,	2,	3,	1,	4 },
40063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "r8_complex4",		GL_R8,		13, 17, 11,	23,	15,	2,	3,	1,	8 },
40073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgba8_complex1",		GL_RGBA8,	11,	20,	8,	25,	14,	0,	0,	0,	8 },
40083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgba8_complex2",		GL_RGBA8,	11,	20,	8,	25,	14,	0,	2,	0,	8 },
40093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgba8_complex3",		GL_RGBA8,	11,	20,	8,	25,	14,	0,	0,	3,	8 },
40103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgba8_complex4",		GL_RGBA8,	11,	20,	8,	25,	14,	0,	2,	3,	8 },
40113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgba32f_complex",	GL_RGBA32F,	11,	20,	8,	25,	14,	0,	2,	3,	8 }
40123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
40133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
40143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(cases); ndx++)
40153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			paramGroup->addChild(new TexImage3DParamsCase(m_context, cases[ndx].name, "",
40163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														  cases[ndx].format,
40173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														  cases[ndx].width,
40183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														  cases[ndx].height,
40193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														  cases[ndx].depth,
40203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														  cases[ndx].imageHeight,
40213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														  cases[ndx].rowLength,
40223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														  cases[ndx].skipImages,
40233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														  cases[ndx].skipRows,
40243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														  cases[ndx].skipPixels,
40253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														  cases[ndx].alignment));
40263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
40273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
40283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// glTexImage3D() pbo cases.
40293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
40303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* pboGroup = new tcu::TestCaseGroup(m_testCtx, "teximage3d_pbo", "glTexImage3D() from PBO");
40313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(pboGroup);
40323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
40333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Parameter cases
40343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const struct
40353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
40363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	name;
40373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	format;
40383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			width;
40393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			height;
40403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			depth;
40413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			imageHeight;
40423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			rowLength;
40433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipImages;
40443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipRows;
40453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipPixels;
40463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			alignment;
40473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			offset;
40483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} parameterCases[] =
40493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
40503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_offset",		GL_RGB8,	23,	19,	8,	0,	0,	0,	0,	0,	1,	67 },
40513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_alignment",		GL_RGB8,	23,	19,	8,	0,	0,	0,	0,	0,	2,	0 },
40523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_image_height",	GL_RGB8,	23,	19,	8,	26,	0,	0,	0,	0,	4,	0 },
40533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_row_length",	GL_RGB8,	23,	19,	8,	0,	27,	0,	0,	0,	4,	0 },
40543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_images",	GL_RGB8,	23,	19,	8,	0,	0,	3,	0,	0,	4,	0 },
40553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_rows",		GL_RGB8,	23,	19,	8,	22,	0,	0,	3,	0,	4,	0 },
40563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_pixels",	GL_RGB8,	23,	19,	8,	0,	25,	0,	0,	2,	4,	0 }
40573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
40583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
40593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
40603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
40613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const string	fmtName		= colorFormats[formatNdx].name;
40623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const deUint32	format		= colorFormats[formatNdx].internalFormat;
40633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int		tex3DWidth	= 11;
40643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int		tex3DHeight	= 20;
40653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int		tex3DDepth	= 8;
40663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
40673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			pboGroup->addChild(new TexImage2DArrayBufferCase	(m_context, (fmtName + "_2d_array").c_str(),	"", format, tex3DWidth, tex3DHeight, tex3DDepth, 0, 0, 0, 0, 0, 4, 0));
40683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			pboGroup->addChild(new TexImage3DBufferCase			(m_context, (fmtName + "_3d").c_str(),			"", format, tex3DWidth, tex3DHeight, tex3DDepth, 0, 0, 0, 0, 0, 4, 0));
40693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
40703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
40713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(parameterCases); ndx++)
40723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
40733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			pboGroup->addChild(new TexImage2DArrayBufferCase(m_context, (string(parameterCases[ndx].name) + "_2d_array").c_str(), "",
40743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].format,
40753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].width,
40763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].depth,
40773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].height,
40783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].imageHeight,
40793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].rowLength,
40803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].skipImages,
40813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].skipRows,
40823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].skipPixels,
40833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].alignment,
40843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].offset));
40853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			pboGroup->addChild(new TexImage3DBufferCase(m_context, (string(parameterCases[ndx].name) + "_3d").c_str(), "",
40863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].format,
40873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].width,
40883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].depth,
40893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].height,
40903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].imageHeight,
40913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].rowLength,
40923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].skipImages,
40933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].skipRows,
40943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].skipPixels,
40953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].alignment,
40963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].offset));
40973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
40983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
40993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
41003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// glTexImage3D() depth cases.
41013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
41023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* shadow3dGroup = new tcu::TestCaseGroup(m_testCtx, "teximage3d_depth", "glTexImage3D() with depth or depth/stencil format");
41033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(shadow3dGroup);
41043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
41053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthStencilFormats); ndx++)
41063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
41073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex3DWidth	= 32;
41083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex3DHeight	= 64;
41093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex3DDepth	= 8;
41103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
41113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			shadow3dGroup->addChild(new TexImage2DArrayDepthCase(m_context, (std::string(depthStencilFormats[ndx].name) + "_2d_array").c_str(), "", depthStencilFormats[ndx].internalFormat, tex3DWidth, tex3DHeight, tex3DDepth));
41123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
41133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
41143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
41153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// glTexImage3D() depth cases with pbo.
41163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
41173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* shadow3dGroup = new tcu::TestCaseGroup(m_testCtx, "teximage3d_depth_pbo", "glTexImage3D() with depth or depth/stencil format with pbo");
41183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(shadow3dGroup);
41193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
41203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthStencilFormats); ndx++)
41213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
41223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex3DWidth	= 32;
41233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex3DHeight	= 64;
41243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex3DDepth	= 8;
41253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
41263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			shadow3dGroup->addChild(new TexImage2DArrayDepthBufferCase(m_context, (std::string(depthStencilFormats[ndx].name) + "_2d_array").c_str(), "", depthStencilFormats[ndx].internalFormat, tex3DWidth, tex3DHeight, tex3DDepth));
41273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
41283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
41293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
41303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Basic TexSubImage3D usage.
41313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
41323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* basicTexSubImageGroup = new tcu::TestCaseGroup(m_testCtx, "basic_texsubimage3d", "Basic glTexSubImage3D() usage");
41333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(basicTexSubImageGroup);
41343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
41353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
41363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	fmtName		= colorFormats[formatNdx].name;
41373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	format		= colorFormats[formatNdx].internalFormat;
41383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex3DWidth	= 32;
41393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex3DHeight	= 64;
41403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex3DDepth	= 8;
41413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
41423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			basicTexSubImageGroup->addChild(new BasicTexSubImage3DCase(m_context, (string(fmtName) + "_3d").c_str(), "", format, tex3DWidth, tex3DHeight, tex3DDepth));
41433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
41443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
41453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
41463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// glTexSubImage3D() unpack params cases.
41473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
41483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* paramGroup = new tcu::TestCaseGroup(m_testCtx, "texsubimage3d_unpack_params", "glTexSubImage3D() unpack parameters");
41493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(paramGroup);
41503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
41513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const struct
41523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
41533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	name;
41543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	format;
41553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			width;
41563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			height;
41573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			depth;
41583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subX;
41593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subY;
41603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subZ;
41613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subW;
41623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subH;
41633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subD;
41643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			imageHeight;
41653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			rowLength;
41663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipImages;
41673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipRows;
41683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipPixels;
41693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			alignment;
41703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} cases[] =
41713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
41723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_image_height",	GL_RGB8,	26, 25, 10,	1,	2,	1,	23,	19,	8,	26,	0,	0,	0,	0,	4 },
41733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_row_length",	GL_RGB8,	26, 25, 10,	1,	2,	1,	23,	19,	8,	0,	27,	0,	0,	0,	4 },
41743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_images",	GL_RGB8,	26, 25, 10,	1,	2,	1,	23,	19,	8,	0,	0,	3,	0,	0,	4 },
41753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_rows",		GL_RGB8,	26, 25, 10,	1,	2,	1,	23,	19,	8,	22,	0,	0,	3,	0,	4 },
41763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_pixels",	GL_RGB8,	26, 25, 10,	1,	2,	1,	23,	19,	8,	0,	25,	0,	0,	2,	4 },
41773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "r8_complex1",		GL_R8,		15,	20,	11,	1,	1,	0,	13, 17, 11,	23,	15,	2,	3,	1,	1 },
41783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "r8_complex2",		GL_R8,		15,	20,	11,	1,	1,	0,	13, 17, 11,	23,	15,	2,	3,	1,	2 },
41793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "r8_complex3",		GL_R8,		15,	20,	11,	1,	1,	0,	13, 17, 11,	23,	15,	2,	3,	1,	4 },
41803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "r8_complex4",		GL_R8,		15,	20,	11,	1,	1,	0,	13, 17, 11,	23,	15,	2,	3,	1,	8 },
41813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgba8_complex1",		GL_RGBA8,	15,	25,	10,	0,	5,	1,	11,	20,	8,	25,	14,	0,	0,	0,	8 },
41823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgba8_complex2",		GL_RGBA8,	15,	25,	10,	0,	5,	1,	11,	20,	8,	25,	14,	0,	2,	0,	8 },
41833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgba8_complex3",		GL_RGBA8,	15,	25,	10,	0,	5,	1,	11,	20,	8,	25,	14,	0,	0,	3,	8 },
41843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgba8_complex4",		GL_RGBA8,	15,	25,	10,	0,	5,	1,	11,	20,	8,	25,	14,	0,	2,	3,	8 },
41853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgba32f_complex",	GL_RGBA32F,	15,	25,	10,	0,	5,	1,	11,	20,	8,	25,	14,	0,	2,	3,	8 }
41863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
41873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
41883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(cases); ndx++)
41893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			paramGroup->addChild(new TexSubImage3DParamsCase(m_context, cases[ndx].name, "",
41903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].format,
41913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].width,
41923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].height,
41933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].depth,
41943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].subX,
41953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].subY,
41963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].subZ,
41973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].subW,
41983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].subH,
41993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].subD,
42003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].imageHeight,
42013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].rowLength,
42023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].skipImages,
42033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].skipRows,
42043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].skipPixels,
42053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 cases[ndx].alignment));
42063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
42073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
42083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// glTexSubImage3D() PBO cases.
42093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
42103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* pboGroup = new tcu::TestCaseGroup(m_testCtx, "texsubimage3d_pbo", "glTexSubImage3D() pixel buffer object tests");
42113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(pboGroup);
42123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
42133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const struct
42143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
42153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	name;
42163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	format;
42173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			width;
42183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			height;
42193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			depth;
42203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subX;
42213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subY;
42223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subZ;
42233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subW;
42243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subH;
42253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subD;
42263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			imageHeight;
42273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			rowLength;
42283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipImages;
42293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipRows;
42303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipPixels;
42313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			alignment;
42323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			offset;
42333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} paramCases[] =
42343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
42353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_offset",		GL_RGB8,	26, 25, 10,	1,	2,	1,	23,	19,	8,	0,	0,	0,	0,	0,	4,	67 },
42363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_image_height",	GL_RGB8,	26, 25, 10,	1,	2,	1,	23,	19,	8,	26,	0,	0,	0,	0,	4,	0 },
42373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_row_length",	GL_RGB8,	26, 25, 10,	1,	2,	1,	23,	19,	8,	0,	27,	0,	0,	0,	4,	0 },
42383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_images",	GL_RGB8,	26, 25, 10,	1,	2,	1,	23,	19,	8,	0,	0,	3,	0,	0,	4,	0 },
42393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_rows",		GL_RGB8,	26, 25, 10,	1,	2,	1,	23,	19,	8,	22,	0,	0,	3,	0,	4,	0 },
42403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_pixels",	GL_RGB8,	26, 25, 10,	1,	2,	1,	23,	19,	8,	0,	25,	0,	0,	2,	4,	0 }
42413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
42423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
42433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(colorFormats); ndx++)
42443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
42453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			pboGroup->addChild(new TexSubImage2DArrayBufferCase(m_context, (std::string(colorFormats[ndx].name) + "_2d_array").c_str(), "",
42463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   colorFormats[ndx].internalFormat,
42473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   26,	// Width
42483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   25,	// Height
42493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   10,	// Depth
42503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   1,	// Sub X
42513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   2,	// Sub Y
42523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0,	// Sub Z
42533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   23,	// Sub W
42543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   19,	// Sub H
42553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   8,	// Sub D
42563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0,	// Image height
42573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0,	// Row length
42583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0,	// Skip images
42593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0,	// Skip rows
42603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0,	// Skip pixels
42613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   4,	// Alignment
42623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0	/* offset */));
42633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			pboGroup->addChild(new TexSubImage3DBufferCase(m_context, (std::string(colorFormats[ndx].name) + "_3d").c_str(), "",
42643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   colorFormats[ndx].internalFormat,
42653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   26,	// Width
42663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   25,	// Height
42673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   10,	// Depth
42683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   1,	// Sub X
42693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   2,	// Sub Y
42703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0,	// Sub Z
42713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   23,	// Sub W
42723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   19,	// Sub H
42733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   8,	// Sub D
42743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0,	// Image height
42753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0,	// Row length
42763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0,	// Skip images
42773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0,	// Skip rows
42783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0,	// Skip pixels
42793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   4,	// Alignment
42803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0	/* offset */));
42813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
42823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
42833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(paramCases); ndx++)
42843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
42853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			pboGroup->addChild(new TexSubImage2DArrayBufferCase(m_context, (std::string(paramCases[ndx].name) + "_2d_array").c_str(), "",
42863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].format,
42873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].width,
42883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].height,
42893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].depth,
42903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subX,
42913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subY,
42923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subZ,
42933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subW,
42943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subH,
42953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subD,
42963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].imageHeight,
42973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].rowLength,
42983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].skipImages,
42993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].skipRows,
43003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].skipPixels,
43013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].alignment,
43023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].offset));
43033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			pboGroup->addChild(new TexSubImage3DBufferCase(m_context, (std::string(paramCases[ndx].name) + "_3d").c_str(), "",
43043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].format,
43053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].width,
43063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].height,
43073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].depth,
43083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subX,
43093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subY,
43103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subZ,
43113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subW,
43123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subH,
43133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subD,
43143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].imageHeight,
43153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].rowLength,
43163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].skipImages,
43173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].skipRows,
43183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].skipPixels,
43193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].alignment,
43203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].offset));
43213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
43223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
43233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
43243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// glTexSubImage3D() depth cases.
43253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
43263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* shadow3dGroup = new tcu::TestCaseGroup(m_testCtx, "texsubimage3d_depth", "glTexSubImage3D() with depth or depth/stencil format");
43273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(shadow3dGroup);
43283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
43293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthStencilFormats); ndx++)
43303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
43313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DArrayWidth		= 57;
43323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DArrayHeight	= 44;
43333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DArrayLevels	= 5;
43343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
43353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			shadow3dGroup->addChild(new TexSubImage2DArrayDepthCase(m_context, (std::string(depthStencilFormats[ndx].name) + "_2d_array").c_str(), "", depthStencilFormats[ndx].internalFormat, tex2DArrayWidth, tex2DArrayHeight, tex2DArrayLevels));
43363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
43373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
43383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
43393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// glTexStorage2D() cases.
43403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
43413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* texStorageGroup = new tcu::TestCaseGroup(m_testCtx, "texstorage2d", "Basic glTexStorage2D() usage");
43423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(texStorageGroup);
43433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
43443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// All formats.
43453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* formatGroup = new tcu::TestCaseGroup(m_testCtx, "format", "glTexStorage2D() with all formats");
43463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		texStorageGroup->addChild(formatGroup);
43473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
43483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Color formats.
43493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
43503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
43513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	fmtName			= colorFormats[formatNdx].name;
43523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	internalFormat	= colorFormats[formatNdx].internalFormat;
43533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DWidth		= 117;
43543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DHeight		= 97;
43553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			tex2DLevels		= maxLevelCount(tex2DWidth, tex2DHeight);
43563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	cubeSize		= 57;
43573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			cubeLevels		= maxLevelCount(cubeSize, cubeSize);
43583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
43593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			formatGroup->addChild(new BasicTexStorage2DCase		(m_context, (string(fmtName) + "_2d").c_str(),		"", internalFormat, tex2DWidth, tex2DHeight, tex2DLevels));
43603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			formatGroup->addChild(new BasicTexStorageCubeCase	(m_context, (string(fmtName) + "_cube").c_str(),	"", internalFormat, cubeSize, cubeLevels));
43613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
43623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
43633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Depth / stencil formats.
43643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(depthStencilFormats); formatNdx++)
43653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
43663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	fmtName			= depthStencilFormats[formatNdx].name;
43673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	internalFormat	= depthStencilFormats[formatNdx].internalFormat;
43683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DWidth		= 117;
43693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DHeight		= 97;
43703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			tex2DLevels		= maxLevelCount(tex2DWidth, tex2DHeight);
43713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	cubeSize		= 57;
43723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			cubeLevels		= maxLevelCount(cubeSize, cubeSize);
43733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
43743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			formatGroup->addChild(new BasicTexStorage2DCase		(m_context, (string(fmtName) + "_2d").c_str(),		"", internalFormat, tex2DWidth, tex2DHeight, tex2DLevels));
43753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			formatGroup->addChild(new BasicTexStorageCubeCase	(m_context, (string(fmtName) + "_cube").c_str(),	"", internalFormat, cubeSize, cubeLevels));
43763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
43773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
43783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Sizes.
43793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const struct
43803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
43813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int				width;
43823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int				height;
43833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int				levels;
43843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} tex2DSizes[] =
43853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
43863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			//	W	H	L
43873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	1,	1,	1 },
43883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	2,	2,	2 },
43893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	64,	32,	7 },
43903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	32,	64,	4 },
43913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	57,	63,	1 },
43923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	57,	63,	2 },
43933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	57,	63,	6 }
43943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
43953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const struct
43963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
43973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		size;
43983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levels;
43993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} cubeSizes[] =
44003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
44013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			//	S	L
44023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	1,	1 },
44033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	2,	2 },
44043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	57,	1 },
44053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	57,	2 },
44063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	57,	6 },
44073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	64,	4 },
44083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	64,	7 },
44093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
44103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
44113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* sizeGroup = new tcu::TestCaseGroup(m_testCtx, "size", "glTexStorage2D() with various sizes");
44123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		texStorageGroup->addChild(sizeGroup);
44133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
44143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(tex2DSizes); ndx++)
44153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
44163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const deUint32		format		= GL_RGBA8;
44173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int					width		= tex2DSizes[ndx].width;
44183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int					height		= tex2DSizes[ndx].height;
44193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int					levels		= tex2DSizes[ndx].levels;
44203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			string				name		= string("2d_") + de::toString(width) + "x" + de::toString(height) + "_" + de::toString(levels) + "_levels";
44213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
44223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			sizeGroup->addChild(new BasicTexStorage2DCase(m_context, name.c_str(), "", format, width, height, levels));
44233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
44243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
44253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(cubeSizes); ndx++)
44263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
44273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const deUint32		format		= GL_RGBA8;
44283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int					size		= cubeSizes[ndx].size;
44293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int					levels		= cubeSizes[ndx].levels;
44303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			string				name		= string("cube_") + de::toString(size) + "x" + de::toString(size) + "_" + de::toString(levels) + "_levels";
44313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
44323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			sizeGroup->addChild(new BasicTexStorageCubeCase(m_context, name.c_str(), "", format, size, levels));
44333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
44343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
44353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
44363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// glTexStorage3D() cases.
44373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
44383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* texStorageGroup = new tcu::TestCaseGroup(m_testCtx, "texstorage3d", "Basic glTexStorage3D() usage");
44393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(texStorageGroup);
44403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
44413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// All formats.
44423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* formatGroup = new tcu::TestCaseGroup(m_testCtx, "format", "glTexStorage3D() with all formats");
44433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		texStorageGroup->addChild(formatGroup);
44443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
44453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Color formats.
44463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
44473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
44483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	fmtName				= colorFormats[formatNdx].name;
44493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	internalFormat		= colorFormats[formatNdx].internalFormat;
44503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DArrayWidth		= 57;
44513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DArrayHeight	= 13;
44523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DArrayLayers	= 7;
44533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			tex2DArrayLevels	= maxLevelCount(tex2DArrayWidth, tex2DArrayHeight);
44543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex3DWidth			= 59;
44553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex3DHeight			= 37;
44563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex3DDepth			= 11;
44573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			tex3DLevels			= maxLevelCount(tex3DWidth, tex3DHeight, tex3DDepth);
44583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
44593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			formatGroup->addChild(new BasicTexStorage2DArrayCase	(m_context, (string(fmtName) + "_2d_array").c_str(),	"", internalFormat, tex2DArrayWidth, tex2DArrayHeight, tex2DArrayLayers, tex2DArrayLevels));
44603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			formatGroup->addChild(new BasicTexStorage3DCase			(m_context, (string(fmtName) + "_3d").c_str(),			"", internalFormat, tex3DWidth, tex3DHeight, tex3DDepth, tex3DLevels));
44613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
44623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
44633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Depth/stencil formats (only 2D texture array is supported).
44643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(depthStencilFormats); formatNdx++)
44653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
44663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	fmtName				= depthStencilFormats[formatNdx].name;
44673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	internalFormat		= depthStencilFormats[formatNdx].internalFormat;
44683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DArrayWidth		= 57;
44693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DArrayHeight	= 13;
44703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DArrayLayers	= 7;
44713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			tex2DArrayLevels	= maxLevelCount(tex2DArrayWidth, tex2DArrayHeight);
44723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
44733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			formatGroup->addChild(new BasicTexStorage2DArrayCase	(m_context, (string(fmtName) + "_2d_array").c_str(),	"", internalFormat, tex2DArrayWidth, tex2DArrayHeight, tex2DArrayLayers, tex2DArrayLevels));
44743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
44753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
44763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Sizes.
44773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const struct
44783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
44793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int				width;
44803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int				height;
44813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int				layers;
44823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int				levels;
44833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} tex2DArraySizes[] =
44843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
44853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			//	W	H	La	Le
44863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	1,	1,	1,	1 },
44873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	2,	2,	2,	2 },
44883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	64,	32,	3,	7 },
44893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	32,	64,	3,	4 },
44903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	57,	63,	5,	1 },
44913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	57,	63,	5,	2 },
44923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	57,	63,	5,	6 }
44933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
44943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const struct
44953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
44963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int				width;
44973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int				height;
44983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int				depth;
44993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int				levels;
45003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} tex3DSizes[] =
45013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
45023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			//	W	H	D	L
45033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	1,	1,	1,	1 },
45043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	2,	2,	2,	2 },
45053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	64,	32,	16,	7 },
45063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	32,	64,	16,	4 },
45073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	32,	16,	64,	4 },
45083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	57,	63,	11,	1 },
45093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	57,	63,	11,	2 },
45103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	57,	63,	11,	6 }
45113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
45123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
45133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* sizeGroup = new tcu::TestCaseGroup(m_testCtx, "size", "glTexStorage2D() with various sizes");
45143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		texStorageGroup->addChild(sizeGroup);
45153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
45163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(tex2DArraySizes); ndx++)
45173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
45183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const deUint32		format		= GL_RGBA8;
45193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int					width		= tex2DArraySizes[ndx].width;
45203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int					height		= tex2DArraySizes[ndx].height;
45213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int					layers		= tex2DArraySizes[ndx].layers;
45223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int					levels		= tex2DArraySizes[ndx].levels;
45233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			string				name		= string("2d_array_") + de::toString(width) + "x" + de::toString(height) + "x" + de::toString(layers) + "_" + de::toString(levels) + "_levels";
45243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
45253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			sizeGroup->addChild(new BasicTexStorage2DArrayCase(m_context, name.c_str(), "", format, width, height, layers, levels));
45263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
45273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
45283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(tex3DSizes); ndx++)
45293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
45303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const deUint32		format		= GL_RGBA8;
45313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int					width		= tex3DSizes[ndx].width;
45323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int					height		= tex3DSizes[ndx].height;
45333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int					depth		= tex3DSizes[ndx].depth;
45343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int					levels		= tex3DSizes[ndx].levels;
45353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			string				name		= string("3d_") + de::toString(width) + "x" + de::toString(height) + "x" + de::toString(depth) + "_" + de::toString(levels) + "_levels";
45363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
45373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			sizeGroup->addChild(new BasicTexStorage3DCase(m_context, name.c_str(), "", format, width, height, depth, levels));
45383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
45393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
45403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
45413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
45423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional
45433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles3
45443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
4545