1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.1 Module
3 * -------------------------------------------------
5 * Copyright 2014 The Android Open Source Project
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * \brief Multisample interpolation state query tests
22 *//*--------------------------------------------------------------------*/
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"
43 using namespace gls::StateQueryUtil;
45 class InterpolationOffsetCase : public TestCase
56 InterpolationOffsetCase (Context& context, const char* name, const char* desc, QueryType verifier, TestType testType);
57 ~InterpolationOffsetCase (void);
60 IterateResult iterate (void);
63 const QueryType m_verifier;
64 const TestType m_testType;
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)
72 DE_ASSERT(m_testType < TEST_LAST);
75 InterpolationOffsetCase::~InterpolationOffsetCase (void)
79 void InterpolationOffsetCase::init (void)
81 const bool supportsES32 = glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::es(3, 2));
83 if (!supportsES32 && !m_context.getContextInfo().isExtensionSupported("GL_OES_shader_multisample_interpolation"))
84 throw tcu::NotSupportedError("Test requires GL_OES_shader_multisample_interpolation extension");
87 InterpolationOffsetCase::IterateResult InterpolationOffsetCase::iterate (void)
89 glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
90 tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: ");
91 gl.enableLogging(true);
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);
100 result.setTestContextResult(m_testCtx);
104 class FragmentInterpolationOffsetBitsCase : public TestCase
107 FragmentInterpolationOffsetBitsCase (Context& context, const char* name, const char* desc, QueryType verifier);
108 ~FragmentInterpolationOffsetBitsCase (void);
111 IterateResult iterate (void);
114 const QueryType m_verifier;
117 FragmentInterpolationOffsetBitsCase::FragmentInterpolationOffsetBitsCase (Context& context, const char* name, const char* desc, QueryType verifier)
118 : TestCase (context, name, desc)
119 , m_verifier (verifier)
123 FragmentInterpolationOffsetBitsCase::~FragmentInterpolationOffsetBitsCase (void)
127 void FragmentInterpolationOffsetBitsCase::init (void)
129 const bool supportsES32 = glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::es(3, 2));
131 if (!supportsES32 && !m_context.getContextInfo().isExtensionSupported("GL_OES_shader_multisample_interpolation"))
132 throw tcu::NotSupportedError("Test requires GL_OES_shader_multisample_interpolation extension");
135 FragmentInterpolationOffsetBitsCase::IterateResult FragmentInterpolationOffsetBitsCase::iterate (void)
137 glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
138 tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: ");
139 gl.enableLogging(true);
141 verifyStateIntegerMin(result, gl, GL_FRAGMENT_INTERPOLATION_OFFSET_BITS, 4, m_verifier);
143 result.setTestContextResult(m_testCtx);
149 ShaderMultisampleInterpolationStateQueryTests::ShaderMultisampleInterpolationStateQueryTests (Context& context)
150 : TestCaseGroup(context, "multisample_interpolation", "Test multisample interpolation states")
154 ShaderMultisampleInterpolationStateQueryTests::~ShaderMultisampleInterpolationStateQueryTests (void)
158 void ShaderMultisampleInterpolationStateQueryTests::init (void)
160 static const struct Verifier
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" },
173 // .min_fragment_interpolation_offset
175 tcu::TestCaseGroup* const group = new tcu::TestCaseGroup(m_testCtx, "min_fragment_interpolation_offset", "Test MIN_FRAGMENT_INTERPOLATION_OFFSET");
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));
182 // .max_fragment_interpolation_offset
184 tcu::TestCaseGroup* const group = new tcu::TestCaseGroup(m_testCtx, "max_fragment_interpolation_offset", "Test MAX_FRAGMENT_INTERPOLATION_OFFSET");
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));
191 // .fragment_interpolation_offset_bits
193 tcu::TestCaseGroup* const group = new tcu::TestCaseGroup(m_testCtx, "fragment_interpolation_offset_bits", "Test FRAGMENT_INTERPOLATION_OFFSET_BITS");
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));