• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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:	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";
52 		default:
53 			DE_ASSERT(DE_FALSE);
54 			return DE_NULL;
55 	}
56 }
57 
58 class IsEnabledStateTestCase : public TestCase, private glu::CallLogWrapper
59 {
60 public:
IsEnabledStateTestCase(Context & context,QueryType verifier,const char * name,const char * description,glw::GLenum targetName,bool initial,glu::ApiType minimumContextVersion)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)
65 		, m_initial				(initial)
66 		, m_verifier			(verifier)
67 		, m_minimumVersion		(minimumContextVersion)
68 	{
69 	}
70 
iterate(void)71 	IterateResult iterate (void)
72 	{
73 		TCU_CHECK_AND_THROW(NotSupportedError, contextSupports(m_context.getRenderContext().getType(), m_minimumVersion), "This test requires a higher context version.");
74 
75 		tcu::ResultCollector result(m_testCtx.getLog(), " // ERROR: ");
76 		enableLogging(true);
77 
78 		// check inital value
79 		verifyStateBoolean(result, *this, m_targetName, m_initial, m_verifier);
80 
81 		// check toggle
82 
83 		GLU_CHECK_CALL(glEnable(m_targetName));
84 
85 		verifyStateBoolean(result, *this, m_targetName, true, m_verifier);
86 
87 		GLU_CHECK_CALL(glDisable(m_targetName));
88 
89 		verifyStateBoolean(result, *this, m_targetName, false, m_verifier);
90 
91 		result.setTestContextResult(m_testCtx);
92 		return STOP;
93 	}
94 
95 private:
96 	const glw::GLenum		m_targetName;
97 	const bool				m_initial;
98 	const QueryType			m_verifier;
99 	const glu::ApiType		m_minimumVersion;
100 };
101 
102 } // anonymous
103 
BooleanStateQueryTests(Context & context)104 BooleanStateQueryTests::BooleanStateQueryTests (Context& context)
105 	: TestCaseGroup(context, "boolean", "Boolean State Query tests")
106 {
107 }
108 
~BooleanStateQueryTests(void)109 BooleanStateQueryTests::~BooleanStateQueryTests (void)
110 {
111 }
112 
init(void)113 void BooleanStateQueryTests::init (void)
114 {
115 	const bool isDebugContext = (m_context.getRenderContext().getType().getFlags() & glu::CONTEXT_DEBUG) != 0;
116 
117 	static const QueryType isEnabledVerifiers[] =
118 	{
119 		QUERY_ISENABLED,
120 		QUERY_BOOLEAN,
121 		QUERY_INTEGER,
122 		QUERY_INTEGER64,
123 		QUERY_FLOAT
124 	};
125 
126 #define FOR_EACH_VERIFIER(VERIFIERS, X) \
127 	for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(VERIFIERS); ++verifierNdx)	\
128 	{																						\
129 		const char* verifierSuffix = getVerifierSuffix((VERIFIERS)[verifierNdx]);			\
130 		const QueryType verifier = (VERIFIERS)[verifierNdx];								\
131 		this->addChild(X);																	\
132 	}
133 
134 	struct StateBoolean
135 	{
136 		const char*		name;
137 		const char*		description;
138 		glw::GLenum		targetName;
139 		bool			value;
140 		glu::ApiType	minimumContext;
141 	};
142 
143 	{
144 		const StateBoolean isEnableds[] =
145 		{
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)},
150 		};
151 
152 		for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(isEnableds); testNdx++)
153 		{
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));
155 		}
156 	}
157 
158 #undef FOR_EACH_VERIFIER
159 }
160 
161 } // Functional
162 } // gles31
163 } // deqp
164