xref: /aosp_15_r20/external/deqp/modules/gles2/functional/es2fBooleanStateQueryTests.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 2.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 "es2fBooleanStateQueryTests.hpp"
25 #include "es2fApiCase.hpp"
26 #include "glsStateQueryUtil.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 gles2
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     virtual void verifyBooleanAnything(tcu::TestContext &testCtx, GLenum name)         = DE_NULL;
57 
58 private:
59     const char *const m_testNamePostfix;
60 };
61 
StateVerifier(const glw::Functions & gl,tcu::TestLog & log,const char * testNamePostfix)62 StateVerifier::StateVerifier(const glw::Functions &gl, tcu::TestLog &log, const char *testNamePostfix)
63     : glu::CallLogWrapper(gl, log)
64     , m_testNamePostfix(testNamePostfix)
65 {
66     enableLogging(true);
67 }
68 
~StateVerifier()69 StateVerifier::~StateVerifier()
70 {
71 }
72 
getTestNamePostfix(void) const73 const char *StateVerifier::getTestNamePostfix(void) const
74 {
75     return m_testNamePostfix;
76 }
77 
78 // IsEnabledVerifier
79 
80 class IsEnabledVerifier : public StateVerifier
81 {
82 public:
83     IsEnabledVerifier(const glw::Functions &gl, tcu::TestLog &log);
84     void verifyBoolean(tcu::TestContext &testCtx, GLenum name, bool reference);
85     void verifyBoolean4(tcu::TestContext &testCtx, GLenum name, bool reference0, bool reference1, bool reference2,
86                         bool reference3);
87     void verifyBooleanAnything(tcu::TestContext &testCtx, GLenum name);
88 };
89 
IsEnabledVerifier(const glw::Functions & gl,tcu::TestLog & log)90 IsEnabledVerifier::IsEnabledVerifier(const glw::Functions &gl, tcu::TestLog &log) : StateVerifier(gl, log, "_isenabled")
91 {
92 }
93 
verifyBoolean(tcu::TestContext & testCtx,GLenum name,bool reference)94 void IsEnabledVerifier::verifyBoolean(tcu::TestContext &testCtx, GLenum name, bool reference)
95 {
96     using tcu::TestLog;
97 
98     const GLboolean state           = glIsEnabled(name);
99     const GLboolean expectedGLState = reference ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE;
100 
101     if (state != expectedGLState)
102     {
103         testCtx.getLog() << TestLog::Message << "// ERROR: expected " << (reference ? "GL_TRUE" : "GL_FALSE")
104                          << TestLog::EndMessage;
105         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
106             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
107     }
108 }
109 
verifyBoolean4(tcu::TestContext & testCtx,GLenum name,bool reference0,bool reference1,bool reference2,bool reference3)110 void IsEnabledVerifier::verifyBoolean4(tcu::TestContext &testCtx, GLenum name, bool reference0, bool reference1,
111                                        bool reference2, bool reference3)
112 {
113     DE_UNREF(testCtx);
114     DE_UNREF(name);
115     DE_UNREF(reference0);
116     DE_UNREF(reference1);
117     DE_UNREF(reference2);
118     DE_UNREF(reference3);
119     DE_ASSERT(false && "not supported");
120 }
121 
verifyBooleanAnything(tcu::TestContext & testCtx,GLenum name)122 void IsEnabledVerifier::verifyBooleanAnything(tcu::TestContext &testCtx, GLenum name)
123 {
124     DE_UNREF(testCtx);
125     DE_UNREF(name);
126     DE_ASSERT(false && "not supported");
127 }
128 // GetBooleanVerifier
129 
130 class GetBooleanVerifier : public StateVerifier
131 {
132 public:
133     GetBooleanVerifier(const glw::Functions &gl, tcu::TestLog &log);
134     void verifyBoolean(tcu::TestContext &testCtx, GLenum name, bool reference);
135     void verifyBoolean4(tcu::TestContext &testCtx, GLenum name, bool reference0, bool reference1, bool reference2,
136                         bool reference3);
137     void verifyBooleanAnything(tcu::TestContext &testCtx, GLenum name);
138 };
139 
GetBooleanVerifier(const glw::Functions & gl,tcu::TestLog & log)140 GetBooleanVerifier::GetBooleanVerifier(const glw::Functions &gl, tcu::TestLog &log)
141     : StateVerifier(gl, log, "_getboolean")
142 {
143 }
144 
verifyBoolean(tcu::TestContext & testCtx,GLenum name,bool reference)145 void GetBooleanVerifier::verifyBoolean(tcu::TestContext &testCtx, GLenum name, bool reference)
146 {
147     using tcu::TestLog;
148 
149     StateQueryMemoryWriteGuard<GLboolean> state;
150     glGetBooleanv(name, &state);
151 
152     if (!state.verifyValidity(testCtx))
153         return;
154 
155     const GLboolean expectedGLState = reference ? GL_TRUE : GL_FALSE;
156 
157     if (state != expectedGLState)
158     {
159         testCtx.getLog() << TestLog::Message << "// ERROR: expected " << (reference ? "GL_TRUE" : "GL_FALSE")
160                          << TestLog::EndMessage;
161         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
162             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
163     }
164 }
165 
verifyBoolean4(tcu::TestContext & testCtx,GLenum name,bool reference0,bool reference1,bool reference2,bool reference3)166 void GetBooleanVerifier::verifyBoolean4(tcu::TestContext &testCtx, GLenum name, bool reference0, bool reference1,
167                                         bool reference2, bool reference3)
168 {
169     using tcu::TestLog;
170 
171     StateQueryMemoryWriteGuard<GLboolean[4]> boolVector4;
172     glGetBooleanv(name, boolVector4);
173 
174     if (!boolVector4.verifyValidity(testCtx))
175         return;
176 
177     const GLboolean referenceAsGLBoolean[] = {
178         reference0 ? GLboolean(GL_TRUE) : GLboolean(GL_FALSE),
179         reference1 ? GLboolean(GL_TRUE) : GLboolean(GL_FALSE),
180         reference2 ? GLboolean(GL_TRUE) : GLboolean(GL_FALSE),
181         reference3 ? GLboolean(GL_TRUE) : GLboolean(GL_FALSE),
182     };
183 
184     if (boolVector4[0] != referenceAsGLBoolean[0] || boolVector4[1] != referenceAsGLBoolean[1] ||
185         boolVector4[2] != referenceAsGLBoolean[2] || boolVector4[3] != referenceAsGLBoolean[3])
186     {
187         testCtx.getLog() << TestLog::Message << "// ERROR: expected "
188                          << (referenceAsGLBoolean[0] ? "GL_TRUE" : "GL_FALSE") << " "
189                          << (referenceAsGLBoolean[1] ? "GL_TRUE" : "GL_FALSE") << " "
190                          << (referenceAsGLBoolean[2] ? "GL_TRUE" : "GL_FALSE") << " "
191                          << (referenceAsGLBoolean[3] ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
192 
193         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
194             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
195     }
196 }
197 
verifyBooleanAnything(tcu::TestContext & testCtx,GLenum name)198 void GetBooleanVerifier::verifyBooleanAnything(tcu::TestContext &testCtx, GLenum name)
199 {
200     using tcu::TestLog;
201 
202     StateQueryMemoryWriteGuard<GLboolean> state;
203     glGetBooleanv(name, &state);
204 
205     state.verifyValidity(testCtx);
206 }
207 
208 //GetIntegerVerifier
209 
210 class GetIntegerVerifier : public StateVerifier
211 {
212 public:
213     GetIntegerVerifier(const glw::Functions &gl, tcu::TestLog &log);
214     void verifyBoolean(tcu::TestContext &testCtx, GLenum name, bool reference);
215     void verifyBoolean4(tcu::TestContext &testCtx, GLenum name, bool reference0, bool reference1, bool reference2,
216                         bool reference3);
217     void verifyBooleanAnything(tcu::TestContext &testCtx, GLenum name);
218 };
219 
GetIntegerVerifier(const glw::Functions & gl,tcu::TestLog & log)220 GetIntegerVerifier::GetIntegerVerifier(const glw::Functions &gl, tcu::TestLog &log)
221     : StateVerifier(gl, log, "_getinteger")
222 {
223 }
224 
verifyBoolean(tcu::TestContext & testCtx,GLenum name,bool reference)225 void GetIntegerVerifier::verifyBoolean(tcu::TestContext &testCtx, GLenum name, bool reference)
226 {
227     using tcu::TestLog;
228 
229     StateQueryMemoryWriteGuard<GLint> state;
230     glGetIntegerv(name, &state);
231 
232     if (!state.verifyValidity(testCtx))
233         return;
234 
235     const GLint expectedGLState = reference ? 1 : 0;
236 
237     if (state != expectedGLState)
238     {
239         testCtx.getLog() << TestLog::Message << "// ERROR: expected " << expectedGLState << TestLog::EndMessage;
240         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
241             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
242     }
243 }
244 
verifyBoolean4(tcu::TestContext & testCtx,GLenum name,bool reference0,bool reference1,bool reference2,bool reference3)245 void GetIntegerVerifier::verifyBoolean4(tcu::TestContext &testCtx, GLenum name, bool reference0, bool reference1,
246                                         bool reference2, bool reference3)
247 {
248     using tcu::TestLog;
249 
250     StateQueryMemoryWriteGuard<GLint[4]> boolVector4;
251     glGetIntegerv(name, boolVector4);
252 
253     if (!boolVector4.verifyValidity(testCtx))
254         return;
255 
256     const GLint referenceAsGLint[] = {
257         reference0 ? 1 : 0,
258         reference1 ? 1 : 0,
259         reference2 ? 1 : 0,
260         reference3 ? 1 : 0,
261     };
262 
263     if (boolVector4[0] != referenceAsGLint[0] || boolVector4[1] != referenceAsGLint[1] ||
264         boolVector4[2] != referenceAsGLint[2] || boolVector4[3] != referenceAsGLint[3])
265     {
266         testCtx.getLog() << TestLog::Message << "// ERROR: expected " << referenceAsGLint[0] << " "
267                          << referenceAsGLint[1] << " " << referenceAsGLint[2] << " " << referenceAsGLint[3] << " "
268                          << TestLog::EndMessage;
269 
270         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
271             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
272     }
273 }
274 
verifyBooleanAnything(tcu::TestContext & testCtx,GLenum name)275 void GetIntegerVerifier::verifyBooleanAnything(tcu::TestContext &testCtx, GLenum name)
276 {
277     using tcu::TestLog;
278 
279     StateQueryMemoryWriteGuard<GLint> state;
280     glGetIntegerv(name, &state);
281 
282     state.verifyValidity(testCtx);
283 }
284 
285 //GetFloatVerifier
286 
287 class GetFloatVerifier : public StateVerifier
288 {
289 public:
290     GetFloatVerifier(const glw::Functions &gl, tcu::TestLog &log);
291     void verifyBoolean(tcu::TestContext &testCtx, GLenum name, bool reference);
292     void verifyBoolean4(tcu::TestContext &testCtx, GLenum name, bool reference0, bool reference1, bool reference2,
293                         bool reference3);
294     void verifyBooleanAnything(tcu::TestContext &testCtx, GLenum name);
295 };
296 
GetFloatVerifier(const glw::Functions & gl,tcu::TestLog & log)297 GetFloatVerifier::GetFloatVerifier(const glw::Functions &gl, tcu::TestLog &log) : StateVerifier(gl, log, "_getfloat")
298 {
299 }
300 
verifyBoolean(tcu::TestContext & testCtx,GLenum name,bool reference)301 void GetFloatVerifier::verifyBoolean(tcu::TestContext &testCtx, GLenum name, bool reference)
302 {
303     using tcu::TestLog;
304 
305     StateQueryMemoryWriteGuard<GLfloat> state;
306     glGetFloatv(name, &state);
307 
308     if (!state.verifyValidity(testCtx))
309         return;
310 
311     const GLfloat expectedGLState = reference ? 1.0f : 0.0f;
312 
313     if (state != expectedGLState)
314     {
315         testCtx.getLog() << TestLog::Message << "// ERROR: expected " << expectedGLState << "; got " << state
316                          << TestLog::EndMessage;
317         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
318             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
319     }
320 }
321 
verifyBoolean4(tcu::TestContext & testCtx,GLenum name,bool reference0,bool reference1,bool reference2,bool reference3)322 void GetFloatVerifier::verifyBoolean4(tcu::TestContext &testCtx, GLenum name, bool reference0, bool reference1,
323                                       bool reference2, bool reference3)
324 {
325     using tcu::TestLog;
326 
327     StateQueryMemoryWriteGuard<GLfloat[4]> boolVector4;
328     glGetFloatv(name, boolVector4);
329 
330     if (!boolVector4.verifyValidity(testCtx))
331         return;
332 
333     const GLfloat referenceAsGLfloat[] = {
334         reference0 ? 1.0f : 0.0f,
335         reference1 ? 1.0f : 0.0f,
336         reference2 ? 1.0f : 0.0f,
337         reference3 ? 1.0f : 0.0f,
338     };
339 
340     if (boolVector4[0] != referenceAsGLfloat[0] || boolVector4[1] != referenceAsGLfloat[1] ||
341         boolVector4[2] != referenceAsGLfloat[2] || boolVector4[3] != referenceAsGLfloat[3])
342     {
343         testCtx.getLog() << TestLog::Message << "// ERROR: expected " << referenceAsGLfloat[0] << " "
344                          << referenceAsGLfloat[1] << " " << referenceAsGLfloat[2] << " " << referenceAsGLfloat[3] << " "
345                          << TestLog::EndMessage;
346 
347         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
348             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
349     }
350 }
351 
verifyBooleanAnything(tcu::TestContext & testCtx,GLenum name)352 void GetFloatVerifier::verifyBooleanAnything(tcu::TestContext &testCtx, GLenum name)
353 {
354     using tcu::TestLog;
355 
356     StateQueryMemoryWriteGuard<GLfloat> state;
357     glGetFloatv(name, &state);
358 
359     state.verifyValidity(testCtx);
360 }
361 
362 } // namespace BooleanStateQueryVerifiers
363 
364 namespace
365 {
366 
367 using namespace BooleanStateQueryVerifiers;
368 
369 class IsEnabledStateTestCase : public ApiCase
370 {
371 public:
IsEnabledStateTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum targetName,bool initial)372     IsEnabledStateTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description,
373                            GLenum targetName, bool initial)
374         : ApiCase(context, name, description)
375         , m_targetName(targetName)
376         , m_initial(initial)
377         , m_verifier(verifier)
378     {
379     }
380 
test(void)381     void test(void)
382     {
383         // check inital value
384         m_verifier->verifyBoolean(m_testCtx, m_targetName, m_initial);
385         expectError(GL_NO_ERROR);
386 
387         // check toggle
388 
389         glEnable(m_targetName);
390         expectError(GL_NO_ERROR);
391 
392         m_verifier->verifyBoolean(m_testCtx, m_targetName, true);
393         expectError(GL_NO_ERROR);
394 
395         glDisable(m_targetName);
396         expectError(GL_NO_ERROR);
397 
398         m_verifier->verifyBoolean(m_testCtx, m_targetName, false);
399         expectError(GL_NO_ERROR);
400     }
401 
402 private:
403     GLenum m_targetName;
404     bool m_initial;
405     StateVerifier *m_verifier;
406 };
407 
408 class DepthWriteMaskTestCase : public ApiCase
409 {
410 public:
DepthWriteMaskTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)411     DepthWriteMaskTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description)
412         : ApiCase(context, name, description)
413         , m_verifier(verifier)
414     {
415     }
416 
test(void)417     void test(void)
418     {
419         m_verifier->verifyBoolean(m_testCtx, GL_DEPTH_WRITEMASK, true);
420         expectError(GL_NO_ERROR);
421 
422         glDepthMask(GL_FALSE);
423         m_verifier->verifyBoolean(m_testCtx, GL_DEPTH_WRITEMASK, false);
424         expectError(GL_NO_ERROR);
425 
426         glDepthMask(GL_TRUE);
427         m_verifier->verifyBoolean(m_testCtx, GL_DEPTH_WRITEMASK, true);
428         expectError(GL_NO_ERROR);
429     }
430 
431 private:
432     StateVerifier *m_verifier;
433 };
434 
435 class SampleCoverageInvertTestCase : public ApiCase
436 {
437 public:
SampleCoverageInvertTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)438     SampleCoverageInvertTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description)
439         : ApiCase(context, name, description)
440         , m_verifier(verifier)
441     {
442     }
443 
test(void)444     void test(void)
445     {
446         m_verifier->verifyBoolean(m_testCtx, GL_SAMPLE_COVERAGE_INVERT, false);
447         expectError(GL_NO_ERROR);
448 
449         glSampleCoverage(1.0f, GL_TRUE);
450         m_verifier->verifyBoolean(m_testCtx, GL_SAMPLE_COVERAGE_INVERT, true);
451         expectError(GL_NO_ERROR);
452 
453         glSampleCoverage(1.0f, GL_FALSE);
454         m_verifier->verifyBoolean(m_testCtx, GL_SAMPLE_COVERAGE_INVERT, false);
455         expectError(GL_NO_ERROR);
456     }
457 
458 private:
459     StateVerifier *m_verifier;
460 };
461 
462 class ShaderCompilerTestCase : public ApiCase
463 {
464 public:
ShaderCompilerTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)465     ShaderCompilerTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description)
466         : ApiCase(context, name, description)
467         , m_verifier(verifier)
468     {
469     }
470 
test(void)471     void test(void)
472     {
473         m_verifier->verifyBooleanAnything(m_testCtx, GL_SHADER_COMPILER);
474         expectError(GL_NO_ERROR);
475     }
476 
477 private:
478     StateVerifier *m_verifier;
479 };
480 
481 class ColorMaskTestCase : public ApiCase
482 {
483 public:
ColorMaskTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)484     ColorMaskTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description)
485         : ApiCase(context, name, description)
486         , m_verifier(verifier)
487     {
488     }
test(void)489     void test(void)
490     {
491         m_verifier->verifyBoolean4(m_testCtx, GL_COLOR_WRITEMASK, true, true, true, true);
492         expectError(GL_NO_ERROR);
493 
494         const struct ColorMask
495         {
496             GLboolean r, g, b, a;
497         } testMasks[] = {
498             {GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE},    {GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE},
499             {GL_TRUE, GL_TRUE, GL_FALSE, GL_TRUE},   {GL_TRUE, GL_TRUE, GL_FALSE, GL_FALSE},
500             {GL_TRUE, GL_FALSE, GL_TRUE, GL_TRUE},   {GL_TRUE, GL_FALSE, GL_TRUE, GL_FALSE},
501             {GL_TRUE, GL_FALSE, GL_FALSE, GL_TRUE},  {GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE},
502             {GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE},   {GL_FALSE, GL_TRUE, GL_TRUE, GL_FALSE},
503             {GL_FALSE, GL_TRUE, GL_FALSE, GL_TRUE},  {GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE},
504             {GL_FALSE, GL_FALSE, GL_TRUE, GL_TRUE},  {GL_FALSE, GL_FALSE, GL_TRUE, GL_FALSE},
505             {GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE}, {GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE},
506         };
507 
508         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(testMasks); ndx++)
509         {
510             glColorMask(testMasks[ndx].r, testMasks[ndx].g, testMasks[ndx].b, testMasks[ndx].a);
511             m_verifier->verifyBoolean4(m_testCtx, GL_COLOR_WRITEMASK, testMasks[ndx].r == GL_TRUE,
512                                        testMasks[ndx].g == GL_TRUE, testMasks[ndx].b == GL_TRUE,
513                                        testMasks[ndx].a == GL_TRUE);
514             expectError(GL_NO_ERROR);
515         }
516     }
517 
518 private:
519     StateVerifier *m_verifier;
520 };
521 
522 #define FOR_EACH_VERIFIER(VERIFIERS, CODE_BLOCK)                                                 \
523     do                                                                                           \
524     {                                                                                            \
525         for (int _verifierNdx = 0; _verifierNdx < DE_LENGTH_OF_ARRAY(VERIFIERS); _verifierNdx++) \
526         {                                                                                        \
527             StateVerifier *verifier = (VERIFIERS)[_verifierNdx];                                 \
528             CODE_BLOCK;                                                                          \
529         }                                                                                        \
530     } while (0)
531 
532 } // namespace
533 
BooleanStateQueryTests(Context & context)534 BooleanStateQueryTests::BooleanStateQueryTests(Context &context)
535     : TestCaseGroup(context, "boolean", "Boolean State Query tests")
536     , m_verifierIsEnabled(DE_NULL)
537     , m_verifierBoolean(DE_NULL)
538     , m_verifierInteger(DE_NULL)
539     , m_verifierFloat(DE_NULL)
540 {
541 }
542 
~BooleanStateQueryTests(void)543 BooleanStateQueryTests::~BooleanStateQueryTests(void)
544 {
545     deinit();
546 }
547 
init(void)548 void BooleanStateQueryTests::init(void)
549 {
550     DE_ASSERT(m_verifierIsEnabled == DE_NULL);
551     DE_ASSERT(m_verifierBoolean == DE_NULL);
552     DE_ASSERT(m_verifierInteger == DE_NULL);
553     DE_ASSERT(m_verifierFloat == DE_NULL);
554 
555     m_verifierIsEnabled =
556         new IsEnabledVerifier(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
557     m_verifierBoolean =
558         new GetBooleanVerifier(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
559     m_verifierInteger =
560         new GetIntegerVerifier(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
561     m_verifierFloat =
562         new GetFloatVerifier(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
563 
564     StateVerifier *isEnabledVerifiers[] = {m_verifierIsEnabled, m_verifierBoolean, m_verifierInteger, m_verifierFloat};
565     StateVerifier *normalVerifiers[]    = {m_verifierBoolean, m_verifierInteger, m_verifierFloat};
566 
567     struct StateBoolean
568     {
569         const char *name;
570         const char *description;
571         GLenum targetName;
572         bool value;
573     };
574     const StateBoolean isEnableds[] = {
575         {"cull_face", "CULL_FACE", GL_CULL_FACE, false},
576         {"polygon_offset_fill", "POLYGON_OFFSET_FILL", GL_POLYGON_OFFSET_FILL, false},
577         {"sample_alpha_to_coverage", "SAMPLE_ALPHA_TO_COVERAGE", GL_SAMPLE_ALPHA_TO_COVERAGE, false},
578         {"sample_coverage", "SAMPLE_COVERAGE", GL_SAMPLE_COVERAGE, false},
579         {"scissor_test", "SCISSOR_TEST", GL_SCISSOR_TEST, false},
580         {"stencil_test", "STENCIL_TEST", GL_STENCIL_TEST, false},
581         {"depth_test", "DEPTH_TEST", GL_DEPTH_TEST, false},
582         {"blend", "BLEND", GL_BLEND, false},
583         {"dither", "DITHER", GL_DITHER, true},
584     };
585     for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(isEnableds); testNdx++)
586         FOR_EACH_VERIFIER(
587             isEnabledVerifiers,
588             addChild(new IsEnabledStateTestCase(
589                 m_context, verifier, (std::string(isEnableds[testNdx].name) + verifier->getTestNamePostfix()).c_str(),
590                 isEnableds[testNdx].description, isEnableds[testNdx].targetName, isEnableds[testNdx].value)));
591 
592     FOR_EACH_VERIFIER(
593         normalVerifiers,
594         addChild(new SampleCoverageInvertTestCase(
595             m_context, verifier, (std::string("sample_coverage_invert") + verifier->getTestNamePostfix()).c_str(),
596             "SAMPLE_COVERAGE_INVERT")));
597     FOR_EACH_VERIFIER(normalVerifiers, addChild(new ColorMaskTestCase(
598                                            m_context, verifier,
599                                            (std::string("color_writemask") + verifier->getTestNamePostfix()).c_str(),
600                                            "COLOR_WRITEMASK")));
601     FOR_EACH_VERIFIER(normalVerifiers, addChild(new DepthWriteMaskTestCase(
602                                            m_context, verifier,
603                                            (std::string("depth_writemask") + verifier->getTestNamePostfix()).c_str(),
604                                            "DEPTH_WRITEMASK")));
605     FOR_EACH_VERIFIER(normalVerifiers, addChild(new ShaderCompilerTestCase(
606                                            m_context, verifier,
607                                            (std::string("shader_compiler") + verifier->getTestNamePostfix()).c_str(),
608                                            "SHADER_COMPILER")));
609 }
610 
deinit(void)611 void BooleanStateQueryTests::deinit(void)
612 {
613     if (m_verifierIsEnabled)
614     {
615         delete m_verifierIsEnabled;
616         m_verifierIsEnabled = DE_NULL;
617     }
618     if (m_verifierBoolean)
619     {
620         delete m_verifierBoolean;
621         m_verifierBoolean = DE_NULL;
622     }
623     if (m_verifierInteger)
624     {
625         delete m_verifierInteger;
626         m_verifierInteger = DE_NULL;
627     }
628     if (m_verifierFloat)
629     {
630         delete m_verifierFloat;
631         m_verifierFloat = DE_NULL;
632     }
633 
634     this->TestCaseGroup::deinit();
635 }
636 
637 } // namespace Functional
638 } // namespace gles2
639 } // namespace deqp
640