13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 2.0 Module
33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * -------------------------------------------------
43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project
63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License");
83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License.
93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at
103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *      http://www.apache.org/licenses/LICENSE-2.0
123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software
143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS,
153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and
173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License.
183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*!
203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file
213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Texture 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 "es2fTextureSpecificationTests.hpp"
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp"
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuImageCompare.hpp"
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluTextureUtil.hpp"
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "sglrContextUtil.hpp"
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "sglrContextWrapper.hpp"
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "sglrGLContext.hpp"
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "sglrReferenceContext.hpp"
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsTextureTestUtil.hpp"
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTextureUtil.hpp"
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuFormatUtil.hpp"
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVectorUtil.hpp"
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp"
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp"
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp"
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp"
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles2
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::string;
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector;
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::pair;
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog;
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Vec4;
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::IVec4;
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::UVec4;
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytcu::TextureFormat mapGLUnsizedInternalFormat (deUint32 internalFormat)
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TextureFormat;
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	switch (internalFormat)
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case GL_ALPHA:				return TextureFormat(TextureFormat::A,		TextureFormat::UNORM_INT8);
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case GL_LUMINANCE:			return TextureFormat(TextureFormat::L,		TextureFormat::UNORM_INT8);
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case GL_LUMINANCE_ALPHA:	return TextureFormat(TextureFormat::LA,		TextureFormat::UNORM_INT8);
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case GL_RGB:				return TextureFormat(TextureFormat::RGB,	TextureFormat::UNORM_INT8);
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case GL_RGBA:				return TextureFormat(TextureFormat::RGBA,	TextureFormat::UNORM_INT8);
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		default:
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			throw tcu::InternalError(string("Can't map GL unsized internal format (") + tcu::toHex(internalFormat).toString() + ") to texture format");
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
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::IVec4 getPixelFormatCompareDepth (const tcu::PixelFormat& pixelFormat, tcu::TextureFormat textureFormat)
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	switch (textureFormat.order)
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case tcu::TextureFormat::L:
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case tcu::TextureFormat::LA:
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return tcu::IVec4(pixelFormat.redBits, pixelFormat.redBits, pixelFormat.redBits, pixelFormat.alphaBits);
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		default:
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return tcu::IVec4(pixelFormat.redBits, pixelFormat.greenBits, pixelFormat.blueBits, pixelFormat.alphaBits);
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic tcu::UVec4 computeCompareThreshold (const tcu::PixelFormat& pixelFormat, tcu::TextureFormat textureFormat)
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const IVec4		texFormatBits		= tcu::getTextureFormatBitDepth(textureFormat);
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const IVec4		pixelFormatBits		= getPixelFormatCompareDepth(pixelFormat, textureFormat);
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const IVec4		accurateFmtBits		= min(pixelFormatBits, texFormatBits);
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const IVec4		compareBits			= select(accurateFmtBits, IVec4(8), greaterThan(accurateFmtBits, IVec4(0))) - 1;
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return (IVec4(1) << (8-compareBits)).asUint();
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass GradientShader : public sglr::ShaderProgram
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GradientShader (void)
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ShaderProgram(sglr::pdec::ShaderProgramDeclaration()
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< sglr::pdec::VertexAttribute("a_position", rr::GENERICVECTYPE_FLOAT)
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< sglr::pdec::VertexAttribute("a_coord", rr::GENERICVECTYPE_FLOAT)
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< sglr::pdec::VertexToFragmentVarying(rr::GENERICVECTYPE_FLOAT)
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< sglr::pdec::FragmentOutput(rr::GENERICVECTYPE_FLOAT)
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< sglr::pdec::VertexSource("attribute highp vec4 a_position;\n"
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"attribute mediump vec2 a_coord;\n"
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"varying mediump vec2 v_coord;\n"
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"void main (void)\n"
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"{\n"
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"	gl_Position = a_position;\n"
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"	v_coord = a_coord;\n"
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"}\n")
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< sglr::pdec::FragmentSource("varying mediump vec2 v_coord;\n"
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  "void main (void)\n"
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  "{\n"
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  "	mediump float x = v_coord.x;\n"
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  "	mediump float y = v_coord.y;\n"
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  "	mediump float f0 = (x + y) * 0.5;\n"
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  "	mediump float f1 = 0.5 + (x - y) * 0.5;\n"
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  "	gl_FragColor = vec4(f0, f1, 1.0-f0, 1.0-f1);\n"
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  "}\n"))
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void shadeVertices (const rr::VertexAttrib* inputs, rr::VertexPacket* const* packets, const int numPackets) const
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx)
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			rr::VertexPacket& packet = *packets[packetNdx];
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			packet.position		= rr::readVertexAttribFloat(inputs[0], packet.instanceNdx, packet.vertexNdx);
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			packet.outputs[0]	= rr::readVertexAttribFloat(inputs[1], packet.instanceNdx, packet.vertexNdx);
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void shadeFragments (rr::FragmentPacket* packets, const int numPackets, const rr::FragmentShadingContext& context) const
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx)
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int fragNdx = 0; fragNdx < 4; ++fragNdx)
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::Vec4		coord	= rr::readTriangleVarying<float>(packets[packetNdx], context, 0, fragNdx);
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const float			x		= coord.x();
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const float			y		= coord.y();
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const float			f0		= (x + y) * 0.5f;
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const float			f1		= 0.5f + (x - y) * 0.5f;
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const tcu::Vec4		fv		= Vec4(f0, f1, 1.0f-f0, 1.0f-f1);
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			rr::writeFragmentOutput(context, packetNdx, fragNdx, 0, tcu::Vec4(f0, f1, 1.0f-f0, 1.0f-f1));
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Tex2DShader : public sglr::ShaderProgram
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Tex2DShader (void)
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ShaderProgram(sglr::pdec::ShaderProgramDeclaration()
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< sglr::pdec::VertexAttribute("a_position", rr::GENERICVECTYPE_FLOAT)
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< sglr::pdec::VertexAttribute("a_coord", rr::GENERICVECTYPE_FLOAT)
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< sglr::pdec::VertexToFragmentVarying(rr::GENERICVECTYPE_FLOAT)
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< sglr::pdec::FragmentOutput(rr::GENERICVECTYPE_FLOAT)
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< sglr::pdec::Uniform("u_sampler0", glu::TYPE_SAMPLER_2D)
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< sglr::pdec::VertexSource("attribute highp vec4 a_position;\n"
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"attribute mediump vec2 a_coord;\n"
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"varying mediump vec2 v_coord;\n"
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"void main (void)\n"
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"{\n"
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"	gl_Position = a_position;\n"
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"	v_coord = a_coord;\n"
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"}\n")
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< sglr::pdec::FragmentSource("uniform sampler2D u_sampler0;\n"
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  "varying mediump vec2 v_coord;\n"
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  "void main (void)\n"
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  "{\n"
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  "	gl_FragColor = texture2D(u_sampler0, v_coord);\n"
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  "}\n"))
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void setUniforms (sglr::Context& ctx, deUint32 program) const
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.useProgram(program);
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.uniform1i(ctx.getUniformLocation(program, "u_sampler0"), 0);
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void shadeVertices (const rr::VertexAttrib* inputs, rr::VertexPacket* const* packets, const int numPackets) const
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx)
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			rr::VertexPacket& packet = *packets[packetNdx];
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			packet.position		= rr::readVertexAttribFloat(inputs[0], packet.instanceNdx, packet.vertexNdx);
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			packet.outputs[0]	= rr::readVertexAttribFloat(inputs[1], packet.instanceNdx, packet.vertexNdx);
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void shadeFragments (rr::FragmentPacket* packets, const int numPackets, const rr::FragmentShadingContext& context) const
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::Vec2 texCoords[4];
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::Vec4 colors[4];
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx)
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// setup tex coords
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int fragNdx = 0; fragNdx < 4; ++fragNdx)
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const tcu::Vec4	coord = rr::readTriangleVarying<float>(packets[packetNdx], context, 0, fragNdx);
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				texCoords[fragNdx] = tcu::Vec2(coord.x(), coord.y());
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// Sample
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_uniforms[0].sampler.tex2D->sample4(colors, texCoords);
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// Write out
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int fragNdx = 0; fragNdx < 4; ++fragNdx)
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				rr::writeFragmentOutput(context, packetNdx, fragNdx, 0, colors[fragNdx]);
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* s_cubeSwizzles[] =
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"vec3(-1, -y, +x)",
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"vec3(+1, -y, -x)",
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"vec3(+x, -1, -y)",
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"vec3(+x, +1, +y)",
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"vec3(-x, -y, -1)",
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"vec3(+x, -y, +1)"
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexCubeShader : public sglr::ShaderProgram
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexCubeShader (tcu::CubeFace face)
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ShaderProgram(sglr::pdec::ShaderProgramDeclaration()
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< sglr::pdec::VertexAttribute("a_position", rr::GENERICVECTYPE_FLOAT)
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< sglr::pdec::VertexAttribute("a_coord", rr::GENERICVECTYPE_FLOAT)
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< sglr::pdec::VertexToFragmentVarying(rr::GENERICVECTYPE_FLOAT)
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< sglr::pdec::FragmentOutput(rr::GENERICVECTYPE_FLOAT)
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< sglr::pdec::Uniform("u_sampler0", glu::TYPE_SAMPLER_CUBE)
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< sglr::pdec::VertexSource("attribute highp vec4 a_position;\n"
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"attribute mediump vec2 a_coord;\n"
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"varying mediump vec2 v_coord;\n"
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"void main (void)\n"
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"{\n"
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"	gl_Position = a_position;\n"
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"	v_coord = a_coord;\n"
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"}\n")
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< sglr::pdec::FragmentSource(string("") +
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  "uniform samplerCube u_sampler0;\n"
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  "varying mediump vec2 v_coord;\n"
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  "void main (void)\n"
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  "{\n"
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  "	mediump float x = v_coord.x*2.0 - 1.0;\n"
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  "	mediump float y = v_coord.y*2.0 - 1.0;\n"
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  "	gl_FragColor = textureCube(u_sampler0, " + s_cubeSwizzles[face] + ");\n"
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  "}\n"))
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_face(face)
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void setUniforms (sglr::Context& ctx, deUint32 program) const
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.useProgram(program);
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ctx.uniform1i(ctx.getUniformLocation(program, "u_sampler0"), 0);
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void shadeVertices (const rr::VertexAttrib* inputs, rr::VertexPacket* const* packets, const int numPackets) const
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx)
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			rr::VertexPacket& packet = *packets[packetNdx];
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			packet.position		= rr::readVertexAttribFloat(inputs[0], packet.instanceNdx, packet.vertexNdx);
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			packet.outputs[0]	= rr::readVertexAttribFloat(inputs[1], packet.instanceNdx, packet.vertexNdx);
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void shadeFragments (rr::FragmentPacket* packets, const int numPackets, const rr::FragmentShadingContext& context) const
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::Vec3 texCoords[4];
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::Vec4 colors[4];
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx)
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// setup tex coords
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int fragNdx = 0; fragNdx < 4; ++fragNdx)
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const tcu::Vec4	coord	= rr::readTriangleVarying<float>(packets[packetNdx], context, 0, fragNdx);
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const float		x		= coord.x()*2.0f - 1.0f;
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const float		y		= coord.y()*2.0f - 1.0f;
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				// Swizzle tex coords
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				switch (m_face)
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					case tcu::CUBEFACE_NEGATIVE_X:	texCoords[fragNdx] = tcu::Vec3(-1.0f,    -y,    +x);		break;
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					case tcu::CUBEFACE_POSITIVE_X:	texCoords[fragNdx] = tcu::Vec3(+1.0f,    -y,    -x);		break;
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					case tcu::CUBEFACE_NEGATIVE_Y:	texCoords[fragNdx] = tcu::Vec3(   +x, -1.0f,    -y);		break;
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					case tcu::CUBEFACE_POSITIVE_Y:	texCoords[fragNdx] = tcu::Vec3(   +x, +1.0f,    +y);		break;
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					case tcu::CUBEFACE_NEGATIVE_Z:	texCoords[fragNdx] = tcu::Vec3(   -x,    -y, -1.0f);		break;
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					case tcu::CUBEFACE_POSITIVE_Z:	texCoords[fragNdx] = tcu::Vec3(   +x,    -y, +1.0f);		break;
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					default:
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						DE_ASSERT(false);
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// Sample
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_uniforms[0].sampler.texCube->sample4(colors, texCoords);
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// Write out
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int fragNdx = 0; fragNdx < 4; ++fragNdx)
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				rr::writeFragmentOutput(context, packetNdx, fragNdx, 0, colors[fragNdx]);
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::CubeFace m_face;
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum TextureType
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TEXTURETYPE_2D = 0,
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TEXTURETYPE_CUBE,
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TEXTURETYPE_LAST
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum Flags
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	MIPMAPS		= (1<<0)
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const deUint32 s_cubeMapFaces[] =
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_TEXTURE_CUBE_MAP_POSITIVE_X,
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureSpecCase : public TestCase, public sglr::ContextWrapper
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								TextureSpecCase		(Context& context, const char* name, const char* desc, const TextureType type, const tcu::TextureFormat format, const deUint32 flags, int width, int height);
3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								~TextureSpecCase	(void);
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult				iterate				(void);
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void				createTexture		(void) = DE_NULL;
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const TextureType			m_texType;
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::TextureFormat	m_texFormat;
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint32				m_flags;
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int					m_width;
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int					m_height;
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								TextureSpecCase		(const TextureSpecCase& other);
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureSpecCase&			operator=			(const TextureSpecCase& other);
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						verifyTex2D			(sglr::GLContext& gles2Context, sglr::ReferenceContext& refContext);
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						verifyTexCube		(sglr::GLContext& gles2Context, sglr::ReferenceContext& refContext);
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						renderTex2D			(tcu::Surface& dst, int width, int height);
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						renderTexCube		(tcu::Surface& dst, int width, int height, tcu::CubeFace face);
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						readPixels			(tcu::Surface& dst, int x, int y, int width, int height);
3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// \todo [2012-03-27 pyry] Renderer should be extended to allow custom attributes, that would clean up this cubemap mess.
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Tex2DShader					m_tex2DShader;
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexCubeShader				m_texCubeNegXShader;
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexCubeShader				m_texCubePosXShader;
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexCubeShader				m_texCubeNegYShader;
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexCubeShader				m_texCubePosYShader;
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexCubeShader				m_texCubeNegZShader;
3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexCubeShader				m_texCubePosZShader;
3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3933c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureSpecCase::TextureSpecCase (Context& context, const char* name, const char* desc, const TextureType type, const tcu::TextureFormat format, const deUint32 flags, int width, int height)
3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCase				(context, name, desc)
3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_texType				(type)
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_texFormat			(format)
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_flags				(flags)
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_width				(width)
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_height				(height)
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_texCubeNegXShader	(tcu::CUBEFACE_NEGATIVE_X)
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_texCubePosXShader	(tcu::CUBEFACE_POSITIVE_X)
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_texCubeNegYShader	(tcu::CUBEFACE_NEGATIVE_Y)
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_texCubePosYShader	(tcu::CUBEFACE_POSITIVE_Y)
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_texCubeNegZShader	(tcu::CUBEFACE_NEGATIVE_Z)
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_texCubePosZShader	(tcu::CUBEFACE_POSITIVE_Z)
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4093c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureSpecCase::~TextureSpecCase (void)
4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4133c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureSpecCase::IterateResult TextureSpecCase::iterate (void)
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::RenderContext&			renderCtx				= TestCase::m_context.getRenderContext();
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::RenderTarget&	renderTarget			= renderCtx.getRenderTarget();
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TestLog&				log						= m_testCtx.getLog();
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(m_width <= 256 && m_height <= 256);
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (renderTarget.getWidth() < m_width || renderTarget.getHeight() < m_height)
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::NotSupportedError("Too small viewport", "", __FILE__, __LINE__);
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Context size, and viewport for GLES2
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	de::Random		rnd			(deStringHash(getName()));
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				width		= deMin32(renderTarget.getWidth(),	256);
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				height		= deMin32(renderTarget.getHeight(),	256);
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				x			= rnd.getInt(0, renderTarget.getWidth()		- width);
4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				y			= rnd.getInt(0, renderTarget.getHeight()	- height);
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Contexts.
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	sglr::GLContext					gles2Context	(renderCtx, log, sglr::GLCONTEXT_LOG_CALLS, tcu::IVec4(x, y, width, height));
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	sglr::ReferenceContextBuffers	refBuffers		(tcu::PixelFormat(8,8,8,renderTarget.getPixelFormat().alphaBits?8:0), 0 /* depth */, 0 /* stencil */, width, height);
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	sglr::ReferenceContext			refContext		(sglr::ReferenceContextLimits(renderCtx), refBuffers.getColorbuffer(), refBuffers.getDepthbuffer(), refBuffers.getStencilbuffer());
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Clear color buffer.
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int ndx = 0; ndx < 2; ndx++)
4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		setContext(ndx ? (sglr::Context*)&refContext : (sglr::Context*)&gles2Context);
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glClearColor(0.125f, 0.25f, 0.5f, 1.0f);
4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Construct texture using both GLES2 and reference contexts.
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int ndx = 0; ndx < 2; ndx++)
4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		setContext(ndx ? (sglr::Context*)&refContext : (sglr::Context*)&gles2Context);
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		createTexture();
4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TCU_CHECK(glGetError() == GL_NO_ERROR);
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Setup texture filtering state.
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int ndx = 0; ndx < 2; ndx++)
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		setContext(ndx ? (sglr::Context*)&refContext : (sglr::Context*)&gles2Context);
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32 texTarget = m_texType == TEXTURETYPE_2D ? GL_TEXTURE_2D : GL_TEXTURE_CUBE_MAP;
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(texTarget, GL_TEXTURE_MIN_FILTER,	(m_flags & MIPMAPS) ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST);
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(texTarget, GL_TEXTURE_MAG_FILTER,	GL_NEAREST);
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(texTarget, GL_TEXTURE_WRAP_S,		GL_CLAMP_TO_EDGE);
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexParameteri(texTarget, GL_TEXTURE_WRAP_T,		GL_CLAMP_TO_EDGE);
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Initialize case result to pass.
4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Disable logging.
4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gles2Context.enableLogging(0);
4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Verify results.
4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	switch (m_texType)
4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case TEXTURETYPE_2D:	verifyTex2D		(gles2Context, refContext);	break;
4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case TEXTURETYPE_CUBE:	verifyTexCube	(gles2Context, refContext);	break;
4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		default:
4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			DE_ASSERT(false);
4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return STOP;
4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureSpecCase::verifyTex2D (sglr::GLContext& gles2Context, sglr::ReferenceContext& refContext)
4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(m_texType == TEXTURETYPE_2D);
4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int levelNdx = 0; levelNdx < numLevels; levelNdx++)
4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int				levelW		= de::max(1, m_width >> levelNdx);
4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int				levelH		= de::max(1, m_height >> levelNdx);
4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::Surface	reference;
4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::Surface	result;
4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (levelW <= 2 || levelH <= 2)
4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			continue; // Don't bother checking.
4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Render with GLES2
4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		setContext(&gles2Context);
4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		renderTex2D(result, levelW, levelH);
5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Render reference.
5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		setContext(&refContext);
5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		renderTex2D(reference, levelW, levelH);
5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::UVec4	threshold	= computeCompareThreshold(m_context.getRenderTarget().getPixelFormat(), m_texFormat);
5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			bool		isOk		= tcu::intThresholdCompare(m_testCtx.getLog(), "Result", "Image comparison result", reference.getAccess(), result.getAccess(), threshold,
5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															   levelNdx == 0 ? tcu::COMPARE_LOG_RESULT : tcu::COMPARE_LOG_ON_ERROR);
5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (!isOk)
5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed");
5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				break;
5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureSpecCase::verifyTexCube (sglr::GLContext& gles2Context, sglr::ReferenceContext& refContext)
5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(m_texType == TEXTURETYPE_CUBE);
5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int levelNdx = 0; levelNdx < numLevels; levelNdx++)
5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int		levelW	= de::max(1, m_width >> levelNdx);
5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int		levelH	= de::max(1, m_height >> levelNdx);
5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool	isOk	= true;
5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::Surface	reference;
5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::Surface	result;
5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (levelW <= 2 || levelH <= 2)
5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				continue; // Don't bother checking.
5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// Render with GLES2
5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			setContext(&gles2Context);
5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			renderTexCube(result, levelW, levelH, (tcu::CubeFace)face);
5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// Render reference.
5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			setContext(&refContext);
5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			renderTexCube(reference, levelW, levelH, (tcu::CubeFace)face);
5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const float	threshold	= 0.02f;
5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			isOk = tcu::fuzzyCompare(m_testCtx.getLog(), "Result", (string("Image comparison result: ") + de::toString((tcu::CubeFace)face)).c_str(), reference, result, threshold,
5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									 levelNdx == 0 ? tcu::COMPARE_LOG_RESULT : tcu::COMPARE_LOG_ON_ERROR);
5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (!isOk)
5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed");
5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				break;
5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!isOk)
5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			break;
5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureSpecCase::renderTex2D (tcu::Surface& dst, int width, int height)
5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			targetW		= getWidth();
5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			targetH		= getHeight();
5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float		w			= (float)width	/ (float)targetW;
5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float		h			= (float)height	/ (float)targetH;
5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	shaderID	= getCurrentContext()->createProgram(&m_tex2DShader);
5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_tex2DShader.setUniforms(*getCurrentContext(), shaderID);
5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(-1.0f + w*2.0f, -1.0f + h*2.0f, 0.0f));
5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Read pixels back.
5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	readPixels(dst, 0, 0, width, height);
5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureSpecCase::renderTexCube (tcu::Surface& dst, int width, int height, tcu::CubeFace face)
5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int		targetW		= getWidth();
5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int		targetH		= getHeight();
5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float	w			= (float)width	/ (float)targetW;
5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float	h			= (float)height	/ (float)targetH;
5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexCubeShader* shaders[] =
5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		&m_texCubeNegXShader,
5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		&m_texCubePosXShader,
5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		&m_texCubeNegYShader,
5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		&m_texCubePosYShader,
5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		&m_texCubeNegZShader,
5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		&m_texCubePosZShader
5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	shaderID	= getCurrentContext()->createProgram(shaders[face]);
5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	shaders[face]->setUniforms(*getCurrentContext(), shaderID);
6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(-1.0f + w*2.0f, -1.0f + h*2.0f, 0.0f));
6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Read pixels back.
6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	readPixels(dst, 0, 0, width, height);
6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureSpecCase::readPixels (tcu::Surface& dst, int x, int y, int width, int height)
6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	dst.setSize(width, height);
6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, dst.getAccess().getDataPtr());
6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Basic TexImage2D() with 2D texture usage
6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicTexImage2DCase : public TextureSpecCase
6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicTexImage2DCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 flags, int width, int height)
6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureSpecCase	(context, name, desc, TEXTURETYPE_2D, glu::mapGLTransferFormat(format, dataType), flags, width, height)
6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(format)
6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(dataType)
6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureFormat	fmt			= m_texFormat;
6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int					numLevels	= (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel	levelData	(fmt);
6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random			rnd			(deStringHash(getName()));
6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D, tex);
6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numLevels; ndx++)
6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMin		= randomVector<4>(rnd);
6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMax		= randomVector<4>(rnd);
6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levelData.setSize(levelW, levelH);
6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage2D(GL_TEXTURE_2D, ndx, m_format, levelW, levelH, 0, m_format, m_dataType, levelData.getAccess().getDataPtr());
6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Basic TexImage2D() with cubemap usage
6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicTexImageCubeCase : public TextureSpecCase
6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicTexImageCubeCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 flags, int width, int height)
6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureSpecCase	(context, name, desc, TEXTURETYPE_CUBE, glu::mapGLTransferFormat(format, dataType), flags, width, height)
6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(format)
6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(dataType)
6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureFormat	fmt			= m_texFormat;
6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int					numLevels	= (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel	levelData	(fmt);
6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random			rnd			(deStringHash(getName()));
6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_width == m_height); // Non-square cubemaps are not supported by GLES2.
6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numLevels; ndx++)
6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levelData.setSize(levelW, levelH);
6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				Vec4 gMin = randomVector<4>(rnd);
6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				Vec4 gMax = randomVector<4>(rnd);
6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glTexImage2D(s_cubeMapFaces[face], ndx, m_format, levelW, levelH, 0, m_format, m_dataType, levelData.getAccess().getDataPtr());
6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Randomized 2D texture specification using TexImage2D
7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RandomOrderTexImage2DCase : public TextureSpecCase
7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	RandomOrderTexImage2DCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 flags, int width, int height)
7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureSpecCase	(context, name, desc, TEXTURETYPE_2D, glu::mapGLTransferFormat(format, dataType), flags, width, height)
7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(format)
7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(dataType)
7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureFormat	fmt			= m_texFormat;
7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int					numLevels	= (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel	levelData	(fmt);
7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random			rnd			(deStringHash(getName()));
7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D, tex);
7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<int>			levels		(numLevels);
7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int i = 0; i < numLevels; i++)
7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levels[i] = i;
7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		rnd.shuffle(levels.begin(), levels.end());
7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numLevels; ndx++)
7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelNdx	= levels[ndx];
7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width	>> levelNdx);
7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height	>> levelNdx);
7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMin		= randomVector<4>(rnd);
7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMax		= randomVector<4>(rnd);
7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levelData.setSize(levelW, levelH);
7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage2D(GL_TEXTURE_2D, levelNdx, m_format, levelW, levelH, 0, m_format, m_dataType, levelData.getAccess().getDataPtr());
7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Randomized cubemap texture specification using TexImage2D
7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RandomOrderTexImageCubeCase : public TextureSpecCase
7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	RandomOrderTexImageCubeCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 flags, int width, int height)
7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureSpecCase	(context, name, desc, TEXTURETYPE_CUBE, glu::mapGLTransferFormat(format, dataType), flags, width, height)
7593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(format)
7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(dataType)
7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureFormat	fmt			= m_texFormat;
7683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int					numLevels	= (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
7693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
7703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel	levelData	(fmt);
7713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random			rnd			(deStringHash(getName()));
7723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_width == m_height); // Non-square cubemaps are not supported by GLES2.
7743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
7763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
7773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
7783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Level-face pairs.
7803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<pair<int, tcu::CubeFace> >	images	(numLevels*6);
7813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numLevels; ndx++)
7833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
7843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				images[ndx*6 + face] = std::make_pair(ndx, (tcu::CubeFace)face);
7853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		rnd.shuffle(images.begin(), images.end());
7873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < (int)images.size(); ndx++)
7893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
7903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int				levelNdx	= images[ndx].first;
7913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::CubeFace	face		= images[ndx].second;
7923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int				levelW		= de::max(1, m_width >> levelNdx);
7933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int				levelH		= de::max(1, m_height >> levelNdx);
7943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4			gMin		= randomVector<4>(rnd);
7953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4			gMax		= randomVector<4>(rnd);
7963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			levelData.setSize(levelW, levelH);
7983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
7993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage2D(s_cubeMapFaces[face], levelNdx, m_format, levelW, levelH, 0, m_format, m_dataType, levelData.getAccess().getDataPtr());
8013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
8023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
8053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
8063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
8073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8083c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic inline int getRowPitch (const tcu::TextureFormat& transferFmt, int rowLen, int alignment)
8093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int basePitch = transferFmt.getPixelSize()*rowLen;
8113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return alignment*(basePitch/alignment + ((basePitch % alignment) ? 1 : 0));
8123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexImage2D() unpack alignment case.
8153c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexImage2DAlignCase : public TextureSpecCase
8163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8173c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
8183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexImage2DAlignCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 flags, int width, int height, int alignment)
8193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureSpecCase	(context, name, desc, TEXTURETYPE_2D, glu::mapGLTransferFormat(format, dataType), flags, width, height)
8203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(format)
8213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(dataType)
8223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment		(alignment)
8233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
8273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
8283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureFormat	fmt			= m_texFormat;
8303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int					numLevels	= (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
8313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
8323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<deUint8>		data;
8333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
8353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D, tex);
8363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
8373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numLevels; ndx++)
8393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
8403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
8413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
8423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorA		(1.0f, 0.0f, 0.0f, 1.0f);
8433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorB		(0.0f, 1.0f, 0.0f, 1.0f);
8443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		rowPitch	= getRowPitch(fmt, levelW, m_alignment);
8453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		cellSize	= de::max(1, de::min(levelW >> 2, levelH >> 2));
8463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.resize(rowPitch*levelH);
8483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithGrid(tcu::PixelBufferAccess(fmt, levelW, levelH, 1, rowPitch, 0, &data[0]), cellSize, colorA, colorB);
8493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage2D(GL_TEXTURE_2D, ndx, m_format, levelW, levelH, 0, m_format, m_dataType, &data[0]);
8513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
8523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
8553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
8563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_alignment;
8573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
8583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexImage2D() unpack alignment case.
8603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexImageCubeAlignCase : public TextureSpecCase
8613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8623c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
8633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexImageCubeAlignCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 flags, int width, int height, int alignment)
8643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureSpecCase	(context, name, desc, TEXTURETYPE_CUBE, glu::mapGLTransferFormat(format, dataType), flags, width, height)
8653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(format)
8663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(dataType)
8673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment		(alignment)
8683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8713c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
8723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
8733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureFormat	fmt			= m_texFormat;
8753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int					numLevels	= (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
8763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
8773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<deUint8>		data;
8783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_width == m_height); // Non-square cubemaps are not supported by GLES2.
8803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
8823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
8833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
8843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numLevels; ndx++)
8863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
8873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
8883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
8893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		rowPitch	= getRowPitch(fmt, levelW, m_alignment);
8903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorA		(1.0f, 0.0f, 0.0f, 1.0f);
8913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorB		(0.0f, 1.0f, 0.0f, 1.0f);
8923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		cellSize	= de::max(1, de::min(levelW >> 2, levelH >> 2));
8933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.resize(rowPitch*levelH);
8953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithGrid(tcu::PixelBufferAccess(fmt, levelW, levelH, 1, rowPitch, 0, &data[0]), cellSize, colorA, colorB);
8963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
8983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glTexImage2D(s_cubeMapFaces[face], ndx, m_format, levelW, levelH, 0, m_format, m_dataType, &data[0]);
8993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
9003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
9033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
9043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_alignment;
9053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
9063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Basic TexSubImage2D() with 2D texture usage
9083c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicTexSubImage2DCase : public TextureSpecCase
9093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9103c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
9113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicTexSubImage2DCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 flags, int width, int height)
9123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureSpecCase	(context, name, desc, TEXTURETYPE_2D, glu::mapGLTransferFormat(format, dataType), flags, width, height)
9133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(format)
9143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(dataType)
9153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
9193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
9203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureFormat	fmt			= m_texFormat;
9223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int					numLevels	= (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
9233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
9243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel	data		(fmt);
9253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random			rnd			(deStringHash(getName()));
9263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
9283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D, tex);
9293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
9303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// First specify full texture.
9323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numLevels; ndx++)
9333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
9343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
9353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
9363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMin		= randomVector<4>(rnd);
9373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMax		= randomVector<4>(rnd);
9383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.setSize(levelW, levelH);
9403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
9413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage2D(GL_TEXTURE_2D, ndx, m_format, levelW, levelH, 0, m_format, m_dataType, data.getAccess().getDataPtr());
9433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
9443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Re-specify parts of each level.
9463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numLevels; ndx++)
9473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
9483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
9493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
9503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		w			= rnd.getInt(1, levelW);
9523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		h			= rnd.getInt(1, levelH);
9533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		x			= rnd.getInt(0, levelW-w);
9543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		y			= rnd.getInt(0, levelH-h);
9553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorA		= randomVector<4>(rnd);
9573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorB		= randomVector<4>(rnd);
9583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		cellSize	= rnd.getInt(2, 16);
9593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.setSize(w, h);
9613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
9623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexSubImage2D(GL_TEXTURE_2D, ndx, x, y, w, h, m_format, m_dataType, data.getAccess().getDataPtr());
9643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
9653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
9683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
9693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
9703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Basic TexSubImage2D() with cubemap usage
9723c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicTexSubImageCubeCase : public TextureSpecCase
9733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9743c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
9753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicTexSubImageCubeCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 flags, int width, int height)
9763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureSpecCase	(context, name, desc, TEXTURETYPE_CUBE, glu::mapGLTransferFormat(format, dataType), flags, width, height)
9773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(format)
9783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(dataType)
9793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
9813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9823c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
9833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
9843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
9853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureFormat	fmt			= m_texFormat;
9863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int					numLevels	= (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
9873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
9883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel	data		(fmt);
9893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random			rnd			(deStringHash(getName()));
9903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_width == m_height); // Non-square cubemaps are not supported by GLES2.
9923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
9943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
9953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
9963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numLevels; ndx++)
9983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
9993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
10003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
10013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.setSize(levelW, levelH);
10033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
10053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
10063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				Vec4 gMin = randomVector<4>(rnd);
10073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				Vec4 gMax = randomVector<4>(rnd);
10083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
10103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glTexImage2D(s_cubeMapFaces[face], ndx, m_format, levelW, levelH, 0, m_format, m_dataType, data.getAccess().getDataPtr());
10123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
10133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
10143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Re-specify parts of each face and level.
10163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numLevels; ndx++)
10173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
10183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
10193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
10203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
10223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
10233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int		w			= rnd.getInt(1, levelW);
10243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int		h			= rnd.getInt(1, levelH);
10253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int		x			= rnd.getInt(0, levelW-w);
10263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int		y			= rnd.getInt(0, levelH-h);
10273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				Vec4	colorA		= randomVector<4>(rnd);
10293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				Vec4	colorB		= randomVector<4>(rnd);
10303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int		cellSize	= rnd.getInt(2, 16);
10313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				data.setSize(w, h);
10333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
10343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glTexSubImage2D(s_cubeMapFaces[face], ndx, x, y, w, h, m_format, m_dataType, data.getAccess().getDataPtr());
10363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
10373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
10383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
10393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
10413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
10423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
10433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexSubImage2D() to texture initialized with empty data
10453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexSubImage2DEmptyTexCase : public TextureSpecCase
10463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10473c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
10483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexSubImage2DEmptyTexCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 flags, int width, int height)
10493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureSpecCase	(context, name, desc, TEXTURETYPE_2D, glu::mapGLTransferFormat(format, dataType), flags, width, height)
10503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(format)
10513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(dataType)
10523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
10543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
10563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
10573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureFormat	fmt			= m_texFormat;
10593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int					numLevels	= (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
10603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
10613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel	data		(fmt);
10623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random			rnd			(deStringHash(getName()));
10633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
10653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D, tex);
10663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
10673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// First allocate storage for each level.
10693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numLevels; ndx++)
10703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
10713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
10723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
10733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage2D(GL_TEXTURE_2D, ndx, m_format, levelW, levelH, 0, m_format, m_dataType, DE_NULL);
10753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
10763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Specify pixel data to all levels using glTexSubImage2D()
10783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numLevels; ndx++)
10793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
10803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
10813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
10823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMin		= randomVector<4>(rnd);
10833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	gMax		= randomVector<4>(rnd);
10843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.setSize(levelW, levelH);
10863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
10873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexSubImage2D(GL_TEXTURE_2D, ndx, 0, 0, levelW, levelH, m_format, m_dataType, data.getAccess().getDataPtr());
10893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
10903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
10913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
10933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
10943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
10953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexSubImage2D() to empty cubemap texture
10973c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexSubImageCubeEmptyTexCase : public TextureSpecCase
10983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10993c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
11003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexSubImageCubeEmptyTexCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 flags, int width, int height)
11013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureSpecCase	(context, name, desc, TEXTURETYPE_CUBE, glu::mapGLTransferFormat(format, dataType), flags, width, height)
11023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(format)
11033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(dataType)
11043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
11053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
11063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11073c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
11083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
11093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
11103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureFormat	fmt			= m_texFormat;
11113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int					numLevels	= (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
11123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
11133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel	data		(fmt);
11143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random			rnd			(deStringHash(getName()));
11153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_width == m_height); // Non-square cubemaps are not supported by GLES2.
11173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
11193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
11203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
11213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Specify storage for each level.
11233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numLevels; ndx++)
11243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
11253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
11263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
11273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
11293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glTexImage2D(s_cubeMapFaces[face], ndx, m_format, levelW, levelH, 0, m_format, m_dataType, DE_NULL);
11303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
11313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Specify data using glTexSubImage2D()
11333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numLevels; ndx++)
11343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
11353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
11363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
11373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.setSize(levelW, levelH);
11393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
11413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
11423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				Vec4 gMin = randomVector<4>(rnd);
11433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				Vec4 gMax = randomVector<4>(rnd);
11443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
11463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glTexSubImage2D(s_cubeMapFaces[face], ndx, 0, 0, levelW, levelH, m_format, m_dataType, data.getAccess().getDataPtr());
11483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
11493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
11503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
11513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
11533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
11543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
11553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexSubImage2D() unpack alignment with 2D texture
11573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexSubImage2DAlignCase : public TextureSpecCase
11583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
11593c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
11603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexSubImage2DAlignCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int width, int height, int subX, int subY, int subW, int subH, int alignment)
11613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureSpecCase	(context, name, desc, TEXTURETYPE_2D, glu::mapGLTransferFormat(format, dataType), 0 /* Mipmaps are never used */, width, height)
11623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(format)
11633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(dataType)
11643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subX			(subX)
11653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subY			(subY)
11663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subW			(subW)
11673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subH			(subH)
11683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment		(alignment)
11693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
11703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
11713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11723c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
11733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
11743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
11753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureFormat	fmt			= m_texFormat;
11763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
11773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<deUint8>		data;
11783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
11803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D, tex);
11813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Specify base level.
11833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		data.resize(fmt.getPixelSize()*m_width*m_height);
11843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::fillWithComponentGradients(tcu::PixelBufferAccess(fmt, m_width, m_height, 1, &data[0]), Vec4(0.0f), Vec4(1.0f));
11853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
11873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexImage2D(GL_TEXTURE_2D, 0, m_format, m_width, m_height, 0, m_format, m_dataType, &data[0]);
11883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Re-specify subrectangle.
11903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int rowPitch = getRowPitch(fmt, m_subW, m_alignment);
11913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		data.resize(rowPitch*m_subH);
11923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::fillWithGrid(tcu::PixelBufferAccess(fmt, m_subW, m_subH, 1, rowPitch, 0, &data[0]), 4, Vec4(1.0f, 0.0f, 0.0f, 1.0f), Vec4(0.0f, 1.0f, 0.0f, 1.0f));
11933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
11953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glTexSubImage2D(GL_TEXTURE_2D, 0, m_subX, m_subY, m_subW, m_subH, m_format, m_dataType, &data[0]);
11963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
11973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
11993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
12003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subX;
12013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subY;
12023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subW;
12033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subH;
12043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_alignment;
12053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
12063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexSubImage2D() unpack alignment with cubemap texture
12083c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexSubImageCubeAlignCase : public TextureSpecCase
12093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
12103c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
12113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexSubImageCubeAlignCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int width, int height, int subX, int subY, int subW, int subH, int alignment)
12123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureSpecCase	(context, name, desc, TEXTURETYPE_CUBE, glu::mapGLTransferFormat(format, dataType), 0 /* Mipmaps are never used */, width, height)
12133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(format)
12143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(dataType)
12153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subX			(subX)
12163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subY			(subY)
12173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subW			(subW)
12183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_subH			(subH)
12193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_alignment		(alignment)
12203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
12213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
12223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12233c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
12243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
12253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
12263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureFormat	fmt			= m_texFormat;
12273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32			tex			= 0;
12283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vector<deUint8>		data;
12293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_width == m_height);
12313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
12333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
12343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Specify base level.
12363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		data.resize(fmt.getPixelSize()*m_width*m_height);
12373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::fillWithComponentGradients(tcu::PixelBufferAccess(fmt, m_width, m_height, 1, &data[0]), Vec4(0.0f), Vec4(1.0f));
12383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
12403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
12413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage2D(s_cubeMapFaces[face], 0, m_format, m_width, m_height, 0, m_format, m_dataType, &data[0]);
12423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Re-specify subrectangle.
12443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int rowPitch = getRowPitch(fmt, m_subW, m_alignment);
12453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		data.resize(rowPitch*m_subH);
12463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::fillWithGrid(tcu::PixelBufferAccess(fmt, m_subW, m_subH, 1, rowPitch, 0, &data[0]), 4, Vec4(1.0f, 0.0f, 0.0f, 1.0f), Vec4(0.0f, 1.0f, 0.0f, 1.0f));
12473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
12493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
12503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexSubImage2D(s_cubeMapFaces[face], 0, m_subX, m_subY, m_subW, m_subH, m_format, m_dataType, &data[0]);
12513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
12523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
12543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
12553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subX;
12563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subY;
12573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subW;
12583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_subH;
12593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int			m_alignment;
12603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
12613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Basic CopyTexImage2D() with 2D texture usage
12653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicCopyTexImage2DCase : public TextureSpecCase
12663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
12673c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
12683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicCopyTexImage2DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, deUint32 flags, int width, int height)
12693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureSpecCase	(context, name, desc, TEXTURETYPE_2D, mapGLUnsizedInternalFormat(internalFormat), flags, width, height)
12703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(internalFormat)
12713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
12723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
12733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12743c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
12753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
12763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
12773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const tcu::RenderTarget&	renderTarget	= TestCase::m_context.getRenderContext().getRenderTarget();
12783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						targetHasRGB	= renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 && renderTarget.getPixelFormat().blueBits > 0;
12793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						targetHasAlpha	= renderTarget.getPixelFormat().alphaBits > 0;
12803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureFormat			fmt				= m_texFormat;
12813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						texHasRGB		= fmt.order != tcu::TextureFormat::A;
12823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						texHasAlpha		= fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA || fmt.order == tcu::TextureFormat::A;
12833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int							numLevels		= (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
12843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32					tex				= 0;
12853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random					rnd				(deStringHash(getName()));
12863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GradientShader				shader;
12873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32					shaderID		= getCurrentContext()->createProgram(&shader);
12883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha))
12903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__);
12913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill render target with gradient.
12933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f));
12943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
12963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D, tex);
12973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
12983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numLevels; ndx++)
12993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
13003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
13013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
13023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		x			= rnd.getInt(0, getWidth()	- levelW);
13033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		y			= rnd.getInt(0, getHeight()	- levelH);
13043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glCopyTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, x, y, levelW, levelH, 0);
13063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
13073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
13083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 m_internalFormat;
13103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
13113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Basic CopyTexImage2D() with cubemap usage
13133c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicCopyTexImageCubeCase : public TextureSpecCase
13143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
13153c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
13163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicCopyTexImageCubeCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, deUint32 flags, int width, int height)
13173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureSpecCase	(context, name, desc, TEXTURETYPE_CUBE, mapGLUnsizedInternalFormat(internalFormat), flags, width, height)
13183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_internalFormat	(internalFormat)
13193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
13203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
13213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13223c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
13233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
13243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
13253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const tcu::RenderTarget&	renderTarget	= TestCase::m_context.getRenderContext().getRenderTarget();
13263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						targetHasRGB	= renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 && renderTarget.getPixelFormat().blueBits > 0;
13273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						targetHasAlpha	= renderTarget.getPixelFormat().alphaBits > 0;
13283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureFormat			fmt				= m_texFormat;
13293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						texHasRGB		= fmt.order != tcu::TextureFormat::A;
13303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						texHasAlpha		= fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA || fmt.order == tcu::TextureFormat::A;
13313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int							numLevels		= (m_flags & MIPMAPS) ? deLog2Floor32(m_width)+1 : 1;
13323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32					tex				= 0;
13333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random					rnd				(deStringHash(getName()));
13343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GradientShader				shader;
13353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32					shaderID		= getCurrentContext()->createProgram(&shader);
13363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_width == m_height); // Non-square cubemaps are not supported by GLES2.
13383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha))
13403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__);
13413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill render target with gradient.
13433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f));
13443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
13463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
13473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numLevels; ndx++)
13493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
13503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int levelW = de::max(1, m_width >> ndx);
13513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int levelH = de::max(1, m_height >> ndx);
13523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
13543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
13553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int x = rnd.getInt(0, getWidth()	- levelW);
13563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int y = rnd.getInt(0, getHeight()	- levelH);
13573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glCopyTexImage2D(s_cubeMapFaces[face], ndx, m_internalFormat, x, y, levelW, levelH, 0);
13593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
13603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
13613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
13623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 m_internalFormat;
13643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
13653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Basic CopyTexSubImage2D() with 2D texture usage
13693c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicCopyTexSubImage2DCase : public TextureSpecCase
13703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
13713c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
13723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicCopyTexSubImage2DCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 flags, int width, int height)
13733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureSpecCase	(context, name, desc, TEXTURETYPE_2D, glu::mapGLTransferFormat(format, dataType), flags, width, height)
13743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(format)
13753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(dataType)
13763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
13773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
13783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13793c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
13803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
13813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
13823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const tcu::RenderTarget&	renderTarget	= TestCase::m_context.getRenderContext().getRenderTarget();
13833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						targetHasRGB	= renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 && renderTarget.getPixelFormat().blueBits > 0;
13843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						targetHasAlpha	= renderTarget.getPixelFormat().alphaBits > 0;
13853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureFormat			fmt				= m_texFormat;
13863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						texHasRGB		= fmt.order != tcu::TextureFormat::A;
13873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						texHasAlpha		= fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA || fmt.order == tcu::TextureFormat::A;
13883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int							numLevels		= (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
13893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32					tex				= 0;
13903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel			data			(fmt);
13913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random					rnd				(deStringHash(getName()));
13923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GradientShader				shader;
13933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32					shaderID		= getCurrentContext()->createProgram(&shader);
13943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha))
13963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__);
13973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
13993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_2D, tex);
14003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
14013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// First specify full texture.
14033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numLevels; ndx++)
14043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
14053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
14063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
14073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorA		= randomVector<4>(rnd);
14093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4	colorB		= randomVector<4>(rnd);
14103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		cellSize	= rnd.getInt(2, 16);
14113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.setSize(levelW, levelH);
14133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
14143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexImage2D(GL_TEXTURE_2D, ndx, m_format, levelW, levelH, 0, m_format, m_dataType, data.getAccess().getDataPtr());
14163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
14173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill render target with gradient.
14193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f));
14203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Re-specify parts of each level.
14223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numLevels; ndx++)
14233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
14243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
14253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
14263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		w			= rnd.getInt(1, levelW);
14283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		h			= rnd.getInt(1, levelH);
14293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		xo			= rnd.getInt(0, levelW-w);
14303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		yo			= rnd.getInt(0, levelH-h);
14313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		x			= rnd.getInt(0, getWidth() - w);
14333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		y			= rnd.getInt(0, getHeight() - h);
14343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glCopyTexSubImage2D(GL_TEXTURE_2D, ndx, xo, yo, x, y, w, h);
14363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
14373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
14383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
14403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
14413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
14423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Basic CopyTexSubImage2D() with cubemap usage
14443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicCopyTexSubImageCubeCase : public TextureSpecCase
14453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
14463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
14473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BasicCopyTexSubImageCubeCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 flags, int width, int height)
14483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureSpecCase	(context, name, desc, TEXTURETYPE_CUBE, glu::mapGLTransferFormat(format, dataType), flags, width, height)
14493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_format			(format)
14503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_dataType		(dataType)
14513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
14523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
14533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14543c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
14553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void createTexture (void)
14563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
14573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const tcu::RenderTarget&	renderTarget	= TestCase::m_context.getRenderContext().getRenderTarget();
14583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						targetHasRGB	= renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 && renderTarget.getPixelFormat().blueBits > 0;
14593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						targetHasAlpha	= renderTarget.getPixelFormat().alphaBits > 0;
14603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureFormat			fmt				= m_texFormat;
14613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						texHasRGB		= fmt.order != tcu::TextureFormat::A;
14623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool						texHasAlpha		= fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA || fmt.order == tcu::TextureFormat::A;
14633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int							numLevels		= (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
14643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32					tex				= 0;
14653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TextureLevel			data			(fmt);
14663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random					rnd				(deStringHash(getName()));
14673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GradientShader				shader;
14683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32					shaderID		= getCurrentContext()->createProgram(&shader);
14693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(m_width == m_height); // Non-square cubemaps are not supported by GLES2.
14713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha))
14733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__);
14743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &tex);
14763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
14773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
14783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numLevels; ndx++)
14803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
14813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
14823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
14833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			data.setSize(levelW, levelH);
14853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
14873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
14883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				Vec4	colorA		= randomVector<4>(rnd);
14893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				Vec4	colorB		= randomVector<4>(rnd);
14903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int		cellSize	= rnd.getInt(2, 16);
14913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
14933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glTexImage2D(s_cubeMapFaces[face], ndx, m_format, levelW, levelH, 0, m_format, m_dataType, data.getAccess().getDataPtr());
14943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
14953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
14963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
14973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill render target with gradient.
14983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f));
14993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Re-specify parts of each face and level.
15013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numLevels; ndx++)
15023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
15033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelW		= de::max(1, m_width >> ndx);
15043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		levelH		= de::max(1, m_height >> ndx);
15053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
15073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
15083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int		w			= rnd.getInt(1, levelW);
15093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int		h			= rnd.getInt(1, levelH);
15103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int		xo			= rnd.getInt(0, levelW-w);
15113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int		yo			= rnd.getInt(0, levelH-h);
15123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int		x			= rnd.getInt(0, getWidth() - w);
15143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int		y			= rnd.getInt(0, getHeight() - h);
15153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glCopyTexSubImage2D(s_cubeMapFaces[face], ndx, xo, yo, x, y, w, h);
15173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
15183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
15193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
15203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_format;
15223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_dataType;
15233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
15243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15253c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureSpecificationTests::TextureSpecificationTests (Context& context)
15263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCaseGroup(context, "specification", "Texture Specification Tests")
15273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
15283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
15293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15303c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureSpecificationTests::~TextureSpecificationTests (void)
15313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
15323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
15333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15343c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureSpecificationTests::init (void)
15353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
15363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	struct
15373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
15383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char*	name;
15393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32	format;
15403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32	dataType;
15413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	} texFormats[] =
15423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
15433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "a8",			GL_ALPHA,			GL_UNSIGNED_BYTE },
15443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "l8",			GL_LUMINANCE,		GL_UNSIGNED_BYTE },
15453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "la88",		GL_LUMINANCE_ALPHA,	GL_UNSIGNED_BYTE },
15463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb565",		GL_RGB,				GL_UNSIGNED_SHORT_5_6_5 },
15473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgb888",		GL_RGB,				GL_UNSIGNED_BYTE },
15483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba4444",	GL_RGBA,			GL_UNSIGNED_SHORT_4_4_4_4 },
15493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba5551",	GL_RGBA,			GL_UNSIGNED_SHORT_5_5_5_1 },
15503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "rgba8888",	GL_RGBA,			GL_UNSIGNED_BYTE }
15513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
15523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Basic TexImage2D usage.
15543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
15553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* basicTexImageGroup = new tcu::TestCaseGroup(m_testCtx, "basic_teximage2d", "Basic glTexImage2D() usage");
15563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(basicTexImageGroup);
15573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(texFormats); formatNdx++)
15583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
15593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	fmtName		= texFormats[formatNdx].name;
15603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	format		= texFormats[formatNdx].format;
15613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	dataType	= texFormats[formatNdx].dataType;
15623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DWidth	= 64;
15633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DHeight	= 128;
15643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	texCubeSize	= 64;
15653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			basicTexImageGroup->addChild(new BasicTexImage2DCase	(m_context,	(string(fmtName) + "_2d").c_str(),		"",	format, dataType, MIPMAPS, tex2DWidth, tex2DHeight));
15673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			basicTexImageGroup->addChild(new BasicTexImageCubeCase	(m_context,	(string(fmtName) + "_cube").c_str(),	"",	format, dataType, MIPMAPS, texCubeSize, texCubeSize));
15683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
15693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
15703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Randomized TexImage2D order.
15723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
15733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* randomTexImageGroup = new tcu::TestCaseGroup(m_testCtx, "random_teximage2d", "Randomized glTexImage2D() usage");
15743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(randomTexImageGroup);
15753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random rnd(9);
15773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// 2D cases.
15793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < 10; ndx++)
15803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
15813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		formatNdx	= rnd.getInt(0, DE_LENGTH_OF_ARRAY(texFormats)-1);
15823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		width		= 1 << rnd.getInt(2, 8);
15833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		height		= 1 << rnd.getInt(2, 8);
15843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			randomTexImageGroup->addChild(new RandomOrderTexImage2DCase(m_context, (string("2d_") + de::toString(ndx)).c_str(), "", texFormats[formatNdx].format, texFormats[formatNdx].dataType, MIPMAPS, width, height));
15863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
15873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Cubemap cases.
15893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < 10; ndx++)
15903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
15913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		formatNdx	= rnd.getInt(0, DE_LENGTH_OF_ARRAY(texFormats)-1);
15923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			int		size		= 1 << rnd.getInt(2, 8);
15933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			randomTexImageGroup->addChild(new RandomOrderTexImageCubeCase(m_context, (string("cube_") + de::toString(ndx)).c_str(), "", texFormats[formatNdx].format, texFormats[formatNdx].dataType, MIPMAPS, size, size));
15953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
15963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
15973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
15983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// TexImage2D unpack alignment.
15993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
16003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* alignGroup = new tcu::TestCaseGroup(m_testCtx, "teximage2d_align", "glTexImage2D() unpack alignment tests");
16013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(alignGroup);
16023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_l8_4_8",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			MIPMAPS,	 4, 8, 8));
16043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_l8_63_1",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			0,			63, 30, 1));
16053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_l8_63_2",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			0,			63, 30, 2));
16063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_l8_63_4",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			0,			63, 30, 4));
16073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_l8_63_8",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			0,			63, 30, 8));
16083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_rgba4444_51_1",		"",	GL_RGBA,		GL_UNSIGNED_SHORT_4_4_4_4,	0,			51, 30, 1));
16093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_rgba4444_51_2",		"",	GL_RGBA,		GL_UNSIGNED_SHORT_4_4_4_4,	0,			51, 30, 2));
16103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_rgba4444_51_4",		"",	GL_RGBA,		GL_UNSIGNED_SHORT_4_4_4_4,	0,			51, 30, 4));
16113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_rgba4444_51_8",		"",	GL_RGBA,		GL_UNSIGNED_SHORT_4_4_4_4,	0,			51, 30, 8));
16123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_rgb888_39_1",		"",	GL_RGB,			GL_UNSIGNED_BYTE,			0,			39, 43, 1));
16133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_rgb888_39_2",		"",	GL_RGB,			GL_UNSIGNED_BYTE,			0,			39, 43, 2));
16143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_rgb888_39_4",		"",	GL_RGB,			GL_UNSIGNED_BYTE,			0,			39, 43, 4));
16153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_rgb888_39_8",		"",	GL_RGB,			GL_UNSIGNED_BYTE,			0,			39, 43, 8));
16163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_rgba8888_47_1",		"",	GL_RGBA,		GL_UNSIGNED_BYTE,			0,			47, 27, 1));
16173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_rgba8888_47_2",		"",	GL_RGBA,		GL_UNSIGNED_BYTE,			0,			47, 27, 2));
16183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_rgba8888_47_4",		"",	GL_RGBA,		GL_UNSIGNED_BYTE,			0,			47, 27, 4));
16193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImage2DAlignCase	(m_context, "2d_rgba8888_47_8",		"",	GL_RGBA,		GL_UNSIGNED_BYTE,			0,			47, 27, 8));
16203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_l8_4_8",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			MIPMAPS,	 4, 4, 8));
16223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_l8_63_1",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			0,			63, 63, 1));
16233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_l8_63_2",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			0,			63, 63, 2));
16243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_l8_63_4",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			0,			63, 63, 4));
16253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_l8_63_8",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			0,			63, 63, 8));
16263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_rgba4444_51_1",	"",	GL_RGBA,		GL_UNSIGNED_SHORT_4_4_4_4,	0,			51, 51, 1));
16273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_rgba4444_51_2",	"",	GL_RGBA,		GL_UNSIGNED_SHORT_4_4_4_4,	0,			51, 51, 2));
16283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_rgba4444_51_4",	"",	GL_RGBA,		GL_UNSIGNED_SHORT_4_4_4_4,	0,			51, 51, 4));
16293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_rgba4444_51_8",	"",	GL_RGBA,		GL_UNSIGNED_SHORT_4_4_4_4,	0,			51, 51, 8));
16303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_rgb888_39_1",		"",	GL_RGB,			GL_UNSIGNED_BYTE,			0,			39, 39, 1));
16313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_rgb888_39_2",		"",	GL_RGB,			GL_UNSIGNED_BYTE,			0,			39, 39, 2));
16323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_rgb888_39_4",		"",	GL_RGB,			GL_UNSIGNED_BYTE,			0,			39, 39, 4));
16333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_rgb888_39_8",		"",	GL_RGB,			GL_UNSIGNED_BYTE,			0,			39, 39, 8));
16343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_rgba8888_47_1",	"",	GL_RGBA,		GL_UNSIGNED_BYTE,			0,			47, 47, 1));
16353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_rgba8888_47_2",	"",	GL_RGBA,		GL_UNSIGNED_BYTE,			0,			47, 47, 2));
16363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_rgba8888_47_4",	"",	GL_RGBA,		GL_UNSIGNED_BYTE,			0,			47, 47, 4));
16373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexImageCubeAlignCase	(m_context, "cube_rgba8888_47_8",	"",	GL_RGBA,		GL_UNSIGNED_BYTE,			0,			47, 47, 8));
16383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
16393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Basic TexSubImage2D usage.
16413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
16423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* basicTexSubImageGroup = new tcu::TestCaseGroup(m_testCtx, "basic_texsubimage2d", "Basic glTexSubImage2D() usage");
16433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(basicTexSubImageGroup);
16443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(texFormats); formatNdx++)
16453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
16463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	fmtName		= texFormats[formatNdx].name;
16473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	format		= texFormats[formatNdx].format;
16483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	dataType	= texFormats[formatNdx].dataType;
16493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DWidth	= 64;
16503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DHeight	= 128;
16513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	texCubeSize	= 64;
16523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			basicTexSubImageGroup->addChild(new BasicTexSubImage2DCase		(m_context,	(string(fmtName) + "_2d").c_str(),		"",	format, dataType, MIPMAPS, tex2DWidth, tex2DHeight));
16543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			basicTexSubImageGroup->addChild(new BasicTexSubImageCubeCase	(m_context,	(string(fmtName) + "_cube").c_str(),	"",	format, dataType, MIPMAPS, texCubeSize, texCubeSize));
16553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
16563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
16573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// TexSubImage2D to empty texture.
16593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
16603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* texSubImageEmptyTexGroup = new tcu::TestCaseGroup(m_testCtx, "texsubimage2d_empty_tex", "glTexSubImage2D() to texture that has storage but no data");
16613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(texSubImageEmptyTexGroup);
16623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(texFormats); formatNdx++)
16633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
16643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	fmtName		= texFormats[formatNdx].name;
16653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	format		= texFormats[formatNdx].format;
16663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			deUint32	dataType	= texFormats[formatNdx].dataType;
16673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DWidth	= 64;
16683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	tex2DHeight	= 32;
16693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int	texCubeSize	= 32;
16703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			texSubImageEmptyTexGroup->addChild(new TexSubImage2DEmptyTexCase	(m_context,	(string(fmtName) + "_2d").c_str(),		"",	format, dataType, MIPMAPS, tex2DWidth, tex2DHeight));
16723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			texSubImageEmptyTexGroup->addChild(new TexSubImageCubeEmptyTexCase	(m_context,	(string(fmtName) + "_cube").c_str(),	"",	format, dataType, MIPMAPS, texCubeSize, texCubeSize));
16733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
16743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
16753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// TexSubImage2D alignment cases.
16773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
16783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* alignGroup = new tcu::TestCaseGroup(m_testCtx, "texsubimage2d_align", "glTexSubImage2D() unpack alignment tests");
16793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(alignGroup);
16803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
16813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_l8_1_1",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			64, 64, 13, 17,  1,  6, 1));
16823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_l8_1_2",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			64, 64, 13, 17,  1,  6, 2));
16833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_l8_1_4",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			64, 64, 13, 17,  1,  6, 4));
16843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_l8_1_8",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			64, 64, 13, 17,  1,  6, 8));
16853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_l8_63_1",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			64, 64,  1,  9, 63, 30, 1));
16863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_l8_63_2",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			64, 64,  1,  9, 63, 30, 2));
16873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_l8_63_4",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			64, 64,  1,  9, 63, 30, 4));
16883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_l8_63_8",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			64, 64,  1,  9, 63, 30, 8));
16893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_rgba4444_51_1",		"",	GL_RGBA,		GL_UNSIGNED_SHORT_4_4_4_4,	64, 64,  7, 29, 51, 30, 1));
16903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_rgba4444_51_2",		"",	GL_RGBA,		GL_UNSIGNED_SHORT_4_4_4_4,	64, 64,  7, 29, 51, 30, 2));
16913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_rgba4444_51_4",		"",	GL_RGBA,		GL_UNSIGNED_SHORT_4_4_4_4,	64, 64,  7, 29, 51, 30, 4));
16923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_rgba4444_51_8",		"",	GL_RGBA,		GL_UNSIGNED_SHORT_4_4_4_4,	64, 64,  7, 29, 51, 30, 8));
16933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_rgb888_39_1",		"",	GL_RGB,			GL_UNSIGNED_BYTE,			64, 64, 11,  8, 39, 43, 1));
16943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_rgb888_39_2",		"",	GL_RGB,			GL_UNSIGNED_BYTE,			64, 64, 11,  8, 39, 43, 2));
16953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_rgb888_39_4",		"",	GL_RGB,			GL_UNSIGNED_BYTE,			64, 64, 11,  8, 39, 43, 4));
16963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_rgb888_39_8",		"",	GL_RGB,			GL_UNSIGNED_BYTE,			64, 64, 11,  8, 39, 43, 8));
16973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_rgba8888_47_1",		"",	GL_RGBA,		GL_UNSIGNED_BYTE,			64, 64, 10,  1, 47, 27, 1));
16983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_rgba8888_47_2",		"",	GL_RGBA,		GL_UNSIGNED_BYTE,			64, 64, 10,  1, 47, 27, 2));
16993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_rgba8888_47_4",		"",	GL_RGBA,		GL_UNSIGNED_BYTE,			64, 64, 10,  1, 47, 27, 4));
17003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImage2DAlignCase		(m_context, "2d_rgba8888_47_8",		"",	GL_RGBA,		GL_UNSIGNED_BYTE,			64, 64, 10,  1, 47, 27, 8));
17013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_l8_1_1",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			64, 64, 13, 17,  1,  6, 1));
17033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_l8_1_2",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			64, 64, 13, 17,  1,  6, 2));
17043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_l8_1_4",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			64, 64, 13, 17,  1,  6, 4));
17053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_l8_1_8",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			64, 64, 13, 17,  1,  6, 8));
17063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_l8_63_1",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			64, 64,  1,  9, 63, 30, 1));
17073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_l8_63_2",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			64, 64,  1,  9, 63, 30, 2));
17083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_l8_63_4",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			64, 64,  1,  9, 63, 30, 4));
17093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_l8_63_8",			"",	GL_LUMINANCE,	GL_UNSIGNED_BYTE,			64, 64,  1,  9, 63, 30, 8));
17103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_rgba4444_51_1",	"",	GL_RGBA,		GL_UNSIGNED_SHORT_4_4_4_4,	64, 64,  7, 29, 51, 30, 1));
17113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_rgba4444_51_2",	"",	GL_RGBA,		GL_UNSIGNED_SHORT_4_4_4_4,	64, 64,  7, 29, 51, 30, 2));
17123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_rgba4444_51_4",	"",	GL_RGBA,		GL_UNSIGNED_SHORT_4_4_4_4,	64, 64,  7, 29, 51, 30, 4));
17133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_rgba4444_51_8",	"",	GL_RGBA,		GL_UNSIGNED_SHORT_4_4_4_4,	64, 64,  7, 29, 51, 30, 8));
17143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_rgb888_39_1",		"",	GL_RGB,			GL_UNSIGNED_BYTE,			64, 64, 11,  8, 39, 43, 1));
17153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_rgb888_39_2",		"",	GL_RGB,			GL_UNSIGNED_BYTE,			64, 64, 11,  8, 39, 43, 2));
17163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_rgb888_39_4",		"",	GL_RGB,			GL_UNSIGNED_BYTE,			64, 64, 11,  8, 39, 43, 4));
17173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_rgb888_39_8",		"",	GL_RGB,			GL_UNSIGNED_BYTE,			64, 64, 11,  8, 39, 43, 8));
17183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_rgba8888_47_1",	"",	GL_RGBA,		GL_UNSIGNED_BYTE,			64, 64, 10,  1, 47, 27, 1));
17193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_rgba8888_47_2",	"",	GL_RGBA,		GL_UNSIGNED_BYTE,			64, 64, 10,  1, 47, 27, 2));
17203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_rgba8888_47_4",	"",	GL_RGBA,		GL_UNSIGNED_BYTE,			64, 64, 10,  1, 47, 27, 4));
17213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		alignGroup->addChild(new TexSubImageCubeAlignCase	(m_context, "cube_rgba8888_47_8",	"",	GL_RGBA,		GL_UNSIGNED_BYTE,			64, 64, 10,  1, 47, 27, 8));
17223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
17233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Basic glCopyTexImage2D() cases
17253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
17263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* copyTexImageGroup = new tcu::TestCaseGroup(m_testCtx, "basic_copyteximage2d", "Basic glCopyTexImage2D() usage");
17273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(copyTexImageGroup);
17283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexImageGroup->addChild(new BasicCopyTexImage2DCase		(m_context, "2d_alpha",				"",	GL_ALPHA,			MIPMAPS,	128, 64));
17303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexImageGroup->addChild(new BasicCopyTexImage2DCase		(m_context, "2d_luminance",			"",	GL_LUMINANCE,		MIPMAPS,	128, 64));
17313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexImageGroup->addChild(new BasicCopyTexImage2DCase		(m_context, "2d_luminance_alpha",	"",	GL_LUMINANCE_ALPHA,	MIPMAPS,	128, 64));
17323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexImageGroup->addChild(new BasicCopyTexImage2DCase		(m_context, "2d_rgb",				"",	GL_RGB,				MIPMAPS,	128, 64));
17333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexImageGroup->addChild(new BasicCopyTexImage2DCase		(m_context, "2d_rgba",				"",	GL_RGBA,			MIPMAPS,	128, 64));
17343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexImageGroup->addChild(new BasicCopyTexImageCubeCase	(m_context, "cube_alpha",			"",	GL_ALPHA,			MIPMAPS,	64, 64));
17363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexImageGroup->addChild(new BasicCopyTexImageCubeCase	(m_context, "cube_luminance",		"",	GL_LUMINANCE,		MIPMAPS,	64, 64));
17373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexImageGroup->addChild(new BasicCopyTexImageCubeCase	(m_context, "cube_luminance_alpha",	"",	GL_LUMINANCE_ALPHA,	MIPMAPS,	64, 64));
17383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexImageGroup->addChild(new BasicCopyTexImageCubeCase	(m_context, "cube_rgb",				"",	GL_RGB,				MIPMAPS,	64, 64));
17393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexImageGroup->addChild(new BasicCopyTexImageCubeCase	(m_context, "cube_rgba",			"",	GL_RGBA,			MIPMAPS,	64, 64));
17403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
17413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Basic glCopyTexSubImage2D() cases
17433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
17443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::TestCaseGroup* copyTexSubImageGroup = new tcu::TestCaseGroup(m_testCtx, "basic_copytexsubimage2d", "Basic glCopyTexSubImage2D() usage");
17453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(copyTexSubImageGroup);
17463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexSubImageGroup->addChild(new BasicCopyTexSubImage2DCase	(m_context, "2d_alpha",				"",	GL_ALPHA,			GL_UNSIGNED_BYTE, MIPMAPS, 128, 64));
17483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexSubImageGroup->addChild(new BasicCopyTexSubImage2DCase	(m_context, "2d_luminance",			"",	GL_LUMINANCE,		GL_UNSIGNED_BYTE, MIPMAPS, 128, 64));
17493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexSubImageGroup->addChild(new BasicCopyTexSubImage2DCase	(m_context, "2d_luminance_alpha",	"",	GL_LUMINANCE_ALPHA,	GL_UNSIGNED_BYTE, MIPMAPS, 128, 64));
17503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexSubImageGroup->addChild(new BasicCopyTexSubImage2DCase	(m_context, "2d_rgb",				"",	GL_RGB,				GL_UNSIGNED_BYTE, MIPMAPS, 128, 64));
17513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexSubImageGroup->addChild(new BasicCopyTexSubImage2DCase	(m_context, "2d_rgba",				"",	GL_RGBA,			GL_UNSIGNED_BYTE, MIPMAPS, 128, 64));
17523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexSubImageGroup->addChild(new BasicCopyTexSubImageCubeCase	(m_context, "cube_alpha",			"",	GL_ALPHA,			GL_UNSIGNED_BYTE, MIPMAPS, 64, 64));
17543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexSubImageGroup->addChild(new BasicCopyTexSubImageCubeCase	(m_context, "cube_luminance",		"",	GL_LUMINANCE,		GL_UNSIGNED_BYTE, MIPMAPS, 64, 64));
17553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexSubImageGroup->addChild(new BasicCopyTexSubImageCubeCase	(m_context, "cube_luminance_alpha",	"",	GL_LUMINANCE_ALPHA,	GL_UNSIGNED_BYTE, MIPMAPS, 64, 64));
17563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexSubImageGroup->addChild(new BasicCopyTexSubImageCubeCase	(m_context, "cube_rgb",				"",	GL_RGB,				GL_UNSIGNED_BYTE, MIPMAPS, 64, 64));
17573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		copyTexSubImageGroup->addChild(new BasicCopyTexSubImageCubeCase	(m_context, "cube_rgba",			"",	GL_RGBA,			GL_UNSIGNED_BYTE, MIPMAPS, 64, 64));
17583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
17593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
17603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
17613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional
17623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles2
17633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
1764