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 State Query tests.
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es3fTextureStateQueryTests.hpp"
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es3fApiCase.hpp"
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsStateQueryUtil.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluRenderContext.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp"
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp"
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deMath.h"
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace glw; // GLint and other GL types
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace deqp::gls;
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing deqp::gls::StateQueryUtil::StateQueryMemoryWriteGuard;
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles3
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace TextureParamVerifiers
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TexParamVerifier
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexParamVerifier : protected glu::CallLogWrapper
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						TexParamVerifier	(const glw::Functions& gl, tcu::TestLog& log, const char* testNamePostfix);
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual				~TexParamVerifier	(); // make GCC happy
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char*			getTestNamePostfix	(void) const;
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void		verifyInteger		(tcu::TestContext& testCtx, GLenum target, GLenum name, GLint reference)	= DE_NULL;
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void		verifyFloat			(tcu::TestContext& testCtx, GLenum target, GLenum name, GLfloat reference)	= DE_NULL;
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const char*	const	m_testNamePostfix;
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
633c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexParamVerifier::TexParamVerifier (const glw::Functions& gl, tcu::TestLog& log, const char* testNamePostfix)
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: glu::CallLogWrapper	(gl, log)
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_testNamePostfix		(testNamePostfix)
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enableLogging(true);
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
693c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexParamVerifier::~TexParamVerifier ()
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst char* TexParamVerifier::getTestNamePostfix (void) const
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_testNamePostfix;
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass GetTexParameterIVerifier : public TexParamVerifier
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GetTexParameterIVerifier	(const glw::Functions& gl, tcu::TestLog& log);
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void	verifyInteger				(tcu::TestContext& testCtx, GLenum target, GLenum name, GLint reference);
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void	verifyFloat					(tcu::TestContext& testCtx, GLenum target, GLenum name, GLfloat reference);
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
873c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGetTexParameterIVerifier::GetTexParameterIVerifier (const glw::Functions& gl, tcu::TestLog& log)
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TexParamVerifier(gl, log, "_gettexparameteri")
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GetTexParameterIVerifier::verifyInteger (tcu::TestContext& testCtx, GLenum target, GLenum name, GLint reference)
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLint> state;
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glGetTexParameteriv(target, name, &state);
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx))
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return;
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state != reference)
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message << "// ERROR: expected " << reference << "; got " << state << TestLog::EndMessage;
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid texture param value");
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GetTexParameterIVerifier::verifyFloat (tcu::TestContext& testCtx, GLenum target, GLenum name, GLfloat reference)
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLint> state;
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glGetTexParameteriv(target, name, &state);
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx))
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return;
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const GLint expectedGLStateMax = StateQueryUtil::roundGLfloatToNearestIntegerHalfUp<GLint>(reference);
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const GLint expectedGLStateMin = StateQueryUtil::roundGLfloatToNearestIntegerHalfDown<GLint>(reference);
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state < expectedGLStateMin || state > expectedGLStateMax)
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message << "// ERROR: expected in range [" << expectedGLStateMin << ", " << expectedGLStateMax << "]; got " << state << TestLog::EndMessage;
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid texture param value");
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass GetTexParameterFVerifier : public TexParamVerifier
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GetTexParameterFVerifier	(const glw::Functions& gl, tcu::TestLog& log);
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void	verifyInteger				(tcu::TestContext& testCtx, GLenum target, GLenum name, GLint reference);
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void	verifyFloat					(tcu::TestContext& testCtx, GLenum target, GLenum name, GLfloat reference);
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1423c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGetTexParameterFVerifier::GetTexParameterFVerifier (const glw::Functions& gl, tcu::TestLog& log)
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TexParamVerifier(gl, log, "_gettexparameterf")
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GetTexParameterFVerifier::verifyInteger (tcu::TestContext& testCtx, GLenum target, GLenum name, GLint reference)
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const GLfloat referenceAsFloat = GLfloat(reference);
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(reference == GLint(referenceAsFloat)); // reference integer must have 1:1 mapping to float for this to work. Reference value is always such value in these tests
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLfloat> state;
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glGetTexParameterfv(target, name, &state);
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx))
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return;
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state != referenceAsFloat)
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message << "// ERROR: expected " << referenceAsFloat << "; got " << state << TestLog::EndMessage;
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GetTexParameterFVerifier::verifyFloat (tcu::TestContext& testCtx, GLenum target, GLenum name, GLfloat reference)
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StateQueryMemoryWriteGuard<GLfloat> state;
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glGetTexParameterfv(target, name, &state);
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!state.verifyValidity(testCtx))
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return;
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (state != reference)
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testCtx.getLog() << TestLog::Message << "// ERROR: expected " << reference << "; got " << state << TestLog::EndMessage;
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // TextureParamVerifiers
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace TextureParamVerifiers;
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Tests
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass IsTextureCase : public ApiCase
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IsTextureCase (Context& context, const char* name, const char* description, GLenum textureTarget)
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase			(context, name, description)
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_textureTarget	(textureTarget)
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		using tcu::TestLog;
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint textureId = 0;
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &textureId);
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(m_textureTarget, textureId);
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkBooleans(glIsTexture(textureId), GL_TRUE);
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteTextures(1, &textureId);
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		checkBooleans(glIsTexture(textureId), GL_FALSE);
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLenum										m_textureTarget;
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureCase : public ApiCase
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureCase (Context& context, TexParamVerifier* verifier, const char* name, const char* description, GLenum textureTarget)
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: ApiCase			(context, name, description)
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_textureTarget	(textureTarget)
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_verifier		(verifier)
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void testTexture (void) = DE_NULL;
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void test (void)
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint textureId = 0;
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &textureId);
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(m_textureTarget, textureId);
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		testTexture();
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteTextures(1, &textureId);
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLenum				m_textureTarget;
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexParamVerifier*	m_verifier;
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureSwizzleCase : public TextureCase
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureSwizzleCase (Context& context, TexParamVerifier* verifier, const char* name, const char* description, GLenum textureTarget, GLenum valueName, GLenum initialValue)
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCase		(context, verifier, name, description, textureTarget)
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_valueName		(valueName)
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_initialValue	(initialValue)
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void testTexture (void)
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_verifier->verifyInteger(m_testCtx, m_textureTarget, m_valueName, m_initialValue);
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const GLenum swizzleValues[] = {GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA, GL_ZERO, GL_ONE};
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(swizzleValues); ++ndx)
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexParameteri(m_textureTarget, m_valueName, swizzleValues[ndx]);
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_verifier->verifyInteger(m_testCtx, m_textureTarget, m_valueName, swizzleValues[ndx]);
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		//check unit conversions with float
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(swizzleValues); ++ndx)
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexParameterf(m_textureTarget, m_valueName, (GLfloat)swizzleValues[ndx]);
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_verifier->verifyInteger(m_testCtx, m_textureTarget, m_valueName, swizzleValues[ndx]);
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLenum m_valueName;
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLenum m_initialValue;
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureWrapCase : public TextureCase
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureWrapCase (Context& context, TexParamVerifier* verifier, const char* name, const char* description, GLenum textureTarget, GLenum valueName)
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCase	(context, verifier, name, description, textureTarget)
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_valueName	(valueName)
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void testTexture (void)
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_verifier->verifyInteger(m_testCtx, m_textureTarget, m_valueName, GL_REPEAT);
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const GLenum wrapValues[] = {GL_CLAMP_TO_EDGE, GL_REPEAT, GL_MIRRORED_REPEAT};
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(wrapValues); ++ndx)
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexParameteri(m_textureTarget, m_valueName, wrapValues[ndx]);
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_verifier->verifyInteger(m_testCtx, m_textureTarget, m_valueName, wrapValues[ndx]);
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		//check unit conversions with float
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(wrapValues); ++ndx)
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexParameterf(m_textureTarget, m_valueName, (GLfloat)wrapValues[ndx]);
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_verifier->verifyInteger(m_testCtx, m_textureTarget, m_valueName, wrapValues[ndx]);
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLenum	m_valueName;
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureMagFilterCase : public TextureCase
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureMagFilterCase (Context& context, TexParamVerifier* verifier, const char* name, const char* description, GLenum textureTarget)
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCase(context, verifier, name, description, textureTarget)
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void testTexture (void)
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_verifier->verifyInteger(m_testCtx, m_textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const GLenum magValues[] = {GL_NEAREST, GL_LINEAR};
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(magValues); ++ndx)
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, magValues[ndx]);
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_verifier->verifyInteger(m_testCtx, m_textureTarget, GL_TEXTURE_MAG_FILTER, magValues[ndx]);
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		//check unit conversions with float
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(magValues); ++ndx)
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexParameterf(m_textureTarget, GL_TEXTURE_MAG_FILTER, (GLfloat)magValues[ndx]);
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_verifier->verifyInteger(m_testCtx, m_textureTarget, GL_TEXTURE_MAG_FILTER, magValues[ndx]);
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureMinFilterCase : public TextureCase
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureMinFilterCase (Context& context, TexParamVerifier* verifier, const char* name, const char* description, GLenum textureTarget)
3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCase(context, verifier, name, description, textureTarget)
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void testTexture (void)
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_verifier->verifyInteger(m_testCtx, m_textureTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR);
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const GLenum minValues[] = {GL_NEAREST, GL_LINEAR, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR};
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(minValues); ++ndx)
3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, minValues[ndx]);
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_verifier->verifyInteger(m_testCtx, m_textureTarget, GL_TEXTURE_MIN_FILTER, minValues[ndx]);
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		//check unit conversions with float
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(minValues); ++ndx)
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexParameterf(m_textureTarget, GL_TEXTURE_MIN_FILTER, (GLfloat)minValues[ndx]);
4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_verifier->verifyInteger(m_testCtx, m_textureTarget, GL_TEXTURE_MIN_FILTER, minValues[ndx]);
4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureLODCase : public TextureCase
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureLODCase (Context& context, TexParamVerifier* verifier, const char* name, const char* description, GLenum textureTarget, GLenum lodTarget, int initialValue)
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCase		(context, verifier, name, description, textureTarget)
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_lodTarget		(lodTarget)
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_initialValue	(initialValue)
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void testTexture (void)
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random rnd(0xabcdef);
4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_verifier->verifyInteger(m_testCtx, m_textureTarget, m_lodTarget, m_initialValue);
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int numIterations = 60;
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numIterations; ++ndx)
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLfloat ref = rnd.getFloat(-64000, 64000);
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexParameterf(m_textureTarget, m_lodTarget, ref);
4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_verifier->verifyFloat(m_testCtx, m_textureTarget, m_lodTarget, ref);
4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check unit conversions with int
4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numIterations; ++ndx)
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLint ref = rnd.getInt(-64000, 64000);
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexParameteri(m_textureTarget, m_lodTarget, ref);
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_verifier->verifyFloat(m_testCtx, m_textureTarget, m_lodTarget, (GLfloat)ref);
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLenum	m_lodTarget;
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int		m_initialValue;
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureLevelCase : public TextureCase
4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureLevelCase (Context& context, TexParamVerifier* verifier, const char* name, const char* description, GLenum textureTarget, GLenum levelTarget, int initialValue)
4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCase		(context, verifier, name, description, textureTarget)
4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_levelTarget		(levelTarget)
4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_initialValue	(initialValue)
4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void testTexture (void)
4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		de::Random rnd(0xabcdef);
4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_verifier->verifyInteger(m_testCtx, m_textureTarget, m_levelTarget, m_initialValue);
4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int numIterations = 60;
4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numIterations; ++ndx)
4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLint ref = rnd.getInt(0, 64000);
4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexParameteri(m_textureTarget, m_levelTarget, ref);
4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_verifier->verifyInteger(m_testCtx, m_textureTarget, m_levelTarget, ref);
4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// check unit conversions with float
4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const float nonSignificantOffsets[] = {-0.45f, -0.25f, 0, 0.45f}; // offsets O so that for any integers z in Z, o in O roundToClosestInt(z+o)==z
4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int numConversionIterations = 30;
4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < numConversionIterations; ++ndx)
4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const GLint ref = rnd.getInt(0, 64000);
4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int offsetNdx = 0; offsetNdx < DE_LENGTH_OF_ARRAY(nonSignificantOffsets); ++offsetNdx)
5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glTexParameterf(m_textureTarget, m_levelTarget, ((GLfloat)ref) + nonSignificantOffsets[offsetNdx]);
5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				expectError(GL_NO_ERROR);
5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				m_verifier->verifyInteger(m_testCtx, m_textureTarget, m_levelTarget, ref);
5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				expectError(GL_NO_ERROR);
5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLenum	m_levelTarget;
5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int		m_initialValue;
5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureCompareModeCase : public TextureCase
5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureCompareModeCase (Context& context, TexParamVerifier* verifier, const char* name, const char* description, GLenum textureTarget)
5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCase(context, verifier, name, description, textureTarget)
5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void testTexture (void)
5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_verifier->verifyInteger(m_testCtx, m_textureTarget, GL_TEXTURE_COMPARE_MODE, GL_NONE);
5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const GLenum modes[] = {GL_COMPARE_REF_TO_TEXTURE, GL_NONE};
5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(modes); ++ndx)
5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexParameteri(m_textureTarget, GL_TEXTURE_COMPARE_MODE, modes[ndx]);
5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_verifier->verifyInteger(m_testCtx, m_textureTarget, GL_TEXTURE_COMPARE_MODE, modes[ndx]);
5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// with float too
5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(modes); ++ndx)
5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexParameterf(m_textureTarget, GL_TEXTURE_COMPARE_MODE, (GLfloat)modes[ndx]);
5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_verifier->verifyInteger(m_testCtx, m_textureTarget, GL_TEXTURE_COMPARE_MODE, modes[ndx]);
5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureCompareFuncCase : public TextureCase
5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureCompareFuncCase (Context& context, TexParamVerifier* verifier, const char* name, const char* description, GLenum textureTarget)
5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCase(context, verifier, name, description, textureTarget)
5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void testTexture (void)
5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_verifier->verifyInteger(m_testCtx, m_textureTarget, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const GLenum compareFuncs[] = {GL_LEQUAL, GL_GEQUAL, GL_LESS, GL_GREATER, GL_EQUAL, GL_NOTEQUAL, GL_ALWAYS, GL_NEVER};
5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(compareFuncs); ++ndx)
5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexParameteri(m_textureTarget, GL_TEXTURE_COMPARE_FUNC, compareFuncs[ndx]);
5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_verifier->verifyInteger(m_testCtx, m_textureTarget, GL_TEXTURE_COMPARE_FUNC, compareFuncs[ndx]);
5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// with float too
5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(compareFuncs); ++ndx)
5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexParameterf(m_textureTarget, GL_TEXTURE_COMPARE_FUNC, (GLfloat)compareFuncs[ndx]);
5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_verifier->verifyInteger(m_testCtx, m_textureTarget, GL_TEXTURE_COMPARE_FUNC, compareFuncs[ndx]);
5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureImmutableLevelsCase : public TextureCase
5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureImmutableLevelsCase (Context& context, TexParamVerifier* verifier, const char* name, const char* description, GLenum textureTarget)
5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCase(context, verifier, name, description, textureTarget)
5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void testTexture (void)
5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_verifier->verifyInteger(m_testCtx, m_textureTarget, GL_TEXTURE_IMMUTABLE_LEVELS, 0);
5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int level = 1; level <= 8; ++level)
6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GLuint textureID = 0;
6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glGenTextures(1, &textureID);
6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glBindTexture(m_textureTarget, textureID);
6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (m_textureTarget == GL_TEXTURE_2D_ARRAY || m_textureTarget == GL_TEXTURE_3D)
6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glTexStorage3D(m_textureTarget, level, GL_RGB8, 256, 256, 256);
6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			else
6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				glTexStorage2D(m_textureTarget, level, GL_RGB8, 256, 256);
6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_verifier->verifyInteger(m_testCtx, m_textureTarget, GL_TEXTURE_IMMUTABLE_LEVELS, level);
6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteTextures(1, &textureID);
6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expectError(GL_NO_ERROR);
6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureImmutableFormatCase : public TextureCase
6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureImmutableFormatCase (Context& context, TexParamVerifier* verifier, const char* name, const char* description, GLenum textureTarget)
6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TextureCase(context, verifier, name, description, textureTarget)
6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void testTexture (void)
6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_verifier->verifyInteger(m_testCtx, m_textureTarget, GL_TEXTURE_IMMUTABLE_FORMAT, 0);
6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const GLenum formats[] =
6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GL_RGBA32I, GL_RGBA32UI, GL_RGBA16I, GL_RGBA16UI, GL_RGBA8, GL_RGBA8I,
6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GL_RGBA8UI, GL_SRGB8_ALPHA8, GL_RGB10_A2, GL_RGB10_A2UI, GL_RGBA4,
6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GL_RGB5_A1, GL_RGB8, GL_RGB565, GL_RG32I, GL_RG32UI, GL_RG16I, GL_RG16UI,
6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GL_RG8, GL_RG8I, GL_RG8UI, GL_R32I, GL_R32UI, GL_R16I, GL_R16UI, GL_R8,
6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GL_R8I, GL_R8UI,
6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GL_RGBA32F, GL_RGBA16F, GL_RGBA8_SNORM, GL_RGB32F,
6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GL_RGB32I, GL_RGB32UI, GL_RGB16F, GL_RGB16I, GL_RGB16UI, GL_RGB8_SNORM,
6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GL_RGB8I, GL_RGB8UI, GL_SRGB8, GL_R11F_G11F_B10F, GL_RGB9_E5, GL_RG32F,
6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GL_RG16F, GL_RG8_SNORM, GL_R32F, GL_R16F, GL_R8_SNORM,
6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const GLenum non3dFormats[] =
6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT16,
6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			GL_DEPTH32F_STENCIL8, GL_DEPTH24_STENCIL8
6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(formats); ++formatNdx)
6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			testSingleFormat(formats[formatNdx]);
6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (m_textureTarget != GL_TEXTURE_3D)
6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(non3dFormats); ++formatNdx)
6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				testSingleFormat(non3dFormats[formatNdx]);
6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void testSingleFormat (GLenum format)
6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLuint textureID = 0;
6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glGenTextures(1, &textureID);
6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glBindTexture(m_textureTarget, textureID);
6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (m_textureTarget == GL_TEXTURE_2D_ARRAY || m_textureTarget == GL_TEXTURE_3D)
6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexStorage3D(m_textureTarget, 1, format, 32, 32, 32);
6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		else
6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glTexStorage2D(m_textureTarget, 1, format, 32, 32);
6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_verifier->verifyInteger(m_testCtx, m_textureTarget, GL_TEXTURE_IMMUTABLE_FORMAT, 1);
6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteTextures(1, &textureID);
6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expectError(GL_NO_ERROR);
6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // anonymous
6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define FOR_EACH_VERIFIER(VERIFIERS, CODE_BLOCK)												\
6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int _verifierNdx = 0; _verifierNdx < DE_LENGTH_OF_ARRAY(VERIFIERS); _verifierNdx++)	\
6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{																							\
6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TexParamVerifier* verifier = VERIFIERS[_verifierNdx];									\
6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		CODE_BLOCK;																				\
6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6903c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureStateQueryTests::TextureStateQueryTests (Context& context)
6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCaseGroup		(context, "texture", "Texture State Query tests")
6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_verifierInt		(DE_NULL)
6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_verifierFloat	(DE_NULL)
6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6973c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureStateQueryTests::~TextureStateQueryTests (void)
6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deinit();
7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureStateQueryTests::init (void)
7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using namespace TextureParamVerifiers;
7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(m_verifierInt == DE_NULL);
7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(m_verifierFloat == DE_NULL);
7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_verifierInt		= new GetTexParameterIVerifier(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_verifierFloat		= new GetTexParameterFVerifier(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TexParamVerifier* verifiers[] = {m_verifierInt, m_verifierFloat};
7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const struct
7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const char*	name;
7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLenum		textureTarget;
7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	} textureTargets[] =
7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "texture_2d",			GL_TEXTURE_2D},
7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "texture_3d",			GL_TEXTURE_3D},
7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "texture_2d_array",	GL_TEXTURE_2D_ARRAY},
7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{ "texture_cube_map",	GL_TEXTURE_CUBE_MAP}
7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(textureTargets); ++ndx)
7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(new IsTextureCase(m_context, (std::string(textureTargets[ndx].name) + "_is_texture").c_str(), "IsTexture",	textureTargets[ndx].textureTarget));
7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FOR_EACH_VERIFIER(verifiers, addChild(new TextureSwizzleCase	(m_context, verifier, (std::string(textureTargets[ndx].name)	+ "_texture_swizzle_r"		+ verifier->getTestNamePostfix()).c_str(), "TEXTURE_SWIZZLE_R",		textureTargets[ndx].textureTarget, GL_TEXTURE_SWIZZLE_R, GL_RED)));
7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FOR_EACH_VERIFIER(verifiers, addChild(new TextureSwizzleCase	(m_context, verifier, (std::string(textureTargets[ndx].name)	+ "_texture_swizzle_g"		+ verifier->getTestNamePostfix()).c_str(), "TEXTURE_SWIZZLE_G",		textureTargets[ndx].textureTarget, GL_TEXTURE_SWIZZLE_G, GL_GREEN)));
7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FOR_EACH_VERIFIER(verifiers, addChild(new TextureSwizzleCase	(m_context, verifier, (std::string(textureTargets[ndx].name)	+ "_texture_swizzle_b"		+ verifier->getTestNamePostfix()).c_str(), "TEXTURE_SWIZZLE_B",		textureTargets[ndx].textureTarget, GL_TEXTURE_SWIZZLE_B, GL_BLUE)));
7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FOR_EACH_VERIFIER(verifiers, addChild(new TextureSwizzleCase	(m_context, verifier, (std::string(textureTargets[ndx].name)	+ "_texture_swizzle_a"		+ verifier->getTestNamePostfix()).c_str(), "TEXTURE_SWIZZLE_A",		textureTargets[ndx].textureTarget, GL_TEXTURE_SWIZZLE_A, GL_ALPHA)));
7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FOR_EACH_VERIFIER(verifiers, addChild(new TextureWrapCase		(m_context, verifier,	(std::string(textureTargets[ndx].name)	+ "_texture_wrap_s"			+ verifier->getTestNamePostfix()).c_str(), "TEXTURE_WRAP_S",		textureTargets[ndx].textureTarget, GL_TEXTURE_WRAP_S)));
7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (textureTargets[ndx].textureTarget == GL_TEXTURE_2D ||
7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			textureTargets[ndx].textureTarget == GL_TEXTURE_3D ||
7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			textureTargets[ndx].textureTarget == GL_TEXTURE_CUBE_MAP)
7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			FOR_EACH_VERIFIER(verifiers, addChild(new TextureWrapCase	(m_context, verifier,	(std::string(textureTargets[ndx].name)	+ "_texture_wrap_t"			+ verifier->getTestNamePostfix()).c_str(), "TEXTURE_WRAP_T",		textureTargets[ndx].textureTarget, GL_TEXTURE_WRAP_T)));
7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (textureTargets[ndx].textureTarget == GL_TEXTURE_3D)
7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			FOR_EACH_VERIFIER(verifiers, addChild(new TextureWrapCase	(m_context, verifier,	(std::string(textureTargets[ndx].name)	+ "_texture_wrap_r"			+ verifier->getTestNamePostfix()).c_str(), "TEXTURE_WRAP_R",		textureTargets[ndx].textureTarget, GL_TEXTURE_WRAP_R)));
7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FOR_EACH_VERIFIER(verifiers, addChild(new TextureMagFilterCase	(m_context, verifier,	(std::string(textureTargets[ndx].name)	+ "_texture_mag_filter"		+ verifier->getTestNamePostfix()).c_str(), "TEXTURE_MAG_FILTER",	textureTargets[ndx].textureTarget)));
7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FOR_EACH_VERIFIER(verifiers, addChild(new TextureMinFilterCase	(m_context, verifier,	(std::string(textureTargets[ndx].name)	+ "_texture_min_filter"		+ verifier->getTestNamePostfix()).c_str(), "TEXTURE_MIN_FILTER",	textureTargets[ndx].textureTarget)));
7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FOR_EACH_VERIFIER(verifiers, addChild(new TextureLODCase		(m_context, verifier,	(std::string(textureTargets[ndx].name)	+ "_texture_min_lod"		+ verifier->getTestNamePostfix()).c_str(), "TEXTURE_MIN_LOD",		textureTargets[ndx].textureTarget, GL_TEXTURE_MIN_LOD, -1000)));
7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FOR_EACH_VERIFIER(verifiers, addChild(new TextureLODCase		(m_context, verifier,	(std::string(textureTargets[ndx].name)	+ "_texture_max_lod"		+ verifier->getTestNamePostfix()).c_str(), "TEXTURE_MAX_LOD",		textureTargets[ndx].textureTarget, GL_TEXTURE_MAX_LOD,  1000)));
7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FOR_EACH_VERIFIER(verifiers, addChild(new TextureLevelCase		(m_context, verifier,	(std::string(textureTargets[ndx].name)	+ "_texture_base_level"		+ verifier->getTestNamePostfix()).c_str(), "TEXTURE_BASE_LEVEL",	textureTargets[ndx].textureTarget, GL_TEXTURE_BASE_LEVEL, 0)));
7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FOR_EACH_VERIFIER(verifiers, addChild(new TextureLevelCase		(m_context, verifier,	(std::string(textureTargets[ndx].name)	+ "_texture_max_level"		+ verifier->getTestNamePostfix()).c_str(), "TEXTURE_MAX_LEVEL",		textureTargets[ndx].textureTarget, GL_TEXTURE_MAX_LEVEL, 1000)));
7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FOR_EACH_VERIFIER(verifiers, addChild(new TextureCompareModeCase(m_context, verifier,	(std::string(textureTargets[ndx].name)	+ "_texture_compare_mode"	+ verifier->getTestNamePostfix()).c_str(), "TEXTURE_COMPARE_MODE",	textureTargets[ndx].textureTarget)));
7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FOR_EACH_VERIFIER(verifiers, addChild(new TextureCompareFuncCase(m_context, verifier,	(std::string(textureTargets[ndx].name)	+ "_texture_compare_func"	+ verifier->getTestNamePostfix()).c_str(), "TEXTURE_COMPARE_FUNC",	textureTargets[ndx].textureTarget)));
7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FOR_EACH_VERIFIER(verifiers, addChild(new TextureImmutableLevelsCase(m_context, verifier,	(std::string(textureTargets[ndx].name) + "_texture_immutable_levels" + verifier->getTestNamePostfix()).c_str(), "TEXTURE_IMMUTABLE_LEVELS",	textureTargets[ndx].textureTarget)));
7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FOR_EACH_VERIFIER(verifiers, addChild(new TextureImmutableFormatCase(m_context, verifier,	(std::string(textureTargets[ndx].name) + "_texture_immutable_format" + verifier->getTestNamePostfix()).c_str(), "TEXTURE_IMMUTABLE_FORMAT",	textureTargets[ndx].textureTarget)));
7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7593c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureStateQueryTests::deinit (void)
7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_verifierInt)
7623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		delete m_verifierInt;
7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_verifierInt = NULL;
7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_verifierFloat)
7673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
7683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		delete m_verifierFloat;
7693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_verifierFloat = NULL;
7703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
7713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	this->TestCaseGroup::deinit();
7733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional
7763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles3
7773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
778