es31fTextureStateQueryTests.cpp revision cb82ed72dcbbfd8a6d07736c3259605227bc984f
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 Texture Param State Query tests. 22 *//*--------------------------------------------------------------------*/ 23 24#include "es31fTextureStateQueryTests.hpp" 25#include "glsStateQueryUtil.hpp" 26#include "gluRenderContext.hpp" 27#include "gluCallLogWrapper.hpp" 28#include "gluObjectWrapper.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_TEXTURE_PARAM_FLOAT: return "get_tex_parameterfv"; 48 case QUERY_TEXTURE_PARAM_INTEGER: return "get_tex_parameteriv"; 49 default: 50 DE_ASSERT(DE_FALSE); 51 return DE_NULL; 52 } 53} 54 55class DepthStencilModeCase : public TestCase 56{ 57public: 58 DepthStencilModeCase (Context& context, QueryType verifier, const char* name, const char* desc); 59 IterateResult iterate (void); 60 61private: 62 const QueryType m_verifier; 63}; 64 65DepthStencilModeCase::DepthStencilModeCase (Context& context, QueryType verifier, const char* name, const char* desc) 66 : TestCase (context, name, desc) 67 , m_verifier (verifier) 68{ 69} 70 71DepthStencilModeCase::IterateResult DepthStencilModeCase::iterate (void) 72{ 73 glu::Texture texture (m_context.getRenderContext()); 74 glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_testCtx.getLog()); 75 tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: "); 76 77 gl.enableLogging(true); 78 79 gl.glBindTexture(GL_TEXTURE_2D, *texture); 80 GLU_EXPECT_NO_ERROR(gl.glGetError(), "bind"); 81 82 { 83 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial"); 84 verifyStateTextureParamInteger(result, gl, GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_DEPTH_COMPONENT, m_verifier); 85 } 86 87 { 88 const tcu::ScopedLogSection section (m_testCtx.getLog(), "Toggle", "Toggle"); 89 const glw::GLint depthComponentInt = GL_DEPTH_COMPONENT; 90 const glw::GLfloat depthComponentFloat = (glw::GLfloat)GL_DEPTH_COMPONENT; 91 92 gl.glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_STENCIL_INDEX); 93 GLU_EXPECT_NO_ERROR(gl.glGetError(), "set state"); 94 verifyStateTextureParamInteger(result, gl, GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_STENCIL_INDEX, m_verifier); 95 96 gl.glTexParameteriv(GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, &depthComponentInt); 97 GLU_EXPECT_NO_ERROR(gl.glGetError(), "set state"); 98 verifyStateTextureParamInteger(result, gl, GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_DEPTH_COMPONENT, m_verifier); 99 100 gl.glTexParameterf(GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_STENCIL_INDEX); 101 GLU_EXPECT_NO_ERROR(gl.glGetError(), "set state"); 102 verifyStateTextureParamInteger(result, gl, GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_STENCIL_INDEX, m_verifier); 103 104 gl.glTexParameterfv(GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, &depthComponentFloat); 105 GLU_EXPECT_NO_ERROR(gl.glGetError(), "set state"); 106 verifyStateTextureParamInteger(result, gl, GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_DEPTH_COMPONENT, m_verifier); 107 } 108 109 result.setTestContextResult(m_testCtx); 110 return STOP; 111} 112 113} // anonymous 114 115TextureStateQueryTests::TextureStateQueryTests (Context& context) 116 : TestCaseGroup(context, "texture", "Texture State Query tests") 117{ 118} 119 120TextureStateQueryTests::~TextureStateQueryTests (void) 121{ 122} 123 124void TextureStateQueryTests::init (void) 125{ 126 static const QueryType verifiers[] = 127 { 128 QUERY_TEXTURE_PARAM_INTEGER, 129 QUERY_TEXTURE_PARAM_FLOAT, 130 }; 131 132#define FOR_EACH_VERIFIER(X) \ 133 for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(verifiers); ++verifierNdx) \ 134 { \ 135 const char* verifierSuffix = getVerifierSuffix(verifiers[verifierNdx]); \ 136 const QueryType verifier = verifiers[verifierNdx]; \ 137 this->addChild(X); \ 138 } 139 140 FOR_EACH_VERIFIER(new DepthStencilModeCase(m_context, verifier, (std::string("depth_stencil_mode_case_") + verifierSuffix).c_str(), "Test DEPTH_STENCIL_TEXTURE_MODE")); 141 142#undef FOR_EACH_VERIFIER 143} 144 145} // Functional 146} // gles31 147} // deqp 148