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