1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.0 Module
3 * -------------------------------------------------
5 * Copyright 2014 The Android Open Source Project
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * \brief Boolean State Query tests.
22 *//*--------------------------------------------------------------------*/
24 #include "es3fBooleanStateQueryTests.hpp"
25 #include "glsStateQueryUtil.hpp"
26 #include "es3fApiCase.hpp"
27 #include "gluRenderContext.hpp"
28 #include "tcuRenderTarget.hpp"
29 #include "glwEnums.hpp"
31 using namespace glw; // GLint and other GL types
32 using deqp::gls::StateQueryUtil::StateQueryMemoryWriteGuard;
40 namespace BooleanStateQueryVerifiers
45 class StateVerifier : protected glu::CallLogWrapper
48 StateVerifier (const glw::Functions& gl, tcu::TestLog& log, const char* testNamePostfix);
49 virtual ~StateVerifier (); // make GCC happy
51 const char* getTestNamePostfix (void) const;
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, bool reference2, bool reference3) = DE_NULL;
56 const char* const m_testNamePostfix;
59 StateVerifier::StateVerifier (const glw::Functions& gl, tcu::TestLog& log, const char* testNamePostfix)
60 : glu::CallLogWrapper (gl, log)
61 , m_testNamePostfix (testNamePostfix)
66 StateVerifier::~StateVerifier ()
70 const char* StateVerifier::getTestNamePostfix (void) const
72 return m_testNamePostfix;
77 class IsEnabledVerifier : public StateVerifier
80 IsEnabledVerifier (const glw::Functions& gl, tcu::TestLog& log);
81 void verifyBoolean (tcu::TestContext& testCtx, GLenum name, bool reference);
82 void verifyBoolean4 (tcu::TestContext& testCtx, GLenum name, bool reference0, bool reference1, bool reference2, bool reference3);
85 IsEnabledVerifier::IsEnabledVerifier (const glw::Functions& gl, tcu::TestLog& log)
86 : StateVerifier(gl, log, "_isenabled")
90 void IsEnabledVerifier::verifyBoolean (tcu::TestContext& testCtx, GLenum name, bool reference)
94 const GLboolean state = glIsEnabled(name);
95 const GLboolean expectedGLState = reference ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE;
97 if (state != expectedGLState)
99 testCtx.getLog() << TestLog::Message << "// ERROR: expected " << (reference ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
100 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
101 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
105 void IsEnabledVerifier::verifyBoolean4 (tcu::TestContext& testCtx, GLenum name, bool reference0, bool reference1, bool reference2, bool reference3)
109 DE_UNREF(reference0);
110 DE_UNREF(reference1);
111 DE_UNREF(reference2);
112 DE_UNREF(reference3);
113 DE_ASSERT(false && "not supported");
116 // GetBooleanVerifier
118 class GetBooleanVerifier : public StateVerifier
121 GetBooleanVerifier (const glw::Functions& gl, tcu::TestLog& log);
122 void verifyBoolean (tcu::TestContext& testCtx, GLenum name, bool reference);
123 void verifyBoolean4 (tcu::TestContext& testCtx, GLenum name, bool reference0, bool reference1, bool reference2, bool reference3);
126 GetBooleanVerifier::GetBooleanVerifier (const glw::Functions& gl, tcu::TestLog& log)
127 : StateVerifier(gl, log, "_getboolean")
131 void GetBooleanVerifier::verifyBoolean (tcu::TestContext& testCtx, GLenum name, bool reference)
135 StateQueryMemoryWriteGuard<GLboolean> state;
136 glGetBooleanv(name, &state);
138 if (!state.verifyValidity(testCtx))
141 const GLboolean expectedGLState = reference ? GL_TRUE : GL_FALSE;
143 if (state != expectedGLState)
145 testCtx.getLog() << TestLog::Message << "// ERROR: expected " << (reference ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
146 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
147 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
151 void GetBooleanVerifier::verifyBoolean4 (tcu::TestContext& testCtx, GLenum name, bool reference0, bool reference1, bool reference2, bool reference3)
155 StateQueryMemoryWriteGuard<GLboolean[4]> boolVector4;
156 glGetBooleanv(name, boolVector4);
158 if (!boolVector4.verifyValidity(testCtx))
161 const GLboolean referenceAsGLBoolean[] =
163 reference0 ? GLboolean(GL_TRUE) : GLboolean(GL_FALSE),
164 reference1 ? GLboolean(GL_TRUE) : GLboolean(GL_FALSE),
165 reference2 ? GLboolean(GL_TRUE) : GLboolean(GL_FALSE),
166 reference3 ? GLboolean(GL_TRUE) : GLboolean(GL_FALSE),
169 if (boolVector4[0] != referenceAsGLBoolean[0] ||
170 boolVector4[1] != referenceAsGLBoolean[1] ||
171 boolVector4[2] != referenceAsGLBoolean[2] ||
172 boolVector4[3] != referenceAsGLBoolean[3])
174 testCtx.getLog() << TestLog::Message << "// ERROR: expected "
175 << (referenceAsGLBoolean[0] ? "GL_TRUE" : "GL_FALSE") << " "
176 << (referenceAsGLBoolean[1] ? "GL_TRUE" : "GL_FALSE") << " "
177 << (referenceAsGLBoolean[2] ? "GL_TRUE" : "GL_FALSE") << " "
178 << (referenceAsGLBoolean[3] ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
180 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
181 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
187 class GetIntegerVerifier : public StateVerifier
190 GetIntegerVerifier (const glw::Functions& gl, tcu::TestLog& log);
191 void verifyBoolean (tcu::TestContext& testCtx, GLenum name, bool reference);
192 void verifyBoolean4 (tcu::TestContext& testCtx, GLenum name, bool reference0, bool reference1, bool reference2, bool reference3);
196 GetIntegerVerifier::GetIntegerVerifier (const glw::Functions& gl, tcu::TestLog& log)
197 : StateVerifier(gl, log, "_getinteger")
201 void GetIntegerVerifier::verifyBoolean (tcu::TestContext& testCtx, GLenum name, bool reference)
205 StateQueryMemoryWriteGuard<GLint> state;
206 glGetIntegerv(name, &state);
208 if (!state.verifyValidity(testCtx))
211 const GLint expectedGLState = reference ? 1 : 0;
213 if (state != expectedGLState)
215 testCtx.getLog() << TestLog::Message << "// ERROR: expected " << expectedGLState << TestLog::EndMessage;
216 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
217 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
221 void GetIntegerVerifier::verifyBoolean4 (tcu::TestContext& testCtx, GLenum name, bool reference0, bool reference1, bool reference2, bool reference3)
225 StateQueryMemoryWriteGuard<GLint[4]> boolVector4;
226 glGetIntegerv(name, boolVector4);
228 if (!boolVector4.verifyValidity(testCtx))
231 const GLint referenceAsGLint[] =
239 if (boolVector4[0] != referenceAsGLint[0] ||
240 boolVector4[1] != referenceAsGLint[1] ||
241 boolVector4[2] != referenceAsGLint[2] ||
242 boolVector4[3] != referenceAsGLint[3])
244 testCtx.getLog() << TestLog::Message << "// ERROR: expected "
245 << referenceAsGLint[0] << " "
246 << referenceAsGLint[1] << " "
247 << referenceAsGLint[2] << " "
248 << referenceAsGLint[3] << " " << TestLog::EndMessage;
250 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
251 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
255 //GetInteger64Verifier
257 class GetInteger64Verifier : public StateVerifier
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, bool reference3);
265 GetInteger64Verifier::GetInteger64Verifier (const glw::Functions& gl, tcu::TestLog& log)
266 : StateVerifier(gl, log, "_getinteger64")
270 void GetInteger64Verifier::verifyBoolean (tcu::TestContext& testCtx, GLenum name, bool reference)
274 StateQueryMemoryWriteGuard<GLint64> state;
275 glGetInteger64v(name, &state);
277 if (!state.verifyValidity(testCtx))
280 const GLint64 expectedGLState = reference ? 1 : 0;
282 if (state != expectedGLState)
284 testCtx.getLog() << TestLog::Message << "// ERROR: expected " << expectedGLState << TestLog::EndMessage;
285 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
286 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
290 void GetInteger64Verifier::verifyBoolean4 (tcu::TestContext& testCtx, GLenum name, bool reference0, bool reference1, bool reference2, bool reference3)
294 StateQueryMemoryWriteGuard<GLint64[4]> boolVector4;
295 glGetInteger64v(name, boolVector4);
297 if (!boolVector4.verifyValidity(testCtx))
300 const GLint64 referenceAsGLint64[] =
308 if (boolVector4[0] != referenceAsGLint64[0] ||
309 boolVector4[1] != referenceAsGLint64[1] ||
310 boolVector4[2] != referenceAsGLint64[2] ||
311 boolVector4[3] != referenceAsGLint64[3])
313 testCtx.getLog() << TestLog::Message << "// ERROR: expected "
314 << referenceAsGLint64[0] << " "
315 << referenceAsGLint64[1] << " "
316 << referenceAsGLint64[2] << " "
317 << referenceAsGLint64[3] << " " << TestLog::EndMessage;
319 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
320 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
326 class GetFloatVerifier : public StateVerifier
329 GetFloatVerifier (const glw::Functions& gl, tcu::TestLog& log);
330 void verifyBoolean (tcu::TestContext& testCtx, GLenum name, bool reference);
331 void verifyBoolean4 (tcu::TestContext& testCtx, GLenum name, bool reference0, bool reference1, bool reference2, bool reference3);
334 GetFloatVerifier::GetFloatVerifier (const glw::Functions& gl, tcu::TestLog& log)
335 : StateVerifier(gl, log, "_getfloat")
339 void GetFloatVerifier::verifyBoolean (tcu::TestContext& testCtx, GLenum name, bool reference)
343 StateQueryMemoryWriteGuard<GLfloat> state;
344 glGetFloatv(name, &state);
346 if (!state.verifyValidity(testCtx))
349 const GLfloat expectedGLState = reference ? 1.0f : 0.0f;
351 if (state != expectedGLState)
353 testCtx.getLog() << TestLog::Message << "// ERROR: expected " << expectedGLState << "; got " << state << TestLog::EndMessage;
354 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
355 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
359 void GetFloatVerifier::verifyBoolean4 (tcu::TestContext& testCtx, GLenum name, bool reference0, bool reference1, bool reference2, bool reference3)
363 StateQueryMemoryWriteGuard<GLfloat[4]> boolVector4;
364 glGetFloatv(name, boolVector4);
366 if (!boolVector4.verifyValidity(testCtx))
369 const GLfloat referenceAsGLfloat[] =
371 reference0 ? 1.0f : 0.0f,
372 reference1 ? 1.0f : 0.0f,
373 reference2 ? 1.0f : 0.0f,
374 reference3 ? 1.0f : 0.0f,
377 if (boolVector4[0] != referenceAsGLfloat[0] ||
378 boolVector4[1] != referenceAsGLfloat[1] ||
379 boolVector4[2] != referenceAsGLfloat[2] ||
380 boolVector4[3] != referenceAsGLfloat[3])
382 testCtx.getLog() << TestLog::Message << "// ERROR: expected "
383 << referenceAsGLfloat[0] << " "
384 << referenceAsGLfloat[1] << " "
385 << referenceAsGLfloat[2] << " "
386 << referenceAsGLfloat[3] << " " << TestLog::EndMessage;
388 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
389 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
393 } // BooleanStateQueryVerifiers
398 using namespace BooleanStateQueryVerifiers;
400 static const char* transformFeedbackTestVertSource = "#version 300 es\n"
403 " gl_Position = vec4(0.0);\n"
405 static const char* transformFeedbackTestFragSource = "#version 300 es\n"
406 "layout(location = 0) out mediump vec4 fragColor;"
409 " fragColor = vec4(0.0);\n"
412 class IsEnabledStateTestCase : public ApiCase
415 IsEnabledStateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum targetName, bool initial)
416 : ApiCase (context, name, description)
417 , m_targetName (targetName)
418 , m_initial (initial)
419 , m_verifier (verifier)
425 // check inital value
426 m_verifier->verifyBoolean(m_testCtx, m_targetName, m_initial);
427 expectError(GL_NO_ERROR);
431 glEnable(m_targetName);
432 expectError(GL_NO_ERROR);
434 m_verifier->verifyBoolean(m_testCtx, m_targetName, true);
435 expectError(GL_NO_ERROR);
437 glDisable(m_targetName);
438 expectError(GL_NO_ERROR);
440 m_verifier->verifyBoolean(m_testCtx, m_targetName, false);
441 expectError(GL_NO_ERROR);
447 StateVerifier* m_verifier;
450 class DepthWriteMaskTestCase : public ApiCase
453 DepthWriteMaskTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
454 : ApiCase (context, name, description)
455 , m_verifier (verifier)
461 m_verifier->verifyBoolean(m_testCtx, GL_DEPTH_WRITEMASK, true);
462 expectError(GL_NO_ERROR);
464 glDepthMask(GL_FALSE);
465 m_verifier->verifyBoolean(m_testCtx, GL_DEPTH_WRITEMASK, false);
466 expectError(GL_NO_ERROR);
468 glDepthMask(GL_TRUE);
469 m_verifier->verifyBoolean(m_testCtx, GL_DEPTH_WRITEMASK, true);
470 expectError(GL_NO_ERROR);
473 StateVerifier* m_verifier;
476 class SampleCoverageInvertTestCase : public ApiCase
479 SampleCoverageInvertTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
480 : ApiCase (context, name, description)
481 , m_verifier (verifier)
487 m_verifier->verifyBoolean(m_testCtx, GL_SAMPLE_COVERAGE_INVERT, false);
488 expectError(GL_NO_ERROR);
490 glSampleCoverage(1.0f, GL_TRUE);
491 m_verifier->verifyBoolean(m_testCtx, GL_SAMPLE_COVERAGE_INVERT, true);
492 expectError(GL_NO_ERROR);
494 glSampleCoverage(1.0f, GL_FALSE);
495 m_verifier->verifyBoolean(m_testCtx, GL_SAMPLE_COVERAGE_INVERT, false);
496 expectError(GL_NO_ERROR);
499 StateVerifier* m_verifier;
502 class InitialBooleanTestCase : public ApiCase
505 InitialBooleanTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum target, bool reference)
506 : ApiCase (context, name, description)
508 , m_reference (reference)
509 , m_verifier (verifier)
515 m_verifier->verifyBoolean(m_testCtx, m_target, m_reference);
516 expectError(GL_NO_ERROR);
522 StateVerifier* m_verifier;
525 class ColorMaskTestCase : public ApiCase
528 ColorMaskTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
529 : ApiCase(context, name, description)
530 , m_verifier (verifier)
535 m_verifier->verifyBoolean4(m_testCtx, GL_COLOR_WRITEMASK, true, true, true, true);
536 expectError(GL_NO_ERROR);
538 const struct ColorMask
540 GLboolean r, g, b, a;
543 { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE },
544 { GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE },
545 { GL_TRUE, GL_TRUE, GL_FALSE, GL_TRUE },
546 { GL_TRUE, GL_TRUE, GL_FALSE, GL_FALSE },
547 { GL_TRUE, GL_FALSE, GL_TRUE, GL_TRUE },
548 { GL_TRUE, GL_FALSE, GL_TRUE, GL_FALSE },
549 { GL_TRUE, GL_FALSE, GL_FALSE, GL_TRUE },
550 { GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE },
551 { GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE },
552 { GL_FALSE, GL_TRUE, GL_TRUE, GL_FALSE },
553 { GL_FALSE, GL_TRUE, GL_FALSE, GL_TRUE },
554 { GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE },
555 { GL_FALSE, GL_FALSE, GL_TRUE, GL_TRUE },
556 { GL_FALSE, GL_FALSE, GL_TRUE, GL_FALSE },
557 { GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE },
558 { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE },
561 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(testMasks); ndx++)
563 glColorMask(testMasks[ndx].r, testMasks[ndx].g, testMasks[ndx].b, testMasks[ndx].a);
564 m_verifier->verifyBoolean4(m_testCtx, GL_COLOR_WRITEMASK, testMasks[ndx].r==GL_TRUE, testMasks[ndx].g==GL_TRUE, testMasks[ndx].b==GL_TRUE, testMasks[ndx].a==GL_TRUE);
565 expectError(GL_NO_ERROR);
569 StateVerifier* m_verifier;
573 class TransformFeedbackTestCase : public ApiCase
576 TransformFeedbackTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
577 : ApiCase (context, name, description)
578 , m_verifier (verifier)
579 , m_transformfeedback (0)
585 glGenTransformFeedbacks(1, &m_transformfeedback);
586 expectError(GL_NO_ERROR);
588 GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER);
589 glShaderSource(shaderVert, 1, &transformFeedbackTestVertSource, DE_NULL);
590 glCompileShader(shaderVert);
591 expectError(GL_NO_ERROR);
593 glGetShaderiv(shaderVert, GL_COMPILE_STATUS, &compileStatus);
594 checkBooleans(compileStatus, GL_TRUE);
596 GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER);
597 glShaderSource(shaderFrag, 1, &transformFeedbackTestFragSource, DE_NULL);
598 glCompileShader(shaderFrag);
599 expectError(GL_NO_ERROR);
600 glGetShaderiv(shaderFrag, GL_COMPILE_STATUS, &compileStatus);
601 checkBooleans(compileStatus, GL_TRUE);
603 GLuint shaderProg = glCreateProgram();
604 glAttachShader(shaderProg, shaderVert);
605 glAttachShader(shaderProg, shaderFrag);
606 const char* transform_feedback_outputs = "gl_Position";
607 glTransformFeedbackVaryings(shaderProg, 1, &transform_feedback_outputs, GL_INTERLEAVED_ATTRIBS);
608 glLinkProgram(shaderProg);
609 expectError(GL_NO_ERROR);
611 glGetProgramiv(shaderProg, GL_LINK_STATUS, &linkStatus);
612 checkBooleans(linkStatus, GL_TRUE);
614 glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, m_transformfeedback);
615 expectError(GL_NO_ERROR);
617 GLuint feedbackBufferId;
618 glGenBuffers(1, &feedbackBufferId);
619 glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, feedbackBufferId);
620 glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_DYNAMIC_READ);
621 glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, feedbackBufferId);
622 expectError(GL_NO_ERROR);
624 glUseProgram(shaderProg);
626 testTransformFeedback();
629 glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
630 glDeleteTransformFeedbacks(1, &m_transformfeedback);
631 glDeleteBuffers(1, &feedbackBufferId);
632 glDeleteShader(shaderVert);
633 glDeleteShader(shaderFrag);
634 glDeleteProgram(shaderProg);
635 expectError(GL_NO_ERROR);
638 virtual void testTransformFeedback (void) = DE_NULL;
641 StateVerifier* m_verifier;
642 GLuint m_transformfeedback;
645 class TransformFeedbackBasicTestCase : public TransformFeedbackTestCase
648 TransformFeedbackBasicTestCase (Context& context, StateVerifier* verifier, const char* name)
649 : TransformFeedbackTestCase (context, verifier, name, "Test TRANSFORM_FEEDBACK_ACTIVE and TRANSFORM_FEEDBACK_PAUSED")
653 void testTransformFeedback (void)
655 glBeginTransformFeedback(GL_POINTS);
656 expectError(GL_NO_ERROR);
658 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_ACTIVE, true);
659 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_PAUSED, false);
660 expectError(GL_NO_ERROR);
662 glPauseTransformFeedback();
663 expectError(GL_NO_ERROR);
665 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_ACTIVE, true);
666 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_PAUSED, true);
667 expectError(GL_NO_ERROR);
669 glResumeTransformFeedback();
670 expectError(GL_NO_ERROR);
672 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_ACTIVE, true);
673 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_PAUSED, false);
674 expectError(GL_NO_ERROR);
676 glEndTransformFeedback();
677 expectError(GL_NO_ERROR);
679 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_ACTIVE, false);
680 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_PAUSED, false);
681 expectError(GL_NO_ERROR);
685 class TransformFeedbackImplicitResumeTestCase : public TransformFeedbackTestCase
688 TransformFeedbackImplicitResumeTestCase (Context& context, StateVerifier* verifier, const char* name)
689 : TransformFeedbackTestCase(context, verifier, name, "EndTransformFeedback performs an implicit ResumeTransformFeedback.")
693 void testTransformFeedback (void)
695 glBeginTransformFeedback(GL_POINTS);
696 expectError(GL_NO_ERROR);
698 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_ACTIVE, true);
699 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_PAUSED, false);
700 expectError(GL_NO_ERROR);
702 glPauseTransformFeedback();
703 expectError(GL_NO_ERROR);
705 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_ACTIVE, true);
706 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_PAUSED, true);
707 expectError(GL_NO_ERROR);
709 glEndTransformFeedback();
710 expectError(GL_NO_ERROR);
712 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_ACTIVE, false);
713 m_verifier->verifyBoolean(m_testCtx, GL_TRANSFORM_FEEDBACK_PAUSED, false);
714 expectError(GL_NO_ERROR);
718 #define FOR_EACH_VERIFIER(VERIFIERS, CODE_BLOCK) \
719 for (int _verifierNdx = 0; _verifierNdx < DE_LENGTH_OF_ARRAY(VERIFIERS); _verifierNdx++) \
721 StateVerifier* verifier = (VERIFIERS)[_verifierNdx]; \
727 BooleanStateQueryTests::BooleanStateQueryTests (Context& context)
728 : TestCaseGroup (context, "boolean", "Boolean State Query tests")
729 , m_verifierIsEnabled (DE_NULL)
730 , m_verifierBoolean (DE_NULL)
731 , m_verifierInteger (DE_NULL)
732 , m_verifierInteger64 (DE_NULL)
733 , m_verifierFloat (DE_NULL)
737 BooleanStateQueryTests::~BooleanStateQueryTests (void)
742 void BooleanStateQueryTests::init (void)
744 DE_ASSERT(m_verifierIsEnabled == DE_NULL);
745 DE_ASSERT(m_verifierBoolean == DE_NULL);
746 DE_ASSERT(m_verifierInteger == DE_NULL);
747 DE_ASSERT(m_verifierInteger64 == DE_NULL);
748 DE_ASSERT(m_verifierFloat == DE_NULL);
750 m_verifierIsEnabled = new IsEnabledVerifier (m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
751 m_verifierBoolean = new GetBooleanVerifier (m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
752 m_verifierInteger = new GetIntegerVerifier (m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
753 m_verifierInteger64 = new GetInteger64Verifier (m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
754 m_verifierFloat = new GetFloatVerifier (m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
756 StateVerifier* isEnabledVerifiers[] = {m_verifierIsEnabled, m_verifierBoolean, m_verifierInteger, m_verifierInteger64, m_verifierFloat};
757 StateVerifier* normalVerifiers[] = {m_verifierBoolean, m_verifierInteger, m_verifierInteger64, m_verifierFloat};
762 const char* description;
766 const StateBoolean isEnableds[] =
768 { "primitive_restart_fixed_index", "PRIMITIVE_RESTART_FIXED_INDEX", GL_PRIMITIVE_RESTART_FIXED_INDEX, false},
769 { "rasterizer_discard", "RASTERIZER_DISCARD", GL_RASTERIZER_DISCARD, false},
770 { "cull_face", "CULL_FACE", GL_CULL_FACE, false},
771 { "polygon_offset_fill", "POLYGON_OFFSET_FILL", GL_POLYGON_OFFSET_FILL, false},
772 { "sample_alpha_to_coverage", "SAMPLE_ALPHA_TO_COVERAGE", GL_SAMPLE_ALPHA_TO_COVERAGE, false},
773 { "sample_coverage", "SAMPLE_COVERAGE", GL_SAMPLE_COVERAGE, false},
774 { "scissor_test", "SCISSOR_TEST", GL_SCISSOR_TEST, false},
775 { "stencil_test", "STENCIL_TEST", GL_STENCIL_TEST, false},
776 { "depth_test", "DEPTH_TEST", GL_DEPTH_TEST, false},
777 { "blend", "BLEND", GL_BLEND, false},
778 { "dither", "DITHER", GL_DITHER, true },
780 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(isEnableds); testNdx++)
782 FOR_EACH_VERIFIER(isEnabledVerifiers, addChild(new IsEnabledStateTestCase(m_context, verifier, (std::string(isEnableds[testNdx].name) + verifier->getTestNamePostfix()).c_str(), isEnableds[testNdx].description, isEnableds[testNdx].targetName, isEnableds[testNdx].value)));
785 FOR_EACH_VERIFIER(normalVerifiers, addChild(new ColorMaskTestCase (m_context, verifier, (std::string("color_writemask") + verifier->getTestNamePostfix()).c_str(), "COLOR_WRITEMASK")));
786 FOR_EACH_VERIFIER(normalVerifiers, addChild(new DepthWriteMaskTestCase (m_context, verifier, (std::string("depth_writemask") + verifier->getTestNamePostfix()).c_str(), "DEPTH_WRITEMASK")));
787 FOR_EACH_VERIFIER(normalVerifiers, addChild(new SampleCoverageInvertTestCase (m_context, verifier, (std::string("sample_coverage_invert") + verifier->getTestNamePostfix()).c_str(), "SAMPLE_COVERAGE_INVERT")));
788 FOR_EACH_VERIFIER(normalVerifiers, addChild(new InitialBooleanTestCase (m_context, verifier, (std::string("shader_compiler") + verifier->getTestNamePostfix()).c_str(), "SHADER_COMPILER", GL_SHADER_COMPILER, true)));
789 FOR_EACH_VERIFIER(normalVerifiers, addChild(new InitialBooleanTestCase (m_context, verifier, (std::string("transform_feedback_active_initial") + verifier->getTestNamePostfix()).c_str(), "initial TRANSFORM_FEEDBACK_ACTIVE", GL_TRANSFORM_FEEDBACK_ACTIVE, false)));
790 FOR_EACH_VERIFIER(normalVerifiers, addChild(new InitialBooleanTestCase (m_context, verifier, (std::string("transform_feedback_paused_initial") + verifier->getTestNamePostfix()).c_str(), "initial TRANSFORM_FEEDBACK_PAUSED", GL_TRANSFORM_FEEDBACK_PAUSED, false)));
791 FOR_EACH_VERIFIER(normalVerifiers, addChild(new TransformFeedbackBasicTestCase (m_context, verifier, (std::string("transform_feedback") + verifier->getTestNamePostfix()).c_str())));
792 FOR_EACH_VERIFIER(normalVerifiers, addChild(new TransformFeedbackImplicitResumeTestCase (m_context, verifier, (std::string("transform_feedback_implicit_resume") + verifier->getTestNamePostfix()).c_str())));
795 void BooleanStateQueryTests::deinit (void)
797 if (m_verifierIsEnabled)
799 delete m_verifierIsEnabled;
800 m_verifierIsEnabled = DE_NULL;
802 if (m_verifierBoolean)
804 delete m_verifierBoolean;
805 m_verifierBoolean = DE_NULL;
807 if (m_verifierInteger)
809 delete m_verifierInteger;
810 m_verifierInteger = DE_NULL;
812 if (m_verifierInteger64)
814 delete m_verifierInteger64;
815 m_verifierInteger64 = DE_NULL;
819 delete m_verifierFloat;
820 m_verifierFloat = DE_NULL;
823 this->TestCaseGroup::deinit();