1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.0 Module
3 * -------------------------------------------------
4 *
5 * Copyright 2014 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 *//*!
20 * \file
21 * \brief State Query tests.
22 *//*--------------------------------------------------------------------*/
23
24 #include "es3fIntegerStateQueryTests.hpp"
25 #include "es3fApiCase.hpp"
26
27 #include "glsStateQueryUtil.hpp"
28
29 #include "gluRenderContext.hpp"
30 #include "gluContextInfo.hpp"
31 #include "gluStrUtil.hpp"
32
33 #include "tcuRenderTarget.hpp"
34
35 #include "deRandom.hpp"
36
37 #include "glwEnums.hpp"
38
39 using namespace glw; // GLint and other GL types
40 using deqp::gls::StateQueryUtil::StateQueryMemoryWriteGuard;
41
42 #ifndef GL_SLUMINANCE_NV
43 #define GL_SLUMINANCE_NV 0x8C46
44 #endif
45 #ifndef GL_SLUMINANCE_ALPHA_NV
46 #define GL_SLUMINANCE_ALPHA_NV 0x8C44
47 #endif
48 #ifndef GL_BGR_NV
49 #define GL_BGR_NV 0x80E0
50 #endif
51
52 namespace deqp
53 {
54 namespace gles3
55 {
56 namespace Functional
57 {
58 namespace IntegerStateQueryVerifiers
59 {
60
61 // StateVerifier
62
63 class StateVerifier : protected glu::CallLogWrapper
64 {
65 public:
66 StateVerifier (const glw::Functions& gl, tcu::TestLog& log, const char* testNamePostfix);
67 virtual ~StateVerifier (); // make GCC happy
68
69 const char* getTestNamePostfix (void) const;
70
71 virtual void verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference) = DE_NULL;
72 virtual void verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3) = DE_NULL;
73 virtual void verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3) = DE_NULL;
74 virtual void verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference) = DE_NULL;
75 virtual void verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference) = DE_NULL;
76 virtual void verifyIntegerLessOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference) = DE_NULL;
77 virtual void verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1) = DE_NULL;
78 virtual void verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength) = DE_NULL;
79 virtual void verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits) = DE_NULL;
80
81 private:
82 const char* const m_testNamePostfix;
83 };
84
StateVerifier(const glw::Functions & gl,tcu::TestLog & log,const char * testNamePostfix)85 StateVerifier::StateVerifier (const glw::Functions& gl, tcu::TestLog& log, const char* testNamePostfix)
86 : glu::CallLogWrapper (gl, log)
87 , m_testNamePostfix (testNamePostfix)
88 {
89 enableLogging(true);
90 }
91
~StateVerifier()92 StateVerifier::~StateVerifier ()
93 {
94 }
95
getTestNamePostfix(void) const96 const char* StateVerifier::getTestNamePostfix (void) const
97 {
98 return m_testNamePostfix;
99 }
100
101 // GetBooleanVerifier
102
103 class GetBooleanVerifier : public StateVerifier
104 {
105 public:
106 GetBooleanVerifier (const glw::Functions& gl, tcu::TestLog& log);
107 void verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference);
108 void verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3);
109 void verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3);
110 void verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference);
111 void verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference);
112 void verifyIntegerLessOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference);
113 void verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1);
114 void verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength);
115 void verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits);
116 };
117
GetBooleanVerifier(const glw::Functions & gl,tcu::TestLog & log)118 GetBooleanVerifier::GetBooleanVerifier (const glw::Functions& gl, tcu::TestLog& log)
119 : StateVerifier(gl, log, "_getboolean")
120 {
121 }
122
verifyInteger(tcu::TestContext & testCtx,GLenum name,GLint reference)123 void GetBooleanVerifier::verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference)
124 {
125 using tcu::TestLog;
126
127 StateQueryMemoryWriteGuard<GLboolean> state;
128 glGetBooleanv(name, &state);
129
130 if (!state.verifyValidity(testCtx))
131 return;
132
133 const GLboolean expectedGLState = reference ? GL_TRUE : GL_FALSE;
134
135 if (state != expectedGLState)
136 {
137 testCtx.getLog() << TestLog::Message << "// ERROR: expected " << (expectedGLState==GL_TRUE ? "GL_TRUE" : "GL_FALSE") << "; got " << (state == GL_TRUE ? "GL_TRUE" : (state == GL_FALSE ? "GL_FALSE" : "non-boolean")) << TestLog::EndMessage;
138 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
139 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
140 }
141 }
142
verifyInteger4(tcu::TestContext & testCtx,GLenum name,GLint reference0,GLint reference1,GLint reference2,GLint reference3)143 void GetBooleanVerifier::verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3)
144 {
145 verifyInteger4Mask(testCtx, name, reference0, true, reference1, true, reference2, true, reference3, true);
146 }
147
verifyInteger4Mask(tcu::TestContext & testCtx,GLenum name,GLint reference0,bool enableRef0,GLint reference1,bool enableRef1,GLint reference2,bool enableRef2,GLint reference3,bool enableRef3)148 void GetBooleanVerifier::verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3)
149 {
150 using tcu::TestLog;
151
152 StateQueryMemoryWriteGuard<GLboolean[4]> boolVector4;
153 glGetBooleanv(name, boolVector4);
154
155 if (!boolVector4.verifyValidity(testCtx))
156 return;
157
158 const GLboolean referenceAsGLBoolean[] =
159 {
160 reference0 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE,
161 reference1 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE,
162 reference2 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE,
163 reference3 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE,
164 };
165
166 if ((enableRef0 && (boolVector4[0] != referenceAsGLBoolean[0])) ||
167 (enableRef1 && (boolVector4[1] != referenceAsGLBoolean[1])) ||
168 (enableRef2 && (boolVector4[2] != referenceAsGLBoolean[2])) ||
169 (enableRef3 && (boolVector4[3] != referenceAsGLBoolean[3])))
170 {
171 testCtx.getLog() << TestLog::Message << "// ERROR: expected "
172 << (enableRef0 ? (referenceAsGLBoolean[0] ? "GL_TRUE" : "GL_FALSE") : " - ") << ", "
173 << (enableRef1 ? (referenceAsGLBoolean[1] ? "GL_TRUE" : "GL_FALSE") : " - ") << ", "
174 << (enableRef2 ? (referenceAsGLBoolean[2] ? "GL_TRUE" : "GL_FALSE") : " - ") << ", "
175 << (enableRef3 ? (referenceAsGLBoolean[3] ? "GL_TRUE" : "GL_FALSE") : " - ") << TestLog::EndMessage;
176
177 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
178 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
179 }
180 }
181
verifyIntegerGreaterOrEqual(tcu::TestContext & testCtx,GLenum name,GLint reference)182 void GetBooleanVerifier::verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference)
183 {
184 using tcu::TestLog;
185
186 StateQueryMemoryWriteGuard<GLboolean> state;
187 glGetBooleanv(name, &state);
188
189 if (!state.verifyValidity(testCtx))
190 return;
191
192 if (state == GL_TRUE) // state is non-zero, could be greater than reference (correct)
193 return;
194
195 if (state == GL_FALSE) // state is zero
196 {
197 if (reference > 0) // and reference is greater than zero?
198 {
199 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage;
200 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
201 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
202 }
203 }
204 else
205 {
206 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE or GL_FALSE" << TestLog::EndMessage;
207 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
208 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
209 }
210 }
211
verifyUnsignedIntegerGreaterOrEqual(tcu::TestContext & testCtx,GLenum name,GLuint reference)212 void GetBooleanVerifier::verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference)
213 {
214 using tcu::TestLog;
215
216 StateQueryMemoryWriteGuard<GLboolean> state;
217 glGetBooleanv(name, &state);
218
219 if (!state.verifyValidity(testCtx))
220 return;
221
222 if (state == GL_TRUE) // state is non-zero, could be greater than reference (correct)
223 return;
224
225 if (state == GL_FALSE) // state is zero
226 {
227 if (reference > 0) // and reference is greater than zero?
228 {
229 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage;
230 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
231 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
232 }
233 }
234 else
235 {
236 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE or GL_FALSE" << TestLog::EndMessage;
237 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
238 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
239 }
240 }
241
verifyIntegerLessOrEqual(tcu::TestContext & testCtx,GLenum name,GLint reference)242 void GetBooleanVerifier::verifyIntegerLessOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference)
243 {
244 using tcu::TestLog;
245
246 StateQueryMemoryWriteGuard<GLboolean> state;
247 glGetBooleanv(name, &state);
248
249 if (!state.verifyValidity(testCtx))
250 return;
251
252 if (state == GL_TRUE) // state is non-zero, could be less than reference (correct)
253 return;
254
255 if (state == GL_FALSE) // state is zero
256 {
257 if (reference < 0) // and reference is less than zero?
258 {
259 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage;
260 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
261 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
262 }
263 }
264 else
265 {
266 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE or GL_FALSE" << TestLog::EndMessage;
267 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
268 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
269 }
270 }
271
verifyIntegerGreaterOrEqual2(tcu::TestContext & testCtx,GLenum name,GLint reference0,GLint reference1)272 void GetBooleanVerifier::verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1)
273 {
274 using tcu::TestLog;
275
276 StateQueryMemoryWriteGuard<GLboolean[2]> boolVector;
277 glGetBooleanv(name, boolVector);
278
279 if (!boolVector.verifyValidity(testCtx))
280 return;
281
282 const GLboolean referenceAsGLBoolean[2] =
283 {
284 reference0 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE,
285 reference1 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE
286 };
287
288 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(referenceAsGLBoolean); ++ndx)
289 {
290 if (boolVector[ndx] == GL_TRUE) // state is non-zero, could be greater than any integer
291 {
292 continue;
293 }
294 else if (boolVector[ndx] == GL_FALSE) // state is zero
295 {
296 if (referenceAsGLBoolean[ndx] > 0) // and reference is greater than zero?
297 {
298 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage;
299 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
300 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
301 }
302 }
303 else
304 {
305 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE or GL_FALSE" << TestLog::EndMessage;
306 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
307 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
308 }
309 }
310 }
311
verifyIntegerAnyOf(tcu::TestContext & testCtx,GLenum name,const GLint references[],size_t referencesLength)312 void GetBooleanVerifier::verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength)
313 {
314 using tcu::TestLog;
315
316 StateQueryMemoryWriteGuard<GLboolean> state;
317 glGetBooleanv(name, &state);
318
319 if (!state.verifyValidity(testCtx))
320 return;
321
322 for (size_t ndx = 0; ndx < referencesLength; ++ndx)
323 {
324 const GLboolean expectedGLState = references[ndx] ? GL_TRUE : GL_FALSE;
325
326 if (state == expectedGLState)
327 return;
328 }
329
330 testCtx.getLog() << TestLog::Message << "// ERROR: got " << (state==GL_TRUE ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
331 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
332 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
333 }
334
verifyStencilMaskInitial(tcu::TestContext & testCtx,GLenum name,int stencilBits)335 void GetBooleanVerifier::verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits)
336 {
337 // if stencilBits == 0, the mask is allowed to be either GL_TRUE or GL_FALSE
338 // otherwise it must be GL_TRUE
339 using tcu::TestLog;
340
341 StateQueryMemoryWriteGuard<GLboolean> state;
342 glGetBooleanv(name, &state);
343
344 if (!state.verifyValidity(testCtx))
345 return;
346
347 if (stencilBits > 0 && state != GL_TRUE)
348 {
349 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage;
350 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
351 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
352 }
353 }
354
355 //GetIntegerVerifier
356
357 class GetIntegerVerifier : public StateVerifier
358 {
359 public:
360 GetIntegerVerifier (const glw::Functions& gl, tcu::TestLog& log);
361 void verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference);
362 void verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3);
363 void verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3);
364 void verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference);
365 void verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference);
366 void verifyIntegerLessOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference);
367 void verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1);
368 void verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength);
369 void verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits);
370 };
371
GetIntegerVerifier(const glw::Functions & gl,tcu::TestLog & log)372 GetIntegerVerifier::GetIntegerVerifier (const glw::Functions& gl, tcu::TestLog& log)
373 : StateVerifier(gl, log, "_getinteger")
374 {
375 }
376
verifyInteger(tcu::TestContext & testCtx,GLenum name,GLint reference)377 void GetIntegerVerifier::verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference)
378 {
379 using tcu::TestLog;
380
381 StateQueryMemoryWriteGuard<GLint> state;
382 glGetIntegerv(name, &state);
383
384 if (!state.verifyValidity(testCtx))
385 return;
386
387 if (state != reference)
388 {
389 testCtx.getLog() << TestLog::Message << "// ERROR: expected " << reference << "; got " << state << TestLog::EndMessage;
390 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
391 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
392 }
393 }
394
verifyInteger4(tcu::TestContext & testCtx,GLenum name,GLint reference0,GLint reference1,GLint reference2,GLint reference3)395 void GetIntegerVerifier::verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3)
396 {
397 verifyInteger4Mask(testCtx, name, reference0, true, reference1, true, reference2, true, reference3, true);
398 }
399
verifyInteger4Mask(tcu::TestContext & testCtx,GLenum name,GLint reference0,bool enableRef0,GLint reference1,bool enableRef1,GLint reference2,bool enableRef2,GLint reference3,bool enableRef3)400 void GetIntegerVerifier::verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3)
401 {
402 using tcu::TestLog;
403
404 StateQueryMemoryWriteGuard<GLint[4]> intVector4;
405 glGetIntegerv(name, intVector4);
406
407 if (!intVector4.verifyValidity(testCtx))
408 return;
409
410 if ((enableRef0 && (intVector4[0] != reference0)) ||
411 (enableRef1 && (intVector4[1] != reference1)) ||
412 (enableRef2 && (intVector4[2] != reference2)) ||
413 (enableRef3 && (intVector4[3] != reference3)))
414 {
415 testCtx.getLog() << TestLog::Message << "// ERROR: expected "
416 << (enableRef0?"":"(") << reference0 << (enableRef0?"":")") << ", "
417 << (enableRef1?"":"(") << reference1 << (enableRef1?"":")") << ", "
418 << (enableRef2?"":"(") << reference2 << (enableRef2?"":")") << ", "
419 << (enableRef3?"":"(") << reference3 << (enableRef3?"":")") << TestLog::EndMessage;
420
421
422 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
423 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
424 }
425 }
426
verifyIntegerGreaterOrEqual(tcu::TestContext & testCtx,GLenum name,GLint reference)427 void GetIntegerVerifier::verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference)
428 {
429 using tcu::TestLog;
430
431 StateQueryMemoryWriteGuard<GLint> state;
432 glGetIntegerv(name, &state);
433
434 if (!state.verifyValidity(testCtx))
435 return;
436
437 if (state < reference)
438 {
439 testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << reference << "; got " << state << TestLog::EndMessage;
440 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
441 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
442 }
443 }
444
verifyUnsignedIntegerGreaterOrEqual(tcu::TestContext & testCtx,GLenum name,GLuint reference)445 void GetIntegerVerifier::verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference)
446 {
447 using tcu::TestLog;
448
449 StateQueryMemoryWriteGuard<GLint> state;
450 glGetIntegerv(name, &state);
451
452 if (!state.verifyValidity(testCtx))
453 return;
454
455 if (GLuint(state) < reference)
456 {
457 testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << reference << "; got " << GLuint(state) << TestLog::EndMessage;
458 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
459 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
460 }
461 }
462
verifyIntegerLessOrEqual(tcu::TestContext & testCtx,GLenum name,GLint reference)463 void GetIntegerVerifier::verifyIntegerLessOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference)
464 {
465 using tcu::TestLog;
466
467 StateQueryMemoryWriteGuard<GLint> state;
468 glGetIntegerv(name, &state);
469
470 if (!state.verifyValidity(testCtx))
471 return;
472
473 if (state > reference)
474 {
475 testCtx.getLog() << TestLog::Message << "// ERROR: expected less or equal to " << reference << "; got " << state << TestLog::EndMessage;
476 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
477 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
478 }
479 }
480
verifyIntegerGreaterOrEqual2(tcu::TestContext & testCtx,GLenum name,GLint reference0,GLint reference1)481 void GetIntegerVerifier::verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1)
482 {
483 using tcu::TestLog;
484
485 StateQueryMemoryWriteGuard<GLint[2]> intVector2;
486 glGetIntegerv(name, intVector2);
487
488 if (!intVector2.verifyValidity(testCtx))
489 return;
490
491 if (intVector2[0] < reference0 || intVector2[1] < reference1)
492 {
493 testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << reference0 << ", " << reference1 << "; got " << intVector2[0] << ", " << intVector2[0] << TestLog::EndMessage;
494 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
495 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
496 }
497 }
498
verifyIntegerAnyOf(tcu::TestContext & testCtx,GLenum name,const GLint references[],size_t referencesLength)499 void GetIntegerVerifier::verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength)
500 {
501 using tcu::TestLog;
502
503 StateQueryMemoryWriteGuard<GLint> state;
504 glGetIntegerv(name, &state);
505
506 if (!state.verifyValidity(testCtx))
507 return;
508
509 for (size_t ndx = 0; ndx < referencesLength; ++ndx)
510 {
511 const GLint expectedGLState = references[ndx];
512
513 if (state == expectedGLState)
514 return;
515 }
516
517 testCtx.getLog() << TestLog::Message << "// ERROR: got " << state << TestLog::EndMessage;
518 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
519 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
520 }
521
verifyStencilMaskInitial(tcu::TestContext & testCtx,GLenum name,int stencilBits)522 void GetIntegerVerifier::verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits)
523 {
524 using tcu::TestLog;
525
526 StateQueryMemoryWriteGuard<GLint> state;
527 glGetIntegerv(name, &state);
528
529 if (!state.verifyValidity(testCtx))
530 return;
531
532 const GLint reference = (1 << stencilBits) - 1;
533
534 if ((state & reference) != reference) // the least significant stencilBits bits should be on
535 {
536 testCtx.getLog() << TestLog::Message << "// ERROR: expected minimum mask of " << reference << "; got " << state << TestLog::EndMessage;
537 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
538 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid mask value");
539 }
540 }
541
542 //GetInteger64Verifier
543
544 class GetInteger64Verifier : public StateVerifier
545 {
546 public:
547 GetInteger64Verifier (const glw::Functions& gl, tcu::TestLog& log);
548 void verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference);
549 void verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3);
550 void verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3);
551 void verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference);
552 void verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference);
553 void verifyIntegerLessOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference);
554 void verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1);
555 void verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength);
556 void verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits);
557 };
558
GetInteger64Verifier(const glw::Functions & gl,tcu::TestLog & log)559 GetInteger64Verifier::GetInteger64Verifier (const glw::Functions& gl, tcu::TestLog& log)
560 : StateVerifier(gl, log, "_getinteger64")
561 {
562 }
563
verifyInteger(tcu::TestContext & testCtx,GLenum name,GLint reference)564 void GetInteger64Verifier::verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference)
565 {
566 using tcu::TestLog;
567
568 StateQueryMemoryWriteGuard<GLint64> state;
569 glGetInteger64v(name, &state);
570
571 if (!state.verifyValidity(testCtx))
572 return;
573
574 if (state != GLint64(reference))
575 {
576 testCtx.getLog() << TestLog::Message << "// ERROR: expected " << reference << "; got " << state << TestLog::EndMessage;
577 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
578 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
579 }
580 }
581
verifyInteger4(tcu::TestContext & testCtx,GLenum name,GLint reference0,GLint reference1,GLint reference2,GLint reference3)582 void GetInteger64Verifier::verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3)
583 {
584 verifyInteger4Mask(testCtx, name, reference0, true, reference1, true, reference2, true, reference3, true);
585 }
586
verifyInteger4Mask(tcu::TestContext & testCtx,GLenum name,GLint reference0,bool enableRef0,GLint reference1,bool enableRef1,GLint reference2,bool enableRef2,GLint reference3,bool enableRef3)587 void GetInteger64Verifier::verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3)
588 {
589 using tcu::TestLog;
590
591 StateQueryMemoryWriteGuard<GLint64[4]> intVector4;
592 glGetInteger64v(name, intVector4);
593
594 if (!intVector4.verifyValidity(testCtx))
595 return;
596
597 if ((enableRef0 && (intVector4[0] != GLint64(reference0))) ||
598 (enableRef1 && (intVector4[1] != GLint64(reference1))) ||
599 (enableRef2 && (intVector4[2] != GLint64(reference2))) ||
600 (enableRef3 && (intVector4[3] != GLint64(reference3))))
601 {
602 testCtx.getLog() << TestLog::Message << "// ERROR: expected "
603 << (enableRef0?"":"(") << reference0 << (enableRef0?"":")") << ", "
604 << (enableRef1?"":"(") << reference1 << (enableRef1?"":")") << ", "
605 << (enableRef2?"":"(") << reference2 << (enableRef2?"":")") << ", "
606 << (enableRef3?"":"(") << reference3 << (enableRef3?"":")") << TestLog::EndMessage;
607
608 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
609 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
610 }
611 }
612
verifyIntegerGreaterOrEqual(tcu::TestContext & testCtx,GLenum name,GLint reference)613 void GetInteger64Verifier::verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference)
614 {
615 using tcu::TestLog;
616
617 StateQueryMemoryWriteGuard<GLint64> state;
618 glGetInteger64v(name, &state);
619
620 if (!state.verifyValidity(testCtx))
621 return;
622
623 if (state < GLint64(reference))
624 {
625 testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLint64(reference) << "; got " << state << TestLog::EndMessage;
626 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
627 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
628 }
629 }
630
verifyUnsignedIntegerGreaterOrEqual(tcu::TestContext & testCtx,GLenum name,GLuint reference)631 void GetInteger64Verifier::verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference)
632 {
633 using tcu::TestLog;
634
635 StateQueryMemoryWriteGuard<GLint64> state;
636 glGetInteger64v(name, &state);
637
638 if (!state.verifyValidity(testCtx))
639 return;
640
641 if (GLuint(state) < GLint64(reference))
642 {
643 testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLint64(reference) << "; got " << GLuint(state) << TestLog::EndMessage;
644 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
645 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
646 }
647 }
648
verifyIntegerLessOrEqual(tcu::TestContext & testCtx,GLenum name,GLint reference)649 void GetInteger64Verifier::verifyIntegerLessOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference)
650 {
651 using tcu::TestLog;
652
653 StateQueryMemoryWriteGuard<GLint64> state;
654 glGetInteger64v(name, &state);
655
656 if (!state.verifyValidity(testCtx))
657 return;
658
659 if (state > GLint64(reference))
660 {
661 testCtx.getLog() << TestLog::Message << "// ERROR: expected less or equal to " << GLint64(reference) << "; got " << state << TestLog::EndMessage;
662 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
663 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
664 }
665 }
666
verifyIntegerGreaterOrEqual2(tcu::TestContext & testCtx,GLenum name,GLint reference0,GLint reference1)667 void GetInteger64Verifier::verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1)
668 {
669 using tcu::TestLog;
670
671 StateQueryMemoryWriteGuard<GLint64[2]> intVector2;
672 glGetInteger64v(name, intVector2);
673
674 if (!intVector2.verifyValidity(testCtx))
675 return;
676
677 if (intVector2[0] < GLint64(reference0) || intVector2[1] < GLint64(reference1))
678 {
679 testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLint64(reference0) << ", " << GLint64(reference1) << "; got " << intVector2[0] << ", " << intVector2[1] << TestLog::EndMessage;
680 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
681 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
682 }
683 }
684
verifyIntegerAnyOf(tcu::TestContext & testCtx,GLenum name,const GLint references[],size_t referencesLength)685 void GetInteger64Verifier::verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength)
686 {
687 using tcu::TestLog;
688
689 StateQueryMemoryWriteGuard<GLint64> state;
690 glGetInteger64v(name, &state);
691
692 if (!state.verifyValidity(testCtx))
693 return;
694
695 for (size_t ndx = 0; ndx < referencesLength; ++ndx)
696 {
697 const GLint64 expectedGLState = GLint64(references[ndx]);
698
699 if (state == expectedGLState)
700 return;
701 }
702
703 testCtx.getLog() << TestLog::Message << "// ERROR: got " << state << TestLog::EndMessage;
704 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
705 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
706 }
707
verifyStencilMaskInitial(tcu::TestContext & testCtx,GLenum name,int stencilBits)708 void GetInteger64Verifier::verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits)
709 {
710 using tcu::TestLog;
711
712 StateQueryMemoryWriteGuard<GLint64> state;
713 glGetInteger64v(name, &state);
714
715 if (!state.verifyValidity(testCtx))
716 return;
717
718 const GLint64 reference = (1ULL << stencilBits) - 1;
719
720 if ((state & reference) != reference) // the least significant stencilBits bits should be on
721 {
722 testCtx.getLog() << TestLog::Message << "// ERROR: expected mimimum mask of " << reference << "; got " << state << TestLog::EndMessage;
723 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
724 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid mask value");
725 }
726 }
727
728 //GetFloatVerifier
729
730 class GetFloatVerifier : public StateVerifier
731 {
732 public:
733 GetFloatVerifier (const glw::Functions& gl, tcu::TestLog& log);
734 void verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference);
735 void verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3);
736 void verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3);
737 void verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference);
738 void verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference);
739 void verifyIntegerLessOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference);
740 void verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1);
741 void verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength);
742 void verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits);
743 };
744
GetFloatVerifier(const glw::Functions & gl,tcu::TestLog & log)745 GetFloatVerifier::GetFloatVerifier (const glw::Functions& gl, tcu::TestLog& log)
746 : StateVerifier(gl, log, "_getfloat")
747 {
748 }
749
verifyInteger(tcu::TestContext & testCtx,GLenum name,GLint reference)750 void GetFloatVerifier::verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference)
751 {
752 using tcu::TestLog;
753
754 const GLfloat referenceAsFloat = GLfloat(reference);
755 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
756
757 StateQueryMemoryWriteGuard<GLfloat> state;
758 glGetFloatv(name, &state);
759
760 if (!state.verifyValidity(testCtx))
761 return;
762
763 if (state != referenceAsFloat)
764 {
765 testCtx.getLog() << TestLog::Message << "// ERROR: expected " << referenceAsFloat << "; got " << state << TestLog::EndMessage;
766 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
767 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
768 }
769 }
770
verifyInteger4(tcu::TestContext & testCtx,GLenum name,GLint reference0,GLint reference1,GLint reference2,GLint reference3)771 void GetFloatVerifier::verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3)
772 {
773 verifyInteger4Mask(testCtx, name, reference0, true, reference1, true, reference2, true, reference3, true);
774 }
775
verifyInteger4Mask(tcu::TestContext & testCtx,GLenum name,GLint reference0,bool enableRef0,GLint reference1,bool enableRef1,GLint reference2,bool enableRef2,GLint reference3,bool enableRef3)776 void GetFloatVerifier::verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3)
777 {
778 using tcu::TestLog;
779
780 StateQueryMemoryWriteGuard<GLfloat[4]> floatVector4;
781 glGetFloatv(name, floatVector4);
782
783 if (!floatVector4.verifyValidity(testCtx))
784 return;
785
786 if ((enableRef0 && (floatVector4[0] != GLfloat(reference0))) ||
787 (enableRef1 && (floatVector4[1] != GLfloat(reference1))) ||
788 (enableRef2 && (floatVector4[2] != GLfloat(reference2))) ||
789 (enableRef3 && (floatVector4[3] != GLfloat(reference3))))
790 {
791 testCtx.getLog() << TestLog::Message << "// ERROR: expected "
792 << (enableRef0?"":"(") << GLfloat(reference0) << (enableRef0?"":")") << ", "
793 << (enableRef1?"":"(") << GLfloat(reference1) << (enableRef1?"":")") << ", "
794 << (enableRef2?"":"(") << GLfloat(reference2) << (enableRef2?"":")") << ", "
795 << (enableRef3?"":"(") << GLfloat(reference3) << (enableRef3?"":")") << TestLog::EndMessage;
796
797 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
798 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
799 }
800 }
801
verifyIntegerGreaterOrEqual(tcu::TestContext & testCtx,GLenum name,GLint reference)802 void GetFloatVerifier::verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference)
803 {
804 using tcu::TestLog;
805
806 StateQueryMemoryWriteGuard<GLfloat> state;
807 glGetFloatv(name, &state);
808
809 if (!state.verifyValidity(testCtx))
810 return;
811
812 if (state < GLfloat(reference))
813 {
814 testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLfloat(reference) << "; got " << state << TestLog::EndMessage;
815 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
816 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
817 }
818 }
819
verifyUnsignedIntegerGreaterOrEqual(tcu::TestContext & testCtx,GLenum name,GLuint reference)820 void GetFloatVerifier::verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference)
821 {
822 using tcu::TestLog;
823
824 StateQueryMemoryWriteGuard<GLfloat> state;
825 glGetFloatv(name, &state);
826
827 if (!state.verifyValidity(testCtx))
828 return;
829
830 if (GLuint(state) < GLfloat(reference))
831 {
832 testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLfloat(reference) << "; got " << GLuint(state) << TestLog::EndMessage;
833 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
834 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
835 }
836 }
837
verifyIntegerLessOrEqual(tcu::TestContext & testCtx,GLenum name,GLint reference)838 void GetFloatVerifier::verifyIntegerLessOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference)
839 {
840 using tcu::TestLog;
841
842 StateQueryMemoryWriteGuard<GLfloat> state;
843 glGetFloatv(name, &state);
844
845 if (!state.verifyValidity(testCtx))
846 return;
847
848 if (state > GLfloat(reference))
849 {
850 testCtx.getLog() << TestLog::Message << "// ERROR: expected less or equal to " << GLfloat(reference) << "; got " << state << TestLog::EndMessage;
851 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
852 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
853 }
854 }
855
verifyIntegerGreaterOrEqual2(tcu::TestContext & testCtx,GLenum name,GLint reference0,GLint reference1)856 void GetFloatVerifier::verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1)
857 {
858 using tcu::TestLog;
859
860 StateQueryMemoryWriteGuard<GLfloat[2]> floatVector2;
861 glGetFloatv(name, floatVector2);
862
863 if (!floatVector2.verifyValidity(testCtx))
864 return;
865
866 if (floatVector2[0] < GLfloat(reference0) || floatVector2[1] < GLfloat(reference1))
867 {
868 testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLfloat(reference0) << ", " << GLfloat(reference1) << "; got " << floatVector2[0] << ", " << floatVector2[1] << TestLog::EndMessage;
869 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
870 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
871 }
872 }
873
verifyIntegerAnyOf(tcu::TestContext & testCtx,GLenum name,const GLint references[],size_t referencesLength)874 void GetFloatVerifier::verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength)
875 {
876 using tcu::TestLog;
877
878 StateQueryMemoryWriteGuard<GLfloat> state;
879 glGetFloatv(name, &state);
880
881 if (!state.verifyValidity(testCtx))
882 return;
883
884 for (size_t ndx = 0; ndx < referencesLength; ++ndx)
885 {
886 const GLfloat expectedGLState = GLfloat(references[ndx]);
887 DE_ASSERT(references[ndx] == GLint(expectedGLState)); // reference integer must have 1:1 mapping to float for this to work. Reference value is always such value in these tests
888
889 if (state == expectedGLState)
890 return;
891 }
892
893 testCtx.getLog() << TestLog::Message << "// ERROR: got " << state << TestLog::EndMessage;
894 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
895 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
896 }
897
verifyStencilMaskInitial(tcu::TestContext & testCtx,GLenum name,int stencilBits)898 void GetFloatVerifier::verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits)
899 {
900 // checking the mask bits with float doesn't make much sense because of conversion errors
901 // just verify that the value is greater or equal to the minimum value
902 const GLint reference = (1 << stencilBits) - 1;
903 verifyIntegerGreaterOrEqual(testCtx, name, reference);
904 }
905
906 } // IntegerStateQueryVerifiers
907
908 namespace
909 {
910
911 using namespace IntegerStateQueryVerifiers;
912 using namespace deqp::gls::StateQueryUtil;
913
914 class ConstantMinimumValueTestCase : public ApiCase
915 {
916 public:
ConstantMinimumValueTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum targetName,GLint minValue)917 ConstantMinimumValueTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum targetName, GLint minValue)
918 : ApiCase (context, name, description)
919 , m_targetName (targetName)
920 , m_minValue (minValue)
921 , m_verifier (verifier)
922 {
923 }
924
test(void)925 void test (void)
926 {
927 m_verifier->verifyUnsignedIntegerGreaterOrEqual(m_testCtx, m_targetName, m_minValue);
928 expectError(GL_NO_ERROR);
929 }
930
931 private:
932 GLenum m_targetName;
933 GLint m_minValue;
934 StateVerifier* m_verifier;
935 };
936
937 class ConstantMaximumValueTestCase : public ApiCase
938 {
939 public:
ConstantMaximumValueTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum targetName,GLint minValue)940 ConstantMaximumValueTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum targetName, GLint minValue)
941 : ApiCase (context, name, description)
942 , m_targetName (targetName)
943 , m_minValue (minValue)
944 , m_verifier (verifier)
945 {
946 }
947
test(void)948 void test (void)
949 {
950 m_verifier->verifyIntegerLessOrEqual(m_testCtx, m_targetName, m_minValue);
951 expectError(GL_NO_ERROR);
952 }
953
954 private:
955 GLenum m_targetName;
956 GLint m_minValue;
957 StateVerifier* m_verifier;
958 };
959
960 class SampleBuffersTestCase : public ApiCase
961 {
962 public:
SampleBuffersTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)963 SampleBuffersTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
964 : ApiCase (context, name, description)
965 , m_verifier (verifier)
966 {
967 }
968
test(void)969 void test (void)
970 {
971 const int expectedSampleBuffers = (m_context.getRenderTarget().getNumSamples() > 1) ? 1 : 0;
972
973 m_log << tcu::TestLog::Message << "Sample count is " << (m_context.getRenderTarget().getNumSamples()) << ", expecting GL_SAMPLE_BUFFERS to be " << expectedSampleBuffers << tcu::TestLog::EndMessage;
974
975 m_verifier->verifyInteger(m_testCtx, GL_SAMPLE_BUFFERS, expectedSampleBuffers);
976 expectError(GL_NO_ERROR);
977 }
978
979 private:
980 StateVerifier* m_verifier;
981 };
982
983 class SamplesTestCase : public ApiCase
984 {
985 public:
SamplesTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)986 SamplesTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
987 : ApiCase (context, name, description)
988 , m_verifier (verifier)
989 {
990 }
991
test(void)992 void test (void)
993 {
994 // MSAA?
995 if (m_context.getRenderTarget().getNumSamples() > 1)
996 {
997 m_log << tcu::TestLog::Message << "Sample count is " << (m_context.getRenderTarget().getNumSamples()) << tcu::TestLog::EndMessage;
998
999 m_verifier->verifyInteger(m_testCtx, GL_SAMPLES, m_context.getRenderTarget().getNumSamples());
1000 expectError(GL_NO_ERROR);
1001 }
1002 else
1003 {
1004 const glw::GLint validSamples[] = {0, 1};
1005
1006 m_log << tcu::TestLog::Message << "Expecting GL_SAMPLES to be 0 or 1" << tcu::TestLog::EndMessage;
1007
1008 m_verifier->verifyIntegerAnyOf(m_testCtx, GL_SAMPLES, validSamples, DE_LENGTH_OF_ARRAY(validSamples));
1009 expectError(GL_NO_ERROR);
1010 }
1011 }
1012
1013 private:
1014 StateVerifier* m_verifier;
1015 };
1016
1017 class HintTestCase : public ApiCase
1018 {
1019 public:
HintTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum targetName)1020 HintTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum targetName)
1021 : ApiCase (context, name, description)
1022 , m_targetName (targetName)
1023 , m_verifier (verifier)
1024 {
1025 }
1026
test(void)1027 void test (void)
1028 {
1029 m_verifier->verifyInteger(m_testCtx, m_targetName, GL_DONT_CARE);
1030 expectError(GL_NO_ERROR);
1031
1032 glHint(m_targetName, GL_NICEST);
1033 m_verifier->verifyInteger(m_testCtx, m_targetName, GL_NICEST);
1034 expectError(GL_NO_ERROR);
1035
1036 glHint(m_targetName, GL_FASTEST);
1037 m_verifier->verifyInteger(m_testCtx, m_targetName, GL_FASTEST);
1038 expectError(GL_NO_ERROR);
1039
1040 glHint(m_targetName, GL_DONT_CARE);
1041 m_verifier->verifyInteger(m_testCtx, m_targetName, GL_DONT_CARE);
1042 expectError(GL_NO_ERROR);
1043 }
1044
1045 private:
1046 GLenum m_targetName;
1047 StateVerifier* m_verifier;
1048 };
1049
1050 class DepthFuncTestCase : public ApiCase
1051 {
1052 public:
DepthFuncTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)1053 DepthFuncTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
1054 : ApiCase (context, name, description)
1055 , m_verifier (verifier)
1056 {
1057 }
1058
test(void)1059 void test (void)
1060 {
1061 m_verifier->verifyInteger(m_testCtx, GL_DEPTH_FUNC, GL_LESS);
1062 expectError(GL_NO_ERROR);
1063
1064 const GLenum depthFunctions[] = {GL_NEVER, GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GREATER, GL_GEQUAL, GL_NOTEQUAL};
1065 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthFunctions); ndx++)
1066 {
1067 glDepthFunc(depthFunctions[ndx]);
1068 expectError(GL_NO_ERROR);
1069
1070 m_verifier->verifyInteger(m_testCtx, GL_DEPTH_FUNC, depthFunctions[ndx]);
1071 expectError(GL_NO_ERROR);
1072 }
1073 }
1074
1075 private:
1076 StateVerifier* m_verifier;
1077 };
1078
1079 class CullFaceTestCase : public ApiCase
1080 {
1081 public:
CullFaceTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)1082 CullFaceTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
1083 : ApiCase (context, name, description)
1084 , m_verifier (verifier)
1085 {
1086 }
1087
test(void)1088 void test (void)
1089 {
1090 m_verifier->verifyInteger(m_testCtx, GL_CULL_FACE_MODE, GL_BACK);
1091 expectError(GL_NO_ERROR);
1092
1093 const GLenum cullFaces[] = {GL_FRONT, GL_BACK, GL_FRONT_AND_BACK};
1094 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(cullFaces); ndx++)
1095 {
1096 glCullFace(cullFaces[ndx]);
1097 expectError(GL_NO_ERROR);
1098
1099 m_verifier->verifyInteger(m_testCtx, GL_CULL_FACE_MODE, cullFaces[ndx]);
1100 expectError(GL_NO_ERROR);
1101 }
1102 }
1103
1104 private:
1105 StateVerifier* m_verifier;
1106 };
1107
1108 class FrontFaceTestCase : public ApiCase
1109 {
1110 public:
FrontFaceTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)1111 FrontFaceTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
1112 : ApiCase (context, name, description)
1113 , m_verifier (verifier)
1114 {
1115 }
1116
test(void)1117 void test (void)
1118 {
1119 m_verifier->verifyInteger(m_testCtx, GL_FRONT_FACE, GL_CCW);
1120 expectError(GL_NO_ERROR);
1121
1122 const GLenum frontFaces[] = {GL_CW, GL_CCW};
1123 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(frontFaces); ndx++)
1124 {
1125 glFrontFace(frontFaces[ndx]);
1126 expectError(GL_NO_ERROR);
1127
1128 m_verifier->verifyInteger(m_testCtx, GL_FRONT_FACE, frontFaces[ndx]);
1129 expectError(GL_NO_ERROR);
1130 }
1131 }
1132
1133 private:
1134 StateVerifier* m_verifier;
1135 };
1136
1137 class ViewPortTestCase : public ApiCase
1138 {
1139 public:
ViewPortTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)1140 ViewPortTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
1141 : ApiCase (context, name, description)
1142 , m_verifier (verifier)
1143 {
1144 }
1145
test(void)1146 void test (void)
1147 {
1148 de::Random rnd(0xabcdef);
1149
1150 GLint maxViewportDimensions[2] = {0};
1151 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, maxViewportDimensions);
1152
1153 // verify initial value of first two values
1154 m_verifier->verifyInteger4(m_testCtx, GL_VIEWPORT, 0, 0, m_context.getRenderTarget().getWidth(), m_context.getRenderTarget().getHeight());
1155 expectError(GL_NO_ERROR);
1156
1157 const int numIterations = 120;
1158 for (int i = 0; i < numIterations; ++i)
1159 {
1160 GLint x = rnd.getInt(-64000, 64000);
1161 GLint y = rnd.getInt(-64000, 64000);
1162 GLsizei width = rnd.getInt(0, maxViewportDimensions[0]);
1163 GLsizei height = rnd.getInt(0, maxViewportDimensions[1]);
1164
1165 glViewport(x, y, width, height);
1166 m_verifier->verifyInteger4(m_testCtx, GL_VIEWPORT, x, y, width, height);
1167 expectError(GL_NO_ERROR);
1168 }
1169 }
1170
1171 private:
1172 StateVerifier* m_verifier;
1173 };
1174
1175 class ScissorBoxTestCase : public ApiCase
1176 {
1177 public:
ScissorBoxTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)1178 ScissorBoxTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
1179 : ApiCase (context, name, description)
1180 , m_verifier (verifier)
1181 {
1182 }
1183
test(void)1184 void test (void)
1185 {
1186 de::Random rnd(0xabcdef);
1187
1188 // verify initial value of first two values
1189 m_verifier->verifyInteger4Mask(m_testCtx, GL_SCISSOR_BOX, 0, true, 0, true, 0, false, 0, false);
1190 expectError(GL_NO_ERROR);
1191
1192 const int numIterations = 120;
1193 for (int i = 0; i < numIterations; ++i)
1194 {
1195 GLint left = rnd.getInt(-64000, 64000);
1196 GLint bottom = rnd.getInt(-64000, 64000);
1197 GLsizei width = rnd.getInt(0, 64000);
1198 GLsizei height = rnd.getInt(0, 64000);
1199
1200 glScissor(left, bottom, width, height);
1201 m_verifier->verifyInteger4(m_testCtx, GL_SCISSOR_BOX, left, bottom, width, height);
1202 expectError(GL_NO_ERROR);
1203 }
1204 }
1205 private:
1206 StateVerifier* m_verifier;
1207 };
1208
1209 class MaxViewportDimsTestCase : public ApiCase
1210 {
1211 public:
MaxViewportDimsTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)1212 MaxViewportDimsTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
1213 : ApiCase (context, name, description)
1214 , m_verifier (verifier)
1215 {
1216 }
1217
test(void)1218 void test (void)
1219 {
1220 m_verifier->verifyIntegerGreaterOrEqual2(m_testCtx, GL_MAX_VIEWPORT_DIMS, m_context.getRenderTarget().getWidth(), m_context.getRenderTarget().getHeight());
1221 expectError(GL_NO_ERROR);
1222 }
1223 private:
1224 StateVerifier* m_verifier;
1225 };
1226
1227 class StencilRefTestCase : public ApiCase
1228 {
1229 public:
StencilRefTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName)1230 StencilRefTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName)
1231 : ApiCase (context, name, description)
1232 , m_verifier (verifier)
1233 , m_testTargetName (testTargetName)
1234 {
1235 }
1236
test(void)1237 void test (void)
1238 {
1239 m_verifier->verifyInteger(m_testCtx, m_testTargetName, 0);
1240 expectError(GL_NO_ERROR);
1241
1242 const int stencilBits = m_context.getRenderTarget().getStencilBits();
1243
1244 for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
1245 {
1246 const int ref = 1 << stencilBit;
1247
1248 glStencilFunc(GL_ALWAYS, ref, 0); // mask should not affect the REF
1249 expectError(GL_NO_ERROR);
1250
1251 m_verifier->verifyInteger(m_testCtx, m_testTargetName, ref);
1252 expectError(GL_NO_ERROR);
1253
1254 glStencilFunc(GL_ALWAYS, ref, ref);
1255 expectError(GL_NO_ERROR);
1256
1257 m_verifier->verifyInteger(m_testCtx, m_testTargetName, ref);
1258 expectError(GL_NO_ERROR);
1259 }
1260 }
1261
1262 private:
1263 StateVerifier* m_verifier;
1264 GLenum m_testTargetName;
1265 };
1266
1267 class StencilRefSeparateTestCase : public ApiCase
1268 {
1269 public:
StencilRefSeparateTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName,GLenum stencilFuncTargetFace)1270 StencilRefSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, GLenum stencilFuncTargetFace)
1271 : ApiCase (context, name, description)
1272 , m_verifier (verifier)
1273 , m_testTargetName (testTargetName)
1274 , m_stencilFuncTargetFace (stencilFuncTargetFace)
1275 {
1276 }
1277
test(void)1278 void test (void)
1279 {
1280 m_verifier->verifyInteger(m_testCtx, m_testTargetName, 0);
1281 expectError(GL_NO_ERROR);
1282
1283 const int stencilBits = m_context.getRenderTarget().getStencilBits();
1284
1285 for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
1286 {
1287 const int ref = 1 << stencilBit;
1288
1289 glStencilFuncSeparate(m_stencilFuncTargetFace, GL_ALWAYS, ref, 0);
1290 expectError(GL_NO_ERROR);
1291
1292 m_verifier->verifyInteger(m_testCtx, m_testTargetName, ref);
1293 expectError(GL_NO_ERROR);
1294
1295 glStencilFuncSeparate(m_stencilFuncTargetFace, GL_ALWAYS, ref, ref);
1296 expectError(GL_NO_ERROR);
1297
1298 m_verifier->verifyInteger(m_testCtx, m_testTargetName, ref);
1299 expectError(GL_NO_ERROR);
1300 }
1301 }
1302 private:
1303 StateVerifier* m_verifier;
1304 GLenum m_testTargetName;
1305 GLenum m_stencilFuncTargetFace;
1306 };
1307
1308 class StencilOpTestCase : public ApiCase
1309 {
1310 public:
StencilOpTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum stencilOpName)1311 StencilOpTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum stencilOpName)
1312 : ApiCase (context, name, description)
1313 , m_verifier (verifier)
1314 , m_stencilOpName (stencilOpName)
1315 {
1316 }
1317
test(void)1318 void test (void)
1319 {
1320 m_verifier->verifyInteger(m_testCtx, m_stencilOpName, GL_KEEP);
1321 expectError(GL_NO_ERROR);
1322
1323 const GLenum stencilOpValues[] = {GL_KEEP, GL_ZERO, GL_REPLACE, GL_INCR, GL_DECR, GL_INVERT, GL_INCR_WRAP, GL_DECR_WRAP};
1324
1325 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(stencilOpValues); ++ndx)
1326 {
1327 SetStencilOp(stencilOpValues[ndx]);
1328 expectError(GL_NO_ERROR);
1329
1330 m_verifier->verifyInteger(m_testCtx, m_stencilOpName, stencilOpValues[ndx]);
1331 expectError(GL_NO_ERROR);
1332 }
1333 }
1334
1335 protected:
SetStencilOp(GLenum stencilOpValue)1336 virtual void SetStencilOp (GLenum stencilOpValue)
1337 {
1338 switch (m_stencilOpName)
1339 {
1340 case GL_STENCIL_FAIL:
1341 case GL_STENCIL_BACK_FAIL:
1342 glStencilOp(stencilOpValue, GL_KEEP, GL_KEEP);
1343 break;
1344
1345 case GL_STENCIL_PASS_DEPTH_FAIL:
1346 case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
1347 glStencilOp(GL_KEEP, stencilOpValue, GL_KEEP);
1348 break;
1349
1350 case GL_STENCIL_PASS_DEPTH_PASS:
1351 case GL_STENCIL_BACK_PASS_DEPTH_PASS:
1352 glStencilOp(GL_KEEP, GL_KEEP, stencilOpValue);
1353 break;
1354
1355 default:
1356 DE_ASSERT(false && "should not happen");
1357 break;
1358 }
1359 }
1360
1361 StateVerifier* m_verifier;
1362 GLenum m_stencilOpName;
1363 };
1364
1365
1366 class StencilOpSeparateTestCase : public StencilOpTestCase
1367 {
1368 public:
StencilOpSeparateTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum stencilOpName,GLenum stencilOpFace)1369 StencilOpSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum stencilOpName, GLenum stencilOpFace)
1370 : StencilOpTestCase (context, verifier, name, description, stencilOpName)
1371 , m_stencilOpFace (stencilOpFace)
1372 {
1373 }
1374
1375 private:
SetStencilOp(GLenum stencilOpValue)1376 void SetStencilOp (GLenum stencilOpValue)
1377 {
1378 switch (m_stencilOpName)
1379 {
1380 case GL_STENCIL_FAIL:
1381 case GL_STENCIL_BACK_FAIL:
1382 glStencilOpSeparate(m_stencilOpFace, stencilOpValue, GL_KEEP, GL_KEEP);
1383 break;
1384
1385 case GL_STENCIL_PASS_DEPTH_FAIL:
1386 case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
1387 glStencilOpSeparate(m_stencilOpFace, GL_KEEP, stencilOpValue, GL_KEEP);
1388 break;
1389
1390 case GL_STENCIL_PASS_DEPTH_PASS:
1391 case GL_STENCIL_BACK_PASS_DEPTH_PASS:
1392 glStencilOpSeparate(m_stencilOpFace, GL_KEEP, GL_KEEP, stencilOpValue);
1393 break;
1394
1395 default:
1396 DE_ASSERT(false && "should not happen");
1397 break;
1398 }
1399 }
1400
1401 GLenum m_stencilOpFace;
1402 };
1403
1404 class StencilFuncTestCase : public ApiCase
1405 {
1406 public:
StencilFuncTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)1407 StencilFuncTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
1408 : ApiCase (context, name, description)
1409 , m_verifier (verifier)
1410 {
1411 }
1412
test(void)1413 void test (void)
1414 {
1415 m_verifier->verifyInteger(m_testCtx, GL_STENCIL_FUNC, GL_ALWAYS);
1416 expectError(GL_NO_ERROR);
1417
1418 const GLenum stencilfuncValues[] = {GL_NEVER, GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GEQUAL, GL_GREATER, GL_NOTEQUAL};
1419
1420 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(stencilfuncValues); ++ndx)
1421 {
1422 glStencilFunc(stencilfuncValues[ndx], 0, 0);
1423 expectError(GL_NO_ERROR);
1424
1425 m_verifier->verifyInteger(m_testCtx, GL_STENCIL_FUNC, stencilfuncValues[ndx]);
1426 expectError(GL_NO_ERROR);
1427
1428 m_verifier->verifyInteger(m_testCtx, GL_STENCIL_BACK_FUNC, stencilfuncValues[ndx]);
1429 expectError(GL_NO_ERROR);
1430 }
1431 }
1432 private:
1433 StateVerifier* m_verifier;
1434 };
1435
1436 class StencilFuncSeparateTestCase : public ApiCase
1437 {
1438 public:
StencilFuncSeparateTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum stencilFuncName,GLenum stencilFuncFace)1439 StencilFuncSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum stencilFuncName, GLenum stencilFuncFace)
1440 : ApiCase (context, name, description)
1441 , m_verifier (verifier)
1442 , m_stencilFuncName (stencilFuncName)
1443 , m_stencilFuncFace (stencilFuncFace)
1444 {
1445 }
1446
test(void)1447 void test (void)
1448 {
1449 m_verifier->verifyInteger(m_testCtx, m_stencilFuncName, GL_ALWAYS);
1450 expectError(GL_NO_ERROR);
1451
1452 const GLenum stencilfuncValues[] = {GL_NEVER, GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GEQUAL, GL_GREATER, GL_NOTEQUAL};
1453
1454 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(stencilfuncValues); ++ndx)
1455 {
1456 glStencilFuncSeparate(m_stencilFuncFace, stencilfuncValues[ndx], 0, 0);
1457 expectError(GL_NO_ERROR);
1458
1459 m_verifier->verifyInteger(m_testCtx, m_stencilFuncName, stencilfuncValues[ndx]);
1460 expectError(GL_NO_ERROR);
1461 }
1462 }
1463 private:
1464 StateVerifier* m_verifier;
1465 GLenum m_stencilFuncName;
1466 GLenum m_stencilFuncFace;
1467 };
1468
1469 class StencilMaskTestCase : public ApiCase
1470 {
1471 public:
StencilMaskTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName)1472 StencilMaskTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName)
1473 : ApiCase (context, name, description)
1474 , m_verifier (verifier)
1475 , m_testTargetName (testTargetName)
1476 {
1477 }
1478
test(void)1479 void test (void)
1480 {
1481 const int stencilBits = m_context.getRenderTarget().getStencilBits();
1482
1483 m_verifier->verifyStencilMaskInitial(m_testCtx, m_testTargetName, stencilBits);
1484 expectError(GL_NO_ERROR);
1485
1486 for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
1487 {
1488 const int mask = 1 << stencilBit;
1489
1490 glStencilFunc(GL_ALWAYS, 0, mask);
1491 expectError(GL_NO_ERROR);
1492
1493 m_verifier->verifyInteger(m_testCtx, m_testTargetName, mask);
1494 expectError(GL_NO_ERROR);
1495 }
1496 }
1497 private:
1498 StateVerifier* m_verifier;
1499 GLenum m_testTargetName;
1500 };
1501
1502 class StencilMaskSeparateTestCase : public ApiCase
1503 {
1504 public:
StencilMaskSeparateTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName,GLenum stencilFuncTargetFace)1505 StencilMaskSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, GLenum stencilFuncTargetFace)
1506 : ApiCase (context, name, description)
1507 , m_verifier (verifier)
1508 , m_testTargetName (testTargetName)
1509 , m_stencilFuncTargetFace (stencilFuncTargetFace)
1510 {
1511 }
1512
test(void)1513 void test (void)
1514 {
1515 const int stencilBits = m_context.getRenderTarget().getStencilBits();
1516
1517 m_verifier->verifyStencilMaskInitial(m_testCtx, m_testTargetName, stencilBits);
1518 expectError(GL_NO_ERROR);
1519
1520 for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
1521 {
1522 const int mask = 1 << stencilBit;
1523
1524 glStencilFuncSeparate(m_stencilFuncTargetFace, GL_ALWAYS, 0, mask);
1525 expectError(GL_NO_ERROR);
1526
1527 m_verifier->verifyInteger(m_testCtx, m_testTargetName, mask);
1528 expectError(GL_NO_ERROR);
1529 }
1530 }
1531 private:
1532 StateVerifier* m_verifier;
1533 GLenum m_testTargetName;
1534 GLenum m_stencilFuncTargetFace;
1535 };
1536
1537 class StencilWriteMaskTestCase : public ApiCase
1538 {
1539 public:
StencilWriteMaskTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName)1540 StencilWriteMaskTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName)
1541 : ApiCase (context, name, description)
1542 , m_verifier (verifier)
1543 , m_testTargetName (testTargetName)
1544 {
1545 }
1546
test(void)1547 void test (void)
1548 {
1549 const int stencilBits = m_context.getRenderTarget().getStencilBits();
1550
1551 for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
1552 {
1553 const int mask = 1 << stencilBit;
1554
1555 glStencilMask(mask);
1556 expectError(GL_NO_ERROR);
1557
1558 m_verifier->verifyInteger(m_testCtx, m_testTargetName, mask);
1559 expectError(GL_NO_ERROR);
1560 }
1561 }
1562 private:
1563 StateVerifier* m_verifier;
1564 GLenum m_testTargetName;
1565 };
1566
1567 class StencilWriteMaskSeparateTestCase : public ApiCase
1568 {
1569 public:
StencilWriteMaskSeparateTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName,GLenum stencilTargetFace)1570 StencilWriteMaskSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, GLenum stencilTargetFace)
1571 : ApiCase (context, name, description)
1572 , m_verifier (verifier)
1573 , m_testTargetName (testTargetName)
1574 , m_stencilTargetFace (stencilTargetFace)
1575 {
1576 }
1577
test(void)1578 void test (void)
1579 {
1580 const int stencilBits = m_context.getRenderTarget().getStencilBits();
1581
1582 for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
1583 {
1584 const int mask = 1 << stencilBit;
1585
1586 glStencilMaskSeparate(m_stencilTargetFace, mask);
1587 expectError(GL_NO_ERROR);
1588
1589 m_verifier->verifyInteger(m_testCtx, m_testTargetName, mask);
1590 expectError(GL_NO_ERROR);
1591 }
1592 }
1593 private:
1594 StateVerifier* m_verifier;
1595 GLenum m_testTargetName;
1596 GLenum m_stencilTargetFace;
1597 };
1598
1599 class PixelStoreTestCase : public ApiCase
1600 {
1601 public:
PixelStoreTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName,int initialValue)1602 PixelStoreTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue)
1603 : ApiCase (context, name, description)
1604 , m_verifier (verifier)
1605 , m_testTargetName (testTargetName)
1606 , m_initialValue (initialValue)
1607 {
1608 }
1609
test(void)1610 void test (void)
1611 {
1612 de::Random rnd(0xabcdef);
1613
1614 m_verifier->verifyInteger(m_testCtx, m_testTargetName, m_initialValue);
1615 expectError(GL_NO_ERROR);
1616
1617 const int numIterations = 120;
1618 for (int i = 0; i < numIterations; ++i)
1619 {
1620 const int referenceValue = rnd.getInt(0, 64000);
1621
1622 glPixelStorei(m_testTargetName, referenceValue);
1623 expectError(GL_NO_ERROR);
1624
1625 m_verifier->verifyInteger(m_testCtx, m_testTargetName, referenceValue);
1626 expectError(GL_NO_ERROR);
1627 }
1628 }
1629
1630 private:
1631 StateVerifier* m_verifier;
1632 GLenum m_testTargetName;
1633 int m_initialValue;
1634 };
1635
1636 class PixelStoreAlignTestCase : public ApiCase
1637 {
1638 public:
PixelStoreAlignTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName)1639 PixelStoreAlignTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName)
1640 : ApiCase (context, name, description)
1641 , m_verifier (verifier)
1642 , m_testTargetName (testTargetName)
1643 {
1644 }
1645
test(void)1646 void test (void)
1647 {
1648 m_verifier->verifyInteger(m_testCtx, m_testTargetName, 4);
1649 expectError(GL_NO_ERROR);
1650
1651 const int alignments[] = {1, 2, 4, 8};
1652
1653 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(alignments); ++ndx)
1654 {
1655 const int referenceValue = alignments[ndx];
1656
1657 glPixelStorei(m_testTargetName, referenceValue);
1658 expectError(GL_NO_ERROR);
1659
1660 m_verifier->verifyInteger(m_testCtx, m_testTargetName, referenceValue);
1661 expectError(GL_NO_ERROR);
1662 }
1663 }
1664
1665 private:
1666 StateVerifier* m_verifier;
1667 GLenum m_testTargetName;
1668 };
1669
1670 class BlendFuncTestCase : public ApiCase
1671 {
1672 public:
BlendFuncTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName,int initialValue)1673 BlendFuncTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue)
1674 : ApiCase (context, name, description)
1675 , m_verifier (verifier)
1676 , m_testTargetName (testTargetName)
1677 , m_initialValue (initialValue)
1678 {
1679 }
1680
test(void)1681 void test (void)
1682 {
1683 m_verifier->verifyInteger(m_testCtx, m_testTargetName, m_initialValue);
1684 expectError(GL_NO_ERROR);
1685
1686 const GLenum blendFuncValues[] =
1687 {
1688 GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR,
1689 GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA, GL_CONSTANT_COLOR,
1690 GL_ONE_MINUS_CONSTANT_COLOR, GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA,
1691 GL_SRC_ALPHA_SATURATE
1692 };
1693
1694 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(blendFuncValues); ++ndx)
1695 {
1696 const GLenum referenceValue = blendFuncValues[ndx];
1697
1698 SetBlendFunc(referenceValue);
1699 expectError(GL_NO_ERROR);
1700
1701 m_verifier->verifyInteger(m_testCtx, m_testTargetName, referenceValue);
1702 expectError(GL_NO_ERROR);
1703 }
1704 }
1705 protected:
SetBlendFunc(GLenum func)1706 virtual void SetBlendFunc (GLenum func)
1707 {
1708 switch (m_testTargetName)
1709 {
1710 case GL_BLEND_SRC_RGB:
1711 case GL_BLEND_SRC_ALPHA:
1712 glBlendFunc(func, GL_ZERO);
1713 break;
1714
1715 case GL_BLEND_DST_RGB:
1716 case GL_BLEND_DST_ALPHA:
1717 glBlendFunc(GL_ZERO, func);
1718 break;
1719
1720 default:
1721 DE_ASSERT(false && "should not happen");
1722 break;
1723 }
1724 }
1725
1726 StateVerifier* m_verifier;
1727 GLenum m_testTargetName;
1728 int m_initialValue;
1729 };
1730
1731 class BlendFuncSeparateTestCase : public BlendFuncTestCase
1732 {
1733 public:
BlendFuncSeparateTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName,int initialValue)1734 BlendFuncSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue)
1735 : BlendFuncTestCase (context, verifier, name, description, testTargetName, initialValue)
1736 {
1737 }
1738
SetBlendFunc(GLenum func)1739 void SetBlendFunc (GLenum func)
1740 {
1741 switch (m_testTargetName)
1742 {
1743 case GL_BLEND_SRC_RGB:
1744 glBlendFuncSeparate(func, GL_ZERO, GL_ZERO, GL_ZERO);
1745 break;
1746
1747 case GL_BLEND_DST_RGB:
1748 glBlendFuncSeparate(GL_ZERO, func, GL_ZERO, GL_ZERO);
1749 break;
1750
1751 case GL_BLEND_SRC_ALPHA:
1752 glBlendFuncSeparate(GL_ZERO, GL_ZERO, func, GL_ZERO);
1753 break;
1754
1755 case GL_BLEND_DST_ALPHA:
1756 glBlendFuncSeparate(GL_ZERO, GL_ZERO, GL_ZERO, func);
1757 break;
1758
1759 default:
1760 DE_ASSERT(false && "should not happen");
1761 break;
1762 }
1763 }
1764 };
1765
1766 class BlendEquationTestCase : public ApiCase
1767 {
1768 public:
BlendEquationTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName,int initialValue)1769 BlendEquationTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue)
1770 : ApiCase (context, name, description)
1771 , m_verifier (verifier)
1772 , m_testTargetName (testTargetName)
1773 , m_initialValue (initialValue)
1774 {
1775 }
1776
test(void)1777 void test (void)
1778 {
1779 m_verifier->verifyInteger(m_testCtx, m_testTargetName, m_initialValue);
1780 expectError(GL_NO_ERROR);
1781
1782 const GLenum blendFuncValues[] =
1783 {
1784 GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT, GL_MIN, GL_MAX
1785 };
1786
1787 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(blendFuncValues); ++ndx)
1788 {
1789 const GLenum referenceValue = blendFuncValues[ndx];
1790
1791 SetBlendEquation(referenceValue);
1792 expectError(GL_NO_ERROR);
1793
1794 m_verifier->verifyInteger(m_testCtx, m_testTargetName, referenceValue);
1795 expectError(GL_NO_ERROR);
1796 }
1797 }
1798 protected:
SetBlendEquation(GLenum equation)1799 virtual void SetBlendEquation (GLenum equation)
1800 {
1801 glBlendEquation(equation);
1802 }
1803
1804 StateVerifier* m_verifier;
1805 GLenum m_testTargetName;
1806 int m_initialValue;
1807 };
1808 class BlendEquationSeparateTestCase : public BlendEquationTestCase
1809 {
1810 public:
BlendEquationSeparateTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName,int initialValue)1811 BlendEquationSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue)
1812 : BlendEquationTestCase (context, verifier, name, description, testTargetName, initialValue)
1813 {
1814 }
1815
1816 protected:
SetBlendEquation(GLenum equation)1817 void SetBlendEquation (GLenum equation)
1818 {
1819 switch (m_testTargetName)
1820 {
1821 case GL_BLEND_EQUATION_RGB:
1822 glBlendEquationSeparate(equation, GL_FUNC_ADD);
1823 break;
1824
1825 case GL_BLEND_EQUATION_ALPHA:
1826 glBlendEquationSeparate(GL_FUNC_ADD, equation);
1827 break;
1828
1829 default:
1830 DE_ASSERT(false && "should not happen");
1831 break;
1832 }
1833 }
1834 };
1835
1836 class ImplementationArrayTestCase : public ApiCase
1837 {
1838 public:
ImplementationArrayTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName,GLenum testTargetLengthTargetName,int minValue)1839 ImplementationArrayTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, GLenum testTargetLengthTargetName, int minValue)
1840 : ApiCase (context, name, description)
1841 , m_verifier (verifier)
1842 , m_testTargetName (testTargetName)
1843 , m_testTargetLengthTargetName (testTargetLengthTargetName)
1844 , m_minValue (minValue)
1845 {
1846 }
1847
test(void)1848 void test (void)
1849 {
1850 m_verifier->verifyIntegerGreaterOrEqual(m_testCtx, m_testTargetLengthTargetName, m_minValue);
1851 expectError(GL_NO_ERROR);
1852
1853 GLint targetArrayLength = 0;
1854 glGetIntegerv(m_testTargetLengthTargetName, &targetArrayLength);
1855 expectError(GL_NO_ERROR);
1856
1857 if (targetArrayLength)
1858 {
1859 std::vector<GLint> queryResult;
1860 queryResult.resize(targetArrayLength, 0);
1861
1862 glGetIntegerv(m_testTargetName, &queryResult[0]);
1863 expectError(GL_NO_ERROR);
1864 }
1865 }
1866
1867 private:
1868 StateVerifier* m_verifier;
1869 GLenum m_testTargetName;
1870 GLenum m_testTargetLengthTargetName;
1871 int m_minValue;
1872 };
1873
1874 class BindingTest : public TestCase
1875 {
1876 public:
1877 BindingTest (Context& context,
1878 const char* name,
1879 const char* desc,
1880 QueryType type);
1881
1882 IterateResult iterate (void);
1883
1884 virtual void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const = 0;
1885
1886 protected:
1887 const QueryType m_type;
1888 };
1889
BindingTest(Context & context,const char * name,const char * desc,QueryType type)1890 BindingTest::BindingTest (Context& context,
1891 const char* name,
1892 const char* desc,
1893 QueryType type)
1894 : TestCase (context, name, desc)
1895 , m_type (type)
1896 {
1897 }
1898
iterate(void)1899 BindingTest::IterateResult BindingTest::iterate (void)
1900 {
1901 glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
1902 tcu::ResultCollector result (m_context.getTestContext().getLog(), " // ERROR: ");
1903
1904 gl.enableLogging(true);
1905
1906 test(gl, result);
1907
1908 result.setTestContextResult(m_testCtx);
1909 return STOP;
1910 }
1911
1912 class TransformFeedbackBindingTestCase : public BindingTest
1913 {
1914 public:
TransformFeedbackBindingTestCase(Context & context,QueryType type,const char * name)1915 TransformFeedbackBindingTestCase (Context& context, QueryType type, const char* name)
1916 : BindingTest(context, name, "GL_TRANSFORM_FEEDBACK_BINDING", type)
1917 {
1918 }
1919
test(glu::CallLogWrapper & gl,tcu::ResultCollector & result) const1920 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
1921 {
1922 static const char* transformFeedbackTestVertSource =
1923 "#version 300 es\n"
1924 "void main (void)\n"
1925 "{\n"
1926 " gl_Position = vec4(0.0);\n"
1927 "}\n\0";
1928 static const char* transformFeedbackTestFragSource =
1929 "#version 300 es\n"
1930 "layout(location = 0) out mediump vec4 fragColor;"
1931 "void main (void)\n"
1932 "{\n"
1933 " fragColor = vec4(0.0);\n"
1934 "}\n\0";
1935
1936 GLuint shaderVert;
1937 GLuint shaderFrag;
1938 GLuint shaderProg;
1939 GLuint transformfeedback = 0;
1940 GLuint feedbackBufferId = 0;
1941
1942 {
1943 const tcu::ScopedLogSection section(gl.getLog(), "Initial", "Initial");
1944 verifyStateInteger(result, gl, GL_TRANSFORM_FEEDBACK_BINDING, 0, m_type);
1945 }
1946
1947 gl.glGenTransformFeedbacks(1, &transformfeedback);
1948 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenTransformFeedbacks");
1949
1950 {
1951 const tcu::ScopedLogSection section(gl.getLog(), "VertexShader", "Vertex Shader");
1952
1953 GLint compileStatus = -1;
1954
1955 shaderVert = gl.glCreateShader(GL_VERTEX_SHADER);
1956 gl.glShaderSource(shaderVert, 1, &transformFeedbackTestVertSource, DE_NULL);
1957 gl.glCompileShader(shaderVert);
1958 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glCompileShader");
1959
1960 gl.glGetShaderiv(shaderVert, GL_COMPILE_STATUS, &compileStatus);
1961 if (compileStatus != GL_TRUE)
1962 result.fail("expected GL_TRUE");
1963 }
1964 {
1965 const tcu::ScopedLogSection section(gl.getLog(), "FragmentShader", "Fragment Shader");
1966
1967 GLint compileStatus = -1;
1968
1969 shaderFrag = gl.glCreateShader(GL_FRAGMENT_SHADER);
1970 gl.glShaderSource(shaderFrag, 1, &transformFeedbackTestFragSource, DE_NULL);
1971 gl.glCompileShader(shaderFrag);
1972 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glCompileShader");
1973
1974 gl.glGetShaderiv(shaderFrag, GL_COMPILE_STATUS, &compileStatus);
1975 if (compileStatus != GL_TRUE)
1976 result.fail("expected GL_TRUE");
1977 }
1978 {
1979 const tcu::ScopedLogSection section(gl.getLog(), "Program", "Create and bind program");
1980
1981 const char* transform_feedback_outputs = "gl_Position";
1982 GLint linkStatus = -1;
1983
1984 shaderProg = gl.glCreateProgram();
1985 gl.glAttachShader(shaderProg, shaderVert);
1986 gl.glAttachShader(shaderProg, shaderFrag);
1987 gl.glTransformFeedbackVaryings(shaderProg, 1, &transform_feedback_outputs, GL_INTERLEAVED_ATTRIBS);
1988 gl.glLinkProgram(shaderProg);
1989 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glLinkProgram");
1990
1991 gl.glGetProgramiv(shaderProg, GL_LINK_STATUS, &linkStatus);
1992 if (linkStatus != GL_TRUE)
1993 result.fail("expected GL_TRUE");
1994 }
1995
1996 gl.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, transformfeedback);
1997 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindTransformFeedback");
1998
1999 gl.glGenBuffers(1, &feedbackBufferId);
2000 gl.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, feedbackBufferId);
2001 gl.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_DYNAMIC_READ);
2002 gl.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, feedbackBufferId);
2003 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "bind buffers");
2004
2005 gl.glUseProgram(shaderProg);
2006
2007 verifyStateInteger(result, gl, GL_TRANSFORM_FEEDBACK_BINDING, transformfeedback, m_type);
2008
2009 gl.glUseProgram(0);
2010 gl.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
2011 gl.glDeleteTransformFeedbacks(1, &transformfeedback);
2012
2013 verifyStateInteger(result, gl, GL_TRANSFORM_FEEDBACK_BINDING, 0, m_type);
2014
2015 gl.glDeleteBuffers(1, &feedbackBufferId);
2016 gl.glDeleteShader(shaderVert);
2017 gl.glDeleteShader(shaderFrag);
2018 gl.glDeleteProgram(shaderProg);
2019 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteProgram");
2020 }
2021 };
2022
2023 class CurrentProgramBindingTestCase : public BindingTest
2024 {
2025 public:
CurrentProgramBindingTestCase(Context & context,QueryType type,const char * name,const char * description)2026 CurrentProgramBindingTestCase (Context& context, QueryType type, const char* name, const char* description)
2027 : BindingTest(context, name, description, type)
2028 {
2029 }
2030
test(glu::CallLogWrapper & gl,tcu::ResultCollector & result) const2031 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
2032 {
2033 static const char* testVertSource =
2034 "#version 300 es\n"
2035 "void main (void)\n"
2036 "{\n"
2037 " gl_Position = vec4(0.0);\n"
2038 "}\n\0";
2039 static const char* testFragSource =
2040 "#version 300 es\n"
2041 "layout(location = 0) out mediump vec4 fragColor;"
2042 "void main (void)\n"
2043 "{\n"
2044 " fragColor = vec4(0.0);\n"
2045 "}\n\0";
2046
2047 GLuint shaderVert;
2048 GLuint shaderFrag;
2049 GLuint shaderProg;
2050
2051 {
2052 const tcu::ScopedLogSection section(gl.getLog(), "Initial", "Initial");
2053
2054 verifyStateInteger(result, gl, GL_CURRENT_PROGRAM, 0, m_type);
2055 }
2056 {
2057 const tcu::ScopedLogSection section(gl.getLog(), "VertexShader", "Vertex Shader");
2058
2059 GLint compileStatus = -1;
2060
2061 shaderVert = gl.glCreateShader(GL_VERTEX_SHADER);
2062 gl.glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
2063 gl.glCompileShader(shaderVert);
2064 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glCompileShader");
2065
2066 gl.glGetShaderiv(shaderVert, GL_COMPILE_STATUS, &compileStatus);
2067 if (compileStatus != GL_TRUE)
2068 result.fail("expected GL_TRUE");
2069 }
2070 {
2071 const tcu::ScopedLogSection section(gl.getLog(), "FragmentShader", "Fragment Shader");
2072
2073 GLint compileStatus = -1;
2074
2075 shaderFrag = gl.glCreateShader(GL_FRAGMENT_SHADER);
2076 gl.glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
2077 gl.glCompileShader(shaderFrag);
2078 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glCompileShader");
2079
2080 gl.glGetShaderiv(shaderFrag, GL_COMPILE_STATUS, &compileStatus);
2081 if (compileStatus != GL_TRUE)
2082 result.fail("expected GL_TRUE");
2083 }
2084 {
2085 const tcu::ScopedLogSection section(gl.getLog(), "Program", "Create and bind program");
2086
2087 GLint linkStatus = -1;
2088
2089 shaderProg = gl.glCreateProgram();
2090 gl.glAttachShader(shaderProg, shaderVert);
2091 gl.glAttachShader(shaderProg, shaderFrag);
2092 gl.glLinkProgram(shaderProg);
2093 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glLinkProgram");
2094
2095 gl.glGetProgramiv(shaderProg, GL_LINK_STATUS, &linkStatus);
2096 if (linkStatus != GL_TRUE)
2097 result.fail("expected GL_TRUE");
2098
2099 gl.glUseProgram(shaderProg);
2100 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glUseProgram");
2101
2102 verifyStateInteger(result, gl, GL_CURRENT_PROGRAM, shaderProg, m_type);
2103 }
2104 {
2105 const tcu::ScopedLogSection section(gl.getLog(), "Delete", "Delete program while in use");
2106
2107 gl.glDeleteShader(shaderVert);
2108 gl.glDeleteShader(shaderFrag);
2109 gl.glDeleteProgram(shaderProg);
2110 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteProgram");
2111
2112 verifyStateInteger(result, gl, GL_CURRENT_PROGRAM, shaderProg, m_type);
2113 }
2114 {
2115 const tcu::ScopedLogSection section(gl.getLog(), "Unbind", "Unbind program");
2116 gl.glUseProgram(0);
2117 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glUseProgram");
2118
2119 verifyStateInteger(result, gl, GL_CURRENT_PROGRAM, 0, m_type);
2120 }
2121 }
2122 };
2123
2124 class VertexArrayBindingTestCase : public BindingTest
2125 {
2126 public:
VertexArrayBindingTestCase(Context & context,QueryType type,const char * name,const char * description)2127 VertexArrayBindingTestCase (Context& context, QueryType type, const char* name, const char* description)
2128 : BindingTest(context, name, description, type)
2129 {
2130 }
2131
test(glu::CallLogWrapper & gl,tcu::ResultCollector & result) const2132 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
2133 {
2134 verifyStateInteger(result, gl, GL_VERTEX_ARRAY_BINDING, 0, m_type);
2135
2136 GLuint vertexArrayObject = 0;
2137 gl.glGenVertexArrays(1, &vertexArrayObject);
2138 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenVertexArrays");
2139
2140 gl.glBindVertexArray(vertexArrayObject);
2141 verifyStateInteger(result, gl, GL_VERTEX_ARRAY_BINDING, vertexArrayObject, m_type);
2142
2143 gl.glDeleteVertexArrays(1, &vertexArrayObject);
2144 verifyStateInteger(result, gl, GL_VERTEX_ARRAY_BINDING, 0, m_type);
2145 }
2146 };
2147
2148 class BufferBindingTestCase : public BindingTest
2149 {
2150 public:
BufferBindingTestCase(Context & context,QueryType type,const char * name,const char * description,GLenum bufferBindingName,GLenum bufferType)2151 BufferBindingTestCase (Context& context, QueryType type, const char* name, const char* description, GLenum bufferBindingName, GLenum bufferType)
2152 : BindingTest (context, name, description, type)
2153 , m_bufferBindingName (bufferBindingName)
2154 , m_bufferType (bufferType)
2155 {
2156 }
2157
test(glu::CallLogWrapper & gl,tcu::ResultCollector & result) const2158 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
2159 {
2160 verifyStateInteger(result, gl, m_bufferBindingName, 0, m_type);
2161
2162 GLuint bufferObject = 0;
2163 gl.glGenBuffers(1, &bufferObject);
2164 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenBuffers");
2165
2166 gl.glBindBuffer(m_bufferType, bufferObject);
2167 verifyStateInteger(result, gl, m_bufferBindingName, bufferObject, m_type);
2168
2169 gl.glDeleteBuffers(1, &bufferObject);
2170 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteBuffers");
2171
2172 verifyStateInteger(result, gl, m_bufferBindingName, 0, m_type);
2173 }
2174
2175 private:
2176 const GLenum m_bufferBindingName;
2177 const GLenum m_bufferType;
2178 };
2179
2180 class ElementArrayBufferBindingTestCase : public BindingTest
2181 {
2182 public:
ElementArrayBufferBindingTestCase(Context & context,QueryType type,const char * name)2183 ElementArrayBufferBindingTestCase (Context& context, QueryType type, const char* name)
2184 : BindingTest(context, name, "GL_ELEMENT_ARRAY_BUFFER_BINDING", type)
2185 {
2186 }
2187
test(glu::CallLogWrapper & gl,tcu::ResultCollector & result) const2188 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
2189 {
2190 // Test with default VAO
2191 {
2192 const tcu::ScopedLogSection section(gl.getLog(), "DefaultVAO", "Test with default VAO");
2193
2194 verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, 0, m_type);
2195
2196 GLuint bufferObject = 0;
2197 gl.glGenBuffers(1, &bufferObject);
2198 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenBuffers");
2199
2200 gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObject);
2201 verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, bufferObject, m_type);
2202
2203 gl.glDeleteBuffers(1, &bufferObject);
2204 verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, 0, m_type);
2205 }
2206
2207 // Test with multiple VAOs
2208 {
2209 const tcu::ScopedLogSection section(gl.getLog(), "WithVAO", "Test with VAO");
2210
2211 GLuint vaos[2] = {0};
2212 GLuint buffers[2] = {0};
2213
2214 gl.glGenVertexArrays(2, vaos);
2215 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenVertexArrays");
2216
2217 gl.glGenBuffers(2, buffers);
2218 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenBuffers");
2219
2220 // initial
2221 gl.glBindVertexArray(vaos[0]);
2222 verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, 0, m_type);
2223
2224 // after setting
2225 gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[0]);
2226 verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, buffers[0], m_type);
2227
2228 // initial of vao 2
2229 gl.glBindVertexArray(vaos[1]);
2230 verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, 0, m_type);
2231
2232 // after setting to 2
2233 gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[1]);
2234 verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, buffers[1], m_type);
2235
2236 // vao 1 still has buffer 1 bound?
2237 gl.glBindVertexArray(vaos[0]);
2238 verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, buffers[0], m_type);
2239
2240 // deleting clears from bound vaos ...
2241 gl.glDeleteBuffers(2, buffers);
2242 verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, 0, m_type);
2243
2244 // ... but does not from non-bound vaos?
2245 gl.glBindVertexArray(vaos[1]);
2246 verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, buffers[1], m_type);
2247
2248 gl.glDeleteVertexArrays(2, vaos);
2249 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteVertexArrays");
2250 }
2251 }
2252 };
2253
2254 class StencilClearValueTestCase : public ApiCase
2255 {
2256 public:
StencilClearValueTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)2257 StencilClearValueTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
2258 : ApiCase (context, name, description)
2259 , m_verifier (verifier)
2260 {
2261 }
2262
test(void)2263 void test (void)
2264 {
2265 m_verifier->verifyInteger(m_testCtx, GL_STENCIL_CLEAR_VALUE, 0);
2266 expectError(GL_NO_ERROR);
2267
2268 const int stencilBits = m_context.getRenderTarget().getStencilBits();
2269
2270 for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
2271 {
2272 const int ref = 1 << stencilBit;
2273
2274 glClearStencil(ref); // mask should not affect the REF
2275 expectError(GL_NO_ERROR);
2276
2277 m_verifier->verifyInteger(m_testCtx, GL_STENCIL_CLEAR_VALUE, ref);
2278 expectError(GL_NO_ERROR);
2279 }
2280 }
2281
2282 private:
2283 StateVerifier* m_verifier;
2284 };
2285
2286 class ActiveTextureTestCase : public ApiCase
2287 {
2288 public:
ActiveTextureTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)2289 ActiveTextureTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
2290 : ApiCase (context, name, description)
2291 , m_verifier (verifier)
2292 {
2293 }
2294
test(void)2295 void test (void)
2296 {
2297 m_verifier->verifyInteger(m_testCtx, GL_ACTIVE_TEXTURE, GL_TEXTURE0);
2298 expectError(GL_NO_ERROR);
2299
2300 GLint textureUnits = 0;
2301 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &textureUnits);
2302 expectError(GL_NO_ERROR);
2303
2304 for (int ndx = 0; ndx < textureUnits; ++ndx)
2305 {
2306 glActiveTexture(GL_TEXTURE0 + ndx);
2307 expectError(GL_NO_ERROR);
2308
2309 m_verifier->verifyInteger(m_testCtx, GL_ACTIVE_TEXTURE, GL_TEXTURE0 + ndx);
2310 expectError(GL_NO_ERROR);
2311 }
2312 }
2313
2314 private:
2315 StateVerifier* m_verifier;
2316 };
2317
2318 class RenderbufferBindingTestCase : public BindingTest
2319 {
2320 public:
RenderbufferBindingTestCase(Context & context,QueryType type,const char * name,const char * description)2321 RenderbufferBindingTestCase (Context& context, QueryType type, const char* name, const char* description)
2322 : BindingTest(context, name, description, type)
2323 {
2324 }
2325
test(glu::CallLogWrapper & gl,tcu::ResultCollector & result) const2326 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
2327 {
2328 verifyStateInteger(result, gl, GL_RENDERBUFFER_BINDING, 0, m_type);
2329
2330 GLuint renderBuffer = 0;
2331 gl.glGenRenderbuffers(1, &renderBuffer);
2332 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenRenderbuffers");
2333
2334 gl.glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer);
2335 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindRenderbuffer");
2336
2337 verifyStateInteger(result, gl, GL_RENDERBUFFER_BINDING, renderBuffer, m_type);
2338
2339 gl.glDeleteRenderbuffers(1, &renderBuffer);
2340 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteRenderbuffers");
2341
2342 verifyStateInteger(result, gl, GL_RENDERBUFFER_BINDING, 0, m_type);
2343 }
2344 };
2345
2346 class SamplerObjectBindingTestCase : public BindingTest
2347 {
2348 public:
SamplerObjectBindingTestCase(Context & context,QueryType type,const char * name,const char * description)2349 SamplerObjectBindingTestCase (Context& context, QueryType type, const char* name, const char* description)
2350 : BindingTest(context, name, description, type)
2351 {
2352 }
2353
test(glu::CallLogWrapper & gl,tcu::ResultCollector & result) const2354 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
2355 {
2356 verifyStateInteger(result, gl, GL_SAMPLER_BINDING, 0, m_type);
2357
2358 {
2359 const tcu::ScopedLogSection section(gl.getLog(), "SingleUnit", "Single unit");
2360
2361 GLuint sampler = 0;
2362 gl.glGenSamplers(1, &sampler);
2363 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenSamplers");
2364
2365 gl.glBindSampler(0, sampler);
2366 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindSampler");
2367
2368 verifyStateInteger(result, gl, GL_SAMPLER_BINDING, sampler, m_type);
2369
2370 gl.glDeleteSamplers(1, &sampler);
2371 verifyStateInteger(result, gl, GL_SAMPLER_BINDING, 0, m_type);
2372 }
2373
2374 {
2375 const tcu::ScopedLogSection section(gl.getLog(), "MultipleUnits", "Multiple units");
2376
2377 GLuint samplerA = 0;
2378 GLuint samplerB = 0;
2379 gl.glGenSamplers(1, &samplerA);
2380 gl.glGenSamplers(1, &samplerB);
2381 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenSamplers");
2382
2383 gl.glBindSampler(1, samplerA);
2384 gl.glBindSampler(2, samplerB);
2385 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindSampler");
2386
2387 verifyStateInteger(result, gl, GL_SAMPLER_BINDING, 0, m_type);
2388
2389 gl.glActiveTexture(GL_TEXTURE1);
2390 verifyStateInteger(result, gl, GL_SAMPLER_BINDING, samplerA, m_type);
2391
2392 gl.glActiveTexture(GL_TEXTURE2);
2393 verifyStateInteger(result, gl, GL_SAMPLER_BINDING, samplerB, m_type);
2394
2395 gl.glDeleteSamplers(1, &samplerB);
2396 gl.glDeleteSamplers(1, &samplerA);
2397 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteSamplers");
2398 }
2399 }
2400 };
2401
2402 class TextureBindingTestCase : public BindingTest
2403 {
2404 public:
TextureBindingTestCase(Context & context,QueryType type,const char * name,const char * description,GLenum testBindingName,GLenum textureType)2405 TextureBindingTestCase (Context& context, QueryType type, const char* name, const char* description, GLenum testBindingName, GLenum textureType)
2406 : BindingTest (context, name, description, type)
2407 , m_testBindingName (testBindingName)
2408 , m_textureType (textureType)
2409 {
2410 }
2411
test(glu::CallLogWrapper & gl,tcu::ResultCollector & result) const2412 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
2413 {
2414 verifyStateInteger(result, gl, m_testBindingName, 0, m_type);
2415
2416 GLuint texture = 0;
2417 gl.glGenTextures(1, &texture);
2418 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenTextures");
2419
2420 gl.glBindTexture(m_textureType, texture);
2421 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindTexture");
2422
2423 verifyStateInteger(result, gl, m_testBindingName, texture, m_type);
2424
2425 gl.glDeleteTextures(1, &texture);
2426 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteTextures");
2427
2428 verifyStateInteger(result, gl, m_testBindingName, 0, m_type);
2429 }
2430 private:
2431 const GLenum m_testBindingName;
2432 const GLenum m_textureType;
2433 };
2434
2435 class FrameBufferBindingTestCase : public BindingTest
2436 {
2437 public:
FrameBufferBindingTestCase(Context & context,QueryType type,const char * name,const char * description)2438 FrameBufferBindingTestCase (Context& context, QueryType type, const char* name, const char* description)
2439 : BindingTest(context, name, description, type)
2440 {
2441 }
2442
test(glu::CallLogWrapper & gl,tcu::ResultCollector & result) const2443 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
2444 {
2445 verifyStateInteger(result, gl, GL_DRAW_FRAMEBUFFER_BINDING, 0, m_type);
2446 verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING, 0, m_type);
2447 verifyStateInteger(result, gl, GL_READ_FRAMEBUFFER_BINDING, 0, m_type);
2448
2449 GLuint framebufferId = 0;
2450 gl.glGenFramebuffers(1, &framebufferId);
2451 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenFramebuffers");
2452
2453 gl.glBindFramebuffer(GL_FRAMEBUFFER, framebufferId);
2454 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "bind GL_FRAMEBUFFER");
2455
2456 verifyStateInteger(result, gl, GL_DRAW_FRAMEBUFFER_BINDING, framebufferId, m_type);
2457 verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING, framebufferId, m_type);
2458 verifyStateInteger(result, gl, GL_READ_FRAMEBUFFER_BINDING, framebufferId, m_type);
2459
2460 gl.glBindFramebuffer(GL_FRAMEBUFFER, 0);
2461 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "unbind GL_FRAMEBUFFER");
2462
2463 verifyStateInteger(result, gl, GL_DRAW_FRAMEBUFFER_BINDING, 0, m_type);
2464 verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING, 0, m_type);
2465 verifyStateInteger(result, gl, GL_READ_FRAMEBUFFER_BINDING, 0, m_type);
2466
2467 gl.glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferId);
2468 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "bind GL_READ_FRAMEBUFFER");
2469
2470 verifyStateInteger(result, gl, GL_DRAW_FRAMEBUFFER_BINDING, 0, m_type);
2471 verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING, 0, m_type);
2472 verifyStateInteger(result, gl, GL_READ_FRAMEBUFFER_BINDING, framebufferId, m_type);
2473
2474 gl.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebufferId);
2475 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "bind GL_DRAW_FRAMEBUFFER");
2476
2477 verifyStateInteger(result, gl, GL_DRAW_FRAMEBUFFER_BINDING, framebufferId, m_type);
2478 verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING, framebufferId, m_type);
2479 verifyStateInteger(result, gl, GL_READ_FRAMEBUFFER_BINDING, framebufferId, m_type);
2480
2481 gl.glDeleteFramebuffers(1, &framebufferId);
2482 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteFramebuffers");
2483
2484 verifyStateInteger(result, gl, GL_DRAW_FRAMEBUFFER_BINDING, 0, m_type);
2485 verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING, 0, m_type);
2486 verifyStateInteger(result, gl, GL_READ_FRAMEBUFFER_BINDING, 0, m_type);
2487 }
2488 };
2489
2490 class ImplementationColorReadTestCase : public ApiCase
2491 {
2492 public:
ImplementationColorReadTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)2493 ImplementationColorReadTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
2494 : ApiCase (context, name, description)
2495 , m_verifier (verifier)
2496 {
2497 }
2498
test(void)2499 void test (void)
2500 {
2501 const GLint defaultColorTypes[] =
2502 {
2503 GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT,
2504 GL_UNSIGNED_INT, GL_INT, GL_HALF_FLOAT, GL_FLOAT, GL_UNSIGNED_SHORT_5_6_5,
2505 GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_5_5_5_1,
2506 GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT_10F_11F_11F_REV
2507 };
2508 const GLint defaultColorFormats[] =
2509 {
2510 GL_RGBA, GL_RGBA_INTEGER, GL_RGB, GL_RGB_INTEGER,
2511 GL_RG, GL_RG_INTEGER, GL_RED, GL_RED_INTEGER
2512 };
2513
2514 std::vector<GLint> validColorTypes;
2515 std::vector<GLint> validColorFormats;
2516
2517 // Defined by the spec
2518
2519 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(defaultColorTypes); ++ndx)
2520 validColorTypes.push_back(defaultColorTypes[ndx]);
2521 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(defaultColorFormats); ++ndx)
2522 validColorFormats.push_back(defaultColorFormats[ndx]);
2523
2524 // Extensions
2525
2526 if (m_context.getContextInfo().isExtensionSupported("GL_EXT_texture_format_BGRA8888") ||
2527 m_context.getContextInfo().isExtensionSupported("GL_APPLE_texture_format_BGRA8888"))
2528 validColorFormats.push_back(GL_BGRA);
2529
2530 if (m_context.getContextInfo().isExtensionSupported("GL_EXT_read_format_bgra"))
2531 {
2532 validColorFormats.push_back(GL_BGRA);
2533 validColorTypes.push_back(GL_UNSIGNED_SHORT_4_4_4_4_REV);
2534 validColorTypes.push_back(GL_UNSIGNED_SHORT_1_5_5_5_REV);
2535 }
2536
2537 if (m_context.getContextInfo().isExtensionSupported("GL_IMG_read_format"))
2538 {
2539 validColorFormats.push_back(GL_BGRA);
2540 validColorTypes.push_back(GL_UNSIGNED_SHORT_4_4_4_4_REV);
2541 }
2542
2543 if (m_context.getContextInfo().isExtensionSupported("GL_NV_sRGB_formats"))
2544 {
2545 validColorFormats.push_back(GL_SLUMINANCE_NV);
2546 validColorFormats.push_back(GL_SLUMINANCE_ALPHA_NV);
2547 }
2548
2549 if (m_context.getContextInfo().isExtensionSupported("GL_NV_bgr"))
2550 {
2551 validColorFormats.push_back(GL_BGR_NV);
2552 }
2553
2554 m_verifier->verifyIntegerAnyOf(m_testCtx, GL_IMPLEMENTATION_COLOR_READ_TYPE, &validColorTypes[0], validColorTypes.size());
2555 m_verifier->verifyIntegerAnyOf(m_testCtx, GL_IMPLEMENTATION_COLOR_READ_FORMAT, &validColorFormats[0], validColorFormats.size());
2556 expectError(GL_NO_ERROR);
2557 }
2558
2559 private:
2560 StateVerifier* m_verifier;
2561 };
2562
2563 class ReadBufferCase : public ApiCase
2564 {
2565 public:
ReadBufferCase(Context & context,StateVerifier * verifier,const char * name,const char * description)2566 ReadBufferCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
2567 : ApiCase (context, name, description)
2568 , m_verifier (verifier)
2569 {
2570 }
2571
test(void)2572 void test (void)
2573 {
2574 const GLint validInitialValues[] = {GL_BACK, GL_NONE};
2575 m_verifier->verifyIntegerAnyOf(m_testCtx, GL_READ_BUFFER, validInitialValues, DE_LENGTH_OF_ARRAY(validInitialValues));
2576 expectError(GL_NO_ERROR);
2577
2578 glReadBuffer(GL_NONE);
2579 m_verifier->verifyInteger(m_testCtx, GL_READ_BUFFER, GL_NONE);
2580 expectError(GL_NO_ERROR);
2581
2582 glReadBuffer(GL_BACK);
2583 m_verifier->verifyInteger(m_testCtx, GL_READ_BUFFER, GL_BACK);
2584 expectError(GL_NO_ERROR);
2585
2586 // test GL_READ_BUFFER with framebuffers
2587
2588 GLuint framebufferId = 0;
2589 glGenFramebuffers(1, &framebufferId);
2590 expectError(GL_NO_ERROR);
2591
2592 GLuint renderbuffer_id = 0;
2593 glGenRenderbuffers(1, &renderbuffer_id);
2594 expectError(GL_NO_ERROR);
2595
2596 glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer_id);
2597 expectError(GL_NO_ERROR);
2598
2599 glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 128, 128);
2600 expectError(GL_NO_ERROR);
2601
2602 glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferId);
2603 expectError(GL_NO_ERROR);
2604
2605 glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbuffer_id);
2606 expectError(GL_NO_ERROR);
2607
2608 m_verifier->verifyInteger(m_testCtx, GL_READ_BUFFER, GL_COLOR_ATTACHMENT0);
2609
2610 glDeleteFramebuffers(1, &framebufferId);
2611 glDeleteRenderbuffers(1, &renderbuffer_id);
2612 expectError(GL_NO_ERROR);
2613
2614 m_verifier->verifyInteger(m_testCtx, GL_READ_BUFFER, GL_BACK);
2615 expectError(GL_NO_ERROR);
2616 }
2617 private:
2618 StateVerifier* m_verifier;
2619 };
2620
2621 class DrawBufferCase : public ApiCase
2622 {
2623 public:
DrawBufferCase(Context & context,StateVerifier * verifier,const char * name,const char * description)2624 DrawBufferCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
2625 : ApiCase (context, name, description)
2626 , m_verifier (verifier)
2627 {
2628 }
2629
test(void)2630 void test (void)
2631 {
2632 const GLint validInitialValues[] = {GL_BACK, GL_NONE};
2633 m_verifier->verifyIntegerAnyOf(m_testCtx, GL_DRAW_BUFFER0, validInitialValues, DE_LENGTH_OF_ARRAY(validInitialValues));
2634 expectError(GL_NO_ERROR);
2635
2636 GLenum bufs = GL_NONE;
2637 glDrawBuffers(1, &bufs);
2638 m_verifier->verifyInteger(m_testCtx, GL_DRAW_BUFFER0, GL_NONE);
2639 expectError(GL_NO_ERROR);
2640
2641 bufs = GL_BACK;
2642 glDrawBuffers(1, &bufs);
2643 m_verifier->verifyInteger(m_testCtx, GL_DRAW_BUFFER0, GL_BACK);
2644 expectError(GL_NO_ERROR);
2645
2646 // test GL_DRAW_BUFFER with framebuffers
2647
2648 GLuint framebufferId = 0;
2649 glGenFramebuffers(1, &framebufferId);
2650 expectError(GL_NO_ERROR);
2651
2652 GLuint renderbuffer_ids[2] = {0};
2653 glGenRenderbuffers(2, renderbuffer_ids);
2654 expectError(GL_NO_ERROR);
2655
2656 glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer_ids[0]);
2657 expectError(GL_NO_ERROR);
2658 glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 128, 128);
2659 expectError(GL_NO_ERROR);
2660
2661 glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer_ids[1]);
2662 expectError(GL_NO_ERROR);
2663 glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 128, 128);
2664 expectError(GL_NO_ERROR);
2665
2666 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebufferId);
2667 expectError(GL_NO_ERROR);
2668
2669 glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbuffer_ids[0]);
2670 expectError(GL_NO_ERROR);
2671 glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_RENDERBUFFER, renderbuffer_ids[1]);
2672 expectError(GL_NO_ERROR);
2673
2674 // only the initial state the draw buffer for fragment color zero is defined
2675 m_verifier->verifyInteger(m_testCtx, GL_DRAW_BUFFER0, GL_COLOR_ATTACHMENT0);
2676
2677 GLenum bufTargets[2] = {GL_NONE, GL_COLOR_ATTACHMENT1};
2678 glDrawBuffers(2, bufTargets);
2679 m_verifier->verifyInteger(m_testCtx, GL_DRAW_BUFFER0, GL_NONE);
2680 m_verifier->verifyInteger(m_testCtx, GL_DRAW_BUFFER1, GL_COLOR_ATTACHMENT1);
2681
2682 glDeleteFramebuffers(1, &framebufferId);
2683 glDeleteRenderbuffers(2, renderbuffer_ids);
2684 expectError(GL_NO_ERROR);
2685
2686 m_verifier->verifyInteger(m_testCtx, GL_DRAW_BUFFER0, GL_BACK);
2687 expectError(GL_NO_ERROR);
2688 }
2689 private:
2690 StateVerifier* m_verifier;
2691 };
2692
getQueryTypeSuffix(QueryType type)2693 static const char* getQueryTypeSuffix (QueryType type)
2694 {
2695 switch (type)
2696 {
2697 case QUERY_BOOLEAN: return "_getboolean";
2698 case QUERY_INTEGER: return "_getinteger";
2699 case QUERY_INTEGER64: return "_getinteger64";
2700 case QUERY_FLOAT: return "_getfloat";
2701 default:
2702 DE_ASSERT(DE_FALSE);
2703 return DE_NULL;
2704 }
2705 }
2706
2707 #define FOR_EACH_VERIFIER(VERIFIERS, CODE_BLOCK) \
2708 for (int _verifierNdx = 0; _verifierNdx < DE_LENGTH_OF_ARRAY(VERIFIERS); _verifierNdx++) \
2709 { \
2710 StateVerifier* verifier = VERIFIERS[_verifierNdx]; \
2711 CODE_BLOCK; \
2712 }
2713
2714 #define FOR_EACH_QUERYTYPE(QUERYTYPES, CODE_BLOCK) \
2715 for (int _queryTypeNdx = 0; _queryTypeNdx < DE_LENGTH_OF_ARRAY(QUERYTYPES); _queryTypeNdx++) \
2716 { \
2717 const QueryType queryType = QUERYTYPES[_queryTypeNdx]; \
2718 CODE_BLOCK; \
2719 }
2720
2721 } // anonymous
2722
IntegerStateQueryTests(Context & context)2723 IntegerStateQueryTests::IntegerStateQueryTests (Context& context)
2724 : TestCaseGroup (context, "integers", "Integer Values")
2725 , m_verifierBoolean (DE_NULL)
2726 , m_verifierInteger (DE_NULL)
2727 , m_verifierInteger64 (DE_NULL)
2728 , m_verifierFloat (DE_NULL)
2729 {
2730 }
2731
~IntegerStateQueryTests(void)2732 IntegerStateQueryTests::~IntegerStateQueryTests (void)
2733 {
2734 deinit();
2735 }
2736
init(void)2737 void IntegerStateQueryTests::init (void)
2738 {
2739 static const QueryType queryTypes[] =
2740 {
2741 QUERY_BOOLEAN,
2742 QUERY_INTEGER,
2743 QUERY_INTEGER64,
2744 QUERY_FLOAT,
2745 };
2746
2747 DE_ASSERT(m_verifierBoolean == DE_NULL);
2748 DE_ASSERT(m_verifierInteger == DE_NULL);
2749 DE_ASSERT(m_verifierInteger64 == DE_NULL);
2750 DE_ASSERT(m_verifierFloat == DE_NULL);
2751
2752 m_verifierBoolean = new GetBooleanVerifier (m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
2753 m_verifierInteger = new GetIntegerVerifier (m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
2754 m_verifierInteger64 = new GetInteger64Verifier (m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
2755 m_verifierFloat = new GetFloatVerifier (m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
2756
2757 const struct LimitedStateInteger
2758 {
2759 const char* name;
2760 const char* description;
2761 GLenum targetName;
2762 GLint value;
2763 } implementationMinLimits[] =
2764 {
2765 { "subpixel_bits", "SUBPIXEL_BITS has minimum value of 4", GL_SUBPIXEL_BITS, 4 },
2766 { "max_3d_texture_size", "MAX_3D_TEXTURE_SIZE has minimum value of 256", GL_MAX_3D_TEXTURE_SIZE, 256 },
2767 { "max_texture_size", "MAX_TEXTURE_SIZE has minimum value of 2048", GL_MAX_TEXTURE_SIZE, 2048},
2768 { "max_array_texture_layers", "MAX_ARRAY_TEXTURE_LAYERS has minimum value of 256", GL_MAX_ARRAY_TEXTURE_LAYERS, 256 },
2769 { "max_cube_map_texture_size", "MAX_CUBE_MAP_TEXTURE_SIZE has minimum value of 2048", GL_MAX_CUBE_MAP_TEXTURE_SIZE, 2048},
2770 { "max_renderbuffer_size", "MAX_RENDERBUFFER_SIZE has minimum value of 2048", GL_MAX_RENDERBUFFER_SIZE, 2048},
2771 { "max_draw_buffers", "MAX_DRAW_BUFFERS has minimum value of 4", GL_MAX_DRAW_BUFFERS, 4 },
2772 { "max_color_attachments", "MAX_COLOR_ATTACHMENTS has minimum value of 4", GL_MAX_COLOR_ATTACHMENTS, 4 },
2773 { "max_elements_indices", "MAX_ELEMENTS_INDICES has minimum value of 0", GL_MAX_ELEMENTS_INDICES, 0 },
2774 { "max_elements_vertices", "MAX_ELEMENTS_VERTICES has minimum value of 0", GL_MAX_ELEMENTS_VERTICES, 0 },
2775 { "num_extensions", "NUM_EXTENSIONS has minimum value of 0", GL_NUM_EXTENSIONS, 0 },
2776 { "major_version", "MAJOR_VERSION has minimum value of 3", GL_MAJOR_VERSION, 3 },
2777 { "minor_version", "MINOR_VERSION has minimum value of 0", GL_MINOR_VERSION, 0 },
2778 { "max_vertex_attribs", "MAX_VERTEX_ATTRIBS has minimum value of 16", GL_MAX_VERTEX_ATTRIBS, 16 },
2779 { "max_vertex_uniform_components", "MAX_VERTEX_UNIFORM_COMPONENTS has minimum value of 1024", GL_MAX_VERTEX_UNIFORM_COMPONENTS, 1024},
2780 { "max_vertex_uniform_vectors", "MAX_VERTEX_UNIFORM_VECTORS has minimum value of 256", GL_MAX_VERTEX_UNIFORM_VECTORS, 256 },
2781 { "max_vertex_uniform_blocks", "MAX_VERTEX_UNIFORM_BLOCKS has minimum value of 12", GL_MAX_VERTEX_UNIFORM_BLOCKS, 12 },
2782 { "max_vertex_output_components", "MAX_VERTEX_OUTPUT_COMPONENTS has minimum value of 64", GL_MAX_VERTEX_OUTPUT_COMPONENTS, 64 },
2783 { "max_vertex_texture_image_units", "MAX_VERTEX_TEXTURE_IMAGE_UNITS has minimum value of 16", GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, 16 },
2784 { "max_fragment_uniform_components", "MAX_FRAGMENT_UNIFORM_COMPONENTS has minimum value of 896", GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, 896 },
2785 { "max_fragment_uniform_vectors", "MAX_FRAGMENT_UNIFORM_VECTORS has minimum value of 224", GL_MAX_FRAGMENT_UNIFORM_VECTORS, 224 },
2786 { "max_fragment_uniform_blocks", "MAX_FRAGMENT_UNIFORM_BLOCKS has minimum value of 12", GL_MAX_FRAGMENT_UNIFORM_BLOCKS, 12 },
2787 { "max_fragment_input_components", "MAX_FRAGMENT_INPUT_COMPONENTS has minimum value of 60", GL_MAX_FRAGMENT_INPUT_COMPONENTS, 60 },
2788 { "max_texture_image_units", "MAX_TEXTURE_IMAGE_UNITS has minimum value of 16", GL_MAX_TEXTURE_IMAGE_UNITS, 16 },
2789 { "max_program_texel_offset", "MAX_PROGRAM_TEXEL_OFFSET has minimum value of 7", GL_MAX_PROGRAM_TEXEL_OFFSET, 7 },
2790 { "max_uniform_buffer_bindings", "MAX_UNIFORM_BUFFER_BINDINGS has minimum value of 24", GL_MAX_UNIFORM_BUFFER_BINDINGS, 24 },
2791 { "max_combined_uniform_blocks", "MAX_COMBINED_UNIFORM_BLOCKS has minimum value of 24", GL_MAX_COMBINED_UNIFORM_BLOCKS, 24 },
2792 { "max_varying_components", "MAX_VARYING_COMPONENTS has minimum value of 60", GL_MAX_VARYING_COMPONENTS, 60 },
2793 { "max_varying_vectors", "MAX_VARYING_VECTORS has minimum value of 15", GL_MAX_VARYING_VECTORS, 15 },
2794 { "max_combined_texture_image_units", "MAX_COMBINED_TEXTURE_IMAGE_UNITS has minimum value of 32", GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, 32 },
2795 { "max_transform_feedback_interleaved_components", "MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS has minimum value of 64", GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, 64 },
2796 { "max_transform_feedback_separate_attribs", "MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS has minimum value of 4", GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, 4 },
2797 { "max_transform_feedback_separate_components", "MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS has minimum value of 4", GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS, 4 },
2798 { "max_samples", "MAX_SAMPLES has minimum value of 4", GL_MAX_SAMPLES, 4 },
2799 { "red_bits", "RED_BITS has minimum value of 0", GL_RED_BITS, 0 },
2800 { "green_bits", "GREEN_BITS has minimum value of 0", GL_GREEN_BITS, 0 },
2801 { "blue_bits", "BLUE_BITS has minimum value of 0", GL_BLUE_BITS, 0 },
2802 { "alpha_bits", "ALPHA_BITS has minimum value of 0", GL_ALPHA_BITS, 0 },
2803 { "depth_bits", "DEPTH_BITS has minimum value of 0", GL_DEPTH_BITS, 0 },
2804 { "stencil_bits", "STENCIL_BITS has minimum value of 0", GL_STENCIL_BITS, 0 },
2805 };
2806 const LimitedStateInteger implementationMaxLimits[] =
2807 {
2808 { "min_program_texel_offset", "MIN_PROGRAM_TEXEL_OFFSET has maximum value of -8", GL_MIN_PROGRAM_TEXEL_OFFSET, -8 },
2809 { "uniform_buffer_offset_alignment", "UNIFORM_BUFFER_OFFSET_ALIGNMENT has minimum value of 1", GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, 256 },
2810 };
2811
2812 // \note implementation defined limits have their own tests so just check the conversions to boolean, int64 and float
2813 StateVerifier* implementationLimitVerifiers[] = {m_verifierBoolean, m_verifierInteger64, m_verifierFloat};
2814
2815 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(implementationMinLimits); testNdx++)
2816 FOR_EACH_VERIFIER(implementationLimitVerifiers, addChild(new ConstantMinimumValueTestCase(m_context, verifier, (std::string(implementationMinLimits[testNdx].name) + verifier->getTestNamePostfix()).c_str(), implementationMinLimits[testNdx].description, implementationMinLimits[testNdx].targetName, implementationMinLimits[testNdx].value)));
2817 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(implementationMaxLimits); testNdx++)
2818 FOR_EACH_VERIFIER(implementationLimitVerifiers, addChild(new ConstantMaximumValueTestCase(m_context, verifier, (std::string(implementationMaxLimits[testNdx].name) + verifier->getTestNamePostfix()).c_str(), implementationMaxLimits[testNdx].description, implementationMaxLimits[testNdx].targetName, implementationMaxLimits[testNdx].value)));
2819
2820 StateVerifier* normalVerifiers[] = {m_verifierBoolean, m_verifierInteger, m_verifierInteger64, m_verifierFloat};
2821
2822 FOR_EACH_VERIFIER(implementationLimitVerifiers, addChild(new SampleBuffersTestCase (m_context, verifier, (std::string("sample_buffers") + verifier->getTestNamePostfix()).c_str(), "SAMPLE_BUFFERS")));
2823
2824 FOR_EACH_VERIFIER(normalVerifiers, addChild(new SamplesTestCase (m_context, verifier, (std::string("samples") + verifier->getTestNamePostfix()).c_str(), "SAMPLES")));
2825 FOR_EACH_VERIFIER(normalVerifiers, addChild(new HintTestCase (m_context, verifier, (std::string("generate_mipmap_hint") + verifier->getTestNamePostfix()).c_str(), "GENERATE_MIPMAP_HINT", GL_GENERATE_MIPMAP_HINT)));
2826 FOR_EACH_VERIFIER(normalVerifiers, addChild(new HintTestCase (m_context, verifier, (std::string("fragment_shader_derivative_hint") + verifier->getTestNamePostfix()).c_str(), "FRAGMENT_SHADER_DERIVATIVE_HINT", GL_FRAGMENT_SHADER_DERIVATIVE_HINT)));
2827 FOR_EACH_VERIFIER(normalVerifiers, addChild(new DepthFuncTestCase (m_context, verifier, (std::string("depth_func") + verifier->getTestNamePostfix()).c_str(), "DEPTH_FUNC")));
2828 FOR_EACH_VERIFIER(normalVerifiers, addChild(new CullFaceTestCase (m_context, verifier, (std::string("cull_face_mode") + verifier->getTestNamePostfix()).c_str(), "CULL_FACE_MODE")));
2829 FOR_EACH_VERIFIER(normalVerifiers, addChild(new FrontFaceTestCase (m_context, verifier, (std::string("front_face_mode") + verifier->getTestNamePostfix()).c_str(), "FRONT_FACE")));
2830 FOR_EACH_VERIFIER(normalVerifiers, addChild(new ViewPortTestCase (m_context, verifier, (std::string("viewport") + verifier->getTestNamePostfix()).c_str(), "VIEWPORT")));
2831 FOR_EACH_VERIFIER(normalVerifiers, addChild(new ScissorBoxTestCase (m_context, verifier, (std::string("scissor_box") + verifier->getTestNamePostfix()).c_str(), "SCISSOR_BOX")));
2832 FOR_EACH_VERIFIER(normalVerifiers, addChild(new MaxViewportDimsTestCase (m_context, verifier, (std::string("max_viewport_dims") + verifier->getTestNamePostfix()).c_str(), "MAX_VIEWPORT_DIMS")));
2833 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilRefTestCase (m_context, verifier, (std::string("stencil_ref") + verifier->getTestNamePostfix()).c_str(), "STENCIL_REF", GL_STENCIL_REF)));
2834 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilRefTestCase (m_context, verifier, (std::string("stencil_back_ref") + verifier->getTestNamePostfix()).c_str(), "STENCIL_BACK_REF", GL_STENCIL_BACK_REF)));
2835 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilRefSeparateTestCase (m_context, verifier, (std::string("stencil_ref_separate") + verifier->getTestNamePostfix()).c_str(), "STENCIL_REF (separate)", GL_STENCIL_REF, GL_FRONT)));
2836 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilRefSeparateTestCase (m_context, verifier, (std::string("stencil_ref_separate_both") + verifier->getTestNamePostfix()).c_str(), "STENCIL_REF (separate)", GL_STENCIL_REF, GL_FRONT_AND_BACK)));
2837 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilRefSeparateTestCase (m_context, verifier, (std::string("stencil_back_ref_separate") + verifier->getTestNamePostfix()).c_str(), "STENCIL_BACK_REF (separate)", GL_STENCIL_BACK_REF, GL_BACK)));
2838 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilRefSeparateTestCase (m_context, verifier, (std::string("stencil_back_ref_separate_both") + verifier->getTestNamePostfix()).c_str(), "STENCIL_BACK_REF (separate)", GL_STENCIL_BACK_REF, GL_FRONT_AND_BACK)));
2839
2840 const struct NamedStencilOp
2841 {
2842 const char* name;
2843
2844 const char* frontDescription;
2845 GLenum frontTarget;
2846 const char* backDescription;
2847 GLenum backTarget;
2848 } stencilOps[] =
2849 {
2850 { "fail", "STENCIL_FAIL", GL_STENCIL_FAIL, "STENCIL_BACK_FAIL", GL_STENCIL_BACK_FAIL },
2851 { "depth_fail", "STENCIL_PASS_DEPTH_FAIL", GL_STENCIL_PASS_DEPTH_FAIL, "STENCIL_BACK_PASS_DEPTH_FAIL", GL_STENCIL_BACK_PASS_DEPTH_FAIL },
2852 { "depth_pass", "STENCIL_PASS_DEPTH_PASS", GL_STENCIL_PASS_DEPTH_PASS, "STENCIL_BACK_PASS_DEPTH_PASS", GL_STENCIL_BACK_PASS_DEPTH_PASS }
2853 };
2854
2855 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(stencilOps); testNdx++)
2856 {
2857 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilOpTestCase (m_context, verifier, (std::string("stencil_") + stencilOps[testNdx].name + verifier->getTestNamePostfix()).c_str(), stencilOps[testNdx].frontDescription, stencilOps[testNdx].frontTarget)));
2858 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilOpTestCase (m_context, verifier, (std::string("stencil_back_") + stencilOps[testNdx].name + verifier->getTestNamePostfix()).c_str(), stencilOps[testNdx].backDescription, stencilOps[testNdx].backTarget)));
2859
2860 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilOpSeparateTestCase (m_context, verifier, (std::string("stencil_") + stencilOps[testNdx].name + "_separate_both" + verifier->getTestNamePostfix()).c_str(), stencilOps[testNdx].frontDescription, stencilOps[testNdx].frontTarget, GL_FRONT_AND_BACK)));
2861 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilOpSeparateTestCase (m_context, verifier, (std::string("stencil_back_") + stencilOps[testNdx].name + "_separate_both" + verifier->getTestNamePostfix()).c_str(), stencilOps[testNdx].backDescription, stencilOps[testNdx].backTarget, GL_FRONT_AND_BACK)));
2862
2863 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilOpSeparateTestCase (m_context, verifier, (std::string("stencil_") + stencilOps[testNdx].name + "_separate" + verifier->getTestNamePostfix()).c_str(), stencilOps[testNdx].frontDescription, stencilOps[testNdx].frontTarget, GL_FRONT)));
2864 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilOpSeparateTestCase (m_context, verifier, (std::string("stencil_back_") + stencilOps[testNdx].name + "_separate" + verifier->getTestNamePostfix()).c_str(), stencilOps[testNdx].backDescription, stencilOps[testNdx].backTarget, GL_BACK)));
2865 }
2866
2867 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilFuncTestCase (m_context, verifier, (std::string("stencil_func") + verifier->getTestNamePostfix()).c_str(), "STENCIL_FUNC")));
2868 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilFuncSeparateTestCase (m_context, verifier, (std::string("stencil_func_separate") + verifier->getTestNamePostfix()).c_str(), "STENCIL_FUNC (separate)", GL_STENCIL_FUNC, GL_FRONT)));
2869 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilFuncSeparateTestCase (m_context, verifier, (std::string("stencil_func_separate_both") + verifier->getTestNamePostfix()).c_str(), "STENCIL_FUNC (separate)", GL_STENCIL_FUNC, GL_FRONT_AND_BACK)));
2870 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilFuncSeparateTestCase (m_context, verifier, (std::string("stencil_back_func_separate") + verifier->getTestNamePostfix()).c_str(), "STENCIL_FUNC (separate)", GL_STENCIL_BACK_FUNC, GL_BACK)));
2871 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilFuncSeparateTestCase (m_context, verifier, (std::string("stencil_back_func_separate_both") + verifier->getTestNamePostfix()).c_str(), "STENCIL_FUNC (separate)", GL_STENCIL_BACK_FUNC, GL_FRONT_AND_BACK)));
2872 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilMaskTestCase (m_context, verifier, (std::string("stencil_value_mask") + verifier->getTestNamePostfix()).c_str(), "STENCIL_VALUE_MASK", GL_STENCIL_VALUE_MASK)));
2873 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilMaskTestCase (m_context, verifier, (std::string("stencil_back_value_mask") + verifier->getTestNamePostfix()).c_str(), "STENCIL_BACK_VALUE_MASK", GL_STENCIL_BACK_VALUE_MASK)));
2874 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilMaskSeparateTestCase (m_context, verifier, (std::string("stencil_value_mask_separate") + verifier->getTestNamePostfix()).c_str(), "STENCIL_VALUE_MASK (separate)", GL_STENCIL_VALUE_MASK, GL_FRONT)));
2875 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilMaskSeparateTestCase (m_context, verifier, (std::string("stencil_value_mask_separate_both") + verifier->getTestNamePostfix()).c_str(), "STENCIL_VALUE_MASK (separate)", GL_STENCIL_VALUE_MASK, GL_FRONT_AND_BACK)));
2876 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilMaskSeparateTestCase (m_context, verifier, (std::string("stencil_back_value_mask_separate") + verifier->getTestNamePostfix()).c_str(), "STENCIL_BACK_VALUE_MASK (separate)", GL_STENCIL_BACK_VALUE_MASK, GL_BACK)));
2877 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilMaskSeparateTestCase (m_context, verifier, (std::string("stencil_back_value_mask_separate_both") + verifier->getTestNamePostfix()).c_str(), "STENCIL_BACK_VALUE_MASK (separate)", GL_STENCIL_BACK_VALUE_MASK, GL_FRONT_AND_BACK)));
2878 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilWriteMaskTestCase (m_context, verifier, (std::string("stencil_writemask") + verifier->getTestNamePostfix()).c_str(), "STENCIL_WRITEMASK", GL_STENCIL_WRITEMASK)));
2879 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilWriteMaskTestCase (m_context, verifier, (std::string("stencil_back_writemask") + verifier->getTestNamePostfix()).c_str(), "STENCIL_BACK_WRITEMASK", GL_STENCIL_BACK_WRITEMASK)));
2880 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilWriteMaskSeparateTestCase (m_context, verifier, (std::string("stencil_writemask_separate") + verifier->getTestNamePostfix()).c_str(), "STENCIL_WRITEMASK (separate)", GL_STENCIL_WRITEMASK, GL_FRONT)));
2881 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilWriteMaskSeparateTestCase (m_context, verifier, (std::string("stencil_writemask_separate_both") + verifier->getTestNamePostfix()).c_str(), "STENCIL_WRITEMASK (separate)", GL_STENCIL_WRITEMASK, GL_FRONT_AND_BACK)));
2882 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilWriteMaskSeparateTestCase (m_context, verifier, (std::string("stencil_back_writemask_separate") + verifier->getTestNamePostfix()).c_str(), "STENCIL_BACK_WRITEMASK (separate)", GL_STENCIL_BACK_WRITEMASK, GL_BACK)));
2883 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilWriteMaskSeparateTestCase (m_context, verifier, (std::string("stencil_back_writemask_separate_both") + verifier->getTestNamePostfix()).c_str(), "STENCIL_BACK_WRITEMASK (separate)", GL_STENCIL_BACK_WRITEMASK, GL_FRONT_AND_BACK)));
2884
2885 const struct PixelStoreState
2886 {
2887 const char* name;
2888 const char* description;
2889 GLenum target;
2890 int initialValue;
2891 } pixelStoreStates[] =
2892 {
2893 { "unpack_image_height","UNPACK_IMAGE_HEIGHT", GL_UNPACK_IMAGE_HEIGHT, 0 },
2894 { "unpack_skip_images", "UNPACK_SKIP_IMAGES", GL_UNPACK_SKIP_IMAGES, 0 },
2895 { "unpack_row_length", "UNPACK_ROW_LENGTH", GL_UNPACK_ROW_LENGTH, 0 },
2896 { "unpack_skip_rows", "UNPACK_SKIP_ROWS", GL_UNPACK_SKIP_ROWS, 0 },
2897 { "unpack_skip_pixels", "UNPACK_SKIP_PIXELS", GL_UNPACK_SKIP_PIXELS, 0 },
2898 { "pack_row_length", "PACK_ROW_LENGTH", GL_PACK_ROW_LENGTH, 0 },
2899 { "pack_skip_rows", "PACK_SKIP_ROWS", GL_PACK_SKIP_ROWS, 0 },
2900 { "pack_skip_pixels", "PACK_SKIP_PIXELS", GL_PACK_SKIP_PIXELS, 0 }
2901 };
2902 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(pixelStoreStates); testNdx++)
2903 {
2904 FOR_EACH_VERIFIER(normalVerifiers, addChild(new PixelStoreTestCase(m_context, verifier, (std::string(pixelStoreStates[testNdx].name) + verifier->getTestNamePostfix()).c_str(), pixelStoreStates[testNdx].description, pixelStoreStates[testNdx].target, pixelStoreStates[testNdx].initialValue)));
2905 }
2906
2907 FOR_EACH_VERIFIER(normalVerifiers, addChild(new PixelStoreAlignTestCase(m_context, verifier, (std::string("unpack_alignment") + verifier->getTestNamePostfix()).c_str(), "UNPACK_ALIGNMENT", GL_UNPACK_ALIGNMENT)));
2908 FOR_EACH_VERIFIER(normalVerifiers, addChild(new PixelStoreAlignTestCase(m_context, verifier, (std::string("pack_alignment") + verifier->getTestNamePostfix()).c_str(), "PACK_ALIGNMENT", GL_PACK_ALIGNMENT)));
2909
2910 const struct BlendColorState
2911 {
2912 const char* name;
2913 const char* description;
2914 GLenum target;
2915 int initialValue;
2916 } blendColorStates[] =
2917 {
2918 { "blend_src_rgb", "BLEND_SRC_RGB", GL_BLEND_SRC_RGB, GL_ONE },
2919 { "blend_src_alpha", "BLEND_SRC_ALPHA", GL_BLEND_SRC_ALPHA, GL_ONE },
2920 { "blend_dst_rgb", "BLEND_DST_RGB", GL_BLEND_DST_RGB, GL_ZERO },
2921 { "blend_dst_alpha", "BLEND_DST_ALPHA", GL_BLEND_DST_ALPHA, GL_ZERO }
2922 };
2923 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(blendColorStates); testNdx++)
2924 {
2925 FOR_EACH_VERIFIER(normalVerifiers, addChild(new BlendFuncTestCase (m_context, verifier, (std::string(blendColorStates[testNdx].name) + verifier->getTestNamePostfix()).c_str(), blendColorStates[testNdx].description, blendColorStates[testNdx].target, blendColorStates[testNdx].initialValue)));
2926 FOR_EACH_VERIFIER(normalVerifiers, addChild(new BlendFuncSeparateTestCase (m_context, verifier, (std::string(blendColorStates[testNdx].name) + "_separate" + verifier->getTestNamePostfix()).c_str(), blendColorStates[testNdx].description, blendColorStates[testNdx].target, blendColorStates[testNdx].initialValue)));
2927 }
2928
2929 const struct BlendEquationState
2930 {
2931 const char* name;
2932 const char* description;
2933 GLenum target;
2934 int initialValue;
2935 } blendEquationStates[] =
2936 {
2937 { "blend_equation_rgb", "BLEND_EQUATION_RGB", GL_BLEND_EQUATION_RGB, GL_FUNC_ADD },
2938 { "blend_equation_alpha", "BLEND_EQUATION_ALPHA", GL_BLEND_EQUATION_ALPHA, GL_FUNC_ADD }
2939 };
2940 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(blendEquationStates); testNdx++)
2941 {
2942 FOR_EACH_VERIFIER(normalVerifiers, addChild(new BlendEquationTestCase (m_context, verifier, (std::string(blendEquationStates[testNdx].name) + + verifier->getTestNamePostfix()).c_str(), blendEquationStates[testNdx].description, blendEquationStates[testNdx].target, blendEquationStates[testNdx].initialValue)));
2943 FOR_EACH_VERIFIER(normalVerifiers, addChild(new BlendEquationSeparateTestCase (m_context, verifier, (std::string(blendEquationStates[testNdx].name) + "_separate" + verifier->getTestNamePostfix()).c_str(), blendEquationStates[testNdx].description, blendEquationStates[testNdx].target, blendEquationStates[testNdx].initialValue)));
2944 }
2945
2946 const struct ImplementationArrayReturningState
2947 {
2948 const char* name;
2949 const char* description;
2950 GLenum target;
2951 GLenum targetLengthTarget;
2952 int minLength;
2953 } implementationArrayReturningStates[] =
2954 {
2955 { "compressed_texture_formats", "COMPRESSED_TEXTURE_FORMATS", GL_COMPRESSED_TEXTURE_FORMATS, GL_NUM_COMPRESSED_TEXTURE_FORMATS, 10 },
2956 { "program_binary_formats", "PROGRAM_BINARY_FORMATS", GL_PROGRAM_BINARY_FORMATS, GL_NUM_PROGRAM_BINARY_FORMATS, 0 },
2957 { "shader_binary_formats", "SHADER_BINARY_FORMATS", GL_SHADER_BINARY_FORMATS, GL_NUM_SHADER_BINARY_FORMATS, 0 }
2958 };
2959 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(implementationArrayReturningStates); testNdx++)
2960 {
2961 FOR_EACH_VERIFIER(normalVerifiers, addChild(new ImplementationArrayTestCase(m_context, verifier, (std::string(implementationArrayReturningStates[testNdx].name) + verifier->getTestNamePostfix()).c_str(), implementationArrayReturningStates[testNdx].description, implementationArrayReturningStates[testNdx].target, implementationArrayReturningStates[testNdx].targetLengthTarget, implementationArrayReturningStates[testNdx].minLength)));
2962 }
2963
2964 const struct BufferBindingState
2965 {
2966 const char* name;
2967 const char* description;
2968 GLenum target;
2969 GLenum type;
2970 } bufferBindingStates[] =
2971 {
2972 { "array_buffer_binding", "ARRAY_BUFFER_BINDING", GL_ARRAY_BUFFER_BINDING, GL_ARRAY_BUFFER },
2973 { "uniform_buffer_binding", "UNIFORM_BUFFER_BINDING", GL_UNIFORM_BUFFER_BINDING, GL_UNIFORM_BUFFER },
2974 { "pixel_pack_buffer_binding", "PIXEL_PACK_BUFFER_BINDING", GL_PIXEL_PACK_BUFFER_BINDING, GL_PIXEL_PACK_BUFFER },
2975 { "pixel_unpack_buffer_binding", "PIXEL_UNPACK_BUFFER_BINDING", GL_PIXEL_UNPACK_BUFFER_BINDING, GL_PIXEL_UNPACK_BUFFER },
2976 { "transform_feedback_buffer_binding", "TRANSFORM_FEEDBACK_BUFFER_BINDING", GL_TRANSFORM_FEEDBACK_BUFFER_BINDING, GL_TRANSFORM_FEEDBACK_BUFFER},
2977 { "copy_read_buffer_binding", "COPY_READ_BUFFER_BINDING", GL_COPY_READ_BUFFER_BINDING, GL_COPY_READ_BUFFER },
2978 { "copy_write_buffer_binding", "COPY_WRITE_BUFFER_BINDING", GL_COPY_WRITE_BUFFER_BINDING, GL_COPY_WRITE_BUFFER }
2979 };
2980 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(bufferBindingStates); testNdx++)
2981 {
2982 FOR_EACH_QUERYTYPE(queryTypes, addChild(new BufferBindingTestCase(m_context, queryType, (std::string(bufferBindingStates[testNdx].name) + getQueryTypeSuffix(queryType)).c_str(), bufferBindingStates[testNdx].description, bufferBindingStates[testNdx].target, bufferBindingStates[testNdx].type)));
2983 }
2984
2985 FOR_EACH_QUERYTYPE(queryTypes, addChild(new ElementArrayBufferBindingTestCase (m_context, queryType, (std::string("element_array_buffer_binding") + getQueryTypeSuffix(queryType)).c_str())));
2986 FOR_EACH_QUERYTYPE(queryTypes, addChild(new TransformFeedbackBindingTestCase (m_context, queryType, (std::string("transform_feedback_binding") + getQueryTypeSuffix(queryType)).c_str())));
2987 FOR_EACH_QUERYTYPE(queryTypes, addChild(new CurrentProgramBindingTestCase (m_context, queryType, (std::string("current_program_binding") + getQueryTypeSuffix(queryType)).c_str(), "CURRENT_PROGRAM")));
2988 FOR_EACH_QUERYTYPE(queryTypes, addChild(new VertexArrayBindingTestCase (m_context, queryType, (std::string("vertex_array_binding") + getQueryTypeSuffix(queryType)).c_str(), "VERTEX_ARRAY_BINDING")));
2989 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilClearValueTestCase (m_context, verifier, (std::string("stencil_clear_value") + verifier->getTestNamePostfix()).c_str(), "STENCIL_CLEAR_VALUE")));
2990 FOR_EACH_VERIFIER(normalVerifiers, addChild(new ActiveTextureTestCase (m_context, verifier, (std::string("active_texture") + verifier->getTestNamePostfix()).c_str(), "ACTIVE_TEXTURE")));
2991 FOR_EACH_QUERYTYPE(queryTypes, addChild(new RenderbufferBindingTestCase (m_context, queryType, (std::string("renderbuffer_binding") + getQueryTypeSuffix(queryType)).c_str(), "RENDERBUFFER_BINDING")));
2992 FOR_EACH_QUERYTYPE(queryTypes, addChild(new SamplerObjectBindingTestCase (m_context, queryType, (std::string("sampler_binding") + getQueryTypeSuffix(queryType)).c_str(), "SAMPLER_BINDING")));
2993
2994 const struct TextureBinding
2995 {
2996 const char* name;
2997 const char* description;
2998 GLenum target;
2999 GLenum type;
3000 } textureBindings[] =
3001 {
3002 { "texture_binding_2d", "TEXTURE_BINDING_2D", GL_TEXTURE_BINDING_2D, GL_TEXTURE_2D },
3003 { "texture_binding_3d", "TEXTURE_BINDING_3D", GL_TEXTURE_BINDING_3D, GL_TEXTURE_3D },
3004 { "texture_binding_2d_array", "TEXTURE_BINDING_2D_ARRAY", GL_TEXTURE_BINDING_2D_ARRAY, GL_TEXTURE_2D_ARRAY },
3005 { "texture_binding_cube_map", "TEXTURE_BINDING_CUBE_MAP", GL_TEXTURE_BINDING_CUBE_MAP, GL_TEXTURE_CUBE_MAP }
3006 };
3007
3008 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(textureBindings); testNdx++)
3009 {
3010 FOR_EACH_QUERYTYPE(queryTypes, addChild(new TextureBindingTestCase(m_context, queryType, (std::string(textureBindings[testNdx].name) + getQueryTypeSuffix(queryType)).c_str(), textureBindings[testNdx].description, textureBindings[testNdx].target, textureBindings[testNdx].type)));
3011 }
3012
3013
3014 FOR_EACH_QUERYTYPE(queryTypes, addChild(new FrameBufferBindingTestCase (m_context, queryType, (std::string("framebuffer_binding") + getQueryTypeSuffix(queryType)).c_str(), "DRAW_FRAMEBUFFER_BINDING and READ_FRAMEBUFFER_BINDING")));
3015 FOR_EACH_VERIFIER(normalVerifiers, addChild(new ImplementationColorReadTestCase (m_context, verifier, (std::string("implementation_color_read") + verifier->getTestNamePostfix()).c_str(), "IMPLEMENTATION_COLOR_READ_TYPE and IMPLEMENTATION_COLOR_READ_FORMAT")));
3016 FOR_EACH_VERIFIER(normalVerifiers, addChild(new ReadBufferCase (m_context, verifier, (std::string("read_buffer") + verifier->getTestNamePostfix()).c_str(), "READ_BUFFER")));
3017 FOR_EACH_VERIFIER(normalVerifiers, addChild(new DrawBufferCase (m_context, verifier, (std::string("draw_buffer") + verifier->getTestNamePostfix()).c_str(), "DRAW_BUFFER")));
3018 }
3019
deinit(void)3020 void IntegerStateQueryTests::deinit (void)
3021 {
3022 if (m_verifierBoolean)
3023 {
3024 delete m_verifierBoolean;
3025 m_verifierBoolean = DE_NULL;
3026 }
3027 if (m_verifierInteger)
3028 {
3029 delete m_verifierInteger;
3030 m_verifierInteger = DE_NULL;
3031 }
3032 if (m_verifierInteger64)
3033 {
3034 delete m_verifierInteger64;
3035 m_verifierInteger64 = DE_NULL;
3036 }
3037 if (m_verifierFloat)
3038 {
3039 delete m_verifierFloat;
3040 m_verifierFloat = DE_NULL;
3041 }
3042
3043 this->TestCaseGroup::deinit();
3044 }
3045
3046 } // Functional
3047 } // gles3
3048 } // deqp
3049