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