1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.1 Module
3 * -------------------------------------------------
4 *
5 * Copyright 2015 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 "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"
31
32 namespace deqp
33 {
34 namespace gles31
35 {
36 namespace Functional
37 {
38 namespace
39 {
40
41 using namespace gls::StateQueryUtil;
42
getVerifierSuffix(QueryType type)43 static const char *getVerifierSuffix(QueryType type)
44 {
45 switch (type)
46 {
47 case QUERY_ISENABLED:
48 return "isenabled";
49 case QUERY_BOOLEAN:
50 return "getboolean";
51 case QUERY_INTEGER:
52 return "getinteger";
53 case QUERY_INTEGER64:
54 return "getinteger64";
55 case QUERY_FLOAT:
56 return "getfloat";
57 default:
58 DE_ASSERT(false);
59 return DE_NULL;
60 }
61 }
62
63 class IsEnabledStateTestCase : public TestCase, private glu::CallLogWrapper
64 {
65 public:
IsEnabledStateTestCase(Context & context,QueryType verifier,const char * name,const char * description,glw::GLenum targetName,bool initial,glu::ApiType minimumContextVersion)66 IsEnabledStateTestCase(Context &context, QueryType verifier, const char *name, const char *description,
67 glw::GLenum targetName, bool initial, glu::ApiType minimumContextVersion)
68 : TestCase(context, name, description)
69 , glu::CallLogWrapper(context.getRenderContext().getFunctions(), context.getTestContext().getLog())
70 , m_targetName(targetName)
71 , m_initial(initial)
72 , m_verifier(verifier)
73 , m_minimumVersion(minimumContextVersion)
74 {
75 }
76
iterate(void)77 IterateResult iterate(void)
78 {
79 if (!contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)))
80 TCU_CHECK_AND_THROW(NotSupportedError,
81 contextSupports(m_context.getRenderContext().getType(), m_minimumVersion),
82 "This test requires a higher context version.");
83
84 tcu::ResultCollector result(m_testCtx.getLog(), " // ERROR: ");
85 enableLogging(true);
86
87 // check inital value
88 verifyStateBoolean(result, *this, m_targetName, m_initial, m_verifier);
89
90 // check toggle
91
92 GLU_CHECK_CALL(glEnable(m_targetName));
93
94 verifyStateBoolean(result, *this, m_targetName, true, m_verifier);
95
96 GLU_CHECK_CALL(glDisable(m_targetName));
97
98 verifyStateBoolean(result, *this, m_targetName, false, m_verifier);
99
100 result.setTestContextResult(m_testCtx);
101 return STOP;
102 }
103
104 private:
105 const glw::GLenum m_targetName;
106 const bool m_initial;
107 const QueryType m_verifier;
108 const glu::ApiType m_minimumVersion;
109 };
110
111 } // namespace
112
BooleanStateQueryTests(Context & context)113 BooleanStateQueryTests::BooleanStateQueryTests(Context &context)
114 : TestCaseGroup(context, "boolean", "Boolean State Query tests")
115 {
116 }
117
~BooleanStateQueryTests(void)118 BooleanStateQueryTests::~BooleanStateQueryTests(void)
119 {
120 }
121
init(void)122 void BooleanStateQueryTests::init(void)
123 {
124 const bool isDebugContext = (m_context.getRenderContext().getType().getFlags() & glu::CONTEXT_DEBUG) != 0;
125
126 static const QueryType isEnabledVerifiers[] = {QUERY_ISENABLED, QUERY_BOOLEAN, QUERY_INTEGER, QUERY_INTEGER64,
127 QUERY_FLOAT};
128
129 #define FOR_EACH_VERIFIER(VERIFIERS, X) \
130 do \
131 { \
132 for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(VERIFIERS); ++verifierNdx) \
133 { \
134 const char *verifierSuffix = getVerifierSuffix((VERIFIERS)[verifierNdx]); \
135 const QueryType verifier = (VERIFIERS)[verifierNdx]; \
136 this->addChild(X); \
137 } \
138 } while (0)
139
140 struct StateBoolean
141 {
142 const char *name;
143 const char *description;
144 glw::GLenum targetName;
145 bool value;
146 glu::ApiType minimumContext;
147 };
148
149 {
150 const StateBoolean isEnableds[] = {
151 {"sample_mask", "SAMPLE_MASK", GL_SAMPLE_MASK, false, glu::ApiType::es(3, 1)},
152 {"sample_shading", "SAMPLE_SHADING", GL_SAMPLE_SHADING, false, glu::ApiType::es(3, 2)},
153 {"debug_output", "DEBUG_OUTPUT", GL_DEBUG_OUTPUT, isDebugContext, glu::ApiType::es(3, 2)},
154 {"debug_output_synchronous", "DEBUG_OUTPUT_SYNCHRONOUS", GL_DEBUG_OUTPUT_SYNCHRONOUS, false,
155 glu::ApiType::es(3, 2)},
156 };
157
158 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(isEnableds); testNdx++)
159 {
160 FOR_EACH_VERIFIER(
161 isEnabledVerifiers,
162 new IsEnabledStateTestCase(m_context, verifier,
163 (std::string(isEnableds[testNdx].name) + "_" + verifierSuffix).c_str(),
164 isEnableds[testNdx].description, isEnableds[testNdx].targetName,
165 isEnableds[testNdx].value, isEnableds[testNdx].minimumContext));
166 }
167 }
168
169 #undef FOR_EACH_VERIFIER
170 }
171
172 } // namespace Functional
173 } // namespace gles31
174 } // namespace deqp
175