13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 2.0 Module
33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * -------------------------------------------------
43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project
63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License");
83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License.
93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at
103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *      http://www.apache.org/licenses/LICENSE-2.0
123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software
143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS,
153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and
173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License.
183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*!
203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file
213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Implementation-defined limit tests.
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es2fImplementationLimitTests.hpp"
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp"
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluDefs.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluStrUtil.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluRenderContext.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp"
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp"
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles2
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace glw; // GL types
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace LimitQuery
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Query function template.
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<typename T>
473c827367444ee418f129b2c238299f49d3264554Jarkko PoyryT query (const glw::Functions& gl, deUint32 param);
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Compare template.
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<typename T>
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline bool compare (const T& min, const T& reported) { return min <= reported; }
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Types for queries
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct NegInt
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint value;
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	NegInt (GLint value_) : value(value_) {}
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::ostream& operator<< (std::ostream& str, const NegInt& v) { return str << v.value; }
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct FloatRange
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float min;
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float max;
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FloatRange (float min_, float max_) : min(min_), max(max_) {}
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::ostream& operator<< (std::ostream& str, const FloatRange& range) { return str << range.min << ", " << range.max; }
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// For custom formatting
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Boolean
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLboolean value;
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Boolean (GLboolean value_) : value(value_) {}
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::ostream& operator<< (std::ostream& str, const Boolean& boolean) { return str << (boolean.value ? "GL_TRUE" : "GL_FALSE"); }
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Query function implementations.
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<>
833c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLint query<GLint> (const glw::Functions& gl, deUint32 param)
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint val = -1;
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.getIntegerv(param, &val);
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return val;
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<>
913c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLfloat query<GLfloat> (const glw::Functions& gl, deUint32 param)
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLfloat val = -1000.f;
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.getFloatv(param, &val);
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return val;
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<>
993c827367444ee418f129b2c238299f49d3264554Jarkko PoyryNegInt query<NegInt> (const glw::Functions& gl, deUint32 param)
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return NegInt(query<GLint>(gl, param));
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<>
1053c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBoolean query<Boolean> (const glw::Functions& gl, deUint32 param)
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLboolean val = GL_FALSE;
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.getBooleanv(param, &val);
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return Boolean(val);
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<>
1133c827367444ee418f129b2c238299f49d3264554Jarkko PoyryFloatRange query<FloatRange> (const glw::Functions& gl, deUint32 param)
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float v[2] = { -1.0f, -1.0f };
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.getFloatv(param, &v[0]);
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return FloatRange(v[0], v[1]);
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Special comparison operators
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<>
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool compare<Boolean> (const Boolean& min, const Boolean& reported)
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return !min.value || (min.value && reported.value);
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<>
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool compare<NegInt> (const NegInt& min, const NegInt& reported)
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Reverse comparison.
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return reported.value <= min.value;
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<>
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool compare<FloatRange> (const FloatRange& min, const FloatRange& reported)
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return reported.min <= min.min && min.max <= reported.max;
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // LimitQuery
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace LimitQuery;
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog;
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<typename T>
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass LimitQueryCase : public TestCase
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LimitQueryCase (Context& context, const char* name, const char* description, deUint32 limit, const T& minRequiredValue)
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: TestCase				(context, name, description)
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_limit				(limit)
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_minRequiredValue	(minRequiredValue)
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult iterate (void)
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const glw::Functions&	gl		= m_context.getRenderContext().getFunctions();
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const T					value	= query<T>(m_context.getRenderContext().getFunctions(), m_limit);
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.getError(), "Query failed");
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const bool isOk = compare<T>(m_minRequiredValue, value);
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx.getLog() << TestLog::Message << "Reported: " << value << TestLog::EndMessage;
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx.getLog() << TestLog::Message << "Minimum required: " << m_minRequiredValue << TestLog::EndMessage;
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!isOk)
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.getLog() << TestLog::Message << "FAIL: reported value is less than minimum required value!" << TestLog::EndMessage;
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx.setTestResult(isOk ? QP_TEST_RESULT_PASS	: QP_TEST_RESULT_FAIL,
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								isOk ? "Pass"				: "Requirement not satisfied");
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return STOP;
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32	m_limit;
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	T			m_minRequiredValue;
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1803c827367444ee418f129b2c238299f49d3264554Jarkko PoyryImplementationLimitTests::ImplementationLimitTests (Context& context)
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCaseGroup(context, "implementation_limits", "Implementation-defined limits")
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1853c827367444ee418f129b2c238299f49d3264554Jarkko PoyryImplementationLimitTests::~ImplementationLimitTests (void)
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ImplementationLimitTests::init (void)
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define LIMIT_CASE(NAME, PARAM, TYPE, MIN_VAL)	\
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(new LimitQueryCase<TYPE>(m_context, #NAME, #PARAM, PARAM, MIN_VAL))
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LIMIT_CASE(subpixel_bits,						GL_SUBPIXEL_BITS,						GLint,		4);
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LIMIT_CASE(max_texture_size,					GL_MAX_TEXTURE_SIZE,					GLint,		64);
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LIMIT_CASE(max_cube_map_texture_size,			GL_MAX_CUBE_MAP_TEXTURE_SIZE,			GLint,		16);
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// GL_MAX_VIEWPORT_DIMS
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LIMIT_CASE(aliased_point_size_range,			GL_ALIASED_POINT_SIZE_RANGE,			FloatRange,	FloatRange(1,1));
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LIMIT_CASE(aliased_line_width_range,			GL_ALIASED_LINE_WIDTH_RANGE,			FloatRange,	FloatRange(1,1));
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//	LIMIT_CASE(sample_buffers,						GL_SAMPLE_BUFFERS,						GLint,		0);
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//	LIMIT_CASE(samples,								GL_SAMPLES,								GLint,		0);
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LIMIT_CASE(num_compressed_texture_formats,		GL_NUM_COMPRESSED_TEXTURE_FORMATS,		GLint,		0);
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LIMIT_CASE(num_shader_binary_formats,			GL_NUM_SHADER_BINARY_FORMATS,			GLint,		0);
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LIMIT_CASE(shader_compiler,						GL_SHADER_COMPILER,						Boolean,	GL_FALSE);
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Shader precision format
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LIMIT_CASE(max_vertex_attribs,					GL_MAX_VERTEX_ATTRIBS,					GLint,		8);
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LIMIT_CASE(max_vertex_uniform_vectors,			GL_MAX_VERTEX_UNIFORM_VECTORS,			GLint,		128);
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LIMIT_CASE(max_varying_vectors,					GL_MAX_VARYING_VECTORS,					GLint,		8);
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LIMIT_CASE(max_combined_texture_image_units,	GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,	GLint,		8);
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LIMIT_CASE(max_vertex_texture_image_units,		GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS,		GLint,		0);
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LIMIT_CASE(max_texture_image_units,				GL_MAX_TEXTURE_IMAGE_UNITS,				GLint,		8);
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LIMIT_CASE(max_fragment_uniform_vectors,		GL_MAX_FRAGMENT_UNIFORM_VECTORS,		GLint,		16);
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LIMIT_CASE(max_renderbuffer_size,				GL_MAX_RENDERBUFFER_SIZE,				GLint,		1);
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles2
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
219