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
InterpolationOffsetCase(Context & context,const char * name,const char * desc,QueryType verifier,TestType 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)
71 {
72 DE_ASSERT(m_testType < TEST_LAST);
73 }
74
~InterpolationOffsetCase(void)75 InterpolationOffsetCase::~InterpolationOffsetCase (void)
76 {
77 }
78
init(void)79 void InterpolationOffsetCase::init (void)
80 {
81 if (!m_context.getContextInfo().isExtensionSupported("GL_OES_shader_multisample_interpolation"))
82 throw tcu::NotSupportedError("Test requires GL_OES_shader_multisample_interpolation extension");
83 }
84
iterate(void)85 InterpolationOffsetCase::IterateResult InterpolationOffsetCase::iterate (void)
86 {
87 glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
88 tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: ");
89 gl.enableLogging(true);
90
91 if (m_testType == TEST_MAX_OFFSET)
92 verifyStateFloatMin(result, gl, GL_MAX_FRAGMENT_INTERPOLATION_OFFSET, 0.5, m_verifier);
93 else if (m_testType == TEST_MIN_OFFSET)
94 verifyStateFloatMax(result, gl, GL_MIN_FRAGMENT_INTERPOLATION_OFFSET, -0.5, m_verifier);
95 else
96 DE_ASSERT(false);
97
98 result.setTestContextResult(m_testCtx);
99 return STOP;
100 }
101
102 class FragmentInterpolationOffsetBitsCase : public TestCase
103 {
104 public:
105 FragmentInterpolationOffsetBitsCase (Context& context, const char* name, const char* desc, QueryType verifier);
106 ~FragmentInterpolationOffsetBitsCase (void);
107
108 void init (void);
109 IterateResult iterate (void);
110
111 private:
112 const QueryType m_verifier;
113 };
114
FragmentInterpolationOffsetBitsCase(Context & context,const char * name,const char * desc,QueryType verifier)115 FragmentInterpolationOffsetBitsCase::FragmentInterpolationOffsetBitsCase (Context& context, const char* name, const char* desc, QueryType verifier)
116 : TestCase (context, name, desc)
117 , m_verifier (verifier)
118 {
119 }
120
~FragmentInterpolationOffsetBitsCase(void)121 FragmentInterpolationOffsetBitsCase::~FragmentInterpolationOffsetBitsCase (void)
122 {
123 }
124
init(void)125 void FragmentInterpolationOffsetBitsCase::init (void)
126 {
127 if (!m_context.getContextInfo().isExtensionSupported("GL_OES_shader_multisample_interpolation"))
128 throw tcu::NotSupportedError("Test requires GL_OES_shader_multisample_interpolation extension");
129 }
130
iterate(void)131 FragmentInterpolationOffsetBitsCase::IterateResult FragmentInterpolationOffsetBitsCase::iterate (void)
132 {
133 glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
134 tcu::ResultCollector result (m_testCtx.getLog(), " // ERROR: ");
135 gl.enableLogging(true);
136
137 verifyStateIntegerMin(result, gl, GL_FRAGMENT_INTERPOLATION_OFFSET_BITS, 4, m_verifier);
138
139 result.setTestContextResult(m_testCtx);
140 return STOP;
141 }
142
143 } // anonymous
144
ShaderMultisampleInterpolationStateQueryTests(Context & context)145 ShaderMultisampleInterpolationStateQueryTests::ShaderMultisampleInterpolationStateQueryTests (Context& context)
146 : TestCaseGroup(context, "multisample_interpolation", "Test multisample interpolation states")
147 {
148 }
149
~ShaderMultisampleInterpolationStateQueryTests(void)150 ShaderMultisampleInterpolationStateQueryTests::~ShaderMultisampleInterpolationStateQueryTests (void)
151 {
152 }
153
init(void)154 void ShaderMultisampleInterpolationStateQueryTests::init (void)
155 {
156 static const struct Verifier
157 {
158 QueryType verifier;
159 const char* name;
160 const char* desc;
161 } verifiers[] =
162 {
163 { QUERY_BOOLEAN, "get_boolean", "Test using getBoolean" },
164 { QUERY_INTEGER, "get_integer", "Test using getInteger" },
165 { QUERY_FLOAT, "get_float", "Test using getFloat" },
166 { QUERY_INTEGER64, "get_integer64", "Test using getInteger64" },
167 };
168
169 // .min_fragment_interpolation_offset
170 {
171 tcu::TestCaseGroup* const group = new tcu::TestCaseGroup(m_testCtx, "min_fragment_interpolation_offset", "Test MIN_FRAGMENT_INTERPOLATION_OFFSET");
172 addChild(group);
173
174 for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(verifiers); ++verifierNdx)
175 group->addChild(new InterpolationOffsetCase(m_context, verifiers[verifierNdx].name, verifiers[verifierNdx].desc, verifiers[verifierNdx].verifier, InterpolationOffsetCase::TEST_MIN_OFFSET));
176 }
177
178 // .max_fragment_interpolation_offset
179 {
180 tcu::TestCaseGroup* const group = new tcu::TestCaseGroup(m_testCtx, "max_fragment_interpolation_offset", "Test MAX_FRAGMENT_INTERPOLATION_OFFSET");
181 addChild(group);
182
183 for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(verifiers); ++verifierNdx)
184 group->addChild(new InterpolationOffsetCase(m_context, verifiers[verifierNdx].name, verifiers[verifierNdx].desc, verifiers[verifierNdx].verifier, InterpolationOffsetCase::TEST_MAX_OFFSET));
185 }
186
187 // .fragment_interpolation_offset_bits
188 {
189 tcu::TestCaseGroup* const group = new tcu::TestCaseGroup(m_testCtx, "fragment_interpolation_offset_bits", "Test FRAGMENT_INTERPOLATION_OFFSET_BITS");
190 addChild(group);
191
192 for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(verifiers); ++verifierNdx)
193 group->addChild(new FragmentInterpolationOffsetBitsCase(m_context, verifiers[verifierNdx].name, verifiers[verifierNdx].desc, verifiers[verifierNdx].verifier));
194 }
195 }
196
197 } // Functional
198 } // gles31
199 } // deqp
200