1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program OpenGL ES 2.0 Module
3*35238bceSAndroid Build Coastguard Worker * -------------------------------------------------
4*35238bceSAndroid Build Coastguard Worker *
5*35238bceSAndroid Build Coastguard Worker * Copyright 2014 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker *
7*35238bceSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker *
11*35238bceSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker *
13*35238bceSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker *
19*35238bceSAndroid Build Coastguard Worker *//*!
20*35238bceSAndroid Build Coastguard Worker * \file
21*35238bceSAndroid Build Coastguard Worker * \brief Implementation-defined limit tests.
22*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker
24*35238bceSAndroid Build Coastguard Worker #include "es2fImplementationLimitTests.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "gluDefs.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "gluStrUtil.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "gluRenderContext.hpp"
29*35238bceSAndroid Build Coastguard Worker
30*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
32*35238bceSAndroid Build Coastguard Worker
33*35238bceSAndroid Build Coastguard Worker namespace deqp
34*35238bceSAndroid Build Coastguard Worker {
35*35238bceSAndroid Build Coastguard Worker namespace gles2
36*35238bceSAndroid Build Coastguard Worker {
37*35238bceSAndroid Build Coastguard Worker namespace Functional
38*35238bceSAndroid Build Coastguard Worker {
39*35238bceSAndroid Build Coastguard Worker
40*35238bceSAndroid Build Coastguard Worker using namespace glw; // GL types
41*35238bceSAndroid Build Coastguard Worker
42*35238bceSAndroid Build Coastguard Worker namespace LimitQuery
43*35238bceSAndroid Build Coastguard Worker {
44*35238bceSAndroid Build Coastguard Worker
45*35238bceSAndroid Build Coastguard Worker // Query function template.
46*35238bceSAndroid Build Coastguard Worker template <typename T>
47*35238bceSAndroid Build Coastguard Worker T query(const glw::Functions &gl, uint32_t param);
48*35238bceSAndroid Build Coastguard Worker
49*35238bceSAndroid Build Coastguard Worker // Compare template.
50*35238bceSAndroid Build Coastguard Worker template <typename T>
compare(const T & min,const T & reported)51*35238bceSAndroid Build Coastguard Worker inline bool compare(const T &min, const T &reported)
52*35238bceSAndroid Build Coastguard Worker {
53*35238bceSAndroid Build Coastguard Worker return min <= reported;
54*35238bceSAndroid Build Coastguard Worker }
55*35238bceSAndroid Build Coastguard Worker
56*35238bceSAndroid Build Coastguard Worker // Types for queries
57*35238bceSAndroid Build Coastguard Worker
58*35238bceSAndroid Build Coastguard Worker struct NegInt
59*35238bceSAndroid Build Coastguard Worker {
60*35238bceSAndroid Build Coastguard Worker GLint value;
NegIntdeqp::gles2::Functional::LimitQuery::NegInt61*35238bceSAndroid Build Coastguard Worker NegInt(GLint value_) : value(value_)
62*35238bceSAndroid Build Coastguard Worker {
63*35238bceSAndroid Build Coastguard Worker }
64*35238bceSAndroid Build Coastguard Worker };
65*35238bceSAndroid Build Coastguard Worker
operator <<(std::ostream & str,const NegInt & v)66*35238bceSAndroid Build Coastguard Worker std::ostream &operator<<(std::ostream &str, const NegInt &v)
67*35238bceSAndroid Build Coastguard Worker {
68*35238bceSAndroid Build Coastguard Worker return str << v.value;
69*35238bceSAndroid Build Coastguard Worker }
70*35238bceSAndroid Build Coastguard Worker
71*35238bceSAndroid Build Coastguard Worker struct FloatRange
72*35238bceSAndroid Build Coastguard Worker {
73*35238bceSAndroid Build Coastguard Worker float min;
74*35238bceSAndroid Build Coastguard Worker float max;
FloatRangedeqp::gles2::Functional::LimitQuery::FloatRange75*35238bceSAndroid Build Coastguard Worker FloatRange(float min_, float max_) : min(min_), max(max_)
76*35238bceSAndroid Build Coastguard Worker {
77*35238bceSAndroid Build Coastguard Worker }
78*35238bceSAndroid Build Coastguard Worker };
79*35238bceSAndroid Build Coastguard Worker
operator <<(std::ostream & str,const FloatRange & range)80*35238bceSAndroid Build Coastguard Worker std::ostream &operator<<(std::ostream &str, const FloatRange &range)
81*35238bceSAndroid Build Coastguard Worker {
82*35238bceSAndroid Build Coastguard Worker return str << range.min << ", " << range.max;
83*35238bceSAndroid Build Coastguard Worker }
84*35238bceSAndroid Build Coastguard Worker
85*35238bceSAndroid Build Coastguard Worker // For custom formatting
86*35238bceSAndroid Build Coastguard Worker struct Boolean
87*35238bceSAndroid Build Coastguard Worker {
88*35238bceSAndroid Build Coastguard Worker GLboolean value;
Booleandeqp::gles2::Functional::LimitQuery::Boolean89*35238bceSAndroid Build Coastguard Worker Boolean(GLboolean value_) : value(value_)
90*35238bceSAndroid Build Coastguard Worker {
91*35238bceSAndroid Build Coastguard Worker }
92*35238bceSAndroid Build Coastguard Worker };
93*35238bceSAndroid Build Coastguard Worker
operator <<(std::ostream & str,const Boolean & boolean)94*35238bceSAndroid Build Coastguard Worker std::ostream &operator<<(std::ostream &str, const Boolean &boolean)
95*35238bceSAndroid Build Coastguard Worker {
96*35238bceSAndroid Build Coastguard Worker return str << (boolean.value ? "GL_TRUE" : "GL_FALSE");
97*35238bceSAndroid Build Coastguard Worker }
98*35238bceSAndroid Build Coastguard Worker
99*35238bceSAndroid Build Coastguard Worker // Query function implementations.
100*35238bceSAndroid Build Coastguard Worker template <>
query(const glw::Functions & gl,uint32_t param)101*35238bceSAndroid Build Coastguard Worker GLint query<GLint>(const glw::Functions &gl, uint32_t param)
102*35238bceSAndroid Build Coastguard Worker {
103*35238bceSAndroid Build Coastguard Worker GLint val = -1;
104*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(param, &val);
105*35238bceSAndroid Build Coastguard Worker return val;
106*35238bceSAndroid Build Coastguard Worker }
107*35238bceSAndroid Build Coastguard Worker
108*35238bceSAndroid Build Coastguard Worker template <>
query(const glw::Functions & gl,uint32_t param)109*35238bceSAndroid Build Coastguard Worker GLfloat query<GLfloat>(const glw::Functions &gl, uint32_t param)
110*35238bceSAndroid Build Coastguard Worker {
111*35238bceSAndroid Build Coastguard Worker GLfloat val = -1000.f;
112*35238bceSAndroid Build Coastguard Worker gl.getFloatv(param, &val);
113*35238bceSAndroid Build Coastguard Worker return val;
114*35238bceSAndroid Build Coastguard Worker }
115*35238bceSAndroid Build Coastguard Worker
116*35238bceSAndroid Build Coastguard Worker template <>
query(const glw::Functions & gl,uint32_t param)117*35238bceSAndroid Build Coastguard Worker NegInt query<NegInt>(const glw::Functions &gl, uint32_t param)
118*35238bceSAndroid Build Coastguard Worker {
119*35238bceSAndroid Build Coastguard Worker return NegInt(query<GLint>(gl, param));
120*35238bceSAndroid Build Coastguard Worker }
121*35238bceSAndroid Build Coastguard Worker
122*35238bceSAndroid Build Coastguard Worker template <>
query(const glw::Functions & gl,uint32_t param)123*35238bceSAndroid Build Coastguard Worker Boolean query<Boolean>(const glw::Functions &gl, uint32_t param)
124*35238bceSAndroid Build Coastguard Worker {
125*35238bceSAndroid Build Coastguard Worker GLboolean val = GL_FALSE;
126*35238bceSAndroid Build Coastguard Worker gl.getBooleanv(param, &val);
127*35238bceSAndroid Build Coastguard Worker return Boolean(val);
128*35238bceSAndroid Build Coastguard Worker }
129*35238bceSAndroid Build Coastguard Worker
130*35238bceSAndroid Build Coastguard Worker template <>
query(const glw::Functions & gl,uint32_t param)131*35238bceSAndroid Build Coastguard Worker FloatRange query<FloatRange>(const glw::Functions &gl, uint32_t param)
132*35238bceSAndroid Build Coastguard Worker {
133*35238bceSAndroid Build Coastguard Worker float v[2] = {-1.0f, -1.0f};
134*35238bceSAndroid Build Coastguard Worker gl.getFloatv(param, &v[0]);
135*35238bceSAndroid Build Coastguard Worker return FloatRange(v[0], v[1]);
136*35238bceSAndroid Build Coastguard Worker }
137*35238bceSAndroid Build Coastguard Worker
138*35238bceSAndroid Build Coastguard Worker // Special comparison operators
139*35238bceSAndroid Build Coastguard Worker template <>
compare(const Boolean & min,const Boolean & reported)140*35238bceSAndroid Build Coastguard Worker bool compare<Boolean>(const Boolean &min, const Boolean &reported)
141*35238bceSAndroid Build Coastguard Worker {
142*35238bceSAndroid Build Coastguard Worker return !min.value || (min.value && reported.value);
143*35238bceSAndroid Build Coastguard Worker }
144*35238bceSAndroid Build Coastguard Worker
145*35238bceSAndroid Build Coastguard Worker template <>
compare(const NegInt & min,const NegInt & reported)146*35238bceSAndroid Build Coastguard Worker bool compare<NegInt>(const NegInt &min, const NegInt &reported)
147*35238bceSAndroid Build Coastguard Worker {
148*35238bceSAndroid Build Coastguard Worker // Reverse comparison.
149*35238bceSAndroid Build Coastguard Worker return reported.value <= min.value;
150*35238bceSAndroid Build Coastguard Worker }
151*35238bceSAndroid Build Coastguard Worker
152*35238bceSAndroid Build Coastguard Worker template <>
compare(const FloatRange & min,const FloatRange & reported)153*35238bceSAndroid Build Coastguard Worker bool compare<FloatRange>(const FloatRange &min, const FloatRange &reported)
154*35238bceSAndroid Build Coastguard Worker {
155*35238bceSAndroid Build Coastguard Worker return reported.min <= min.min && min.max <= reported.max;
156*35238bceSAndroid Build Coastguard Worker }
157*35238bceSAndroid Build Coastguard Worker
158*35238bceSAndroid Build Coastguard Worker } // namespace LimitQuery
159*35238bceSAndroid Build Coastguard Worker
160*35238bceSAndroid Build Coastguard Worker using namespace LimitQuery;
161*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
162*35238bceSAndroid Build Coastguard Worker
163*35238bceSAndroid Build Coastguard Worker template <typename T>
164*35238bceSAndroid Build Coastguard Worker class LimitQueryCase : public TestCase
165*35238bceSAndroid Build Coastguard Worker {
166*35238bceSAndroid Build Coastguard Worker public:
LimitQueryCase(Context & context,const char * name,const char * description,uint32_t limit,const T & minRequiredValue)167*35238bceSAndroid Build Coastguard Worker LimitQueryCase(Context &context, const char *name, const char *description, uint32_t limit,
168*35238bceSAndroid Build Coastguard Worker const T &minRequiredValue)
169*35238bceSAndroid Build Coastguard Worker : TestCase(context, name, description)
170*35238bceSAndroid Build Coastguard Worker , m_limit(limit)
171*35238bceSAndroid Build Coastguard Worker , m_minRequiredValue(minRequiredValue)
172*35238bceSAndroid Build Coastguard Worker {
173*35238bceSAndroid Build Coastguard Worker }
174*35238bceSAndroid Build Coastguard Worker
iterate(void)175*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void)
176*35238bceSAndroid Build Coastguard Worker {
177*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
178*35238bceSAndroid Build Coastguard Worker const T value = query<T>(m_context.getRenderContext().getFunctions(), m_limit);
179*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "Query failed");
180*35238bceSAndroid Build Coastguard Worker
181*35238bceSAndroid Build Coastguard Worker const bool isOk = compare<T>(m_minRequiredValue, value);
182*35238bceSAndroid Build Coastguard Worker
183*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "Reported: " << value << TestLog::EndMessage;
184*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "Minimum required: " << m_minRequiredValue << TestLog::EndMessage;
185*35238bceSAndroid Build Coastguard Worker
186*35238bceSAndroid Build Coastguard Worker if (!isOk)
187*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "FAIL: reported value is less than minimum required value!"
188*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
189*35238bceSAndroid Build Coastguard Worker
190*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(isOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
191*35238bceSAndroid Build Coastguard Worker isOk ? "Pass" : "Requirement not satisfied");
192*35238bceSAndroid Build Coastguard Worker return STOP;
193*35238bceSAndroid Build Coastguard Worker }
194*35238bceSAndroid Build Coastguard Worker
195*35238bceSAndroid Build Coastguard Worker private:
196*35238bceSAndroid Build Coastguard Worker uint32_t m_limit;
197*35238bceSAndroid Build Coastguard Worker T m_minRequiredValue;
198*35238bceSAndroid Build Coastguard Worker };
199*35238bceSAndroid Build Coastguard Worker
ImplementationLimitTests(Context & context)200*35238bceSAndroid Build Coastguard Worker ImplementationLimitTests::ImplementationLimitTests(Context &context)
201*35238bceSAndroid Build Coastguard Worker : TestCaseGroup(context, "implementation_limits", "Implementation-defined limits")
202*35238bceSAndroid Build Coastguard Worker {
203*35238bceSAndroid Build Coastguard Worker }
204*35238bceSAndroid Build Coastguard Worker
~ImplementationLimitTests(void)205*35238bceSAndroid Build Coastguard Worker ImplementationLimitTests::~ImplementationLimitTests(void)
206*35238bceSAndroid Build Coastguard Worker {
207*35238bceSAndroid Build Coastguard Worker }
208*35238bceSAndroid Build Coastguard Worker
init(void)209*35238bceSAndroid Build Coastguard Worker void ImplementationLimitTests::init(void)
210*35238bceSAndroid Build Coastguard Worker {
211*35238bceSAndroid Build Coastguard Worker #define LIMIT_CASE(NAME, PARAM, TYPE, MIN_VAL) \
212*35238bceSAndroid Build Coastguard Worker addChild(new LimitQueryCase<TYPE>(m_context, #NAME, #PARAM, PARAM, MIN_VAL))
213*35238bceSAndroid Build Coastguard Worker
214*35238bceSAndroid Build Coastguard Worker LIMIT_CASE(subpixel_bits, GL_SUBPIXEL_BITS, GLint, 4);
215*35238bceSAndroid Build Coastguard Worker LIMIT_CASE(max_texture_size, GL_MAX_TEXTURE_SIZE, GLint, 64);
216*35238bceSAndroid Build Coastguard Worker LIMIT_CASE(max_cube_map_texture_size, GL_MAX_CUBE_MAP_TEXTURE_SIZE, GLint, 16);
217*35238bceSAndroid Build Coastguard Worker // GL_MAX_VIEWPORT_DIMS
218*35238bceSAndroid Build Coastguard Worker LIMIT_CASE(aliased_point_size_range, GL_ALIASED_POINT_SIZE_RANGE, FloatRange, FloatRange(1, 1));
219*35238bceSAndroid Build Coastguard Worker LIMIT_CASE(aliased_line_width_range, GL_ALIASED_LINE_WIDTH_RANGE, FloatRange, FloatRange(1, 1));
220*35238bceSAndroid Build Coastguard Worker // LIMIT_CASE(sample_buffers, GL_SAMPLE_BUFFERS, GLint, 0);
221*35238bceSAndroid Build Coastguard Worker // LIMIT_CASE(samples, GL_SAMPLES, GLint, 0);
222*35238bceSAndroid Build Coastguard Worker LIMIT_CASE(num_compressed_texture_formats, GL_NUM_COMPRESSED_TEXTURE_FORMATS, GLint, 0);
223*35238bceSAndroid Build Coastguard Worker LIMIT_CASE(num_shader_binary_formats, GL_NUM_SHADER_BINARY_FORMATS, GLint, 0);
224*35238bceSAndroid Build Coastguard Worker LIMIT_CASE(shader_compiler, GL_SHADER_COMPILER, Boolean, GL_FALSE);
225*35238bceSAndroid Build Coastguard Worker // Shader precision format
226*35238bceSAndroid Build Coastguard Worker LIMIT_CASE(max_vertex_attribs, GL_MAX_VERTEX_ATTRIBS, GLint, 8);
227*35238bceSAndroid Build Coastguard Worker LIMIT_CASE(max_vertex_uniform_vectors, GL_MAX_VERTEX_UNIFORM_VECTORS, GLint, 128);
228*35238bceSAndroid Build Coastguard Worker LIMIT_CASE(max_varying_vectors, GL_MAX_VARYING_VECTORS, GLint, 8);
229*35238bceSAndroid Build Coastguard Worker LIMIT_CASE(max_combined_texture_image_units, GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, GLint, 8);
230*35238bceSAndroid Build Coastguard Worker LIMIT_CASE(max_vertex_texture_image_units, GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, GLint, 0);
231*35238bceSAndroid Build Coastguard Worker LIMIT_CASE(max_texture_image_units, GL_MAX_TEXTURE_IMAGE_UNITS, GLint, 8);
232*35238bceSAndroid Build Coastguard Worker LIMIT_CASE(max_fragment_uniform_vectors, GL_MAX_FRAGMENT_UNIFORM_VECTORS, GLint, 16);
233*35238bceSAndroid Build Coastguard Worker LIMIT_CASE(max_renderbuffer_size, GL_MAX_RENDERBUFFER_SIZE, GLint, 1);
234*35238bceSAndroid Build Coastguard Worker }
235*35238bceSAndroid Build Coastguard Worker
236*35238bceSAndroid Build Coastguard Worker } // namespace Functional
237*35238bceSAndroid Build Coastguard Worker } // namespace gles2
238*35238bceSAndroid Build Coastguard Worker } // namespace deqp
239