1e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------- 2e5c31af7Sopenharmony_ci * drawElements Quality Program OpenGL ES 3.1 Module 3e5c31af7Sopenharmony_ci * ------------------------------------------------- 4e5c31af7Sopenharmony_ci * 5e5c31af7Sopenharmony_ci * Copyright 2015 The Android Open Source Project 6e5c31af7Sopenharmony_ci * 7e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 8e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License. 9e5c31af7Sopenharmony_ci * You may obtain a copy of the License at 10e5c31af7Sopenharmony_ci * 11e5c31af7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 12e5c31af7Sopenharmony_ci * 13e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 14e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 15e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and 17e5c31af7Sopenharmony_ci * limitations under the License. 18e5c31af7Sopenharmony_ci * 19e5c31af7Sopenharmony_ci *//*! 20e5c31af7Sopenharmony_ci * \file 21e5c31af7Sopenharmony_ci * \brief Framebuffer Default State Query tests. 22e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/ 23e5c31af7Sopenharmony_ci 24e5c31af7Sopenharmony_ci#include "es31fFramebufferDefaultStateQueryTests.hpp" 25e5c31af7Sopenharmony_ci#include "glsStateQueryUtil.hpp" 26e5c31af7Sopenharmony_ci#include "gluRenderContext.hpp" 27e5c31af7Sopenharmony_ci#include "gluCallLogWrapper.hpp" 28e5c31af7Sopenharmony_ci#include "gluObjectWrapper.hpp" 29e5c31af7Sopenharmony_ci#include "glwFunctions.hpp" 30e5c31af7Sopenharmony_ci#include "glwEnums.hpp" 31e5c31af7Sopenharmony_ci 32e5c31af7Sopenharmony_cinamespace deqp 33e5c31af7Sopenharmony_ci{ 34e5c31af7Sopenharmony_cinamespace gles31 35e5c31af7Sopenharmony_ci{ 36e5c31af7Sopenharmony_cinamespace Functional 37e5c31af7Sopenharmony_ci{ 38e5c31af7Sopenharmony_cinamespace 39e5c31af7Sopenharmony_ci{ 40e5c31af7Sopenharmony_ci 41e5c31af7Sopenharmony_ciusing namespace gls::StateQueryUtil; 42e5c31af7Sopenharmony_ci 43e5c31af7Sopenharmony_cistatic const char* getVerifierSuffix (QueryType type) 44e5c31af7Sopenharmony_ci{ 45e5c31af7Sopenharmony_ci switch (type) 46e5c31af7Sopenharmony_ci { 47e5c31af7Sopenharmony_ci case QUERY_FRAMEBUFFER_INTEGER: return "get_framebuffer_parameteriv"; 48e5c31af7Sopenharmony_ci default: 49e5c31af7Sopenharmony_ci DE_ASSERT(DE_FALSE); 50e5c31af7Sopenharmony_ci return DE_NULL; 51e5c31af7Sopenharmony_ci } 52e5c31af7Sopenharmony_ci} 53e5c31af7Sopenharmony_ci 54e5c31af7Sopenharmony_ciclass FramebufferTest : public TestCase 55e5c31af7Sopenharmony_ci{ 56e5c31af7Sopenharmony_cipublic: 57e5c31af7Sopenharmony_ci FramebufferTest (Context& context, QueryType verifier, const char* name, const char* desc); 58e5c31af7Sopenharmony_ci IterateResult iterate (void); 59e5c31af7Sopenharmony_ci 60e5c31af7Sopenharmony_ciprotected: 61e5c31af7Sopenharmony_ci virtual void checkInitial (tcu::ResultCollector& result, glu::CallLogWrapper& gl) = 0; 62e5c31af7Sopenharmony_ci virtual void checkSet (tcu::ResultCollector& result, glu::CallLogWrapper& gl) = 0; 63e5c31af7Sopenharmony_ci 64e5c31af7Sopenharmony_ci const QueryType m_verifier; 65e5c31af7Sopenharmony_ci}; 66e5c31af7Sopenharmony_ci 67e5c31af7Sopenharmony_ciFramebufferTest::FramebufferTest (Context& context, QueryType verifier, const char* name, const char* desc) 68e5c31af7Sopenharmony_ci : TestCase (context, name, desc) 69e5c31af7Sopenharmony_ci , m_verifier (verifier) 70e5c31af7Sopenharmony_ci{ 71e5c31af7Sopenharmony_ci} 72e5c31af7Sopenharmony_ci 73e5c31af7Sopenharmony_ciFramebufferTest::IterateResult FramebufferTest::iterate (void) 74e5c31af7Sopenharmony_ci{ 75e5c31af7Sopenharmony_ci glu::Framebuffer fbo (m_context.getRenderContext()); 76e5c31af7Sopenharmony_ci glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_testCtx.getLog()); 77e5c31af7Sopenharmony_ci tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: "); 78e5c31af7Sopenharmony_ci 79e5c31af7Sopenharmony_ci gl.enableLogging(true); 80e5c31af7Sopenharmony_ci 81e5c31af7Sopenharmony_ci gl.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, *fbo); 82e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.glGetError(), "bind"); 83e5c31af7Sopenharmony_ci 84e5c31af7Sopenharmony_ci { 85e5c31af7Sopenharmony_ci const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial"); 86e5c31af7Sopenharmony_ci checkInitial(result, gl); 87e5c31af7Sopenharmony_ci } 88e5c31af7Sopenharmony_ci 89e5c31af7Sopenharmony_ci { 90e5c31af7Sopenharmony_ci const tcu::ScopedLogSection section(m_testCtx.getLog(), "Set", "Set"); 91e5c31af7Sopenharmony_ci checkSet(result, gl); 92e5c31af7Sopenharmony_ci } 93e5c31af7Sopenharmony_ci 94e5c31af7Sopenharmony_ci result.setTestContextResult(m_testCtx); 95e5c31af7Sopenharmony_ci return STOP; 96e5c31af7Sopenharmony_ci} 97e5c31af7Sopenharmony_ci 98e5c31af7Sopenharmony_ciclass FramebufferDimensionTest : public FramebufferTest 99e5c31af7Sopenharmony_ci{ 100e5c31af7Sopenharmony_cipublic: 101e5c31af7Sopenharmony_ci enum DimensionType 102e5c31af7Sopenharmony_ci { 103e5c31af7Sopenharmony_ci DIMENSION_WIDTH = 0, 104e5c31af7Sopenharmony_ci DIMENSION_HEIGHT, 105e5c31af7Sopenharmony_ci 106e5c31af7Sopenharmony_ci DIMENSION_LAST 107e5c31af7Sopenharmony_ci }; 108e5c31af7Sopenharmony_ci 109e5c31af7Sopenharmony_ci FramebufferDimensionTest (Context& context, QueryType verifier, DimensionType dimension, const char* name, const char* desc); 110e5c31af7Sopenharmony_ci void checkInitial (tcu::ResultCollector& result, glu::CallLogWrapper& gl); 111e5c31af7Sopenharmony_ci void checkSet (tcu::ResultCollector& result, glu::CallLogWrapper& gl); 112e5c31af7Sopenharmony_ci 113e5c31af7Sopenharmony_ciprivate: 114e5c31af7Sopenharmony_ci const DimensionType m_dimension; 115e5c31af7Sopenharmony_ci}; 116e5c31af7Sopenharmony_ci 117e5c31af7Sopenharmony_ciFramebufferDimensionTest::FramebufferDimensionTest (Context& context, QueryType verifier, DimensionType dimension, const char* name, const char* desc) 118e5c31af7Sopenharmony_ci : FramebufferTest (context, verifier, name, desc) 119e5c31af7Sopenharmony_ci , m_dimension (dimension) 120e5c31af7Sopenharmony_ci{ 121e5c31af7Sopenharmony_ci DE_ASSERT(dimension < DIMENSION_LAST); 122e5c31af7Sopenharmony_ci} 123e5c31af7Sopenharmony_ci 124e5c31af7Sopenharmony_civoid FramebufferDimensionTest::checkInitial (tcu::ResultCollector& result, glu::CallLogWrapper& gl) 125e5c31af7Sopenharmony_ci{ 126e5c31af7Sopenharmony_ci const glw::GLenum pname = (m_dimension == DIMENSION_WIDTH) ? (GL_FRAMEBUFFER_DEFAULT_WIDTH) : (GL_FRAMEBUFFER_DEFAULT_HEIGHT); 127e5c31af7Sopenharmony_ci verifyStateFramebufferInteger(result, gl, GL_DRAW_FRAMEBUFFER, pname, 0, m_verifier); 128e5c31af7Sopenharmony_ci} 129e5c31af7Sopenharmony_ci 130e5c31af7Sopenharmony_civoid FramebufferDimensionTest::checkSet (tcu::ResultCollector& result, glu::CallLogWrapper& gl) 131e5c31af7Sopenharmony_ci{ 132e5c31af7Sopenharmony_ci const glw::GLenum pname = (m_dimension == DIMENSION_WIDTH) ? (GL_FRAMEBUFFER_DEFAULT_WIDTH) : (GL_FRAMEBUFFER_DEFAULT_HEIGHT); 133e5c31af7Sopenharmony_ci 134e5c31af7Sopenharmony_ci gl.glFramebufferParameteri(GL_DRAW_FRAMEBUFFER, pname, 32); 135e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.glGetError(), "set state"); 136e5c31af7Sopenharmony_ci 137e5c31af7Sopenharmony_ci verifyStateFramebufferInteger(result, gl, GL_DRAW_FRAMEBUFFER, pname, 32, m_verifier); 138e5c31af7Sopenharmony_ci} 139e5c31af7Sopenharmony_ci 140e5c31af7Sopenharmony_ciclass FramebufferSamplesTest : public FramebufferTest 141e5c31af7Sopenharmony_ci{ 142e5c31af7Sopenharmony_cipublic: 143e5c31af7Sopenharmony_ci FramebufferSamplesTest (Context& context, QueryType verifier, const char* name, const char* desc); 144e5c31af7Sopenharmony_ci void checkInitial (tcu::ResultCollector& result, glu::CallLogWrapper& gl); 145e5c31af7Sopenharmony_ci void checkSet (tcu::ResultCollector& result, glu::CallLogWrapper& gl); 146e5c31af7Sopenharmony_ci}; 147e5c31af7Sopenharmony_ci 148e5c31af7Sopenharmony_ciFramebufferSamplesTest::FramebufferSamplesTest (Context& context, QueryType verifier, const char* name, const char* desc) 149e5c31af7Sopenharmony_ci : FramebufferTest(context, verifier, name, desc) 150e5c31af7Sopenharmony_ci{ 151e5c31af7Sopenharmony_ci} 152e5c31af7Sopenharmony_ci 153e5c31af7Sopenharmony_civoid FramebufferSamplesTest::checkInitial (tcu::ResultCollector& result, glu::CallLogWrapper& gl) 154e5c31af7Sopenharmony_ci{ 155e5c31af7Sopenharmony_ci verifyStateFramebufferInteger(result, gl, GL_DRAW_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_SAMPLES, 0, m_verifier); 156e5c31af7Sopenharmony_ci} 157e5c31af7Sopenharmony_ci 158e5c31af7Sopenharmony_civoid FramebufferSamplesTest::checkSet (tcu::ResultCollector& result, glu::CallLogWrapper& gl) 159e5c31af7Sopenharmony_ci{ 160e5c31af7Sopenharmony_ci gl.glFramebufferParameteri(GL_DRAW_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_SAMPLES, 1); 161e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.glGetError(), "set state"); 162e5c31af7Sopenharmony_ci verifyStateFramebufferIntegerMin(result, gl, GL_DRAW_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_SAMPLES, 1, m_verifier); 163e5c31af7Sopenharmony_ci 164e5c31af7Sopenharmony_ci gl.glFramebufferParameteri(GL_DRAW_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_SAMPLES, 0); 165e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.glGetError(), "set state"); 166e5c31af7Sopenharmony_ci verifyStateFramebufferInteger(result, gl, GL_DRAW_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_SAMPLES, 0, m_verifier); 167e5c31af7Sopenharmony_ci} 168e5c31af7Sopenharmony_ci 169e5c31af7Sopenharmony_ciclass FramebufferFixedSampleLocationsTest : public FramebufferTest 170e5c31af7Sopenharmony_ci{ 171e5c31af7Sopenharmony_cipublic: 172e5c31af7Sopenharmony_ci FramebufferFixedSampleLocationsTest (Context& context, QueryType verifier, const char* name, const char* desc); 173e5c31af7Sopenharmony_ci void checkInitial (tcu::ResultCollector& result, glu::CallLogWrapper& gl); 174e5c31af7Sopenharmony_ci void checkSet (tcu::ResultCollector& result, glu::CallLogWrapper& gl); 175e5c31af7Sopenharmony_ci}; 176e5c31af7Sopenharmony_ci 177e5c31af7Sopenharmony_ciFramebufferFixedSampleLocationsTest::FramebufferFixedSampleLocationsTest (Context& context, QueryType verifier, const char* name, const char* desc) 178e5c31af7Sopenharmony_ci : FramebufferTest(context, verifier, name, desc) 179e5c31af7Sopenharmony_ci{ 180e5c31af7Sopenharmony_ci} 181e5c31af7Sopenharmony_ci 182e5c31af7Sopenharmony_civoid FramebufferFixedSampleLocationsTest::checkInitial (tcu::ResultCollector& result, glu::CallLogWrapper& gl) 183e5c31af7Sopenharmony_ci{ 184e5c31af7Sopenharmony_ci verifyStateFramebufferInteger(result, gl, GL_DRAW_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS, 0, m_verifier); 185e5c31af7Sopenharmony_ci} 186e5c31af7Sopenharmony_ci 187e5c31af7Sopenharmony_civoid FramebufferFixedSampleLocationsTest::checkSet (tcu::ResultCollector& result, glu::CallLogWrapper& gl) 188e5c31af7Sopenharmony_ci{ 189e5c31af7Sopenharmony_ci gl.glFramebufferParameteri(GL_DRAW_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS, GL_TRUE); 190e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.glGetError(), "set state"); 191e5c31af7Sopenharmony_ci verifyStateFramebufferInteger(result, gl, GL_DRAW_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS, GL_TRUE, m_verifier); 192e5c31af7Sopenharmony_ci} 193e5c31af7Sopenharmony_ci 194e5c31af7Sopenharmony_ci} // anonymous 195e5c31af7Sopenharmony_ci 196e5c31af7Sopenharmony_ciFramebufferDefaultStateQueryTests::FramebufferDefaultStateQueryTests (Context& context) 197e5c31af7Sopenharmony_ci : TestCaseGroup(context, "framebuffer_default", "Framebuffer Default State Query tests") 198e5c31af7Sopenharmony_ci{ 199e5c31af7Sopenharmony_ci} 200e5c31af7Sopenharmony_ci 201e5c31af7Sopenharmony_ciFramebufferDefaultStateQueryTests::~FramebufferDefaultStateQueryTests (void) 202e5c31af7Sopenharmony_ci{ 203e5c31af7Sopenharmony_ci} 204e5c31af7Sopenharmony_ci 205e5c31af7Sopenharmony_civoid FramebufferDefaultStateQueryTests::init (void) 206e5c31af7Sopenharmony_ci{ 207e5c31af7Sopenharmony_ci static const QueryType verifiers[] = 208e5c31af7Sopenharmony_ci { 209e5c31af7Sopenharmony_ci QUERY_FRAMEBUFFER_INTEGER, 210e5c31af7Sopenharmony_ci }; 211e5c31af7Sopenharmony_ci 212e5c31af7Sopenharmony_ci#define FOR_EACH_VERIFIER(X) \ 213e5c31af7Sopenharmony_ci do { \ 214e5c31af7Sopenharmony_ci for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(verifiers); ++verifierNdx) \ 215e5c31af7Sopenharmony_ci { \ 216e5c31af7Sopenharmony_ci const char* verifierSuffix = getVerifierSuffix(verifiers[verifierNdx]); \ 217e5c31af7Sopenharmony_ci const QueryType verifier = verifiers[verifierNdx]; \ 218e5c31af7Sopenharmony_ci this->addChild(X); \ 219e5c31af7Sopenharmony_ci } \ 220e5c31af7Sopenharmony_ci } while (0) 221e5c31af7Sopenharmony_ci 222e5c31af7Sopenharmony_ci FOR_EACH_VERIFIER(new FramebufferDimensionTest (m_context, verifier, FramebufferDimensionTest::DIMENSION_WIDTH, (std::string("framebuffer_default_width_") + verifierSuffix).c_str(), "Test FRAMEBUFFER_DEFAULT_WIDTH")); 223e5c31af7Sopenharmony_ci FOR_EACH_VERIFIER(new FramebufferDimensionTest (m_context, verifier, FramebufferDimensionTest::DIMENSION_HEIGHT, (std::string("framebuffer_default_height_") + verifierSuffix).c_str(), "Test FRAMEBUFFER_DEFAULT_HEIGHT")); 224e5c31af7Sopenharmony_ci FOR_EACH_VERIFIER(new FramebufferSamplesTest (m_context, verifier, (std::string("framebuffer_default_samples_") + verifierSuffix).c_str(), "Test FRAMEBUFFER_DEFAULT_SAMPLES")); 225e5c31af7Sopenharmony_ci FOR_EACH_VERIFIER(new FramebufferFixedSampleLocationsTest (m_context, verifier, (std::string("framebuffer_default_fixed_sample_locations_") + verifierSuffix).c_str(), "Test FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS")); 226e5c31af7Sopenharmony_ci 227e5c31af7Sopenharmony_ci#undef FOR_EACH_VERIFIER 228e5c31af7Sopenharmony_ci} 229e5c31af7Sopenharmony_ci 230e5c31af7Sopenharmony_ci} // Functional 231e5c31af7Sopenharmony_ci} // gles31 232e5c31af7Sopenharmony_ci} // deqp 233