1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker  * drawElements Quality Program OpenGL ES 3.1 Module
3*35238bceSAndroid Build Coastguard Worker  * -------------------------------------------------
4*35238bceSAndroid Build Coastguard Worker  *
5*35238bceSAndroid Build Coastguard Worker  * Copyright 2014 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker  *
7*35238bceSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker  *
11*35238bceSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker  *
13*35238bceSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker  * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker  *
19*35238bceSAndroid Build Coastguard Worker  *//*!
20*35238bceSAndroid Build Coastguard Worker  * \file
21*35238bceSAndroid Build Coastguard Worker  * \brief Multisample interpolation state query tests
22*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker 
24*35238bceSAndroid Build Coastguard Worker #include "es31fShaderMultisampleInterpolationStateQueryTests.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "gluCallLogWrapper.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "gluContextInfo.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "gluRenderContext.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "glsStateQueryUtil.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
32*35238bceSAndroid Build Coastguard Worker 
33*35238bceSAndroid Build Coastguard Worker namespace deqp
34*35238bceSAndroid Build Coastguard Worker {
35*35238bceSAndroid Build Coastguard Worker namespace gles31
36*35238bceSAndroid Build Coastguard Worker {
37*35238bceSAndroid Build Coastguard Worker namespace Functional
38*35238bceSAndroid Build Coastguard Worker {
39*35238bceSAndroid Build Coastguard Worker namespace
40*35238bceSAndroid Build Coastguard Worker {
41*35238bceSAndroid Build Coastguard Worker 
42*35238bceSAndroid Build Coastguard Worker using namespace gls::StateQueryUtil;
43*35238bceSAndroid Build Coastguard Worker 
44*35238bceSAndroid Build Coastguard Worker class InterpolationOffsetCase : public TestCase
45*35238bceSAndroid Build Coastguard Worker {
46*35238bceSAndroid Build Coastguard Worker public:
47*35238bceSAndroid Build Coastguard Worker     enum TestType
48*35238bceSAndroid Build Coastguard Worker     {
49*35238bceSAndroid Build Coastguard Worker         TEST_MIN_OFFSET = 0,
50*35238bceSAndroid Build Coastguard Worker         TEST_MAX_OFFSET,
51*35238bceSAndroid Build Coastguard Worker 
52*35238bceSAndroid Build Coastguard Worker         TEST_LAST
53*35238bceSAndroid Build Coastguard Worker     };
54*35238bceSAndroid Build Coastguard Worker 
55*35238bceSAndroid Build Coastguard Worker     InterpolationOffsetCase(Context &context, const char *name, const char *desc, QueryType verifier,
56*35238bceSAndroid Build Coastguard Worker                             TestType testType);
57*35238bceSAndroid Build Coastguard Worker     ~InterpolationOffsetCase(void);
58*35238bceSAndroid Build Coastguard Worker 
59*35238bceSAndroid Build Coastguard Worker     void init(void);
60*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
61*35238bceSAndroid Build Coastguard Worker 
62*35238bceSAndroid Build Coastguard Worker private:
63*35238bceSAndroid Build Coastguard Worker     const QueryType m_verifier;
64*35238bceSAndroid Build Coastguard Worker     const TestType m_testType;
65*35238bceSAndroid Build Coastguard Worker };
66*35238bceSAndroid Build Coastguard Worker 
InterpolationOffsetCase(Context & context,const char * name,const char * desc,QueryType verifier,TestType testType)67*35238bceSAndroid Build Coastguard Worker InterpolationOffsetCase::InterpolationOffsetCase(Context &context, const char *name, const char *desc,
68*35238bceSAndroid Build Coastguard Worker                                                  QueryType verifier, TestType testType)
69*35238bceSAndroid Build Coastguard Worker     : TestCase(context, name, desc)
70*35238bceSAndroid Build Coastguard Worker     , m_verifier(verifier)
71*35238bceSAndroid Build Coastguard Worker     , m_testType(testType)
72*35238bceSAndroid Build Coastguard Worker {
73*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(m_testType < TEST_LAST);
74*35238bceSAndroid Build Coastguard Worker }
75*35238bceSAndroid Build Coastguard Worker 
~InterpolationOffsetCase(void)76*35238bceSAndroid Build Coastguard Worker InterpolationOffsetCase::~InterpolationOffsetCase(void)
77*35238bceSAndroid Build Coastguard Worker {
78*35238bceSAndroid Build Coastguard Worker }
79*35238bceSAndroid Build Coastguard Worker 
init(void)80*35238bceSAndroid Build Coastguard Worker void InterpolationOffsetCase::init(void)
81*35238bceSAndroid Build Coastguard Worker {
82*35238bceSAndroid Build Coastguard Worker     auto ctxType            = m_context.getRenderContext().getType();
83*35238bceSAndroid Build Coastguard Worker     const bool isES32orGL45 = glu::contextSupports(ctxType, glu::ApiType::es(3, 2)) ||
84*35238bceSAndroid Build Coastguard Worker                               glu::contextSupports(ctxType, glu::ApiType::core(4, 5));
85*35238bceSAndroid Build Coastguard Worker 
86*35238bceSAndroid Build Coastguard Worker     if (!isES32orGL45 && !m_context.getContextInfo().isExtensionSupported("GL_OES_shader_multisample_interpolation"))
87*35238bceSAndroid Build Coastguard Worker         throw tcu::NotSupportedError("Test requires GL_OES_shader_multisample_interpolation extension");
88*35238bceSAndroid Build Coastguard Worker }
89*35238bceSAndroid Build Coastguard Worker 
iterate(void)90*35238bceSAndroid Build Coastguard Worker InterpolationOffsetCase::IterateResult InterpolationOffsetCase::iterate(void)
91*35238bceSAndroid Build Coastguard Worker {
92*35238bceSAndroid Build Coastguard Worker     glu::CallLogWrapper gl(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
93*35238bceSAndroid Build Coastguard Worker     tcu::ResultCollector result(m_testCtx.getLog(), " // ERROR: ");
94*35238bceSAndroid Build Coastguard Worker     gl.enableLogging(true);
95*35238bceSAndroid Build Coastguard Worker 
96*35238bceSAndroid Build Coastguard Worker     if (m_testType == TEST_MAX_OFFSET)
97*35238bceSAndroid Build Coastguard Worker     {
98*35238bceSAndroid Build Coastguard Worker         glw::GLfloat fragmentInterpolationOffsetBits = 0.0;
99*35238bceSAndroid Build Coastguard Worker         gl.glGetFloatv(GL_FRAGMENT_INTERPOLATION_OFFSET_BITS, &fragmentInterpolationOffsetBits);
100*35238bceSAndroid Build Coastguard Worker         GLU_EXPECT_NO_ERROR(gl.glGetError(), "glGetIntegerv");
101*35238bceSAndroid Build Coastguard Worker 
102*35238bceSAndroid Build Coastguard Worker         glw::GLfloat ULP = 1.0f / powf(2, fragmentInterpolationOffsetBits);
103*35238bceSAndroid Build Coastguard Worker 
104*35238bceSAndroid Build Coastguard Worker         verifyStateFloatMin(result, gl, GL_MAX_FRAGMENT_INTERPOLATION_OFFSET, 0.5f - ULP, m_verifier);
105*35238bceSAndroid Build Coastguard Worker     }
106*35238bceSAndroid Build Coastguard Worker     else if (m_testType == TEST_MIN_OFFSET)
107*35238bceSAndroid Build Coastguard Worker         verifyStateFloatMax(result, gl, GL_MIN_FRAGMENT_INTERPOLATION_OFFSET, -0.5f, m_verifier);
108*35238bceSAndroid Build Coastguard Worker     else
109*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(false);
110*35238bceSAndroid Build Coastguard Worker 
111*35238bceSAndroid Build Coastguard Worker     result.setTestContextResult(m_testCtx);
112*35238bceSAndroid Build Coastguard Worker     return STOP;
113*35238bceSAndroid Build Coastguard Worker }
114*35238bceSAndroid Build Coastguard Worker 
115*35238bceSAndroid Build Coastguard Worker class FragmentInterpolationOffsetBitsCase : public TestCase
116*35238bceSAndroid Build Coastguard Worker {
117*35238bceSAndroid Build Coastguard Worker public:
118*35238bceSAndroid Build Coastguard Worker     FragmentInterpolationOffsetBitsCase(Context &context, const char *name, const char *desc, QueryType verifier);
119*35238bceSAndroid Build Coastguard Worker     ~FragmentInterpolationOffsetBitsCase(void);
120*35238bceSAndroid Build Coastguard Worker 
121*35238bceSAndroid Build Coastguard Worker     void init(void);
122*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
123*35238bceSAndroid Build Coastguard Worker 
124*35238bceSAndroid Build Coastguard Worker private:
125*35238bceSAndroid Build Coastguard Worker     const QueryType m_verifier;
126*35238bceSAndroid Build Coastguard Worker };
127*35238bceSAndroid Build Coastguard Worker 
FragmentInterpolationOffsetBitsCase(Context & context,const char * name,const char * desc,QueryType verifier)128*35238bceSAndroid Build Coastguard Worker FragmentInterpolationOffsetBitsCase::FragmentInterpolationOffsetBitsCase(Context &context, const char *name,
129*35238bceSAndroid Build Coastguard Worker                                                                          const char *desc, QueryType verifier)
130*35238bceSAndroid Build Coastguard Worker     : TestCase(context, name, desc)
131*35238bceSAndroid Build Coastguard Worker     , m_verifier(verifier)
132*35238bceSAndroid Build Coastguard Worker {
133*35238bceSAndroid Build Coastguard Worker }
134*35238bceSAndroid Build Coastguard Worker 
~FragmentInterpolationOffsetBitsCase(void)135*35238bceSAndroid Build Coastguard Worker FragmentInterpolationOffsetBitsCase::~FragmentInterpolationOffsetBitsCase(void)
136*35238bceSAndroid Build Coastguard Worker {
137*35238bceSAndroid Build Coastguard Worker }
138*35238bceSAndroid Build Coastguard Worker 
init(void)139*35238bceSAndroid Build Coastguard Worker void FragmentInterpolationOffsetBitsCase::init(void)
140*35238bceSAndroid Build Coastguard Worker {
141*35238bceSAndroid Build Coastguard Worker     auto ctxType            = m_context.getRenderContext().getType();
142*35238bceSAndroid Build Coastguard Worker     const bool isES32orGL45 = glu::contextSupports(ctxType, glu::ApiType::es(3, 2)) ||
143*35238bceSAndroid Build Coastguard Worker                               glu::contextSupports(ctxType, glu::ApiType::core(4, 5));
144*35238bceSAndroid Build Coastguard Worker 
145*35238bceSAndroid Build Coastguard Worker     if (!isES32orGL45 && !m_context.getContextInfo().isExtensionSupported("GL_OES_shader_multisample_interpolation"))
146*35238bceSAndroid Build Coastguard Worker         throw tcu::NotSupportedError("Test requires GL_OES_shader_multisample_interpolation extension");
147*35238bceSAndroid Build Coastguard Worker }
148*35238bceSAndroid Build Coastguard Worker 
iterate(void)149*35238bceSAndroid Build Coastguard Worker FragmentInterpolationOffsetBitsCase::IterateResult FragmentInterpolationOffsetBitsCase::iterate(void)
150*35238bceSAndroid Build Coastguard Worker {
151*35238bceSAndroid Build Coastguard Worker     glu::CallLogWrapper gl(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
152*35238bceSAndroid Build Coastguard Worker     tcu::ResultCollector result(m_testCtx.getLog(), " // ERROR: ");
153*35238bceSAndroid Build Coastguard Worker     gl.enableLogging(true);
154*35238bceSAndroid Build Coastguard Worker 
155*35238bceSAndroid Build Coastguard Worker     verifyStateIntegerMin(result, gl, GL_FRAGMENT_INTERPOLATION_OFFSET_BITS, 4, m_verifier);
156*35238bceSAndroid Build Coastguard Worker 
157*35238bceSAndroid Build Coastguard Worker     result.setTestContextResult(m_testCtx);
158*35238bceSAndroid Build Coastguard Worker     return STOP;
159*35238bceSAndroid Build Coastguard Worker }
160*35238bceSAndroid Build Coastguard Worker 
161*35238bceSAndroid Build Coastguard Worker } // namespace
162*35238bceSAndroid Build Coastguard Worker 
ShaderMultisampleInterpolationStateQueryTests(Context & context)163*35238bceSAndroid Build Coastguard Worker ShaderMultisampleInterpolationStateQueryTests::ShaderMultisampleInterpolationStateQueryTests(Context &context)
164*35238bceSAndroid Build Coastguard Worker     : TestCaseGroup(context, "multisample_interpolation", "Test multisample interpolation states")
165*35238bceSAndroid Build Coastguard Worker {
166*35238bceSAndroid Build Coastguard Worker }
167*35238bceSAndroid Build Coastguard Worker 
~ShaderMultisampleInterpolationStateQueryTests(void)168*35238bceSAndroid Build Coastguard Worker ShaderMultisampleInterpolationStateQueryTests::~ShaderMultisampleInterpolationStateQueryTests(void)
169*35238bceSAndroid Build Coastguard Worker {
170*35238bceSAndroid Build Coastguard Worker }
171*35238bceSAndroid Build Coastguard Worker 
init(void)172*35238bceSAndroid Build Coastguard Worker void ShaderMultisampleInterpolationStateQueryTests::init(void)
173*35238bceSAndroid Build Coastguard Worker {
174*35238bceSAndroid Build Coastguard Worker     static const struct Verifier
175*35238bceSAndroid Build Coastguard Worker     {
176*35238bceSAndroid Build Coastguard Worker         QueryType verifier;
177*35238bceSAndroid Build Coastguard Worker         const char *name;
178*35238bceSAndroid Build Coastguard Worker         const char *desc;
179*35238bceSAndroid Build Coastguard Worker     } verifiers[] = {
180*35238bceSAndroid Build Coastguard Worker         {QUERY_BOOLEAN, "get_boolean", "Test using getBoolean"},
181*35238bceSAndroid Build Coastguard Worker         {QUERY_INTEGER, "get_integer", "Test using getInteger"},
182*35238bceSAndroid Build Coastguard Worker         {QUERY_FLOAT, "get_float", "Test using getFloat"},
183*35238bceSAndroid Build Coastguard Worker         {QUERY_INTEGER64, "get_integer64", "Test using getInteger64"},
184*35238bceSAndroid Build Coastguard Worker     };
185*35238bceSAndroid Build Coastguard Worker 
186*35238bceSAndroid Build Coastguard Worker     // .min_fragment_interpolation_offset
187*35238bceSAndroid Build Coastguard Worker     {
188*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *const group = new tcu::TestCaseGroup(m_testCtx, "min_fragment_interpolation_offset",
189*35238bceSAndroid Build Coastguard Worker                                                                  "Test MIN_FRAGMENT_INTERPOLATION_OFFSET");
190*35238bceSAndroid Build Coastguard Worker         addChild(group);
191*35238bceSAndroid Build Coastguard Worker 
192*35238bceSAndroid Build Coastguard Worker         for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(verifiers); ++verifierNdx)
193*35238bceSAndroid Build Coastguard Worker             group->addChild(new InterpolationOffsetCase(m_context, verifiers[verifierNdx].name,
194*35238bceSAndroid Build Coastguard Worker                                                         verifiers[verifierNdx].desc, verifiers[verifierNdx].verifier,
195*35238bceSAndroid Build Coastguard Worker                                                         InterpolationOffsetCase::TEST_MIN_OFFSET));
196*35238bceSAndroid Build Coastguard Worker     }
197*35238bceSAndroid Build Coastguard Worker 
198*35238bceSAndroid Build Coastguard Worker     // .max_fragment_interpolation_offset
199*35238bceSAndroid Build Coastguard Worker     {
200*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *const group = new tcu::TestCaseGroup(m_testCtx, "max_fragment_interpolation_offset",
201*35238bceSAndroid Build Coastguard Worker                                                                  "Test MAX_FRAGMENT_INTERPOLATION_OFFSET");
202*35238bceSAndroid Build Coastguard Worker         addChild(group);
203*35238bceSAndroid Build Coastguard Worker 
204*35238bceSAndroid Build Coastguard Worker         for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(verifiers); ++verifierNdx)
205*35238bceSAndroid Build Coastguard Worker             group->addChild(new InterpolationOffsetCase(m_context, verifiers[verifierNdx].name,
206*35238bceSAndroid Build Coastguard Worker                                                         verifiers[verifierNdx].desc, verifiers[verifierNdx].verifier,
207*35238bceSAndroid Build Coastguard Worker                                                         InterpolationOffsetCase::TEST_MAX_OFFSET));
208*35238bceSAndroid Build Coastguard Worker     }
209*35238bceSAndroid Build Coastguard Worker 
210*35238bceSAndroid Build Coastguard Worker     // .fragment_interpolation_offset_bits
211*35238bceSAndroid Build Coastguard Worker     {
212*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *const group = new tcu::TestCaseGroup(m_testCtx, "fragment_interpolation_offset_bits",
213*35238bceSAndroid Build Coastguard Worker                                                                  "Test FRAGMENT_INTERPOLATION_OFFSET_BITS");
214*35238bceSAndroid Build Coastguard Worker         addChild(group);
215*35238bceSAndroid Build Coastguard Worker 
216*35238bceSAndroid Build Coastguard Worker         for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(verifiers); ++verifierNdx)
217*35238bceSAndroid Build Coastguard Worker             group->addChild(new FragmentInterpolationOffsetBitsCase(
218*35238bceSAndroid Build Coastguard Worker                 m_context, verifiers[verifierNdx].name, verifiers[verifierNdx].desc, verifiers[verifierNdx].verifier));
219*35238bceSAndroid Build Coastguard Worker     }
220*35238bceSAndroid Build Coastguard Worker }
221*35238bceSAndroid Build Coastguard Worker 
222*35238bceSAndroid Build Coastguard Worker } // namespace Functional
223*35238bceSAndroid Build Coastguard Worker } // namespace gles31
224*35238bceSAndroid Build Coastguard Worker } // namespace deqp
225