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