1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.1 Module
3 * -------------------------------------------------
4 *
5 * Copyright 2015 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 Framebuffer Default State Query tests.
22 *//*--------------------------------------------------------------------*/
23
24 #include "es31fFramebufferDefaultStateQueryTests.hpp"
25 #include "glsStateQueryUtil.hpp"
26 #include "gluRenderContext.hpp"
27 #include "gluCallLogWrapper.hpp"
28 #include "gluObjectWrapper.hpp"
29 #include "glwFunctions.hpp"
30 #include "glwEnums.hpp"
31
32 namespace deqp
33 {
34 namespace gles31
35 {
36 namespace Functional
37 {
38 namespace
39 {
40
41 using namespace gls::StateQueryUtil;
42
getVerifierSuffix(QueryType type)43 static const char *getVerifierSuffix(QueryType type)
44 {
45 switch (type)
46 {
47 case QUERY_FRAMEBUFFER_INTEGER:
48 return "get_framebuffer_parameteriv";
49 default:
50 DE_ASSERT(false);
51 return DE_NULL;
52 }
53 }
54
55 class FramebufferTest : public TestCase
56 {
57 public:
58 FramebufferTest(Context &context, QueryType verifier, const char *name, const char *desc);
59 IterateResult iterate(void);
60
61 protected:
62 virtual void checkInitial(tcu::ResultCollector &result, glu::CallLogWrapper &gl) = 0;
63 virtual void checkSet(tcu::ResultCollector &result, glu::CallLogWrapper &gl) = 0;
64
65 const QueryType m_verifier;
66 };
67
FramebufferTest(Context & context,QueryType verifier,const char * name,const char * desc)68 FramebufferTest::FramebufferTest(Context &context, QueryType verifier, const char *name, const char *desc)
69 : TestCase(context, name, desc)
70 , m_verifier(verifier)
71 {
72 }
73
iterate(void)74 FramebufferTest::IterateResult FramebufferTest::iterate(void)
75 {
76 glu::Framebuffer fbo(m_context.getRenderContext());
77 glu::CallLogWrapper gl(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
78 tcu::ResultCollector result(m_testCtx.getLog(), " // ERROR: ");
79
80 gl.enableLogging(true);
81
82 gl.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, *fbo);
83 GLU_EXPECT_NO_ERROR(gl.glGetError(), "bind");
84
85 {
86 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
87 checkInitial(result, gl);
88 }
89
90 {
91 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Set", "Set");
92 checkSet(result, gl);
93 }
94
95 result.setTestContextResult(m_testCtx);
96 return STOP;
97 }
98
99 class FramebufferDimensionTest : public FramebufferTest
100 {
101 public:
102 enum DimensionType
103 {
104 DIMENSION_WIDTH = 0,
105 DIMENSION_HEIGHT,
106
107 DIMENSION_LAST
108 };
109
110 FramebufferDimensionTest(Context &context, QueryType verifier, DimensionType dimension, const char *name,
111 const char *desc);
112 void checkInitial(tcu::ResultCollector &result, glu::CallLogWrapper &gl);
113 void checkSet(tcu::ResultCollector &result, glu::CallLogWrapper &gl);
114
115 private:
116 const DimensionType m_dimension;
117 };
118
FramebufferDimensionTest(Context & context,QueryType verifier,DimensionType dimension,const char * name,const char * desc)119 FramebufferDimensionTest::FramebufferDimensionTest(Context &context, QueryType verifier, DimensionType dimension,
120 const char *name, const char *desc)
121 : FramebufferTest(context, verifier, name, desc)
122 , m_dimension(dimension)
123 {
124 DE_ASSERT(dimension < DIMENSION_LAST);
125 }
126
checkInitial(tcu::ResultCollector & result,glu::CallLogWrapper & gl)127 void FramebufferDimensionTest::checkInitial(tcu::ResultCollector &result, glu::CallLogWrapper &gl)
128 {
129 const glw::GLenum pname =
130 (m_dimension == DIMENSION_WIDTH) ? (GL_FRAMEBUFFER_DEFAULT_WIDTH) : (GL_FRAMEBUFFER_DEFAULT_HEIGHT);
131 verifyStateFramebufferInteger(result, gl, GL_DRAW_FRAMEBUFFER, pname, 0, m_verifier);
132 }
133
checkSet(tcu::ResultCollector & result,glu::CallLogWrapper & gl)134 void FramebufferDimensionTest::checkSet(tcu::ResultCollector &result, glu::CallLogWrapper &gl)
135 {
136 const glw::GLenum pname =
137 (m_dimension == DIMENSION_WIDTH) ? (GL_FRAMEBUFFER_DEFAULT_WIDTH) : (GL_FRAMEBUFFER_DEFAULT_HEIGHT);
138
139 gl.glFramebufferParameteri(GL_DRAW_FRAMEBUFFER, pname, 32);
140 GLU_EXPECT_NO_ERROR(gl.glGetError(), "set state");
141
142 verifyStateFramebufferInteger(result, gl, GL_DRAW_FRAMEBUFFER, pname, 32, m_verifier);
143 }
144
145 class FramebufferSamplesTest : public FramebufferTest
146 {
147 public:
148 FramebufferSamplesTest(Context &context, QueryType verifier, const char *name, const char *desc);
149 void checkInitial(tcu::ResultCollector &result, glu::CallLogWrapper &gl);
150 void checkSet(tcu::ResultCollector &result, glu::CallLogWrapper &gl);
151 };
152
FramebufferSamplesTest(Context & context,QueryType verifier,const char * name,const char * desc)153 FramebufferSamplesTest::FramebufferSamplesTest(Context &context, QueryType verifier, const char *name, const char *desc)
154 : FramebufferTest(context, verifier, name, desc)
155 {
156 }
157
checkInitial(tcu::ResultCollector & result,glu::CallLogWrapper & gl)158 void FramebufferSamplesTest::checkInitial(tcu::ResultCollector &result, glu::CallLogWrapper &gl)
159 {
160 verifyStateFramebufferInteger(result, gl, GL_DRAW_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_SAMPLES, 0, m_verifier);
161 }
162
checkSet(tcu::ResultCollector & result,glu::CallLogWrapper & gl)163 void FramebufferSamplesTest::checkSet(tcu::ResultCollector &result, glu::CallLogWrapper &gl)
164 {
165 gl.glFramebufferParameteri(GL_DRAW_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_SAMPLES, 1);
166 GLU_EXPECT_NO_ERROR(gl.glGetError(), "set state");
167 verifyStateFramebufferIntegerMin(result, gl, GL_DRAW_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_SAMPLES, 1, m_verifier);
168
169 gl.glFramebufferParameteri(GL_DRAW_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_SAMPLES, 0);
170 GLU_EXPECT_NO_ERROR(gl.glGetError(), "set state");
171 verifyStateFramebufferInteger(result, gl, GL_DRAW_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_SAMPLES, 0, m_verifier);
172 }
173
174 class FramebufferFixedSampleLocationsTest : public FramebufferTest
175 {
176 public:
177 FramebufferFixedSampleLocationsTest(Context &context, QueryType verifier, const char *name, const char *desc);
178 void checkInitial(tcu::ResultCollector &result, glu::CallLogWrapper &gl);
179 void checkSet(tcu::ResultCollector &result, glu::CallLogWrapper &gl);
180 };
181
FramebufferFixedSampleLocationsTest(Context & context,QueryType verifier,const char * name,const char * desc)182 FramebufferFixedSampleLocationsTest::FramebufferFixedSampleLocationsTest(Context &context, QueryType verifier,
183 const char *name, const char *desc)
184 : FramebufferTest(context, verifier, name, desc)
185 {
186 }
187
checkInitial(tcu::ResultCollector & result,glu::CallLogWrapper & gl)188 void FramebufferFixedSampleLocationsTest::checkInitial(tcu::ResultCollector &result, glu::CallLogWrapper &gl)
189 {
190 verifyStateFramebufferInteger(result, gl, GL_DRAW_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS, 0,
191 m_verifier);
192 }
193
checkSet(tcu::ResultCollector & result,glu::CallLogWrapper & gl)194 void FramebufferFixedSampleLocationsTest::checkSet(tcu::ResultCollector &result, glu::CallLogWrapper &gl)
195 {
196 gl.glFramebufferParameteri(GL_DRAW_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS, GL_TRUE);
197 GLU_EXPECT_NO_ERROR(gl.glGetError(), "set state");
198 verifyStateFramebufferInteger(result, gl, GL_DRAW_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS,
199 GL_TRUE, m_verifier);
200 }
201
202 } // namespace
203
FramebufferDefaultStateQueryTests(Context & context)204 FramebufferDefaultStateQueryTests::FramebufferDefaultStateQueryTests(Context &context)
205 : TestCaseGroup(context, "framebuffer_default", "Framebuffer Default State Query tests")
206 {
207 }
208
~FramebufferDefaultStateQueryTests(void)209 FramebufferDefaultStateQueryTests::~FramebufferDefaultStateQueryTests(void)
210 {
211 }
212
init(void)213 void FramebufferDefaultStateQueryTests::init(void)
214 {
215 static const QueryType verifiers[] = {
216 QUERY_FRAMEBUFFER_INTEGER,
217 };
218
219 #define FOR_EACH_VERIFIER(X) \
220 do \
221 { \
222 for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(verifiers); ++verifierNdx) \
223 { \
224 const char *verifierSuffix = getVerifierSuffix(verifiers[verifierNdx]); \
225 const QueryType verifier = verifiers[verifierNdx]; \
226 this->addChild(X); \
227 } \
228 } while (0)
229
230 FOR_EACH_VERIFIER(new FramebufferDimensionTest(m_context, verifier, FramebufferDimensionTest::DIMENSION_WIDTH,
231 (std::string("framebuffer_default_width_") + verifierSuffix).c_str(),
232 "Test FRAMEBUFFER_DEFAULT_WIDTH"));
233 FOR_EACH_VERIFIER(new FramebufferDimensionTest(
234 m_context, verifier, FramebufferDimensionTest::DIMENSION_HEIGHT,
235 (std::string("framebuffer_default_height_") + verifierSuffix).c_str(), "Test FRAMEBUFFER_DEFAULT_HEIGHT"));
236 FOR_EACH_VERIFIER(new FramebufferSamplesTest(m_context, verifier,
237 (std::string("framebuffer_default_samples_") + verifierSuffix).c_str(),
238 "Test FRAMEBUFFER_DEFAULT_SAMPLES"));
239 FOR_EACH_VERIFIER(new FramebufferFixedSampleLocationsTest(
240 m_context, verifier, (std::string("framebuffer_default_fixed_sample_locations_") + verifierSuffix).c_str(),
241 "Test FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS"));
242
243 #undef FOR_EACH_VERIFIER
244 }
245
246 } // namespace Functional
247 } // namespace gles31
248 } // namespace deqp
249