1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.1 Module
3 * -------------------------------------------------
5 * Copyright 2015 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 "es31fBooleanStateQueryTests.hpp"
25 #include "glsStateQueryUtil.hpp"
26 #include "gluRenderContext.hpp"
27 #include "gluCallLogWrapper.hpp"
28 #include "tcuRenderTarget.hpp"
29 #include "glwFunctions.hpp"
30 #include "glwEnums.hpp"
41 using namespace gls::StateQueryUtil;
43 static const char* getVerifierSuffix (QueryType type)
47 case QUERY_ISENABLED: return "isenabled";
48 case QUERY_BOOLEAN: return "getboolean";
49 case QUERY_INTEGER: return "getinteger";
50 case QUERY_INTEGER64: return "getinteger64";
51 case QUERY_FLOAT: return "getfloat";
58 class IsEnabledStateTestCase : public TestCase, private glu::CallLogWrapper
61 IsEnabledStateTestCase (Context& context, QueryType verifier, const char* name, const char* description, glw::GLenum targetName, bool initial, glu::ApiType minimumContextVersion)
62 : TestCase (context, name, description)
63 , glu::CallLogWrapper (context.getRenderContext().getFunctions(), context.getTestContext().getLog())
64 , m_targetName (targetName)
66 , m_verifier (verifier)
67 , m_minimumVersion (minimumContextVersion)
71 IterateResult iterate (void)
73 TCU_CHECK_AND_THROW(NotSupportedError, contextSupports(m_context.getRenderContext().getType(), m_minimumVersion), "This test requires a higher context version.");
75 tcu::ResultCollector result(m_testCtx.getLog(), " // ERROR: ");
79 verifyStateBoolean(result, *this, m_targetName, m_initial, m_verifier);
83 GLU_CHECK_CALL(glEnable(m_targetName));
85 verifyStateBoolean(result, *this, m_targetName, true, m_verifier);
87 GLU_CHECK_CALL(glDisable(m_targetName));
89 verifyStateBoolean(result, *this, m_targetName, false, m_verifier);
91 result.setTestContextResult(m_testCtx);
96 const glw::GLenum m_targetName;
98 const QueryType m_verifier;
99 const glu::ApiType m_minimumVersion;
104 BooleanStateQueryTests::BooleanStateQueryTests (Context& context)
105 : TestCaseGroup(context, "boolean", "Boolean State Query tests")
109 BooleanStateQueryTests::~BooleanStateQueryTests (void)
113 void BooleanStateQueryTests::init (void)
115 const bool isDebugContext = (m_context.getRenderContext().getType().getFlags() & glu::CONTEXT_DEBUG) != 0;
117 static const QueryType isEnabledVerifiers[] =
126 #define FOR_EACH_VERIFIER(VERIFIERS, X) \
127 for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(VERIFIERS); ++verifierNdx) \
129 const char* verifierSuffix = getVerifierSuffix((VERIFIERS)[verifierNdx]); \
130 const QueryType verifier = (VERIFIERS)[verifierNdx]; \
137 const char* description;
138 glw::GLenum targetName;
140 glu::ApiType minimumContext;
144 const StateBoolean isEnableds[] =
146 { "sample_mask", "SAMPLE_MASK", GL_SAMPLE_MASK, false, glu::ApiType::es(3, 1)},
147 { "sample_shading", "SAMPLE_SHADING", GL_SAMPLE_SHADING, false, glu::ApiType::es(3, 2)},
148 { "debug_output", "DEBUG_OUTPUT", GL_DEBUG_OUTPUT, isDebugContext, glu::ApiType::es(3, 2)},
149 { "debug_output_synchronous", "DEBUG_OUTPUT_SYNCHRONOUS", GL_DEBUG_OUTPUT_SYNCHRONOUS, false, glu::ApiType::es(3, 2)},
152 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(isEnableds); testNdx++)
154 FOR_EACH_VERIFIER(isEnabledVerifiers, new IsEnabledStateTestCase(m_context, verifier, (std::string(isEnableds[testNdx].name) + "_" + verifierSuffix).c_str(), isEnableds[testNdx].description, isEnableds[testNdx].targetName, isEnableds[testNdx].value, isEnableds[testNdx].minimumContext));
158 #undef FOR_EACH_VERIFIER