13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 3.0 Module
33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * -------------------------------------------------
43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project
63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License");
83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License.
93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at
103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *      http://www.apache.org/licenses/LICENSE-2.0
123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software
143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS,
153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and
173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License.
183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*!
203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file
213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Texture format performance tests.
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es3pTextureCases.hpp"
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsShaderPerformanceCase.hpp"
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTextureUtil.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuRenderTarget.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluTexture.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluTextureUtil.hpp"
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluStrUtil.hpp"
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp"
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp"
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp"
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles3
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Performance
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace gls;
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace glw; // GL types
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Vec2;
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Vec3;
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Vec4;
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::IVec4;
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::string;
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector;
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog;
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
543c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexture2DRenderCase::Texture2DRenderCase (Context&			context,
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  const char*		name,
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  const char*		description,
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  deUint32			internalFormat,
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  deUint32			wrapS,
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  deUint32			wrapT,
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  deUint32			minFilter,
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  deUint32			magFilter,
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  const tcu::Mat3&	coordTransform,
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  int				numTextures,
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  bool				powerOfTwo)
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: ShaderPerformanceCase	(context.getTestContext(), context.getRenderContext(), name, description, CASETYPE_FRAGMENT)
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_internalFormat		(internalFormat)
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_wrapS				(wrapS)
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_wrapT				(wrapT)
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_minFilter			(minFilter)
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_magFilter			(magFilter)
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_coordTransform		(coordTransform)
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_numTextures			(numTextures)
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_powerOfTwo			(powerOfTwo)
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
773c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexture2DRenderCase::~Texture2DRenderCase (void)
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (vector<glu::Texture2D*>::iterator i = m_textures.begin(); i != m_textures.end(); i++)
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		delete *i;
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_textures.clear();
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic inline int roundDownToPowerOfTwo (int val)
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(val >= 0);
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int l0 = deClz32(val);
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return val & ~((1<<(31-l0))-1);
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Texture2DRenderCase::init (void)
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TestLog& log = m_testCtx.getLog();
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::TextureFormat		texFormat	= glu::mapGLInternalFormat(m_internalFormat);
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::TextureFormatInfo	fmtInfo		= tcu::getTextureFormatInfo(texFormat);
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::Precision			samplerPrec	= (texFormat.type == tcu::TextureFormat::FLOAT			||
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												   texFormat.type == tcu::TextureFormat::UNSIGNED_INT32	||
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												   texFormat.type == tcu::TextureFormat::SIGNED_INT32)
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												? glu::PRECISION_HIGHP : glu::PRECISION_MEDIUMP;
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glu::DataType				samplerType	= glu::getSampler2DType(texFormat);
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const bool						isIntUint	= samplerType == glu::TYPE_INT_SAMPLER_2D || samplerType == glu::TYPE_UINT_SAMPLER_2D;
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								width		= m_renderCtx.getRenderTarget().getWidth();
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								height		= m_renderCtx.getRenderTarget().getHeight();
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_powerOfTwo)
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		width	= roundDownToPowerOfTwo(width);
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		height	= roundDownToPowerOfTwo(height);
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool mipmaps = m_minFilter == GL_NEAREST_MIPMAP_NEAREST ||
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				   m_minFilter == GL_NEAREST_MIPMAP_LINEAR	||
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				   m_minFilter == GL_LINEAR_MIPMAP_NEAREST	||
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				   m_minFilter == GL_LINEAR_MIPMAP_LINEAR;
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(m_powerOfTwo || (!mipmaps && m_wrapS == GL_CLAMP_TO_EDGE && m_wrapT == GL_CLAMP_TO_EDGE));
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec2 p00 = (m_coordTransform * Vec3(0.0f, 0.0f, 1.0f)).swizzle(0,1);
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec2 p10 = (m_coordTransform * Vec3(1.0f, 0.0f, 1.0f)).swizzle(0,1);
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec2 p01 = (m_coordTransform * Vec3(0.0f, 1.0f, 1.0f)).swizzle(0,1);
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec2 p11 = (m_coordTransform * Vec3(1.0f, 1.0f, 1.0f)).swizzle(0,1);
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_attributes.push_back(AttribSpec("a_coords", Vec4(p00.x(), p00.y(), 0.0f, 0.0f),
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  Vec4(p10.x(), p10.y(), 0.0f, 0.0f),
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  Vec4(p01.x(), p01.y(), 0.0f, 0.0f),
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												  Vec4(p11.x(), p11.y(), 0.0f, 0.0f)));
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::Message << "Size: " << width << "x" << height << TestLog::EndMessage;
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::Message << "Format: " <<glu::getPixelFormatName(m_internalFormat) << TestLog::EndMessage;
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::Message << "Coords: " << p00 << ", " << p10 << ", " << p01 << ", " << p11 << TestLog::EndMessage;
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::Message << "Wrap: " << glu::getTextureWrapModeStr(m_wrapS) << " / " << glu::getTextureWrapModeStr(m_wrapT) << TestLog::EndMessage;
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::Message << "Filter: " << glu::getTextureFilterStr(m_minFilter) << " / " << glu::getTextureFilterStr(m_magFilter) << TestLog::EndMessage;
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::Message << "Mipmaps: " << (mipmaps ? "true" : "false") << TestLog::EndMessage;
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::Message << "Using additive blending." << TestLog::EndMessage;
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Use same viewport size as texture size.
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	setViewportSize(width, height);
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_vertShaderSource =
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"#version 300 es\n"
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"in highp vec4 a_position;\n"
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"in mediump vec2 a_coords;\n"
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"out mediump vec2 v_coords;\n"
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"void main (void)\n"
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"{\n"
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"	gl_Position = a_position;\n"
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"	v_coords = a_coords;\n"
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"}\n";
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::ostringstream fragSrc;
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	fragSrc << "#version 300 es\n";
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	fragSrc << "layout(location = 0) out mediump vec4 o_color;\n";
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	fragSrc << "in mediump vec2 v_coords;\n";
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int texNdx = 0; texNdx < m_numTextures; texNdx++)
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		fragSrc << "uniform " << glu::getPrecisionName(samplerPrec) << " " << glu::getDataTypeName(samplerType) << " u_sampler" << texNdx << ";\n";
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	fragSrc << "void main (void)\n"
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "{\n";
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int texNdx = 0; texNdx < m_numTextures; texNdx++)
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (texNdx == 0)
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			fragSrc << "\t" << glu::getPrecisionName(samplerPrec) << " vec4 r = ";
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		else
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			fragSrc << "\tr += ";
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (isIntUint)
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			fragSrc << "vec4(";
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		fragSrc << "texture(u_sampler" << texNdx << ", v_coords)";
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (isIntUint)
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			fragSrc << ")";
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		fragSrc << ";\n";
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	fragSrc << "	o_color = r;\n"
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< "}\n";
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_fragShaderSource = fragSrc.str();
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_textures.reserve(m_numTextures);
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int texNdx = 0; texNdx < m_numTextures; texNdx++)
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const IVec4 swizzles[] = { IVec4(0,1,2,3), IVec4(1,2,3,0), IVec4(2,3,0,1), IVec4(3,0,1,2),
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										  IVec4(3,2,1,0), IVec4(2,1,0,3), IVec4(1,0,3,2), IVec4(0,3,2,1) };
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const IVec4& sw = swizzles[texNdx % DE_LENGTH_OF_ARRAY(swizzles)];
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::Texture2D* texture = new glu::Texture2D(m_renderCtx, m_internalFormat, width, height);
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_textures.push_back(texture);
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Fill levels.
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int numLevels = mipmaps ? texture->getRefTexture().getNumLevels() : 1;
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int levelNdx = 0; levelNdx < numLevels; levelNdx++)
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// \todo [2013-06-02 pyry] Values are not scaled back to 0..1 range in shaders.
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			texture->getRefTexture().allocLevel(levelNdx);
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::fillWithComponentGradients(texture->getRefTexture().getLevel(levelNdx),
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											fmtInfo.valueMin.swizzle(sw[0], sw[1], sw[2], sw[3]),
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											fmtInfo.valueMax.swizzle(sw[0], sw[1], sw[2], sw[3]));
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		texture->upload();
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ShaderPerformanceCase::init();
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Texture2DRenderCase::deinit (void)
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (vector<glu::Texture2D*>::iterator i = m_textures.begin(); i != m_textures.end(); i++)
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		delete *i;
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_textures.clear();
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ShaderPerformanceCase::deinit();
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Texture2DRenderCase::setupProgram (deUint32 program)
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glw::Functions& gl = m_renderCtx.getFunctions();
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int texNdx = 0; texNdx < m_numTextures; texNdx++)
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int samplerLoc = gl.getUniformLocation(program, (string("u_sampler") + de::toString(texNdx)).c_str());
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.uniform1i(samplerLoc, texNdx);
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Texture2DRenderCase::setupRenderState (void)
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glw::Functions& gl = m_renderCtx.getFunctions();
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Setup additive blending.
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.enable(GL_BLEND);
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.blendFunc(GL_ONE, GL_ONE);
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.blendEquation(GL_FUNC_ADD);
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Setup textures.
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int texNdx = 0; texNdx < m_numTextures; texNdx++)
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.activeTexture(GL_TEXTURE0 + texNdx);
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.bindTexture(GL_TEXTURE_2D, m_textures[texNdx]->getGLTexture());
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,	m_minFilter);
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,	m_magFilter);
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,		m_wrapS);
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,		m_wrapT);
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Performance
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles3
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
257