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 Boolean State Query tests.
22 *//*--------------------------------------------------------------------*/
23
24 #include "es3fBooleanStateQueryTests.hpp"
25 #include "glsStateQueryUtil.hpp"
26 #include "es3fApiCase.hpp"
27 #include "gluRenderContext.hpp"
28 #include "tcuRenderTarget.hpp"
29 #include "glwEnums.hpp"
30
31 using namespace glw; // GLint and other GL types
32 using deqp::gls::StateQueryUtil::StateQueryMemoryWriteGuard;
33
34 namespace deqp
35 {
36 namespace gles3
37 {
38 namespace Functional
39 {
40 namespace BooleanStateQueryVerifiers
41 {
42
43 // StateVerifier
44
45 class StateVerifier : protected glu::CallLogWrapper
46 {
47 public:
48 StateVerifier(const glw::Functions &gl, tcu::TestLog &log, const char *testNamePostfix);
49 virtual ~StateVerifier(); // make GCC happy
50
51 const char *getTestNamePostfix(void) const;
52
53 virtual void verifyBoolean(tcu::TestContext &testCtx, GLenum name, bool reference) = DE_NULL;
54 virtual void verifyBoolean4(tcu::TestContext &testCtx, GLenum name, bool reference0, bool reference1,
55 bool reference2, bool reference3) = DE_NULL;
56
57 private:
58 const char *const m_testNamePostfix;
59 };
60
StateVerifier(const glw::Functions & gl,tcu::TestLog & log,const char * testNamePostfix)61 StateVerifier::StateVerifier(const glw::Functions &gl, tcu::TestLog &log, const char *testNamePostfix)
62 : glu::CallLogWrapper(gl, log)
63 , m_testNamePostfix(testNamePostfix)
64 {
65 enableLogging(true);
66 }
67
~StateVerifier()68 StateVerifier::~StateVerifier()
69 {
70 }
71
getTestNamePostfix(void) const72 const char *StateVerifier::getTestNamePostfix(void) const
73 {
74 return m_testNamePostfix;
75 }
76
77 // IsEnabledVerifier
78
79 class IsEnabledVerifier : public StateVerifier
80 {
81 public:
82 IsEnabledVerifier(const glw::Functions &gl, tcu::TestLog &log);
83 void verifyBoolean(tcu::TestContext &testCtx, GLenum name, bool reference);
84 void verifyBoolean4(tcu::TestContext &testCtx, GLenum name, bool reference0, bool reference1, bool reference2,
85 bool reference3);
86 };
87
IsEnabledVerifier(const glw::Functions & gl,tcu::TestLog & log)88 IsEnabledVerifier::IsEnabledVerifier(const glw::Functions &gl, tcu::TestLog &log) : StateVerifier(gl, log, "_isenabled")
89 {
90 }
91
verifyBoolean(tcu::TestContext & testCtx,GLenum name,bool reference)92 void IsEnabledVerifier::verifyBoolean(tcu::TestContext &testCtx, GLenum name, bool reference)
93 {
94 using tcu::TestLog;
95
96 const GLboolean state = glIsEnabled(name);
97 const GLboolean expectedGLState = reference ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE;
98
99 if (state != expectedGLState)
100 {
101 testCtx.getLog() << TestLog::Message << "// ERROR: expected " << (reference ? "GL_TRUE" : "GL_FALSE")
102 << TestLog::EndMessage;
103 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
104 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
105 }
106 }
107
verifyBoolean4(tcu::TestContext & testCtx,GLenum name,bool reference0,bool reference1,bool reference2,bool reference3)108 void IsEnabledVerifier::verifyBoolean4(tcu::TestContext &testCtx, GLenum name, bool reference0, bool reference1,
109 bool reference2, bool reference3)
110 {
111 DE_UNREF(testCtx);
112 DE_UNREF(name);
113 DE_UNREF(reference0);
114 DE_UNREF(reference1);
115 DE_UNREF(reference2);
116 DE_UNREF(reference3);
117 DE_ASSERT(false && "not supported");
118 }
119
120 // GetBooleanVerifier
121
122 class GetBooleanVerifier : public StateVerifier
123 {
124 public:
125 GetBooleanVerifier(const glw::Functions &gl, tcu::TestLog &log);
126 void verifyBoolean(tcu::TestContext &testCtx, GLenum name, bool reference);
127 void verifyBoolean4(tcu::TestContext &testCtx, GLenum name, bool reference0, bool reference1, bool reference2,
128 bool reference3);
129 };
130
GetBooleanVerifier(const glw::Functions & gl,tcu::TestLog & log)131 GetBooleanVerifier::GetBooleanVerifier(const glw::Functions &gl, tcu::TestLog &log)
132 : StateVerifier(gl, log, "_getboolean")
133 {
134 }
135
verifyBoolean(tcu::TestContext & testCtx,GLenum name,bool reference)136 void GetBooleanVerifier::verifyBoolean(tcu::TestContext &testCtx, GLenum name, bool reference)
137 {
138 using tcu::TestLog;
139
140 StateQueryMemoryWriteGuard<GLboolean> state;
141 glGetBooleanv(name, &state);
142
143 if (!state.verifyValidity(testCtx))
144 return;
145
146 const GLboolean expectedGLState = reference ? GL_TRUE : GL_FALSE;
147
148 if (state != expectedGLState)
149 {
150 testCtx.getLog() << TestLog::Message << "// ERROR: expected " << (reference ? "GL_TRUE" : "GL_FALSE")
151 << TestLog::EndMessage;
152 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
153 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
154 }
155 }
156
verifyBoolean4(tcu::TestContext & testCtx,GLenum name,bool reference0,bool reference1,bool reference2,bool reference3)157 void GetBooleanVerifier::verifyBoolean4(tcu::TestContext &testCtx, GLenum name, bool reference0, bool reference1,
158 bool reference2, bool reference3)
159 {
160 using tcu::TestLog;
161
162 StateQueryMemoryWriteGuard<GLboolean[4]> boolVector4;
163 glGetBooleanv(name, boolVector4);
164
165 if (!boolVector4.verifyValidity(testCtx))
166 return;
167
168 const GLboolean referenceAsGLBoolean[] = {
169 reference0 ? GLboolean(GL_TRUE) : GLboolean(GL_FALSE),
170 reference1 ? GLboolean(GL_TRUE) : GLboolean(GL_FALSE),
171 reference2 ? GLboolean(GL_TRUE) : GLboolean(GL_FALSE),
172 reference3 ? GLboolean(GL_TRUE) : GLboolean(GL_FALSE),
173 };
174
175 if (boolVector4[0] != referenceAsGLBoolean[0] || boolVector4[1] != referenceAsGLBoolean[1] ||
176 boolVector4[2] != referenceAsGLBoolean[2] || boolVector4[3] != referenceAsGLBoolean[3])
177 {
178 testCtx.getLog() << TestLog::Message << "// ERROR: expected "
179 << (referenceAsGLBoolean[0] ? "GL_TRUE" : "GL_FALSE") << " "
180 << (referenceAsGLBoolean[1] ? "GL_TRUE" : "GL_FALSE") << " "
181 << (referenceAsGLBoolean[2] ? "GL_TRUE" : "GL_FALSE") << " "
182 << (referenceAsGLBoolean[3] ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
183
184 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
185 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
186 }
187 }
188
189 //GetIntegerVerifier
190
191 class GetIntegerVerifier : public StateVerifier
192 {
193 public:
194 GetIntegerVerifier(const glw::Functions &gl, tcu::TestLog &log);
195 void verifyBoolean(tcu::TestContext &testCtx, GLenum name, bool reference);
196 void verifyBoolean4(tcu::TestContext &testCtx, GLenum name, bool reference0, bool reference1, bool reference2,
197 bool reference3);
198 };
199
GetIntegerVerifier(const glw::Functions & gl,tcu::TestLog & log)200 GetIntegerVerifier::GetIntegerVerifier(const glw::Functions &gl, tcu::TestLog &log)
201 : StateVerifier(gl, log, "_getinteger")
202 {
203 }
204
verifyBoolean(tcu::TestContext & testCtx,GLenum name,bool reference)205 void GetIntegerVerifier::verifyBoolean(tcu::TestContext &testCtx, GLenum name, bool reference)
206 {
207 using tcu::TestLog;
208
209 StateQueryMemoryWriteGuard<GLint> state;
210 glGetIntegerv(name, &state);
211
212 if (!state.verifyValidity(testCtx))
213 return;
214
215 const GLint expectedGLState = reference ? 1 : 0;
216
217 if (state != expectedGLState)
218 {
219 testCtx.getLog() << TestLog::Message << "// ERROR: expected " << expectedGLState << TestLog::EndMessage;
220 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
221 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
222 }
223 }
224
verifyBoolean4(tcu::TestContext & testCtx,GLenum name,bool reference0,bool reference1,bool reference2,bool reference3)225 void GetIntegerVerifier::verifyBoolean4(tcu::TestContext &testCtx, GLenum name, bool reference0, bool reference1,
226 bool reference2, bool reference3)
227 {
228 using tcu::TestLog;
229
230 StateQueryMemoryWriteGuard<GLint[4]> boolVector4;
231 glGetIntegerv(name, boolVector4);
232
233 if (!boolVector4.verifyValidity(testCtx))
234 return;
235
236 const GLint referenceAsGLint[] = {
237 reference0 ? 1 : 0,
238 reference1 ? 1 : 0,
239 reference2 ? 1 : 0,
240 reference3 ? 1 : 0,
241 };
242
243 if (boolVector4[0] != referenceAsGLint[0] || boolVector4[1] != referenceAsGLint[1] ||
244 boolVector4[2] != referenceAsGLint[2] || boolVector4[3] != referenceAsGLint[3])
245 {
246 testCtx.getLog() << TestLog::Message << "// ERROR: expected " << referenceAsGLint[0] << " "
247 << referenceAsGLint[1] << " " << referenceAsGLint[2] << " " << referenceAsGLint[3] << " "
248 << TestLog::EndMessage;
249
250 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
251 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
252 }
253 }
254
255 //GetInteger64Verifier
256
257 class GetInteger64Verifier : public StateVerifier
258 {
259 public:
260 GetInteger64Verifier(const glw::Functions &gl, tcu::TestLog &log);
261 void verifyBoolean(tcu::TestContext &testCtx, GLenum name, bool reference);
262 void verifyBoolean4(tcu::TestContext &testCtx, GLenum name, bool reference0, bool reference1, bool reference2,
263 bool reference3);
264 };
265
GetInteger64Verifier(const glw::Functions & gl,tcu::TestLog & log)266 GetInteger64Verifier::GetInteger64Verifier(const glw::Functions &gl, tcu::TestLog &log)
267 : StateVerifier(gl, log, "_getinteger64")
268 {
269 }
270
verifyBoolean(tcu::TestContext & testCtx,GLenum name,bool reference)271 void GetInteger64Verifier::verifyBoolean(tcu::TestContext &testCtx, GLenum name, bool reference)
272 {
273 using tcu::TestLog;
274
275 StateQueryMemoryWriteGuard<GLint64> state;
276 glGetInteger64v(name, &state);
277
278 if (!state.verifyValidity(testCtx))
279 return;
280
281 const GLint64 expectedGLState = reference ? 1 : 0;
282
283 if (state != expectedGLState)
284 {
285 testCtx.getLog() << TestLog::Message << "// ERROR: expected " << expectedGLState << TestLog::EndMessage;
286 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
287 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
288 }
289 }
290
verifyBoolean4(tcu::TestContext & testCtx,GLenum name,bool reference0,bool reference1,bool reference2,bool reference3)291 void GetInteger64Verifier::verifyBoolean4(tcu::TestContext &testCtx, GLenum name, bool reference0, bool reference1,
292 bool reference2, bool reference3)
293 {
294 using tcu::TestLog;
295
296 StateQueryMemoryWriteGuard<GLint64[4]> boolVector4;
297 glGetInteger64v(name, boolVector4);
298
299 if (!boolVector4.verifyValidity(testCtx))
300 return;
301
302 const GLint64 referenceAsGLint64[] = {
303 reference0 ? 1 : 0,
304 reference1 ? 1 : 0,
305 reference2 ? 1 : 0,
306 reference3 ? 1 : 0,
307 };
308
309 if (boolVector4[0] != referenceAsGLint64[0] || boolVector4[1] != referenceAsGLint64[1] ||
310 boolVector4[2] != referenceAsGLint64[2] || boolVector4[3] != referenceAsGLint64[3])
311 {
312 testCtx.getLog() << TestLog::Message << "// ERROR: expected " << referenceAsGLint64[0] << " "
313 << referenceAsGLint64[1] << " " << referenceAsGLint64[2] << " " << referenceAsGLint64[3] << " "
314 << TestLog::EndMessage;
315
316 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
317 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
318 }
319 }
320
321 //GetFloatVerifier
322
323 class GetFloatVerifier : public StateVerifier
324 {
325 public:
326 GetFloatVerifier(const glw::Functions &gl, tcu::TestLog &log);
327 void verifyBoolean(tcu::TestContext &testCtx, GLenum name, bool reference);
328 void verifyBoolean4(tcu::TestContext &testCtx, GLenum name, bool reference0, bool reference1, bool reference2,
329 bool reference3);
330 };
331
GetFloatVerifier(const glw::Functions & gl,tcu::TestLog & log)332 GetFloatVerifier::GetFloatVerifier(const glw::Functions &gl, tcu::TestLog &log) : StateVerifier(gl, log, "_getfloat")
333 {
334 }
335
verifyBoolean(tcu::TestContext & testCtx,GLenum name,bool reference)336 void GetFloatVerifier::verifyBoolean(tcu::TestContext &testCtx, GLenum name, bool reference)
337 {
338 using tcu::TestLog;
339
340 StateQueryMemoryWriteGuard<GLfloat> state;
341 glGetFloatv(name, &state);
342
343 if (!state.verifyValidity(testCtx))
344 return;
345
346 const GLfloat expectedGLState = reference ? 1.0f : 0.0f;
347
348 if (state != expectedGLState)
349 {
350 testCtx.getLog() << TestLog::Message << "// ERROR: expected " << expectedGLState << "; got " << state
351 << TestLog::EndMessage;
352 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
353 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
354 }
355 }
356
verifyBoolean4(tcu::TestContext & testCtx,GLenum name,bool reference0,bool reference1,bool reference2,bool reference3)357 void GetFloatVerifier::verifyBoolean4(tcu::TestContext &testCtx, GLenum name, bool reference0, bool reference1,
358 bool reference2, bool reference3)
359 {
360 using tcu::TestLog;
361
362 StateQueryMemoryWriteGuard<GLfloat[4]> boolVector4;
363 glGetFloatv(name, boolVector4);
364
365 if (!boolVector4.verifyValidity(testCtx))
366 return;
367
368 const GLfloat referenceAsGLfloat[] = {
369 reference0 ? 1.0f : 0.0f,
370 reference1 ? 1.0f : 0.0f,
371 reference2 ? 1.0f : 0.0f,
372 reference3 ? 1.0f : 0.0f,
373 };
374
375 if (boolVector4[0] != referenceAsGLfloat[0] || boolVector4[1] != referenceAsGLfloat[1] ||
376 boolVector4[2] != referenceAsGLfloat[2] || boolVector4[3] != referenceAsGLfloat[3])
377 {
378 testCtx.getLog() << TestLog::Message << "// ERROR: expected " << referenceAsGLfloat[0] << " "
379 << referenceAsGLfloat[1] << " " << referenceAsGLfloat[2] << " " << referenceAsGLfloat[3] << " "
380 << TestLog::EndMessage;
381
382 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
383 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
384 }
385 }
386
387 } // namespace BooleanStateQueryVerifiers
388
389 namespace
390 {
391
392 using namespace BooleanStateQueryVerifiers;
393
394 static const char *transformFeedbackTestVertSource = "#version 300 es\n"
395 "void main (void)\n"
396 "{\n"
397 " gl_Position = vec4(0.0);\n"
398 "}\n\0";
399 static const char *transformFeedbackTestFragSource = "#version 300 es\n"
400 "layout(location = 0) out mediump vec4 fragColor;"
401 "void main (void)\n"
402 "{\n"
403 " fragColor = vec4(0.0);\n"
404 "}\n\0";
405
406 class IsEnabledStateTestCase : public ApiCase
407 {
408 public:
IsEnabledStateTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum targetName,bool initial)409 IsEnabledStateTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description,
410 GLenum targetName, bool initial)
411 : ApiCase(context, name, description)
412 , m_targetName(targetName)
413 , m_initial(initial)
414 , m_verifier(verifier)
415 {
416 }
417
test(void)418 void test(void)
419 {
420 // check inital value
421 m_verifier->verifyBoolean(m_testCtx, m_targetName, m_initial);
422 expectError(GL_NO_ERROR);
423
424 // check toggle
425
426 glEnable(m_targetName);
427 expectError(GL_NO_ERROR);
428
429 m_verifier->verifyBoolean(m_testCtx, m_targetName, true);
430 expectError(GL_NO_ERROR);
431
432 glDisable(m_targetName);
433 expectError(GL_NO_ERROR);
434
435 m_verifier->verifyBoolean(m_testCtx, m_targetName, false);
436 expectError(GL_NO_ERROR);
437 }
438
439 private:
440 GLenum m_targetName;
441 bool m_initial;
442 StateVerifier *m_verifier;
443 };
444
445 class DepthWriteMaskTestCase : public ApiCase
446 {
447 public:
DepthWriteMaskTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)448 DepthWriteMaskTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description)
449 : ApiCase(context, name, description)
450 , m_verifier(verifier)
451 {
452 }
453
test(void)454 void test(void)
455 {
456 m_verifier->verifyBoolean(m_testCtx, GL_DEPTH_WRITEMASK, true);
457 expectError(GL_NO_ERROR);
458
459 glDepthMask(GL_FALSE);
460 m_verifier->verifyBoolean(m_testCtx, GL_DEPTH_WRITEMASK, false);
461 expectError(GL_NO_ERROR);
462
463 glDepthMask(GL_TRUE);
464 m_verifier->verifyBoolean(m_testCtx, GL_DEPTH_WRITEMASK, true);
465 expectError(GL_NO_ERROR);
466 }
467
468 private:
469 StateVerifier *m_verifier;
470 };
471
472 class SampleCoverageInvertTestCase : public ApiCase
473 {
474 public:
SampleCoverageInvertTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)475 SampleCoverageInvertTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description)
476 : ApiCase(context, name, description)
477 , m_verifier(verifier)
478 {
479 }
480
test(void)481 void test(void)
482 {
483 m_verifier->verifyBoolean(m_testCtx, GL_SAMPLE_COVERAGE_INVERT, false);
484 expectError(GL_NO_ERROR);
485
486 glSampleCoverage(1.0f, GL_TRUE);
487 m_verifier->verifyBoolean(m_testCtx, GL_SAMPLE_COVERAGE_INVERT, true);
488 expectError(GL_NO_ERROR);
489
490 glSampleCoverage(1.0f, GL_FALSE);
491 m_verifier->verifyBoolean(m_testCtx, GL_SAMPLE_COVERAGE_INVERT, false);
492 expectError(GL_NO_ERROR);
493 }
494
495 private:
496 StateVerifier *m_verifier;
497 };
498
499 class InitialBooleanTestCase : public ApiCase
500 {
501 public:
InitialBooleanTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum target,bool reference)502 InitialBooleanTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description,
503 GLenum target, bool reference)
504 : ApiCase(context, name, description)
505 , m_target(target)
506 , m_reference(reference)
507 , m_verifier(verifier)
508 {
509 }
510
test(void)511 void test(void)
512 {
513 m_verifier->verifyBoolean(m_testCtx, m_target, m_reference);
514 expectError(GL_NO_ERROR);
515 }
516
517 private:
518 GLenum m_target;
519 bool m_reference;
520 StateVerifier *m_verifier;
521 };
522
523 class ColorMaskTestCase : public ApiCase
524 {
525 public:
ColorMaskTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)526 ColorMaskTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description)
527 : ApiCase(context, name, description)
528 , m_verifier(verifier)
529 {
530 }
test(void)531 void test(void)
532 {
533 m_verifier->verifyBoolean4(m_testCtx, GL_COLOR_WRITEMASK, true, true, true, true);
534 expectError(GL_NO_ERROR);
535
536 const struct ColorMask
537 {
538 GLboolean r, g, b, a;
539 } testMasks[] = {
540 {GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE}, {GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE},
541 {GL_TRUE, GL_TRUE, GL_FALSE, GL_TRUE}, {GL_TRUE, GL_TRUE, GL_FALSE, GL_FALSE},
542 {GL_TRUE, GL_FALSE, GL_TRUE, GL_TRUE}, {GL_TRUE, GL_FALSE, GL_TRUE, GL_FALSE},
543 {GL_TRUE, GL_FALSE, GL_FALSE, GL_TRUE}, {GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE},
544 {GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE}, {GL_FALSE, GL_TRUE, GL_TRUE, GL_FALSE},
545 {GL_FALSE, GL_TRUE, GL_FALSE, GL_TRUE}, {GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE},
546 {GL_FALSE, GL_FALSE, GL_TRUE, GL_TRUE}, {GL_FALSE, GL_FALSE, GL_TRUE, GL_FALSE},
547 {GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE}, {GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE},
548 };
549
550 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(testMasks); ndx++)
551 {
552 glColorMask(testMasks[ndx].r, testMasks[ndx].g, testMasks[ndx].b, testMasks[ndx].a);
553 m_verifier->verifyBoolean4(m_testCtx, GL_COLOR_WRITEMASK, testMasks[ndx].r == GL_TRUE,
554 testMasks[ndx].g == GL_TRUE, testMasks[ndx].b == GL_TRUE,
555 testMasks[ndx].a == GL_TRUE);
556 expectError(GL_NO_ERROR);
557 }
558 }
559
560 private:
561 StateVerifier *m_verifier;
562 };
563
564 class TransformFeedbackTestCase : public ApiCase
565 {
566 public:
TransformFeedbackTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)567 TransformFeedbackTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description)
568 : ApiCase(context, name, description)
569 , m_verifier(verifier)
570 , m_transformfeedback(0)
571 {
572 }
573
test(void)574 void test(void)
575 {
576 glGenTransformFeedbacks(1, &m_transformfeedback);
577 expectError(GL_NO_ERROR);
578
579 GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
580 glShaderSource(shaderVert, 1, &transformFeedbackTestVertSource, DE_NULL);
581 glCompileShader(shaderVert);
582 expectError(GL_NO_ERROR);
583 GLint compileStatus;
584 glGetShaderiv(shaderVert, GL_COMPILE_STATUS, &compileStatus);
585 checkBooleans(compileStatus, GL_TRUE);
586
587 GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
588 glShaderSource(shaderFrag, 1, &transformFeedbackTestFragSource, DE_NULL);
589 glCompileShader(shaderFrag);
590 expectError(GL_NO_ERROR);
591 glGetShaderiv(shaderFrag, GL_COMPILE_STATUS, &compileStatus);
592 checkBooleans(compileStatus, GL_TRUE);
593
594 GLuint shaderProg = glCreateProgram();
595 glAttachShader(shaderProg, shaderVert);
596 glAttachShader(shaderProg, shaderFrag);
597 const char *transform_feedback_outputs = "gl_Position";
598 glTransformFeedbackVaryings(shaderProg, 1, &transform_feedback_outputs, GL_INTERLEAVED_ATTRIBS);
599 glLinkProgram(shaderProg);
600 expectError(GL_NO_ERROR);
601 GLint linkStatus;
602 glGetProgramiv(shaderProg, GL_LINK_STATUS, &linkStatus);
603 checkBooleans(linkStatus, GL_TRUE);
604
605 glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, m_transformfeedback);
606 expectError(GL_NO_ERROR);
607
608 GLuint feedbackBufferId;
609 glGenBuffers(1, &feedbackBufferId);
610 glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, feedbackBufferId);
611 glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_DYNAMIC_READ);
612 glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, feedbackBufferId);
613 expectError(GL_NO_ERROR);
614
615 glUseProgram(shaderProg);
616
617 testTransformFeedback();
618
619 glUseProgram(0);
620 glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
621 glDeleteTransformFeedbacks(1, &m_transformfeedback);
622 glDeleteBuffers(1, &feedbackBufferId);
623 glDeleteShader(shaderVert);
624 glDeleteShader(shaderFrag);
625 glDeleteProgram(shaderProg);
626 expectError(GL_NO_ERROR);
627 }
628
629 virtual void testTransformFeedback(void) = DE_NULL;
630
631 protected:
632 StateVerifier *m_verifier;
633 GLuint m_transformfeedback;
634 };
635
636 class TransformFeedbackBasicTestCase : public TransformFeedbackTestCase
637 {
638 public:
TransformFeedbackBasicTestCase(Context & context,StateVerifier * verifier,const char * name)639 TransformFeedbackBasicTestCase(Context &context, StateVerifier *verifier, const char *name)
640 : TransformFeedbackTestCase(context, verifier, name,
641 "Test TRANSFORM_FEEDBACK_ACTIVE and TRANSFORM_FEEDBACK_PAUSED")
642 {
643 }
644
testTransformFeedback(void)645 void testTransformFeedback(void)
646 {
647 glBeginTransformFeedback(GL_POINTS);
648 expectError(GL_NO_ERROR);
649
650 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_ACTIVE, true);
651 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_PAUSED, false);
652 expectError(GL_NO_ERROR);
653
654 glPauseTransformFeedback();
655 expectError(GL_NO_ERROR);
656
657 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_ACTIVE, true);
658 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_PAUSED, true);
659 expectError(GL_NO_ERROR);
660
661 glResumeTransformFeedback();
662 expectError(GL_NO_ERROR);
663
664 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_ACTIVE, true);
665 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_PAUSED, false);
666 expectError(GL_NO_ERROR);
667
668 glEndTransformFeedback();
669 expectError(GL_NO_ERROR);
670
671 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_ACTIVE, false);
672 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_PAUSED, false);
673 expectError(GL_NO_ERROR);
674 }
675 };
676
677 class TransformFeedbackImplicitResumeTestCase : public TransformFeedbackTestCase
678 {
679 public:
TransformFeedbackImplicitResumeTestCase(Context & context,StateVerifier * verifier,const char * name)680 TransformFeedbackImplicitResumeTestCase(Context &context, StateVerifier *verifier, const char *name)
681 : TransformFeedbackTestCase(context, verifier, name,
682 "EndTransformFeedback performs an implicit ResumeTransformFeedback.")
683 {
684 }
685
testTransformFeedback(void)686 void testTransformFeedback(void)
687 {
688 glBeginTransformFeedback(GL_POINTS);
689 expectError(GL_NO_ERROR);
690
691 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_ACTIVE, true);
692 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_PAUSED, false);
693 expectError(GL_NO_ERROR);
694
695 glPauseTransformFeedback();
696 expectError(GL_NO_ERROR);
697
698 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_ACTIVE, true);
699 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_PAUSED, true);
700 expectError(GL_NO_ERROR);
701
702 glEndTransformFeedback();
703 expectError(GL_NO_ERROR);
704
705 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_ACTIVE, false);
706 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_PAUSED, false);
707 expectError(GL_NO_ERROR);
708 }
709 };
710
711 #define FOR_EACH_VERIFIER(VERIFIERS, CODE_BLOCK) \
712 do \
713 { \
714 for (int _verifierNdx = 0; _verifierNdx < DE_LENGTH_OF_ARRAY(VERIFIERS); _verifierNdx++) \
715 { \
716 StateVerifier *verifier = (VERIFIERS)[_verifierNdx]; \
717 CODE_BLOCK; \
718 } \
719 } while (0)
720
721 } // namespace
722
BooleanStateQueryTests(Context & context)723 BooleanStateQueryTests::BooleanStateQueryTests(Context &context)
724 : TestCaseGroup(context, "boolean", "Boolean State Query tests")
725 , m_verifierIsEnabled(DE_NULL)
726 , m_verifierBoolean(DE_NULL)
727 , m_verifierInteger(DE_NULL)
728 , m_verifierInteger64(DE_NULL)
729 , m_verifierFloat(DE_NULL)
730 {
731 }
732
~BooleanStateQueryTests(void)733 BooleanStateQueryTests::~BooleanStateQueryTests(void)
734 {
735 deinit();
736 }
737
init(void)738 void BooleanStateQueryTests::init(void)
739 {
740 DE_ASSERT(m_verifierIsEnabled == DE_NULL);
741 DE_ASSERT(m_verifierBoolean == DE_NULL);
742 DE_ASSERT(m_verifierInteger == DE_NULL);
743 DE_ASSERT(m_verifierInteger64 == DE_NULL);
744 DE_ASSERT(m_verifierFloat == DE_NULL);
745
746 m_verifierIsEnabled =
747 new IsEnabledVerifier(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
748 m_verifierBoolean =
749 new GetBooleanVerifier(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
750 m_verifierInteger =
751 new GetIntegerVerifier(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
752 m_verifierInteger64 =
753 new GetInteger64Verifier(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
754 m_verifierFloat =
755 new GetFloatVerifier(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
756
757 StateVerifier *isEnabledVerifiers[] = {m_verifierIsEnabled, m_verifierBoolean, m_verifierInteger,
758 m_verifierInteger64, m_verifierFloat};
759 StateVerifier *normalVerifiers[] = {m_verifierBoolean, m_verifierInteger, m_verifierInteger64, m_verifierFloat};
760
761 struct StateBoolean
762 {
763 const char *name;
764 const char *description;
765 GLenum targetName;
766 bool value;
767 };
768 const StateBoolean isEnableds[] = {
769 {"primitive_restart_fixed_index", "PRIMITIVE_RESTART_FIXED_INDEX", GL_PRIMITIVE_RESTART_FIXED_INDEX, false},
770 {"rasterizer_discard", "RASTERIZER_DISCARD", GL_RASTERIZER_DISCARD, false},
771 {"cull_face", "CULL_FACE", GL_CULL_FACE, false},
772 {"polygon_offset_fill", "POLYGON_OFFSET_FILL", GL_POLYGON_OFFSET_FILL, false},
773 {"sample_alpha_to_coverage", "SAMPLE_ALPHA_TO_COVERAGE", GL_SAMPLE_ALPHA_TO_COVERAGE, false},
774 {"sample_coverage", "SAMPLE_COVERAGE", GL_SAMPLE_COVERAGE, false},
775 {"scissor_test", "SCISSOR_TEST", GL_SCISSOR_TEST, false},
776 {"stencil_test", "STENCIL_TEST", GL_STENCIL_TEST, false},
777 {"depth_test", "DEPTH_TEST", GL_DEPTH_TEST, false},
778 {"blend", "BLEND", GL_BLEND, false},
779 {"dither", "DITHER", GL_DITHER, true},
780 };
781 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(isEnableds); testNdx++)
782 {
783 FOR_EACH_VERIFIER(
784 isEnabledVerifiers,
785 addChild(new IsEnabledStateTestCase(
786 m_context, verifier, (std::string(isEnableds[testNdx].name) + verifier->getTestNamePostfix()).c_str(),
787 isEnableds[testNdx].description, isEnableds[testNdx].targetName, isEnableds[testNdx].value)));
788 }
789
790 FOR_EACH_VERIFIER(normalVerifiers, addChild(new ColorMaskTestCase(
791 m_context, verifier,
792 (std::string("color_writemask") + verifier->getTestNamePostfix()).c_str(),
793 "COLOR_WRITEMASK")));
794 FOR_EACH_VERIFIER(normalVerifiers, addChild(new DepthWriteMaskTestCase(
795 m_context, verifier,
796 (std::string("depth_writemask") + verifier->getTestNamePostfix()).c_str(),
797 "DEPTH_WRITEMASK")));
798 FOR_EACH_VERIFIER(
799 normalVerifiers,
800 addChild(new SampleCoverageInvertTestCase(
801 m_context, verifier, (std::string("sample_coverage_invert") + verifier->getTestNamePostfix()).c_str(),
802 "SAMPLE_COVERAGE_INVERT")));
803 FOR_EACH_VERIFIER(normalVerifiers, addChild(new InitialBooleanTestCase(
804 m_context, verifier,
805 (std::string("shader_compiler") + verifier->getTestNamePostfix()).c_str(),
806 "SHADER_COMPILER", GL_SHADER_COMPILER, true)));
807 FOR_EACH_VERIFIER(normalVerifiers,
808 addChild(new InitialBooleanTestCase(
809 m_context, verifier,
810 (std::string("transform_feedback_active_initial") + verifier->getTestNamePostfix()).c_str(),
811 "initial TRANSFORM_FEEDBACK_ACTIVE", GL_TRANSFORM_FEEDBACK_ACTIVE, false)));
812 FOR_EACH_VERIFIER(normalVerifiers,
813 addChild(new InitialBooleanTestCase(
814 m_context, verifier,
815 (std::string("transform_feedback_paused_initial") + verifier->getTestNamePostfix()).c_str(),
816 "initial TRANSFORM_FEEDBACK_PAUSED", GL_TRANSFORM_FEEDBACK_PAUSED, false)));
817 FOR_EACH_VERIFIER(
818 normalVerifiers,
819 addChild(new TransformFeedbackBasicTestCase(
820 m_context, verifier, (std::string("transform_feedback") + verifier->getTestNamePostfix()).c_str())));
821 FOR_EACH_VERIFIER(
822 normalVerifiers,
823 addChild(new TransformFeedbackImplicitResumeTestCase(
824 m_context, verifier,
825 (std::string("transform_feedback_implicit_resume") + verifier->getTestNamePostfix()).c_str())));
826 }
827
deinit(void)828 void BooleanStateQueryTests::deinit(void)
829 {
830 if (m_verifierIsEnabled)
831 {
832 delete m_verifierIsEnabled;
833 m_verifierIsEnabled = DE_NULL;
834 }
835 if (m_verifierBoolean)
836 {
837 delete m_verifierBoolean;
838 m_verifierBoolean = DE_NULL;
839 }
840 if (m_verifierInteger)
841 {
842 delete m_verifierInteger;
843 m_verifierInteger = DE_NULL;
844 }
845 if (m_verifierInteger64)
846 {
847 delete m_verifierInteger64;
848 m_verifierInteger64 = DE_NULL;
849 }
850 if (m_verifierFloat)
851 {
852 delete m_verifierFloat;
853 m_verifierFloat = DE_NULL;
854 }
855
856 this->TestCaseGroup::deinit();
857 }
858
859 } // namespace Functional
860 } // namespace gles3
861 } // namespace deqp
862