1e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------- 2e5c31af7Sopenharmony_ci * drawElements Quality Program OpenGL ES 3.1 Module 3e5c31af7Sopenharmony_ci * ------------------------------------------------- 4e5c31af7Sopenharmony_ci * 5e5c31af7Sopenharmony_ci * Copyright 2014 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 Multisample interpolation state query tests 22e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/ 23e5c31af7Sopenharmony_ci 24e5c31af7Sopenharmony_ci#include "es31fShaderMultisampleInterpolationStateQueryTests.hpp" 25e5c31af7Sopenharmony_ci#include "tcuTestLog.hpp" 26e5c31af7Sopenharmony_ci#include "gluCallLogWrapper.hpp" 27e5c31af7Sopenharmony_ci#include "gluContextInfo.hpp" 28e5c31af7Sopenharmony_ci#include "gluRenderContext.hpp" 29e5c31af7Sopenharmony_ci#include "glsStateQueryUtil.hpp" 30e5c31af7Sopenharmony_ci#include "glwEnums.hpp" 31e5c31af7Sopenharmony_ci#include "glwFunctions.hpp" 32e5c31af7Sopenharmony_ci 33e5c31af7Sopenharmony_ci 34e5c31af7Sopenharmony_cinamespace deqp 35e5c31af7Sopenharmony_ci{ 36e5c31af7Sopenharmony_cinamespace gles31 37e5c31af7Sopenharmony_ci{ 38e5c31af7Sopenharmony_cinamespace Functional 39e5c31af7Sopenharmony_ci{ 40e5c31af7Sopenharmony_cinamespace 41e5c31af7Sopenharmony_ci{ 42e5c31af7Sopenharmony_ci 43e5c31af7Sopenharmony_ciusing namespace gls::StateQueryUtil; 44e5c31af7Sopenharmony_ci 45e5c31af7Sopenharmony_ciclass InterpolationOffsetCase : public TestCase 46e5c31af7Sopenharmony_ci{ 47e5c31af7Sopenharmony_cipublic: 48e5c31af7Sopenharmony_ci enum TestType 49e5c31af7Sopenharmony_ci { 50e5c31af7Sopenharmony_ci TEST_MIN_OFFSET = 0, 51e5c31af7Sopenharmony_ci TEST_MAX_OFFSET, 52e5c31af7Sopenharmony_ci 53e5c31af7Sopenharmony_ci TEST_LAST 54e5c31af7Sopenharmony_ci }; 55e5c31af7Sopenharmony_ci 56e5c31af7Sopenharmony_ci InterpolationOffsetCase (Context& context, const char* name, const char* desc, QueryType verifier, TestType testType); 57e5c31af7Sopenharmony_ci ~InterpolationOffsetCase (void); 58e5c31af7Sopenharmony_ci 59e5c31af7Sopenharmony_ci void init (void); 60e5c31af7Sopenharmony_ci IterateResult iterate (void); 61e5c31af7Sopenharmony_ci 62e5c31af7Sopenharmony_ciprivate: 63e5c31af7Sopenharmony_ci const QueryType m_verifier; 64e5c31af7Sopenharmony_ci const TestType m_testType; 65e5c31af7Sopenharmony_ci}; 66e5c31af7Sopenharmony_ci 67e5c31af7Sopenharmony_ciInterpolationOffsetCase::InterpolationOffsetCase (Context& context, const char* name, const char* desc, QueryType verifier, TestType testType) 68e5c31af7Sopenharmony_ci : TestCase (context, name, desc) 69e5c31af7Sopenharmony_ci , m_verifier (verifier) 70e5c31af7Sopenharmony_ci , m_testType (testType) 71e5c31af7Sopenharmony_ci{ 72e5c31af7Sopenharmony_ci DE_ASSERT(m_testType < TEST_LAST); 73e5c31af7Sopenharmony_ci} 74e5c31af7Sopenharmony_ci 75e5c31af7Sopenharmony_ciInterpolationOffsetCase::~InterpolationOffsetCase (void) 76e5c31af7Sopenharmony_ci{ 77e5c31af7Sopenharmony_ci} 78e5c31af7Sopenharmony_ci 79e5c31af7Sopenharmony_civoid InterpolationOffsetCase::init (void) 80e5c31af7Sopenharmony_ci{ 81e5c31af7Sopenharmony_ci auto ctxType = m_context.getRenderContext().getType(); 82e5c31af7Sopenharmony_ci const bool isES32orGL45 = glu::contextSupports(ctxType, glu::ApiType::es(3, 2)) || 83e5c31af7Sopenharmony_ci glu::contextSupports(ctxType, glu::ApiType::core(4, 5)); 84e5c31af7Sopenharmony_ci 85e5c31af7Sopenharmony_ci if (!isES32orGL45 && !m_context.getContextInfo().isExtensionSupported("GL_OES_shader_multisample_interpolation")) 86e5c31af7Sopenharmony_ci throw tcu::NotSupportedError("Test requires GL_OES_shader_multisample_interpolation extension"); 87e5c31af7Sopenharmony_ci} 88e5c31af7Sopenharmony_ci 89e5c31af7Sopenharmony_ciInterpolationOffsetCase::IterateResult InterpolationOffsetCase::iterate (void) 90e5c31af7Sopenharmony_ci{ 91e5c31af7Sopenharmony_ci glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_testCtx.getLog()); 92e5c31af7Sopenharmony_ci tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: "); 93e5c31af7Sopenharmony_ci gl.enableLogging(true); 94e5c31af7Sopenharmony_ci 95e5c31af7Sopenharmony_ci if (m_testType == TEST_MAX_OFFSET) 96e5c31af7Sopenharmony_ci { 97e5c31af7Sopenharmony_ci glw::GLfloat fragmentInterpolationOffsetBits = 0.0; 98e5c31af7Sopenharmony_ci gl.glGetFloatv(GL_FRAGMENT_INTERPOLATION_OFFSET_BITS, &fragmentInterpolationOffsetBits); 99e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.glGetError(), "glGetIntegerv"); 100e5c31af7Sopenharmony_ci 101e5c31af7Sopenharmony_ci glw::GLfloat ULP = 1.0f / powf(2, fragmentInterpolationOffsetBits); 102e5c31af7Sopenharmony_ci 103e5c31af7Sopenharmony_ci verifyStateFloatMin(result, gl, GL_MAX_FRAGMENT_INTERPOLATION_OFFSET, 0.5f-ULP, m_verifier); 104e5c31af7Sopenharmony_ci } 105e5c31af7Sopenharmony_ci else if (m_testType == TEST_MIN_OFFSET) 106e5c31af7Sopenharmony_ci verifyStateFloatMax(result, gl, GL_MIN_FRAGMENT_INTERPOLATION_OFFSET, -0.5f, m_verifier); 107e5c31af7Sopenharmony_ci else 108e5c31af7Sopenharmony_ci DE_ASSERT(false); 109e5c31af7Sopenharmony_ci 110e5c31af7Sopenharmony_ci result.setTestContextResult(m_testCtx); 111e5c31af7Sopenharmony_ci return STOP; 112e5c31af7Sopenharmony_ci} 113e5c31af7Sopenharmony_ci 114e5c31af7Sopenharmony_ciclass FragmentInterpolationOffsetBitsCase : public TestCase 115e5c31af7Sopenharmony_ci{ 116e5c31af7Sopenharmony_cipublic: 117e5c31af7Sopenharmony_ci FragmentInterpolationOffsetBitsCase (Context& context, const char* name, const char* desc, QueryType verifier); 118e5c31af7Sopenharmony_ci ~FragmentInterpolationOffsetBitsCase (void); 119e5c31af7Sopenharmony_ci 120e5c31af7Sopenharmony_ci void init (void); 121e5c31af7Sopenharmony_ci IterateResult iterate (void); 122e5c31af7Sopenharmony_ci 123e5c31af7Sopenharmony_ciprivate: 124e5c31af7Sopenharmony_ci const QueryType m_verifier; 125e5c31af7Sopenharmony_ci}; 126e5c31af7Sopenharmony_ci 127e5c31af7Sopenharmony_ciFragmentInterpolationOffsetBitsCase::FragmentInterpolationOffsetBitsCase (Context& context, const char* name, const char* desc, QueryType verifier) 128e5c31af7Sopenharmony_ci : TestCase (context, name, desc) 129e5c31af7Sopenharmony_ci , m_verifier (verifier) 130e5c31af7Sopenharmony_ci{ 131e5c31af7Sopenharmony_ci} 132e5c31af7Sopenharmony_ci 133e5c31af7Sopenharmony_ciFragmentInterpolationOffsetBitsCase::~FragmentInterpolationOffsetBitsCase (void) 134e5c31af7Sopenharmony_ci{ 135e5c31af7Sopenharmony_ci} 136e5c31af7Sopenharmony_ci 137e5c31af7Sopenharmony_civoid FragmentInterpolationOffsetBitsCase::init (void) 138e5c31af7Sopenharmony_ci{ 139e5c31af7Sopenharmony_ci auto ctxType = m_context.getRenderContext().getType(); 140e5c31af7Sopenharmony_ci const bool isES32orGL45 = glu::contextSupports(ctxType, glu::ApiType::es(3, 2)) || 141e5c31af7Sopenharmony_ci glu::contextSupports(ctxType, glu::ApiType::core(4, 5)); 142e5c31af7Sopenharmony_ci 143e5c31af7Sopenharmony_ci if (!isES32orGL45 && !m_context.getContextInfo().isExtensionSupported("GL_OES_shader_multisample_interpolation")) 144e5c31af7Sopenharmony_ci throw tcu::NotSupportedError("Test requires GL_OES_shader_multisample_interpolation extension"); 145e5c31af7Sopenharmony_ci} 146e5c31af7Sopenharmony_ci 147e5c31af7Sopenharmony_ciFragmentInterpolationOffsetBitsCase::IterateResult FragmentInterpolationOffsetBitsCase::iterate (void) 148e5c31af7Sopenharmony_ci{ 149e5c31af7Sopenharmony_ci glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_testCtx.getLog()); 150e5c31af7Sopenharmony_ci tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: "); 151e5c31af7Sopenharmony_ci gl.enableLogging(true); 152e5c31af7Sopenharmony_ci 153e5c31af7Sopenharmony_ci verifyStateIntegerMin(result, gl, GL_FRAGMENT_INTERPOLATION_OFFSET_BITS, 4, m_verifier); 154e5c31af7Sopenharmony_ci 155e5c31af7Sopenharmony_ci result.setTestContextResult(m_testCtx); 156e5c31af7Sopenharmony_ci return STOP; 157e5c31af7Sopenharmony_ci} 158e5c31af7Sopenharmony_ci 159e5c31af7Sopenharmony_ci} // anonymous 160e5c31af7Sopenharmony_ci 161e5c31af7Sopenharmony_ciShaderMultisampleInterpolationStateQueryTests::ShaderMultisampleInterpolationStateQueryTests (Context& context) 162e5c31af7Sopenharmony_ci : TestCaseGroup(context, "multisample_interpolation", "Test multisample interpolation states") 163e5c31af7Sopenharmony_ci{ 164e5c31af7Sopenharmony_ci} 165e5c31af7Sopenharmony_ci 166e5c31af7Sopenharmony_ciShaderMultisampleInterpolationStateQueryTests::~ShaderMultisampleInterpolationStateQueryTests (void) 167e5c31af7Sopenharmony_ci{ 168e5c31af7Sopenharmony_ci} 169e5c31af7Sopenharmony_ci 170e5c31af7Sopenharmony_civoid ShaderMultisampleInterpolationStateQueryTests::init (void) 171e5c31af7Sopenharmony_ci{ 172e5c31af7Sopenharmony_ci static const struct Verifier 173e5c31af7Sopenharmony_ci { 174e5c31af7Sopenharmony_ci QueryType verifier; 175e5c31af7Sopenharmony_ci const char* name; 176e5c31af7Sopenharmony_ci const char* desc; 177e5c31af7Sopenharmony_ci } verifiers[] = 178e5c31af7Sopenharmony_ci { 179e5c31af7Sopenharmony_ci { QUERY_BOOLEAN, "get_boolean", "Test using getBoolean" }, 180e5c31af7Sopenharmony_ci { QUERY_INTEGER, "get_integer", "Test using getInteger" }, 181e5c31af7Sopenharmony_ci { QUERY_FLOAT, "get_float", "Test using getFloat" }, 182e5c31af7Sopenharmony_ci { QUERY_INTEGER64, "get_integer64", "Test using getInteger64" }, 183e5c31af7Sopenharmony_ci }; 184e5c31af7Sopenharmony_ci 185e5c31af7Sopenharmony_ci // .min_fragment_interpolation_offset 186e5c31af7Sopenharmony_ci { 187e5c31af7Sopenharmony_ci tcu::TestCaseGroup* const group = new tcu::TestCaseGroup(m_testCtx, "min_fragment_interpolation_offset", "Test MIN_FRAGMENT_INTERPOLATION_OFFSET"); 188e5c31af7Sopenharmony_ci addChild(group); 189e5c31af7Sopenharmony_ci 190e5c31af7Sopenharmony_ci for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(verifiers); ++verifierNdx) 191e5c31af7Sopenharmony_ci group->addChild(new InterpolationOffsetCase(m_context, verifiers[verifierNdx].name, verifiers[verifierNdx].desc, verifiers[verifierNdx].verifier, InterpolationOffsetCase::TEST_MIN_OFFSET)); 192e5c31af7Sopenharmony_ci } 193e5c31af7Sopenharmony_ci 194e5c31af7Sopenharmony_ci // .max_fragment_interpolation_offset 195e5c31af7Sopenharmony_ci { 196e5c31af7Sopenharmony_ci tcu::TestCaseGroup* const group = new tcu::TestCaseGroup(m_testCtx, "max_fragment_interpolation_offset", "Test MAX_FRAGMENT_INTERPOLATION_OFFSET"); 197e5c31af7Sopenharmony_ci addChild(group); 198e5c31af7Sopenharmony_ci 199e5c31af7Sopenharmony_ci for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(verifiers); ++verifierNdx) 200e5c31af7Sopenharmony_ci group->addChild(new InterpolationOffsetCase(m_context, verifiers[verifierNdx].name, verifiers[verifierNdx].desc, verifiers[verifierNdx].verifier, InterpolationOffsetCase::TEST_MAX_OFFSET)); 201e5c31af7Sopenharmony_ci } 202e5c31af7Sopenharmony_ci 203e5c31af7Sopenharmony_ci // .fragment_interpolation_offset_bits 204e5c31af7Sopenharmony_ci { 205e5c31af7Sopenharmony_ci tcu::TestCaseGroup* const group = new tcu::TestCaseGroup(m_testCtx, "fragment_interpolation_offset_bits", "Test FRAGMENT_INTERPOLATION_OFFSET_BITS"); 206e5c31af7Sopenharmony_ci addChild(group); 207e5c31af7Sopenharmony_ci 208e5c31af7Sopenharmony_ci for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(verifiers); ++verifierNdx) 209e5c31af7Sopenharmony_ci group->addChild(new FragmentInterpolationOffsetBitsCase(m_context, verifiers[verifierNdx].name, verifiers[verifierNdx].desc, verifiers[verifierNdx].verifier)); 210e5c31af7Sopenharmony_ci } 211e5c31af7Sopenharmony_ci} 212e5c31af7Sopenharmony_ci 213e5c31af7Sopenharmony_ci} // Functional 214e5c31af7Sopenharmony_ci} // gles31 215e5c31af7Sopenharmony_ci} // deqp 216