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 "es31fTextureSpecificationTests.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 "es31fFboTestUtil.hpp"
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp"
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles31
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 Poyryenum
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VIEWPORT_WIDTH	= 256,
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VIEWPORT_HEIGHT	= 256
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic inline int maxLevelCount (int size)
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return (int)deLog2Floor32(size)+1;
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <int Size>
783c827367444ee418f129b2c238299f49d3264554Jarkko 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))
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Vector<float, Size> res;
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int ndx = 0; ndx < Size; ndx++)
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		res[ndx] = rnd.getFloat(minVal[ndx], maxVal[ndx]);
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return res;
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic tcu::CubeFace getCubeFaceFromNdx (int ndx)
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	switch (ndx)
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case 0:	return tcu::CUBEFACE_POSITIVE_X;
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case 1:	return tcu::CUBEFACE_NEGATIVE_X;
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case 2:	return tcu::CUBEFACE_POSITIVE_Y;
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case 3:	return tcu::CUBEFACE_NEGATIVE_Y;
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case 4:	return tcu::CUBEFACE_POSITIVE_Z;
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case 5:	return tcu::CUBEFACE_NEGATIVE_Z;
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		default:
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			DE_ASSERT(false);
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return tcu::CUBEFACE_LAST;
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureSpecCase : public TestCase, public sglr::ContextWrapper
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						TextureSpecCase			(Context& context, const char* name, const char* desc);
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						~TextureSpecCase		(void);
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult		iterate					(void);
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual bool		checkExtensionSupport	(void)	{ return true; }
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void		createTexture			(void)																= DE_NULL;
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void		verifyTexture			(sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext)	= DE_NULL;
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Utilities.
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void				renderTex				(tcu::Surface& dst, deUint32 program, int width, int height);
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void				readPixels				(tcu::Surface& dst, int x, int y, int width, int height);
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						TextureSpecCase			(const TextureSpecCase& other);
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureSpecCase&	operator=				(const TextureSpecCase& other);
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1253c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureSpecCase::TextureSpecCase (Context& context, const char* name, const char* desc)
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCase(context, name, desc)
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1303c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureSpecCase::~TextureSpecCase (void)
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1343c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureSpecCase::IterateResult TextureSpecCase::iterate (void)
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::RenderContext&			renderCtx				= TestCase::m_context.getRenderContext();
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::RenderTarget&	renderTarget			= renderCtx.getRenderTarget();
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TestLog&				log						= m_testCtx.getLog();
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (renderTarget.getWidth() < VIEWPORT_WIDTH || renderTarget.getHeight() < VIEWPORT_HEIGHT)
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::NotSupportedError("Too small viewport", "", __FILE__, __LINE__);
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!checkExtensionSupport())
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::NotSupportedError("Extension not supported", "", __FILE__, __LINE__);
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Context size, and viewport for GLES3.1
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	de::Random	rnd			(deStringHash(getName()));
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			width		= deMin32(renderTarget.getWidth(),	VIEWPORT_WIDTH);
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			height		= deMin32(renderTarget.getHeight(),	VIEWPORT_HEIGHT);
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			x			= rnd.getInt(0, renderTarget.getWidth()		- width);
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			y			= rnd.getInt(0, renderTarget.getHeight()	- height);
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Contexts.
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	sglr::GLContext					gles31Context	(renderCtx, log, sglr::GLCONTEXT_LOG_CALLS, tcu::IVec4(x, y, width, height));
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	sglr::ReferenceContextBuffers	refBuffers		(tcu::PixelFormat(8,8,8,renderTarget.getPixelFormat().alphaBits?8:0), 0 /* depth */, 0 /* stencil */, width, height);
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	sglr::ReferenceContext			refContext		(sglr::ReferenceContextLimits(renderCtx), refBuffers.getColorbuffer(), refBuffers.getDepthbuffer(), refBuffers.getStencilbuffer());
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Clear color buffer.
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int ndx = 0; ndx < 2; ndx++)
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		setContext(ndx ? (sglr::Context*)&refContext : (sglr::Context*)&gles31Context);
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glClearColor(0.125f, 0.25f, 0.5f, 1.0f);
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Construct texture using both GLES3.1 and reference contexts.
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int ndx = 0; ndx < 2; ndx++)
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		setContext(ndx ? (sglr::Context*)&refContext : (sglr::Context*)&gles31Context);
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		createTexture();
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TCU_CHECK(glGetError() == GL_NO_ERROR);
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Initialize case result to pass.
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Disable logging.
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gles31Context.enableLogging(0);
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Verify results.
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	verifyTexture(gles31Context, refContext);
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return STOP;
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureSpecCase::renderTex (tcu::Surface& dst, deUint32 program, int width, int height)
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int		targetW		= getWidth();
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int		targetH		= getHeight();
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float	w			= (float)width	/ (float)targetW;
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float	h			= (float)height	/ (float)targetH;
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1943c827367444ee418f129b2c238299f49d3264554Jarkko 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));
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Read pixels back.
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	readPixels(dst, 0, 0, width, height);
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureSpecCase::readPixels (tcu::Surface& dst, int x, int y, int width, int height)
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	dst.setSize(width, height);
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, dst.getAccess().getDataPtr());
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureCubeArraySpecCase : public TextureSpecCase
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							TextureCubeArraySpecCase	(Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int size, int depth, int numLevels);
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							~TextureCubeArraySpecCase	(void);
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual bool			checkExtensionSupport		(void);
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			verifyTexture				(sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext);
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureFormat		m_texFormat;
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureFormatInfo	m_texFormatInfo;
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_size;
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_depth;
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						m_numLevels;
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2233c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureCubeArraySpecCase::TextureCubeArraySpecCase (Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int size, int depth, int numLevels)
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TextureSpecCase		(context, name, desc)
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_texFormat			(format)
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_texFormatInfo		(tcu::getTextureFormatInfo(format))
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_size				(size)
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_depth				(depth)
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_numLevels			(numLevels)
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2333c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureCubeArraySpecCase::~TextureCubeArraySpecCase (void)
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool TextureCubeArraySpecCase::checkExtensionSupport (void)
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_context.getContextInfo().isExtensionSupported("GL_EXT_texture_cube_map_array");
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureCubeArraySpecCase::verifyTexture (sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext)
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureCubeArrayShader	shader			(glu::getSamplerCubeArrayType(m_texFormat), glu::TYPE_FLOAT_VEC4);
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				shaderIDgles	= gles3Context.createProgram(&shader);
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				shaderIDRef		= refContext.createProgram(&shader);
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	shader.setTexScaleBias(m_texFormatInfo.lookupScale, m_texFormatInfo.lookupBias);
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Set state.
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int ndx = 0; ndx < 2; ndx++)
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		sglr::Context* ctx = ndx ? static_cast<sglr::Context*>(&refContext) : static_cast<sglr::Context*>(&gles3Context);
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		setContext(ctx);
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_MIN_FILTER,	GL_NEAREST_MIPMAP_NEAREST);
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_MAG_FILTER,	GL_NEAREST);
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_WRAP_S,		GL_CLAMP_TO_EDGE);
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_WRAP_T,		GL_CLAMP_TO_EDGE);
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_WRAP_R,		GL_CLAMP_TO_EDGE);
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_MAX_LEVEL,	m_numLevels-1);
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int layerFaceNdx = 0; layerFaceNdx < m_depth; layerFaceNdx++)
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int			layerNdx	= layerFaceNdx / 6;
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const tcu::CubeFace	face		= getCubeFaceFromNdx(layerFaceNdx % 6);
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool				layerOk		= true;
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		shader.setLayer(layerNdx);
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		shader.setFace(face);
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int levelNdx = 0; levelNdx < m_numLevels; levelNdx++)
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int				levelSize	= de::max(1, m_size	>> levelNdx);
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::Surface	reference;
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::Surface	result;
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (levelSize <= 2)
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				continue; // Fuzzy compare doesn't work for images this small.
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int ndx = 0; ndx < 2; ndx++)
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				tcu::Surface&	dst			= ndx ? reference									: result;
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				sglr::Context*	ctx			= ndx ? static_cast<sglr::Context*>(&refContext)	: static_cast<sglr::Context*>(&gles3Context);
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				deUint32		shaderID	= ndx ? shaderIDRef									: shaderIDgles;
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				setContext(ctx);
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				shader.setUniforms(*ctx, shaderID);
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				renderTex(dst, shaderID, levelSize, levelSize);
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const float		threshold		= 0.02f;
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			string			levelStr		= de::toString(levelNdx);
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			string			layerFaceStr	= de::toString(layerFaceNdx);
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			string			name			= string("LayerFace") + layerFaceStr + "Level" + levelStr;
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			string			desc			= string("Layer-face ") + layerFaceStr + ", Level " + levelStr;
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			bool			isFaceOk		= tcu::fuzzyCompare(m_testCtx.getLog(), name.c_str(), desc.c_str(), reference, result, threshold,
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																(levelNdx == 0 && layerFaceNdx == 0) == 0 ? tcu::COMPARE_LOG_RESULT : tcu::COMPARE_LOG_ON_ERROR);
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (!isFaceOk)
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed");
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				layerOk = false;
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				break;
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!layerOk)
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			break;
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Basic TexImage3D() with cube map array texture usage
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicTexImageCubeArrayCase : public TextureCubeArraySpecCase
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicTexImageCubeArrayCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size, int numLayers)
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCubeArraySpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), size, numLayers, maxLevelCount(size))
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat			(internalFormat)
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				tex			= 0;
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel		levelData	(m_texFormat);
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random				rnd			(deStringHash(getName()));
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat		transferFmt	= glu::getTransferFormat(m_texFormat);
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, tex);
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_size	>> ndx);
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMin		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMax		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levelData.setSize(levelW, levelW, m_depth);
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, ndx, m_internalFormat, levelW, levelW, m_depth, 0, transferFmt.format, transferFmt.dataType, levelData.getAccess().getDataPtr());
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 m_internalFormat;
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Basic glTexStorage3D() with cube map array texture usage
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicTexStorageCubeArrayCase : public TextureCubeArraySpecCase
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicTexStorageCubeArrayCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size, int numLayers, int numLevels)
3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCubeArraySpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), size, numLayers, numLevels)
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat			(internalFormat)
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				tex			= 0;
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel		levelData	(m_texFormat);
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random				rnd			(deStringHash(getName()));
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat		transferFmt	= glu::getTransferFormat(m_texFormat);
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures	(1, &tex);
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture	(GL_TEXTURE_CUBE_MAP_ARRAY, tex);
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexStorage3D	(GL_TEXTURE_CUBE_MAP_ARRAY, m_numLevels, m_internalFormat, m_size, m_size, m_depth);
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei	(GL_UNPACK_ALIGNMENT, 1);
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_size	>> ndx);
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMin		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMax		= randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levelData.setSize(levelW, levelW, m_depth);
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, ndx, 0, 0, 0, levelW, levelW, m_depth, transferFmt.format, transferFmt.dataType, levelData.getAccess().getDataPtr());
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 m_internalFormat;
3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Pixel buffer object cases.
3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexImage3D() cube map array from pixel buffer object.
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexImageCubeArrayBufferCase : public TextureCubeArraySpecCase
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexImageCubeArrayBufferCase (Context&		context,
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   const char*	name,
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   const char*	desc,
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   deUint32		internalFormat,
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   int			size,
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   int			depth,
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   int			imageHeight,
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   int			rowLength,
4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   int			skipImages,
4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   int			skipRows,
4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   int			skipPixels,
4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   int			alignment,
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							   int			offset)
4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCubeArraySpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), size, depth, 1)
4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat			(internalFormat)
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_imageHeight				(imageHeight)
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_rowLength				(rowLength)
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipImages				(skipImages)
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipRows				(skipRows)
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipPixels				(skipPixels)
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment				(alignment)
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_offset					(offset)
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat		transferFmt		= glu::getTransferFormat(m_texFormat);
4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						pixelSize		= m_texFormat.getPixelSize();
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						rowLength		= m_rowLength > 0 ? m_rowLength : m_size;
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						rowPitch		= deAlign32(rowLength*pixelSize, m_alignment);
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						imageHeight		= m_imageHeight > 0 ? m_imageHeight : m_size;
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						slicePitch		= imageHeight*rowPitch;
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				tex				= 0;
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				buf				= 0;
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<deUint8>			data;
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_numLevels == 1);
4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill data with grid.
4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		data.resize(slicePitch*(m_depth+m_skipImages) + m_offset);
4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cScale		= m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cBias		= m_texFormatInfo.valueMin;
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorA		= Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias;
4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorB		= Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias;
4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_size, m_size, m_depth, rowPitch, slicePitch, &data[0] + m_skipImages*slicePitch + m_skipRows*rowPitch + m_skipPixels*pixelSize + m_offset), 4, colorA, colorB);
4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenBuffers(1, &buf);
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW);
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_IMAGE_HEIGHT,	m_imageHeight);
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ROW_LENGTH,		m_rowLength);
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_IMAGES,	m_skipImages);
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_ROWS,		m_skipRows);
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_PIXELS,	m_skipPixels);
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT,		m_alignment);
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, tex);
4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, m_internalFormat, m_size, m_size, m_depth, 0, transferFmt.format, transferFmt.dataType, (const void*)(deUintptr)m_offset);
4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_imageHeight;
4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_rowLength;
4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipImages;
4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipRows;
4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipPixels;
4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_alignment;
4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_offset;
4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexSubImage3D() cube map array PBO case.
4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexSubImageCubeArrayBufferCase : public TextureCubeArraySpecCase
4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexSubImageCubeArrayBufferCase (Context&		context,
4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 const char*	name,
4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 const char*	desc,
4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 deUint32		internalFormat,
4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			size,
4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			depth,
4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			subX,
4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			subY,
4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			subZ,
4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			subW,
4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			subH,
4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			subD,
4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			imageHeight,
4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			rowLength,
4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			skipImages,
4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			skipRows,
4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			skipPixels,
4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			alignment,
4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			offset)
4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCubeArraySpecCase	(context, name, desc, glu::mapGLInternalFormat(internalFormat), size, depth, 1)
5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat			(internalFormat)
5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subX					(subX)
5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subY					(subY)
5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subZ					(subZ)
5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subW					(subW)
5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subH					(subH)
5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subD					(subD)
5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_imageHeight				(imageHeight)
5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_rowLength				(rowLength)
5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipImages				(skipImages)
5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipRows				(skipRows)
5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_skipPixels				(skipPixels)
5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment				(alignment)
5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_offset					(offset)
5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat		transferFmt		= glu::getTransferFormat(m_texFormat);
5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						pixelSize		= m_texFormat.getPixelSize();
5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				tex				= 0;
5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				buf				= 0;
5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<deUint8>			data;
5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_numLevels == 1);
5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, tex);
5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill with gradient.
5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		rowPitch		= deAlign32(pixelSize*m_size,  4);
5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		slicePitch		= rowPitch*m_size;
5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.resize(slicePitch*m_depth);
5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_size, m_size, m_depth, rowPitch, slicePitch, &data[0]), m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, m_internalFormat, m_size, m_size, m_depth, 0, transferFmt.format, transferFmt.dataType, &data[0]);
5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill data with grid.
5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		rowLength		= m_rowLength > 0 ? m_rowLength : m_subW;
5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		rowPitch		= deAlign32(rowLength*pixelSize, m_alignment);
5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		imageHeight		= m_imageHeight > 0 ? m_imageHeight : m_subH;
5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		slicePitch		= imageHeight*rowPitch;
5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cScale			= m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	cBias			= m_texFormatInfo.valueMin;
5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorA			= Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias;
5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorB			= Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias;
5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.resize(slicePitch*(m_depth+m_skipImages) + m_offset);
5543c827367444ee418f129b2c238299f49d3264554Jarkko 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);
5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenBuffers(1, &buf);
5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindBuffer(GL_PIXEL_UNPACK_BUFFER,	buf);
5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBufferData(GL_PIXEL_UNPACK_BUFFER,	(int)data.size(), &data[0], GL_STATIC_DRAW);
5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_IMAGE_HEIGHT,	m_imageHeight);
5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ROW_LENGTH,		m_rowLength);
5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_IMAGES,	m_skipImages);
5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_ROWS,		m_skipRows);
5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_PIXELS,	m_skipPixels);
5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT,		m_alignment);
5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, m_subX, m_subY, m_subZ, m_subW, m_subH, m_subD, transferFmt.format, transferFmt.dataType, (const void*)(deIntptr)m_offset);
5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_internalFormat;
5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subX;
5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subY;
5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subZ;
5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subW;
5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subH;
5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subD;
5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_imageHeight;
5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_rowLength;
5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipImages;
5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipRows;
5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_skipPixels;
5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_alignment;
5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_offset;
5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexImage3D() depth case.
5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexImageCubeArrayDepthCase : public TextureCubeArraySpecCase
5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexImageCubeArrayDepthCase (Context&	context,
5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							  const char*	name,
5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							  const char*	desc,
5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							  deUint32		internalFormat,
5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							  int			imageSize,
5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							  int			numLayers)
5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCubeArraySpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), imageSize, numLayers, maxLevelCount(imageSize))
5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat		(internalFormat)
5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// we are interested in the behavior near [-2, 2], map it to visible range [0, 1]
6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_texFormatInfo.lookupBias = Vec4(0.25f, 0.0f, 0.0f, 1.0f);
6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_texFormatInfo.lookupScale = Vec4(0.5f, 1.0f, 1.0f, 0.0f);
6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat	fmt			= glu::getTransferFormat(m_texFormat);
6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel	levelData	(m_texFormat);
6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, tex);
6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_CHECK();
6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int   levelW		= de::max(1, m_size >> ndx);
6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4  gMin		= Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4  gMax		= Vec4(2.0f, 1.5f, -1.0f, 2.0f);
6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levelData.setSize(levelW, levelW, m_depth);
6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, ndx, m_internalFormat, levelW, levelW, m_depth, 0, fmt.format, fmt.dataType, levelData.getAccess().getDataPtr());
6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32 m_internalFormat;
6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexSubImage3D() depth case.
6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexSubImageCubeArrayDepthCase : public TextureCubeArraySpecCase
6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexSubImageCubeArrayDepthCase (Context&		context,
6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 const char*	name,
6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 const char*	desc,
6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 deUint32		internalFormat,
6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			imageSize,
6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								 int			numLayers)
6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCubeArraySpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), imageSize, numLayers, maxLevelCount(imageSize))
6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat		(internalFormat)
6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// we are interested in the behavior near [-2, 2], map it to visible range [0, 1]
6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_texFormatInfo.lookupBias = Vec4(0.25f, 0.0f, 0.0f, 1.0f);
6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_texFormatInfo.lookupScale = Vec4(0.5f, 1.0f, 1.0f, 0.0f);
6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat	fmt			= glu::getTransferFormat(m_texFormat);
6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random			rnd			(deStringHash(getName()));
6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel	levelData	(m_texFormat);
6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, tex);
6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_CHECK();
6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// First specify full texture.
6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int   levelW		= de::max(1, m_size >> ndx);
6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4  gMin		= Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4  gMax		= Vec4(2.0f, 1.5f, -1.0f, 2.0f);
6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levelData.setSize(levelW, levelW, m_depth);
6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, ndx, m_internalFormat, levelW, levelW, m_depth, 0, fmt.format, fmt.dataType, levelData.getAccess().getDataPtr());
6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Re-specify parts of each level.
6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < m_numLevels; ndx++)
6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	levelW		= de::max(1, m_size >> ndx);
6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	w			= rnd.getInt(1, levelW);
6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	h			= rnd.getInt(1, levelW);
6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	d			= rnd.getInt(1, m_depth);
6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	x			= rnd.getInt(0, levelW-w);
6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	y			= rnd.getInt(0, levelW-h);
6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	z			= rnd.getInt(0, m_depth-d);
6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4	colorA		= Vec4(2.0f, 1.5f, -1.0f, 2.0f);
6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4	colorB		= Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	cellSize	= rnd.getInt(2, 16);
6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levelData.setSize(w, h, d);
6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithGrid(levelData.getAccess(), cellSize, colorA, colorB);
6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, ndx, x, y, z, w, h, d, fmt.format, fmt.dataType, levelData.getAccess().getDataPtr());
6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32 m_internalFormat;
6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexImage3D() depth case with pbo.
7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexImageCubeArrayDepthBufferCase : public TextureCubeArraySpecCase
7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexImageCubeArrayDepthBufferCase (Context&	context,
7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									const char*	name,
7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									const char*	desc,
7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									deUint32	internalFormat,
7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									int			imageSize,
7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									int			numLayers)
7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCubeArraySpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), imageSize, numLayers, 1)
7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat		(internalFormat)
7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// we are interested in the behavior near [-2, 2], map it to visible range [0, 1]
7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_texFormatInfo.lookupBias = Vec4(0.25f, 0.0f, 0.0f, 1.0f);
7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_texFormatInfo.lookupScale = Vec4(0.5f, 1.0f, 1.0f, 0.0f);
7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::TransferFormat		transferFmt		= glu::getTransferFormat(m_texFormat);
7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						pixelSize		= m_texFormat.getPixelSize();
7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						rowLength		= m_size;
7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						alignment		= 4;
7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						rowPitch		= deAlign32(rowLength*pixelSize, alignment);
7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						imageHeight		= m_size;
7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int						slicePitch		= imageHeight*rowPitch;
7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				tex				= 0;
7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32				buf				= 0;
7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<deUint8>			data;
7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_numLevels == 1);
7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill data with grid.
7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		data.resize(slicePitch*m_depth);
7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4 gMin = Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4 gMax = Vec4(2.0f, 1.5f, -1.0f, 2.0f);
7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_size, m_size, m_depth, rowPitch, slicePitch, &data[0]), gMin, gMax);
7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenBuffers(1, &buf);
7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW);
7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_IMAGE_HEIGHT,	imageHeight);
7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ROW_LENGTH,		rowLength);
7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_IMAGES,	0);
7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_ROWS,		0);
7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_SKIP_PIXELS,	0);
7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT,		alignment);
7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, tex);
7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, m_internalFormat, m_size, m_size, m_depth, 0, transferFmt.format, transferFmt.dataType, DE_NULL);
7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteBuffers(1, &buf);
7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32 m_internalFormat;
7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7623c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureSpecificationTests::TextureSpecificationTests (Context& context)
7633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCaseGroup(context, "specification", "Texture Specification Tests")
7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7673c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureSpecificationTests::~TextureSpecificationTests (void)
7683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7713c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureSpecificationTests::init (void)
7723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	struct
7743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char*	name;
7763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32	internalFormat;
7773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	} colorFormats[] =
7783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba32f",			GL_RGBA32F,			},
7803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba32i",			GL_RGBA32I,			},
7813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba32ui",			GL_RGBA32UI,		},
7823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba16f",			GL_RGBA16F,			},
7833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba16i",			GL_RGBA16I,			},
7843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba16ui",			GL_RGBA16UI,		},
7853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba8",				GL_RGBA8,			},
7863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba8i",				GL_RGBA8I,			},
7873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba8ui",			GL_RGBA8UI,			},
7883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "srgb8_alpha8",		GL_SRGB8_ALPHA8,	},
7893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb10_a2",			GL_RGB10_A2,		},
7903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb10_a2ui",			GL_RGB10_A2UI,		},
7913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba4",				GL_RGBA4,			},
7923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb5_a1",			GL_RGB5_A1,			},
7933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba8_snorm",		GL_RGBA8_SNORM,		},
7943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb8",				GL_RGB8,			},
7953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb565",				GL_RGB565,			},
7963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "r11f_g11f_b10f",		GL_R11F_G11F_B10F,	},
7973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb32f",				GL_RGB32F,			},
7983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb32i",				GL_RGB32I,			},
7993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb32ui",			GL_RGB32UI,			},
8003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb16f",				GL_RGB16F,			},
8013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb16i",				GL_RGB16I,			},
8023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb16ui",			GL_RGB16UI,			},
8033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb8_snorm",			GL_RGB8_SNORM,		},
8043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb8i",				GL_RGB8I,			},
8053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb8ui",				GL_RGB8UI,			},
8063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "srgb8",				GL_SRGB8,			},
8073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb9_e5",			GL_RGB9_E5,			},
8083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rg32f",				GL_RG32F,			},
8093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rg32i",				GL_RG32I,			},
8103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rg32ui",				GL_RG32UI,			},
8113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rg16f",				GL_RG16F,			},
8123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rg16i",				GL_RG16I,			},
8133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rg16ui",				GL_RG16UI,			},
8143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rg8",				GL_RG8,				},
8153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rg8i",				GL_RG8I,			},
8163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rg8ui",				GL_RG8UI,			},
8173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rg8_snorm",			GL_RG8_SNORM,		},
8183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "r32f",				GL_R32F,			},
8193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "r32i",				GL_R32I,			},
8203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "r32ui",				GL_R32UI,			},
8213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "r16f",				GL_R16F,			},
8223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "r16i",				GL_R16I,			},
8233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "r16ui",				GL_R16UI,			},
8243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "r8",					GL_R8,				},
8253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "r8i",				GL_R8I,				},
8263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "r8ui",				GL_R8UI,			},
8273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "r8_snorm",			GL_R8_SNORM,		}
8283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
8293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static const struct
8313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char*	name;
8333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32	internalFormat;
8343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	} depthStencilFormats[] =
8353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Depth and stencil formats
8373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "depth_component32f",	GL_DEPTH_COMPONENT32F	},
8383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "depth_component24",	GL_DEPTH_COMPONENT24	},
8393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "depth_component16",	GL_DEPTH_COMPONENT16	},
8403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "depth32f_stencil8",	GL_DEPTH32F_STENCIL8	},
8413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "depth24_stencil8",	GL_DEPTH24_STENCIL8		}
8423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
8433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Basic TexImage3D usage.
8453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* basicTexImageGroup = new tcu::TestCaseGroup(m_testCtx, "basic_teximage3d", "Basic glTexImage3D() usage");
8473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(basicTexImageGroup);
8483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
8493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
8503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	fmtName				= colorFormats[formatNdx].name;
8513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	format				= colorFormats[formatNdx].internalFormat;
8523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	texCubeArraySize	= 64;
8533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	texCubeArrayLayers	= 6;
8543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			basicTexImageGroup->addChild(new BasicTexImageCubeArrayCase	(m_context,	(string(fmtName) + "_cube_array").c_str(),	"",	format, texCubeArraySize, texCubeArrayLayers));
8563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
8573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// glTexImage3D() pbo cases.
8603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* pboGroup = new tcu::TestCaseGroup(m_testCtx, "teximage3d_pbo", "glTexImage3D() from PBO");
8623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(pboGroup);
8633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Parameter cases
8653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const struct
8663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
8673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	name;
8683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	format;
8693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			size;
8703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			depth;
8713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			imageHeight;
8723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			rowLength;
8733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipImages;
8743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipRows;
8753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipPixels;
8763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			alignment;
8773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			offset;
8783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} parameterCases[] =
8793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
8803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_offset",		GL_RGB8,	23,	6,	0,	0,	0,	0,	0,	1,	67 },
8813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_alignment",		GL_RGB8,	23,	6,	0,	0,	0,	0,	0,	2,	0 },
8823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_image_height",	GL_RGB8,	23,	6,	26,	0,	0,	0,	0,	4,	0 },
8833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_row_length",	GL_RGB8,	23,	6,	0,	27,	0,	0,	0,	4,	0 },
8843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_images",	GL_RGB8,	23,	6,	0,	0,	3,	0,	0,	4,	0 },
8853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_rows",		GL_RGB8,	23,	6,	26,	0,	0,	3,	0,	4,	0 },
8863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_pixels",	GL_RGB8,	23,	6,	0,	25,	0,	0,	2,	4,	0 }
8873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
8883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
8903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
8913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const string	fmtName				= colorFormats[formatNdx].name;
8923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const deUint32	format				= colorFormats[formatNdx].internalFormat;
8933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int		texCubeArraySize	= 20;
8943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int		texCubeDepth		= 6;
8953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			pboGroup->addChild(new TexImageCubeArrayBufferCase	(m_context, (fmtName + "_cube_array").c_str(),	"", format, texCubeArraySize, texCubeDepth, 0, 0, 0, 0, 0, 4, 0));
8973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
8983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(parameterCases); ndx++)
9003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
9013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			pboGroup->addChild(new TexImageCubeArrayBufferCase(m_context, (string(parameterCases[ndx].name) + "_cube_array").c_str(), "",
9023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].format,
9033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].size,
9043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].depth,
9053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].imageHeight,
9063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].rowLength,
9073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].skipImages,
9083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].skipRows,
9093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].skipPixels,
9103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].alignment,
9113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														parameterCases[ndx].offset));
9123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
9133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// glTexImage3D() depth cases.
9163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* shadow3dGroup = new tcu::TestCaseGroup(m_testCtx, "teximage3d_depth", "glTexImage3D() with depth or depth/stencil format");
9183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(shadow3dGroup);
9193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthStencilFormats); ndx++)
9213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
9223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	texCubeArraySize	= 64;
9233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	texCubeArrayDepth	= 6;
9243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			shadow3dGroup->addChild(new TexImageCubeArrayDepthCase(m_context, (std::string(depthStencilFormats[ndx].name) + "_cube_array").c_str(), "", depthStencilFormats[ndx].internalFormat, texCubeArraySize, texCubeArrayDepth));
9263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
9273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// glTexImage3D() depth cases with pbo.
9303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* shadow3dGroup = new tcu::TestCaseGroup(m_testCtx, "teximage3d_depth_pbo", "glTexImage3D() with depth or depth/stencil format with pbo");
9323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(shadow3dGroup);
9333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthStencilFormats); ndx++)
9353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
9363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	texCubeArraySize	= 64;
9373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	texCubeArrayDepth	= 6;
9383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			shadow3dGroup->addChild(new TexImageCubeArrayDepthBufferCase(m_context, (std::string(depthStencilFormats[ndx].name) + "_cube_array").c_str(), "", depthStencilFormats[ndx].internalFormat, texCubeArraySize, texCubeArrayDepth));
9403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
9413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// glTexSubImage3D() PBO cases.
9443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* pboGroup = new tcu::TestCaseGroup(m_testCtx, "texsubimage3d_pbo", "glTexSubImage3D() pixel buffer object tests");
9463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(pboGroup);
9473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const struct
9493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
9503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	name;
9513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	format;
9523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			size;
9533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			depth;
9543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subX;
9553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subY;
9563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subZ;
9573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subW;
9583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subH;
9593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			subD;
9603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			imageHeight;
9613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			rowLength;
9623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipImages;
9633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipRows;
9643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			skipPixels;
9653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			alignment;
9663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			offset;
9673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} paramCases[] =
9683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
9693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_offset",		GL_RGB8,	26, 12,	1,	2,	1,	23,	19,	8,	0,	0,	0,	0,	0,	4,	67 },
9703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_image_height",	GL_RGB8,	26, 12,	1,	2,	1,	23,	19,	8,	26,	0,	0,	0,	0,	4,	0 },
9713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_row_length",	GL_RGB8,	26, 12,	1,	2,	1,	23,	19,	8,	0,	27,	0,	0,	0,	4,	0 },
9723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_images",	GL_RGB8,	26, 12,	1,	2,	1,	23,	19,	8,	0,	0,	3,	0,	0,	4,	0 },
9733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_rows",		GL_RGB8,	26, 12,	1,	2,	1,	23,	19,	8,	22,	0,	0,	3,	0,	4,	0 },
9743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{ "rgb8_skip_pixels",	GL_RGB8,	26, 12,	1,	2,	1,	23,	19,	8,	0,	25,	0,	0,	2,	4,	0 }
9753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
9763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(colorFormats); ndx++)
9783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
9793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			pboGroup->addChild(new TexSubImageCubeArrayBufferCase(m_context, (std::string(colorFormats[ndx].name) + "_cube_array").c_str(), "",
9803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   colorFormats[ndx].internalFormat,
9813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   26,	// Size
9823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   12,	// Depth
9833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   1,	// Sub X
9843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   2,	// Sub Y
9853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0,	// Sub Z
9863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   23,	// Sub W
9873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   19,	// Sub H
9883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   8,	// Sub D
9893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0,	// Image height
9903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0,	// Row length
9913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0,	// Skip images
9923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0,	// Skip rows
9933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0,	// Skip pixels
9943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   4,	// Alignment
9953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   0	/* offset */));
9963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
9973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(paramCases); ndx++)
9993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
10003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			pboGroup->addChild(new TexSubImageCubeArrayBufferCase(m_context, (std::string(paramCases[ndx].name) + "_cube_array").c_str(), "",
10013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].format,
10023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].size,
10033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].depth,
10043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subX,
10053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subY,
10063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subZ,
10073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subW,
10083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subH,
10093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].subD,
10103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].imageHeight,
10113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].rowLength,
10123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].skipImages,
10133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].skipRows,
10143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].skipPixels,
10153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].alignment,
10163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														   paramCases[ndx].offset));
10173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
10183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
10193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// glTexSubImage3D() depth cases.
10213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* shadow3dGroup = new tcu::TestCaseGroup(m_testCtx, "texsubimage3d_depth", "glTexSubImage3D() with depth or depth/stencil format");
10233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(shadow3dGroup);
10243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthStencilFormats); ndx++)
10263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
10273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	texCubeArraySize	= 57;
10283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	texCubeArrayLayers	= 6;
10293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			shadow3dGroup->addChild(new TexSubImageCubeArrayDepthCase(m_context, (std::string(depthStencilFormats[ndx].name) + "_cube_array").c_str(), "", depthStencilFormats[ndx].internalFormat, texCubeArraySize, texCubeArrayLayers));
10313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
10323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
10333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// glTexStorage3D() cases.
10353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* texStorageGroup = new tcu::TestCaseGroup(m_testCtx, "texstorage3d", "Basic glTexStorage3D() usage");
10373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(texStorageGroup);
10383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// All formats.
10403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* formatGroup = new tcu::TestCaseGroup(m_testCtx, "format", "glTexStorage3D() with all formats");
10413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		texStorageGroup->addChild(formatGroup);
10423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Color formats.
10443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
10453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
10463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	fmtName				= colorFormats[formatNdx].name;
10473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	internalFormat		= colorFormats[formatNdx].internalFormat;
10483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	texCubeArraySize	= 57;
10493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	texCubeArrayLayers	= 6;
10503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			texCubeArrayLevels	= maxLevelCount(texCubeArraySize);
10513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			formatGroup->addChild(new BasicTexStorageCubeArrayCase	(m_context, (string(fmtName) + "_cube_array").c_str(),	"", internalFormat, texCubeArraySize, texCubeArrayLayers, texCubeArrayLevels));
10533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
10543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Depth/stencil formats (only 2D texture array is supported).
10563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(depthStencilFormats); formatNdx++)
10573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
10583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	fmtName				= depthStencilFormats[formatNdx].name;
10593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	internalFormat		= depthStencilFormats[formatNdx].internalFormat;
10603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	texCubeArraySize	= 57;
10613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	texCubeArrayLayers	= 6;
10623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int			texCubeArrayLevels	= maxLevelCount(texCubeArraySize);
10633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			formatGroup->addChild(new BasicTexStorageCubeArrayCase	(m_context, (string(fmtName) + "_cube_array").c_str(),	"", internalFormat, texCubeArraySize, texCubeArrayLayers, texCubeArrayLevels));
10653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
10663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Sizes.
10683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const struct
10693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
10703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int				size;
10713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int				layers;
10723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int				levels;
10733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} texCubeArraySizes[] =
10743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
10753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			//	Sz	La	Le
10763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	1,	6,	1 },
10773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	2,	6,	2 },
10783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	32,	6,	3 },
10793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	64,	6,	4 },
10803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	57,	12,	1 },
10813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	57,	12,	2 },
10823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{	57,	12,	6 }
10833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
10843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* sizeGroup = new tcu::TestCaseGroup(m_testCtx, "size", "glTexStorage3D() with various sizes");
10863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		texStorageGroup->addChild(sizeGroup);
10873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(texCubeArraySizes); ndx++)
10893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
10903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const deUint32		format		= GL_RGBA8;
10913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int					size		= texCubeArraySizes[ndx].size;
10923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int					layers		= texCubeArraySizes[ndx].layers;
10933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int					levels		= texCubeArraySizes[ndx].levels;
10943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			string				name		= string("cube_array_") + de::toString(size) + "x" + de::toString(size) + "x" + de::toString(layers) + "_" + de::toString(levels) + "_levels";
10953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			sizeGroup->addChild(new BasicTexStorageCubeArrayCase(m_context, name.c_str(), "", format, size, layers, levels));
10973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
10983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
10993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
11003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional
11023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles3
11033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
1104