1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker * OpenGL Conformance Test Suite
3*35238bceSAndroid Build Coastguard Worker * -----------------------------
4*35238bceSAndroid Build Coastguard Worker *
5*35238bceSAndroid Build Coastguard Worker * Copyright (c) 2015-2016 The Khronos Group Inc.
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
22*35238bceSAndroid Build Coastguard Worker */ /*-------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker
24*35238bceSAndroid Build Coastguard Worker /**
25*35238bceSAndroid Build Coastguard Worker */ /*!
26*35238bceSAndroid Build Coastguard Worker * \file gl4cDirectStateAccessFramebuffersAndRenderbuffersTests.cpp
27*35238bceSAndroid Build Coastguard Worker * \brief Conformance tests for the Direct State Access feature functionality (Framebuffers and Renderbuffer access part).
28*35238bceSAndroid Build Coastguard Worker */ /*------------------------------------------------------------------------------------------------------------------------*/
29*35238bceSAndroid Build Coastguard Worker
30*35238bceSAndroid Build Coastguard Worker /* Includes. */
31*35238bceSAndroid Build Coastguard Worker #include "gl4cDirectStateAccessTests.hpp"
32*35238bceSAndroid Build Coastguard Worker
33*35238bceSAndroid Build Coastguard Worker #include "deSharedPtr.hpp"
34*35238bceSAndroid Build Coastguard Worker
35*35238bceSAndroid Build Coastguard Worker #include "gluContextInfo.hpp"
36*35238bceSAndroid Build Coastguard Worker #include "gluDefs.hpp"
37*35238bceSAndroid Build Coastguard Worker #include "gluPixelTransfer.hpp"
38*35238bceSAndroid Build Coastguard Worker #include "gluStrUtil.hpp"
39*35238bceSAndroid Build Coastguard Worker
40*35238bceSAndroid Build Coastguard Worker #include "tcuFuzzyImageCompare.hpp"
41*35238bceSAndroid Build Coastguard Worker #include "tcuImageCompare.hpp"
42*35238bceSAndroid Build Coastguard Worker #include "tcuRenderTarget.hpp"
43*35238bceSAndroid Build Coastguard Worker #include "tcuSurface.hpp"
44*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
45*35238bceSAndroid Build Coastguard Worker
46*35238bceSAndroid Build Coastguard Worker #include "glw.h"
47*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
48*35238bceSAndroid Build Coastguard Worker
49*35238bceSAndroid Build Coastguard Worker #include <algorithm>
50*35238bceSAndroid Build Coastguard Worker #include <climits>
51*35238bceSAndroid Build Coastguard Worker #include <cmath>
52*35238bceSAndroid Build Coastguard Worker #include <set>
53*35238bceSAndroid Build Coastguard Worker #include <sstream>
54*35238bceSAndroid Build Coastguard Worker #include <stack>
55*35238bceSAndroid Build Coastguard Worker #include <string>
56*35238bceSAndroid Build Coastguard Worker #include <vector>
57*35238bceSAndroid Build Coastguard Worker
58*35238bceSAndroid Build Coastguard Worker namespace gl4cts
59*35238bceSAndroid Build Coastguard Worker {
60*35238bceSAndroid Build Coastguard Worker namespace DirectStateAccess
61*35238bceSAndroid Build Coastguard Worker {
62*35238bceSAndroid Build Coastguard Worker namespace Framebuffers
63*35238bceSAndroid Build Coastguard Worker {
64*35238bceSAndroid Build Coastguard Worker /******************************** Framebuffer Creation Test Implementation ********************************/
65*35238bceSAndroid Build Coastguard Worker
66*35238bceSAndroid Build Coastguard Worker /** @brief Creation Test constructor.
67*35238bceSAndroid Build Coastguard Worker *
68*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
69*35238bceSAndroid Build Coastguard Worker */
CreationTest(deqp::Context & context)70*35238bceSAndroid Build Coastguard Worker CreationTest::CreationTest(deqp::Context &context)
71*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "framebuffers_creation", "Framebuffer Objects Creation Test")
72*35238bceSAndroid Build Coastguard Worker {
73*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
74*35238bceSAndroid Build Coastguard Worker }
75*35238bceSAndroid Build Coastguard Worker
76*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Creation Test cases.
77*35238bceSAndroid Build Coastguard Worker *
78*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
79*35238bceSAndroid Build Coastguard Worker */
iterate()80*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult CreationTest::iterate()
81*35238bceSAndroid Build Coastguard Worker {
82*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
83*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
84*35238bceSAndroid Build Coastguard Worker
85*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
86*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
87*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
88*35238bceSAndroid Build Coastguard Worker
89*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
90*35238bceSAndroid Build Coastguard Worker {
91*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
92*35238bceSAndroid Build Coastguard Worker
93*35238bceSAndroid Build Coastguard Worker return STOP;
94*35238bceSAndroid Build Coastguard Worker }
95*35238bceSAndroid Build Coastguard Worker
96*35238bceSAndroid Build Coastguard Worker /* Running tests. */
97*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
98*35238bceSAndroid Build Coastguard Worker bool is_error = false;
99*35238bceSAndroid Build Coastguard Worker
100*35238bceSAndroid Build Coastguard Worker /* Framebuffers' objects */
101*35238bceSAndroid Build Coastguard Worker static const glw::GLuint framebuffers_count = 2;
102*35238bceSAndroid Build Coastguard Worker
103*35238bceSAndroid Build Coastguard Worker glw::GLuint framebuffers_legacy[framebuffers_count] = {};
104*35238bceSAndroid Build Coastguard Worker glw::GLuint framebuffers_dsa[framebuffers_count] = {};
105*35238bceSAndroid Build Coastguard Worker
106*35238bceSAndroid Build Coastguard Worker try
107*35238bceSAndroid Build Coastguard Worker {
108*35238bceSAndroid Build Coastguard Worker /* Check legacy state creation. */
109*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(framebuffers_count, framebuffers_legacy);
110*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
111*35238bceSAndroid Build Coastguard Worker
112*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < framebuffers_count; ++i)
113*35238bceSAndroid Build Coastguard Worker {
114*35238bceSAndroid Build Coastguard Worker if (gl.isFramebuffer(framebuffers_legacy[i]))
115*35238bceSAndroid Build Coastguard Worker {
116*35238bceSAndroid Build Coastguard Worker is_ok = false;
117*35238bceSAndroid Build Coastguard Worker
118*35238bceSAndroid Build Coastguard Worker /* Log. */
119*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
120*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message
121*35238bceSAndroid Build Coastguard Worker << "GenFramebuffers has created default objects, but it should create only a names."
122*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
123*35238bceSAndroid Build Coastguard Worker }
124*35238bceSAndroid Build Coastguard Worker }
125*35238bceSAndroid Build Coastguard Worker
126*35238bceSAndroid Build Coastguard Worker /* Check direct state creation. */
127*35238bceSAndroid Build Coastguard Worker gl.createFramebuffers(framebuffers_count, framebuffers_dsa);
128*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateFramebuffers has failed");
129*35238bceSAndroid Build Coastguard Worker
130*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < framebuffers_count; ++i)
131*35238bceSAndroid Build Coastguard Worker {
132*35238bceSAndroid Build Coastguard Worker if (!gl.isFramebuffer(framebuffers_dsa[i]))
133*35238bceSAndroid Build Coastguard Worker {
134*35238bceSAndroid Build Coastguard Worker is_ok = false;
135*35238bceSAndroid Build Coastguard Worker
136*35238bceSAndroid Build Coastguard Worker /* Log. */
137*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
138*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "CreateFramebuffers has not created default objects."
139*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
140*35238bceSAndroid Build Coastguard Worker }
141*35238bceSAndroid Build Coastguard Worker }
142*35238bceSAndroid Build Coastguard Worker }
143*35238bceSAndroid Build Coastguard Worker catch (...)
144*35238bceSAndroid Build Coastguard Worker {
145*35238bceSAndroid Build Coastguard Worker is_ok = false;
146*35238bceSAndroid Build Coastguard Worker is_error = true;
147*35238bceSAndroid Build Coastguard Worker }
148*35238bceSAndroid Build Coastguard Worker
149*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
150*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < framebuffers_count; ++i)
151*35238bceSAndroid Build Coastguard Worker {
152*35238bceSAndroid Build Coastguard Worker if (framebuffers_legacy[i])
153*35238bceSAndroid Build Coastguard Worker {
154*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &framebuffers_legacy[i]);
155*35238bceSAndroid Build Coastguard Worker
156*35238bceSAndroid Build Coastguard Worker framebuffers_legacy[i] = 0;
157*35238bceSAndroid Build Coastguard Worker }
158*35238bceSAndroid Build Coastguard Worker
159*35238bceSAndroid Build Coastguard Worker if (framebuffers_dsa[i])
160*35238bceSAndroid Build Coastguard Worker {
161*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &framebuffers_dsa[i]);
162*35238bceSAndroid Build Coastguard Worker
163*35238bceSAndroid Build Coastguard Worker framebuffers_dsa[i] = 0;
164*35238bceSAndroid Build Coastguard Worker }
165*35238bceSAndroid Build Coastguard Worker }
166*35238bceSAndroid Build Coastguard Worker
167*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
168*35238bceSAndroid Build Coastguard Worker while (gl.getError())
169*35238bceSAndroid Build Coastguard Worker ;
170*35238bceSAndroid Build Coastguard Worker
171*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
172*35238bceSAndroid Build Coastguard Worker if (is_ok)
173*35238bceSAndroid Build Coastguard Worker {
174*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
175*35238bceSAndroid Build Coastguard Worker }
176*35238bceSAndroid Build Coastguard Worker else
177*35238bceSAndroid Build Coastguard Worker {
178*35238bceSAndroid Build Coastguard Worker if (is_error)
179*35238bceSAndroid Build Coastguard Worker {
180*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
181*35238bceSAndroid Build Coastguard Worker }
182*35238bceSAndroid Build Coastguard Worker else
183*35238bceSAndroid Build Coastguard Worker {
184*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
185*35238bceSAndroid Build Coastguard Worker }
186*35238bceSAndroid Build Coastguard Worker }
187*35238bceSAndroid Build Coastguard Worker
188*35238bceSAndroid Build Coastguard Worker return STOP;
189*35238bceSAndroid Build Coastguard Worker }
190*35238bceSAndroid Build Coastguard Worker
191*35238bceSAndroid Build Coastguard Worker /******************************** Framebuffer Renderbuffer Attachment Test Implementation ********************************/
192*35238bceSAndroid Build Coastguard Worker
193*35238bceSAndroid Build Coastguard Worker /** @brief Framebuffer Renderbuffer Attachment Test constructor.
194*35238bceSAndroid Build Coastguard Worker *
195*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
196*35238bceSAndroid Build Coastguard Worker */
RenderbufferAttachmentTest(deqp::Context & context)197*35238bceSAndroid Build Coastguard Worker RenderbufferAttachmentTest::RenderbufferAttachmentTest(deqp::Context &context)
198*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "framebuffers_renderbuffer_attachment", "Framebuffer Renderbuffer Attachment Test")
199*35238bceSAndroid Build Coastguard Worker , m_fbo(0)
200*35238bceSAndroid Build Coastguard Worker , m_rbo(0)
201*35238bceSAndroid Build Coastguard Worker {
202*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
203*35238bceSAndroid Build Coastguard Worker }
204*35238bceSAndroid Build Coastguard Worker
205*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Framebuffer Renderbuffer Attachment Test cases.
206*35238bceSAndroid Build Coastguard Worker *
207*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
208*35238bceSAndroid Build Coastguard Worker */
iterate()209*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult RenderbufferAttachmentTest::iterate()
210*35238bceSAndroid Build Coastguard Worker {
211*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
212*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
213*35238bceSAndroid Build Coastguard Worker
214*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
215*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
216*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
217*35238bceSAndroid Build Coastguard Worker
218*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
219*35238bceSAndroid Build Coastguard Worker {
220*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
221*35238bceSAndroid Build Coastguard Worker
222*35238bceSAndroid Build Coastguard Worker return STOP;
223*35238bceSAndroid Build Coastguard Worker }
224*35238bceSAndroid Build Coastguard Worker
225*35238bceSAndroid Build Coastguard Worker /* Running tests. */
226*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
227*35238bceSAndroid Build Coastguard Worker bool is_error = false;
228*35238bceSAndroid Build Coastguard Worker
229*35238bceSAndroid Build Coastguard Worker try
230*35238bceSAndroid Build Coastguard Worker {
231*35238bceSAndroid Build Coastguard Worker glw::GLint max_color_attachments = 8 /* Specification minimum OpenGL 4.5 Core Profile p. 627 */;
232*35238bceSAndroid Build Coastguard Worker
233*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
234*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
235*35238bceSAndroid Build Coastguard Worker
236*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < max_color_attachments; ++i)
237*35238bceSAndroid Build Coastguard Worker {
238*35238bceSAndroid Build Coastguard Worker is_ok &= Test(GL_COLOR_ATTACHMENT0 + i, GL_RGBA8);
239*35238bceSAndroid Build Coastguard Worker Clean();
240*35238bceSAndroid Build Coastguard Worker }
241*35238bceSAndroid Build Coastguard Worker
242*35238bceSAndroid Build Coastguard Worker is_ok &= Test(GL_DEPTH_ATTACHMENT, GL_DEPTH_COMPONENT24);
243*35238bceSAndroid Build Coastguard Worker Clean();
244*35238bceSAndroid Build Coastguard Worker
245*35238bceSAndroid Build Coastguard Worker is_ok &= Test(GL_STENCIL_ATTACHMENT, GL_STENCIL_INDEX8);
246*35238bceSAndroid Build Coastguard Worker Clean();
247*35238bceSAndroid Build Coastguard Worker
248*35238bceSAndroid Build Coastguard Worker is_ok &= Test(GL_DEPTH_STENCIL_ATTACHMENT, GL_DEPTH24_STENCIL8);
249*35238bceSAndroid Build Coastguard Worker Clean();
250*35238bceSAndroid Build Coastguard Worker }
251*35238bceSAndroid Build Coastguard Worker catch (...)
252*35238bceSAndroid Build Coastguard Worker {
253*35238bceSAndroid Build Coastguard Worker is_ok = false;
254*35238bceSAndroid Build Coastguard Worker is_error = true;
255*35238bceSAndroid Build Coastguard Worker }
256*35238bceSAndroid Build Coastguard Worker
257*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
258*35238bceSAndroid Build Coastguard Worker Clean();
259*35238bceSAndroid Build Coastguard Worker
260*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
261*35238bceSAndroid Build Coastguard Worker if (is_ok)
262*35238bceSAndroid Build Coastguard Worker {
263*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
264*35238bceSAndroid Build Coastguard Worker }
265*35238bceSAndroid Build Coastguard Worker else
266*35238bceSAndroid Build Coastguard Worker {
267*35238bceSAndroid Build Coastguard Worker if (is_error)
268*35238bceSAndroid Build Coastguard Worker {
269*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
270*35238bceSAndroid Build Coastguard Worker }
271*35238bceSAndroid Build Coastguard Worker else
272*35238bceSAndroid Build Coastguard Worker {
273*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
274*35238bceSAndroid Build Coastguard Worker }
275*35238bceSAndroid Build Coastguard Worker }
276*35238bceSAndroid Build Coastguard Worker
277*35238bceSAndroid Build Coastguard Worker return STOP;
278*35238bceSAndroid Build Coastguard Worker }
279*35238bceSAndroid Build Coastguard Worker
280*35238bceSAndroid Build Coastguard Worker /** @brief Test functionality.
281*35238bceSAndroid Build Coastguard Worker *
282*35238bceSAndroid Build Coastguard Worker * @param [in] attachment Framebuffer attachment.
283*35238bceSAndroid Build Coastguard Worker * @param [in] internalformat Internal format.
284*35238bceSAndroid Build Coastguard Worker *
285*35238bceSAndroid Build Coastguard Worker * @return True if test succeeded, false otherwise.
286*35238bceSAndroid Build Coastguard Worker */
Test(glw::GLenum attachment,glw::GLenum internalformat)287*35238bceSAndroid Build Coastguard Worker bool RenderbufferAttachmentTest::Test(glw::GLenum attachment, glw::GLenum internalformat)
288*35238bceSAndroid Build Coastguard Worker {
289*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
290*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
291*35238bceSAndroid Build Coastguard Worker
292*35238bceSAndroid Build Coastguard Worker /* RBO creation. */
293*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(1, &m_rbo);
294*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
295*35238bceSAndroid Build Coastguard Worker
296*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo);
297*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer has failed");
298*35238bceSAndroid Build Coastguard Worker
299*35238bceSAndroid Build Coastguard Worker gl.renderbufferStorage(GL_RENDERBUFFER, internalformat, 1, 1);
300*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
301*35238bceSAndroid Build Coastguard Worker
302*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, 0);
303*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer has failed");
304*35238bceSAndroid Build Coastguard Worker
305*35238bceSAndroid Build Coastguard Worker /* FBO creation. */
306*35238bceSAndroid Build Coastguard Worker gl.createFramebuffers(1, &m_fbo);
307*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateFramebuffers has failed");
308*35238bceSAndroid Build Coastguard Worker
309*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferRenderbuffer(m_fbo, attachment, GL_RENDERBUFFER, m_rbo);
310*35238bceSAndroid Build Coastguard Worker
311*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
312*35238bceSAndroid Build Coastguard Worker {
313*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
314*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "NamedFramebufferRenderbuffer for "
315*35238bceSAndroid Build Coastguard Worker << glu::getFramebufferAttachmentStr(attachment) << " attachment failed with error value "
316*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(error) << "." << tcu::TestLog::EndMessage;
317*35238bceSAndroid Build Coastguard Worker
318*35238bceSAndroid Build Coastguard Worker return false;
319*35238bceSAndroid Build Coastguard Worker }
320*35238bceSAndroid Build Coastguard Worker
321*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
322*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
323*35238bceSAndroid Build Coastguard Worker
324*35238bceSAndroid Build Coastguard Worker glw::GLenum status = gl.checkFramebufferStatus(GL_FRAMEBUFFER);
325*35238bceSAndroid Build Coastguard Worker
326*35238bceSAndroid Build Coastguard Worker if (GL_FRAMEBUFFER_COMPLETE != status)
327*35238bceSAndroid Build Coastguard Worker {
328*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
329*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Named Framebuffer Renderbuffer Attachment test failed because of framebuffer "
330*35238bceSAndroid Build Coastguard Worker << glu::getFramebufferStatusStr(status) << " with renderbuffer set up as "
331*35238bceSAndroid Build Coastguard Worker << glu::getFramebufferAttachmentStr(attachment) << " attachment." << tcu::TestLog::EndMessage;
332*35238bceSAndroid Build Coastguard Worker
333*35238bceSAndroid Build Coastguard Worker return false;
334*35238bceSAndroid Build Coastguard Worker }
335*35238bceSAndroid Build Coastguard Worker
336*35238bceSAndroid Build Coastguard Worker return true;
337*35238bceSAndroid Build Coastguard Worker }
338*35238bceSAndroid Build Coastguard Worker
339*35238bceSAndroid Build Coastguard Worker /** @brief Clean up GL state.
340*35238bceSAndroid Build Coastguard Worker */
Clean()341*35238bceSAndroid Build Coastguard Worker void RenderbufferAttachmentTest::Clean()
342*35238bceSAndroid Build Coastguard Worker {
343*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
344*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
345*35238bceSAndroid Build Coastguard Worker
346*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
347*35238bceSAndroid Build Coastguard Worker if (m_fbo)
348*35238bceSAndroid Build Coastguard Worker {
349*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &m_fbo);
350*35238bceSAndroid Build Coastguard Worker
351*35238bceSAndroid Build Coastguard Worker m_fbo = 0;
352*35238bceSAndroid Build Coastguard Worker }
353*35238bceSAndroid Build Coastguard Worker
354*35238bceSAndroid Build Coastguard Worker if (m_rbo)
355*35238bceSAndroid Build Coastguard Worker {
356*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &m_rbo);
357*35238bceSAndroid Build Coastguard Worker
358*35238bceSAndroid Build Coastguard Worker m_rbo = 0;
359*35238bceSAndroid Build Coastguard Worker }
360*35238bceSAndroid Build Coastguard Worker
361*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
362*35238bceSAndroid Build Coastguard Worker while (gl.getError())
363*35238bceSAndroid Build Coastguard Worker ;
364*35238bceSAndroid Build Coastguard Worker }
365*35238bceSAndroid Build Coastguard Worker
366*35238bceSAndroid Build Coastguard Worker /******************************** Framebuffer Texture Attachment Test Implementation ********************************/
367*35238bceSAndroid Build Coastguard Worker
368*35238bceSAndroid Build Coastguard Worker /** @brief Creation Test constructor.
369*35238bceSAndroid Build Coastguard Worker *
370*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
371*35238bceSAndroid Build Coastguard Worker */
TextureAttachmentTest(deqp::Context & context)372*35238bceSAndroid Build Coastguard Worker TextureAttachmentTest::TextureAttachmentTest(deqp::Context &context)
373*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "framebuffers_texture_attachment", "Framebuffer Texture Attachment Test")
374*35238bceSAndroid Build Coastguard Worker , m_fbo(0)
375*35238bceSAndroid Build Coastguard Worker , m_to(0)
376*35238bceSAndroid Build Coastguard Worker {
377*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
378*35238bceSAndroid Build Coastguard Worker }
379*35238bceSAndroid Build Coastguard Worker
380*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Creation Test cases.
381*35238bceSAndroid Build Coastguard Worker *
382*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
383*35238bceSAndroid Build Coastguard Worker */
iterate()384*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult TextureAttachmentTest::iterate()
385*35238bceSAndroid Build Coastguard Worker {
386*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
387*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
388*35238bceSAndroid Build Coastguard Worker
389*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
390*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
391*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
392*35238bceSAndroid Build Coastguard Worker
393*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
394*35238bceSAndroid Build Coastguard Worker {
395*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
396*35238bceSAndroid Build Coastguard Worker
397*35238bceSAndroid Build Coastguard Worker return STOP;
398*35238bceSAndroid Build Coastguard Worker }
399*35238bceSAndroid Build Coastguard Worker
400*35238bceSAndroid Build Coastguard Worker /* Running tests. */
401*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
402*35238bceSAndroid Build Coastguard Worker bool is_error = false;
403*35238bceSAndroid Build Coastguard Worker
404*35238bceSAndroid Build Coastguard Worker try
405*35238bceSAndroid Build Coastguard Worker {
406*35238bceSAndroid Build Coastguard Worker glw::GLint max_color_attachments = 8 /* Specification minimum OpenGL 4.5 Core Profile p. 627 */;
407*35238bceSAndroid Build Coastguard Worker
408*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
409*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
410*35238bceSAndroid Build Coastguard Worker
411*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < s_targets_count; ++i)
412*35238bceSAndroid Build Coastguard Worker {
413*35238bceSAndroid Build Coastguard Worker for (glw::GLuint j = 1; j <= MaxTextureLevels(s_targets[i]); ++j)
414*35238bceSAndroid Build Coastguard Worker {
415*35238bceSAndroid Build Coastguard Worker for (glw::GLint k = 0; k < max_color_attachments; ++k)
416*35238bceSAndroid Build Coastguard Worker {
417*35238bceSAndroid Build Coastguard Worker is_ok &= Test(GL_COLOR_ATTACHMENT0 + k, true, s_targets[i], GL_RGBA8, j);
418*35238bceSAndroid Build Coastguard Worker Clean();
419*35238bceSAndroid Build Coastguard Worker }
420*35238bceSAndroid Build Coastguard Worker
421*35238bceSAndroid Build Coastguard Worker is_ok &= Test(GL_DEPTH_ATTACHMENT, false, s_targets[i], GL_DEPTH_COMPONENT24, j);
422*35238bceSAndroid Build Coastguard Worker Clean();
423*35238bceSAndroid Build Coastguard Worker
424*35238bceSAndroid Build Coastguard Worker is_ok &= Test(GL_STENCIL_ATTACHMENT, false, s_targets[i], GL_STENCIL_INDEX8, j);
425*35238bceSAndroid Build Coastguard Worker Clean();
426*35238bceSAndroid Build Coastguard Worker
427*35238bceSAndroid Build Coastguard Worker is_ok &= Test(GL_DEPTH_STENCIL_ATTACHMENT, false, s_targets[i], GL_DEPTH24_STENCIL8, j);
428*35238bceSAndroid Build Coastguard Worker Clean();
429*35238bceSAndroid Build Coastguard Worker }
430*35238bceSAndroid Build Coastguard Worker }
431*35238bceSAndroid Build Coastguard Worker }
432*35238bceSAndroid Build Coastguard Worker catch (...)
433*35238bceSAndroid Build Coastguard Worker {
434*35238bceSAndroid Build Coastguard Worker is_ok = false;
435*35238bceSAndroid Build Coastguard Worker is_error = true;
436*35238bceSAndroid Build Coastguard Worker }
437*35238bceSAndroid Build Coastguard Worker
438*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
439*35238bceSAndroid Build Coastguard Worker Clean();
440*35238bceSAndroid Build Coastguard Worker
441*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
442*35238bceSAndroid Build Coastguard Worker if (is_ok)
443*35238bceSAndroid Build Coastguard Worker {
444*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
445*35238bceSAndroid Build Coastguard Worker }
446*35238bceSAndroid Build Coastguard Worker else
447*35238bceSAndroid Build Coastguard Worker {
448*35238bceSAndroid Build Coastguard Worker if (is_error)
449*35238bceSAndroid Build Coastguard Worker {
450*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
451*35238bceSAndroid Build Coastguard Worker }
452*35238bceSAndroid Build Coastguard Worker else
453*35238bceSAndroid Build Coastguard Worker {
454*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
455*35238bceSAndroid Build Coastguard Worker }
456*35238bceSAndroid Build Coastguard Worker }
457*35238bceSAndroid Build Coastguard Worker
458*35238bceSAndroid Build Coastguard Worker return STOP;
459*35238bceSAndroid Build Coastguard Worker }
460*35238bceSAndroid Build Coastguard Worker
461*35238bceSAndroid Build Coastguard Worker /** @brief Test functionality.
462*35238bceSAndroid Build Coastguard Worker *
463*35238bceSAndroid Build Coastguard Worker * @param [in] attachment Framebuffer attachment.
464*35238bceSAndroid Build Coastguard Worker * @param [in] is_color_attachment Is color attachment tested.
465*35238bceSAndroid Build Coastguard Worker * @param [in] texture_target Texture target.
466*35238bceSAndroid Build Coastguard Worker * @param [in] internalformat Internal format ot be tested.
467*35238bceSAndroid Build Coastguard Worker * @param [in] levels Number of levels.
468*35238bceSAndroid Build Coastguard Worker *
469*35238bceSAndroid Build Coastguard Worker * @return True if test succeeded, false otherwise.
470*35238bceSAndroid Build Coastguard Worker */
Test(glw::GLenum attachment,bool is_color_attachment,glw::GLenum texture_target,glw::GLenum internalformat,glw::GLuint levels)471*35238bceSAndroid Build Coastguard Worker bool TextureAttachmentTest::Test(glw::GLenum attachment, bool is_color_attachment, glw::GLenum texture_target,
472*35238bceSAndroid Build Coastguard Worker glw::GLenum internalformat, glw::GLuint levels)
473*35238bceSAndroid Build Coastguard Worker {
474*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
475*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
476*35238bceSAndroid Build Coastguard Worker
477*35238bceSAndroid Build Coastguard Worker /* RBO creation. */
478*35238bceSAndroid Build Coastguard Worker gl.genTextures(1, &m_to);
479*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
480*35238bceSAndroid Build Coastguard Worker
481*35238bceSAndroid Build Coastguard Worker gl.bindTexture(texture_target, m_to);
482*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
483*35238bceSAndroid Build Coastguard Worker
484*35238bceSAndroid Build Coastguard Worker if (GL_TEXTURE_2D_MULTISAMPLE == texture_target)
485*35238bceSAndroid Build Coastguard Worker {
486*35238bceSAndroid Build Coastguard Worker gl.texStorage2DMultisample(texture_target, 1, internalformat, (glw::GLuint)std::pow((double)2, (double)levels),
487*35238bceSAndroid Build Coastguard Worker (glw::GLuint)std::pow((double)2, (double)levels), GL_FALSE);
488*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
489*35238bceSAndroid Build Coastguard Worker }
490*35238bceSAndroid Build Coastguard Worker else
491*35238bceSAndroid Build Coastguard Worker {
492*35238bceSAndroid Build Coastguard Worker gl.texStorage2D(texture_target, levels, internalformat, (glw::GLuint)std::pow((double)2, (double)levels),
493*35238bceSAndroid Build Coastguard Worker (glw::GLuint)std::pow((double)2, (double)levels));
494*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
495*35238bceSAndroid Build Coastguard Worker }
496*35238bceSAndroid Build Coastguard Worker
497*35238bceSAndroid Build Coastguard Worker gl.bindTexture(texture_target, 0);
498*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer has failed");
499*35238bceSAndroid Build Coastguard Worker
500*35238bceSAndroid Build Coastguard Worker /* FBO creation. */
501*35238bceSAndroid Build Coastguard Worker gl.createFramebuffers(1, &m_fbo);
502*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateFramebuffers has failed");
503*35238bceSAndroid Build Coastguard Worker
504*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < levels; ++i)
505*35238bceSAndroid Build Coastguard Worker {
506*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferTexture(m_fbo, attachment, m_to, i);
507*35238bceSAndroid Build Coastguard Worker
508*35238bceSAndroid Build Coastguard Worker SubTestAttachmentError(attachment, texture_target, i, levels);
509*35238bceSAndroid Build Coastguard Worker
510*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
511*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
512*35238bceSAndroid Build Coastguard Worker
513*35238bceSAndroid Build Coastguard Worker if (is_color_attachment)
514*35238bceSAndroid Build Coastguard Worker {
515*35238bceSAndroid Build Coastguard Worker gl.drawBuffer(attachment);
516*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawBuffer has failed");
517*35238bceSAndroid Build Coastguard Worker
518*35238bceSAndroid Build Coastguard Worker gl.readBuffer(attachment);
519*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadBuffer has failed");
520*35238bceSAndroid Build Coastguard Worker }
521*35238bceSAndroid Build Coastguard Worker
522*35238bceSAndroid Build Coastguard Worker SubTestStatus(attachment, texture_target, i, levels);
523*35238bceSAndroid Build Coastguard Worker
524*35238bceSAndroid Build Coastguard Worker if (GL_TEXTURE_2D_MULTISAMPLE != texture_target)
525*35238bceSAndroid Build Coastguard Worker {
526*35238bceSAndroid Build Coastguard Worker Clear();
527*35238bceSAndroid Build Coastguard Worker
528*35238bceSAndroid Build Coastguard Worker if (!SubTestContent(attachment, texture_target, internalformat, i, levels))
529*35238bceSAndroid Build Coastguard Worker {
530*35238bceSAndroid Build Coastguard Worker return false;
531*35238bceSAndroid Build Coastguard Worker }
532*35238bceSAndroid Build Coastguard Worker }
533*35238bceSAndroid Build Coastguard Worker
534*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
535*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
536*35238bceSAndroid Build Coastguard Worker }
537*35238bceSAndroid Build Coastguard Worker
538*35238bceSAndroid Build Coastguard Worker return true;
539*35238bceSAndroid Build Coastguard Worker }
540*35238bceSAndroid Build Coastguard Worker
541*35238bceSAndroid Build Coastguard Worker /** @brief Check error and log.
542*35238bceSAndroid Build Coastguard Worker *
543*35238bceSAndroid Build Coastguard Worker * @param [in] attachment Framebuffer attachment.
544*35238bceSAndroid Build Coastguard Worker * @param [in] texture_target Texture target.
545*35238bceSAndroid Build Coastguard Worker * @param [in] level Tested level.
546*35238bceSAndroid Build Coastguard Worker * @param [in] levels Number of levels.
547*35238bceSAndroid Build Coastguard Worker *
548*35238bceSAndroid Build Coastguard Worker * @return True if no error, false otherwise.
549*35238bceSAndroid Build Coastguard Worker */
SubTestAttachmentError(glw::GLenum attachment,glw::GLenum texture_target,glw::GLuint level,glw::GLuint levels)550*35238bceSAndroid Build Coastguard Worker bool TextureAttachmentTest::SubTestAttachmentError(glw::GLenum attachment, glw::GLenum texture_target,
551*35238bceSAndroid Build Coastguard Worker glw::GLuint level, glw::GLuint levels)
552*35238bceSAndroid Build Coastguard Worker {
553*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
554*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
555*35238bceSAndroid Build Coastguard Worker
556*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
557*35238bceSAndroid Build Coastguard Worker {
558*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
559*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "NamedFramebufferTexture for " << glu::getFramebufferAttachmentStr(attachment)
560*35238bceSAndroid Build Coastguard Worker << " attachment of " << glu::getTextureTargetStr(texture_target) << " texture and texture level " << level
561*35238bceSAndroid Build Coastguard Worker << " of texture with " << levels << " levels failed with error value " << glu::getErrorStr(error) << "."
562*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
563*35238bceSAndroid Build Coastguard Worker
564*35238bceSAndroid Build Coastguard Worker return false;
565*35238bceSAndroid Build Coastguard Worker }
566*35238bceSAndroid Build Coastguard Worker
567*35238bceSAndroid Build Coastguard Worker return true;
568*35238bceSAndroid Build Coastguard Worker }
569*35238bceSAndroid Build Coastguard Worker
570*35238bceSAndroid Build Coastguard Worker /** @brief Check status and log.
571*35238bceSAndroid Build Coastguard Worker *
572*35238bceSAndroid Build Coastguard Worker * @param [in] attachment Framebuffer attachment.
573*35238bceSAndroid Build Coastguard Worker * @param [in] texture_target Texture target.
574*35238bceSAndroid Build Coastguard Worker * @param [in] level Tested level.
575*35238bceSAndroid Build Coastguard Worker * @param [in] levels Number of levels.
576*35238bceSAndroid Build Coastguard Worker *
577*35238bceSAndroid Build Coastguard Worker * @return True if FRAMEBUFFER_COMPLETE, false otherwise.
578*35238bceSAndroid Build Coastguard Worker */
SubTestStatus(glw::GLenum attachment,glw::GLenum texture_target,glw::GLuint level,glw::GLuint levels)579*35238bceSAndroid Build Coastguard Worker bool TextureAttachmentTest::SubTestStatus(glw::GLenum attachment, glw::GLenum texture_target, glw::GLuint level,
580*35238bceSAndroid Build Coastguard Worker glw::GLuint levels)
581*35238bceSAndroid Build Coastguard Worker {
582*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
583*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
584*35238bceSAndroid Build Coastguard Worker
585*35238bceSAndroid Build Coastguard Worker glw::GLenum status = gl.checkFramebufferStatus(GL_FRAMEBUFFER);
586*35238bceSAndroid Build Coastguard Worker
587*35238bceSAndroid Build Coastguard Worker if (GL_FRAMEBUFFER_COMPLETE != status)
588*35238bceSAndroid Build Coastguard Worker {
589*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
590*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Named Framebuffer Texture Attachment test failed because of framebuffer "
591*35238bceSAndroid Build Coastguard Worker << glu::getFramebufferStatusStr(status) << " status with " << glu::getTextureTargetStr(texture_target)
592*35238bceSAndroid Build Coastguard Worker << " texture set up as " << glu::getFramebufferAttachmentStr(attachment) << " attachment and texture level "
593*35238bceSAndroid Build Coastguard Worker << level << " of texture with " << levels << " levels." << tcu::TestLog::EndMessage;
594*35238bceSAndroid Build Coastguard Worker
595*35238bceSAndroid Build Coastguard Worker return false;
596*35238bceSAndroid Build Coastguard Worker }
597*35238bceSAndroid Build Coastguard Worker
598*35238bceSAndroid Build Coastguard Worker return true;
599*35238bceSAndroid Build Coastguard Worker }
600*35238bceSAndroid Build Coastguard Worker
601*35238bceSAndroid Build Coastguard Worker /** @brief Check framebuffer content and log.
602*35238bceSAndroid Build Coastguard Worker *
603*35238bceSAndroid Build Coastguard Worker * @param [in] attachment Framebuffer attachment.
604*35238bceSAndroid Build Coastguard Worker * @param [in] texture_target Texture target.
605*35238bceSAndroid Build Coastguard Worker * @param [in] internalformat Tested internal format.
606*35238bceSAndroid Build Coastguard Worker * @param [in] level Tested level.
607*35238bceSAndroid Build Coastguard Worker * @param [in] levels Number of levels.
608*35238bceSAndroid Build Coastguard Worker *
609*35238bceSAndroid Build Coastguard Worker * @return True if FRAMEBUFFER_COMPLETE, false otherwise.
610*35238bceSAndroid Build Coastguard Worker */
SubTestContent(glw::GLenum attachment,glw::GLenum texture_target,glw::GLenum internalformat,glw::GLuint level,glw::GLuint levels)611*35238bceSAndroid Build Coastguard Worker bool TextureAttachmentTest::SubTestContent(glw::GLenum attachment, glw::GLenum texture_target,
612*35238bceSAndroid Build Coastguard Worker glw::GLenum internalformat, glw::GLuint level, glw::GLuint levels)
613*35238bceSAndroid Build Coastguard Worker {
614*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
615*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
616*35238bceSAndroid Build Coastguard Worker
617*35238bceSAndroid Build Coastguard Worker /* Check framebuffer's color content. */
618*35238bceSAndroid Build Coastguard Worker if (GL_RGBA8 == internalformat)
619*35238bceSAndroid Build Coastguard Worker {
620*35238bceSAndroid Build Coastguard Worker glw::GLfloat color[4] = {0.f};
621*35238bceSAndroid Build Coastguard Worker
622*35238bceSAndroid Build Coastguard Worker gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_FLOAT, color);
623*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
624*35238bceSAndroid Build Coastguard Worker
625*35238bceSAndroid Build Coastguard Worker for (int i = 0; i < 4 /* color components */; ++i)
626*35238bceSAndroid Build Coastguard Worker {
627*35238bceSAndroid Build Coastguard Worker if (de::abs(s_reference_color[i] - color[i]) > 0.0625 /* precision */)
628*35238bceSAndroid Build Coastguard Worker {
629*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
630*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Named Framebuffer Texture Layer Attachment test failed with "
631*35238bceSAndroid Build Coastguard Worker << glu::getTextureTargetStr(texture_target) << " texture set up as "
632*35238bceSAndroid Build Coastguard Worker << glu::getFramebufferAttachmentStr(attachment) << " attachment and texture level " << level
633*35238bceSAndroid Build Coastguard Worker << " of texture with " << levels << " levels. The color content of the framebuffer was ["
634*35238bceSAndroid Build Coastguard Worker << color[0] << ", " << color[1] << ", " << color[2] << ", " << color[3] << "], but ["
635*35238bceSAndroid Build Coastguard Worker << s_reference_color[0] << ", " << s_reference_color[1] << ", " << s_reference_color[2] << ", "
636*35238bceSAndroid Build Coastguard Worker << s_reference_color[3] << "] was expected." << tcu::TestLog::EndMessage;
637*35238bceSAndroid Build Coastguard Worker
638*35238bceSAndroid Build Coastguard Worker return false;
639*35238bceSAndroid Build Coastguard Worker }
640*35238bceSAndroid Build Coastguard Worker }
641*35238bceSAndroid Build Coastguard Worker }
642*35238bceSAndroid Build Coastguard Worker
643*35238bceSAndroid Build Coastguard Worker /* Check framebuffer's depth content. */
644*35238bceSAndroid Build Coastguard Worker if ((GL_DEPTH_COMPONENT24 == internalformat) || (GL_DEPTH24_STENCIL8 == internalformat))
645*35238bceSAndroid Build Coastguard Worker {
646*35238bceSAndroid Build Coastguard Worker glw::GLfloat depth = 0.f;
647*35238bceSAndroid Build Coastguard Worker
648*35238bceSAndroid Build Coastguard Worker gl.readPixels(0, 0, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
649*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
650*35238bceSAndroid Build Coastguard Worker
651*35238bceSAndroid Build Coastguard Worker if (de::abs(s_reference_depth - depth) > 0.0625 /* precision */)
652*35238bceSAndroid Build Coastguard Worker {
653*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
654*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Named Framebuffer Texture Layer Attachment test failed "
655*35238bceSAndroid Build Coastguard Worker << "with texture set up as " << glu::getFramebufferAttachmentStr(attachment)
656*35238bceSAndroid Build Coastguard Worker << " attachment and texture level " << level << " of texture with " << levels
657*35238bceSAndroid Build Coastguard Worker << " levels. The depth content of the framebuffer was [" << depth << "], but [" << s_reference_depth
658*35238bceSAndroid Build Coastguard Worker << "] was expected." << tcu::TestLog::EndMessage;
659*35238bceSAndroid Build Coastguard Worker
660*35238bceSAndroid Build Coastguard Worker return false;
661*35238bceSAndroid Build Coastguard Worker }
662*35238bceSAndroid Build Coastguard Worker }
663*35238bceSAndroid Build Coastguard Worker
664*35238bceSAndroid Build Coastguard Worker /* Check framebuffer's stencil content. */
665*35238bceSAndroid Build Coastguard Worker if ((GL_STENCIL_INDEX8 == internalformat) || (GL_DEPTH24_STENCIL8 == internalformat))
666*35238bceSAndroid Build Coastguard Worker {
667*35238bceSAndroid Build Coastguard Worker glw::GLint stencil = 0;
668*35238bceSAndroid Build Coastguard Worker
669*35238bceSAndroid Build Coastguard Worker gl.readPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_INT, &stencil);
670*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
671*35238bceSAndroid Build Coastguard Worker
672*35238bceSAndroid Build Coastguard Worker if (s_reference_stencil != stencil)
673*35238bceSAndroid Build Coastguard Worker {
674*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
675*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Named Framebuffer Texture Layer Attachment test failed "
676*35238bceSAndroid Build Coastguard Worker << "with texture set up as " << glu::getFramebufferAttachmentStr(attachment)
677*35238bceSAndroid Build Coastguard Worker << " attachment and texture level " << level << " of texture with " << levels
678*35238bceSAndroid Build Coastguard Worker << " levels. The stencil content of the framebuffer was [" << stencil << "], but ["
679*35238bceSAndroid Build Coastguard Worker << s_reference_stencil << "] was expected." << tcu::TestLog::EndMessage;
680*35238bceSAndroid Build Coastguard Worker
681*35238bceSAndroid Build Coastguard Worker return false;
682*35238bceSAndroid Build Coastguard Worker }
683*35238bceSAndroid Build Coastguard Worker }
684*35238bceSAndroid Build Coastguard Worker
685*35238bceSAndroid Build Coastguard Worker return true;
686*35238bceSAndroid Build Coastguard Worker }
687*35238bceSAndroid Build Coastguard Worker
688*35238bceSAndroid Build Coastguard Worker /** @brief Query max texture levels.
689*35238bceSAndroid Build Coastguard Worker *
690*35238bceSAndroid Build Coastguard Worker * @param [in] texture_target Texture target.
691*35238bceSAndroid Build Coastguard Worker *
692*35238bceSAndroid Build Coastguard Worker * @return Max texture levels.
693*35238bceSAndroid Build Coastguard Worker */
MaxTextureLevels(glw::GLenum texture_target)694*35238bceSAndroid Build Coastguard Worker glw::GLuint TextureAttachmentTest::MaxTextureLevels(glw::GLenum texture_target)
695*35238bceSAndroid Build Coastguard Worker {
696*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
697*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
698*35238bceSAndroid Build Coastguard Worker
699*35238bceSAndroid Build Coastguard Worker glw::GLint max_texture_size = 1024 /* Specification default. */;
700*35238bceSAndroid Build Coastguard Worker
701*35238bceSAndroid Build Coastguard Worker switch (texture_target)
702*35238bceSAndroid Build Coastguard Worker {
703*35238bceSAndroid Build Coastguard Worker case GL_TEXTURE_RECTANGLE:
704*35238bceSAndroid Build Coastguard Worker case GL_TEXTURE_2D_MULTISAMPLE:
705*35238bceSAndroid Build Coastguard Worker return 1;
706*35238bceSAndroid Build Coastguard Worker
707*35238bceSAndroid Build Coastguard Worker case GL_TEXTURE_2D:
708*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size);
709*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
710*35238bceSAndroid Build Coastguard Worker
711*35238bceSAndroid Build Coastguard Worker return (glw::GLuint)std::log((double)max_texture_size);
712*35238bceSAndroid Build Coastguard Worker
713*35238bceSAndroid Build Coastguard Worker case GL_TEXTURE_CUBE_MAP:
714*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &max_texture_size);
715*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
716*35238bceSAndroid Build Coastguard Worker
717*35238bceSAndroid Build Coastguard Worker return (glw::GLuint)std::log((double)max_texture_size);
718*35238bceSAndroid Build Coastguard Worker
719*35238bceSAndroid Build Coastguard Worker default:
720*35238bceSAndroid Build Coastguard Worker throw 0;
721*35238bceSAndroid Build Coastguard Worker }
722*35238bceSAndroid Build Coastguard Worker
723*35238bceSAndroid Build Coastguard Worker /* For compiler warnings only. */
724*35238bceSAndroid Build Coastguard Worker return 0;
725*35238bceSAndroid Build Coastguard Worker }
726*35238bceSAndroid Build Coastguard Worker
727*35238bceSAndroid Build Coastguard Worker /** @brief Clear texture.
728*35238bceSAndroid Build Coastguard Worker */
Clear()729*35238bceSAndroid Build Coastguard Worker void TextureAttachmentTest::Clear()
730*35238bceSAndroid Build Coastguard Worker {
731*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
732*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
733*35238bceSAndroid Build Coastguard Worker
734*35238bceSAndroid Build Coastguard Worker /* Setup clear values. */
735*35238bceSAndroid Build Coastguard Worker gl.clearColor(s_reference_color[0], s_reference_color[1], s_reference_color[2], s_reference_color[3]);
736*35238bceSAndroid Build Coastguard Worker gl.clearDepth(s_reference_depth);
737*35238bceSAndroid Build Coastguard Worker gl.clearStencil(s_reference_stencil);
738*35238bceSAndroid Build Coastguard Worker
739*35238bceSAndroid Build Coastguard Worker /* Clear rbo/fbo. */
740*35238bceSAndroid Build Coastguard Worker gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
741*35238bceSAndroid Build Coastguard Worker }
742*35238bceSAndroid Build Coastguard Worker
743*35238bceSAndroid Build Coastguard Worker /** @brief Clean up GL state.
744*35238bceSAndroid Build Coastguard Worker */
Clean()745*35238bceSAndroid Build Coastguard Worker void TextureAttachmentTest::Clean()
746*35238bceSAndroid Build Coastguard Worker {
747*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
748*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
749*35238bceSAndroid Build Coastguard Worker
750*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
751*35238bceSAndroid Build Coastguard Worker if (m_fbo)
752*35238bceSAndroid Build Coastguard Worker {
753*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &m_fbo);
754*35238bceSAndroid Build Coastguard Worker
755*35238bceSAndroid Build Coastguard Worker m_fbo = 0;
756*35238bceSAndroid Build Coastguard Worker }
757*35238bceSAndroid Build Coastguard Worker
758*35238bceSAndroid Build Coastguard Worker if (m_to)
759*35238bceSAndroid Build Coastguard Worker {
760*35238bceSAndroid Build Coastguard Worker gl.deleteTextures(1, &m_to);
761*35238bceSAndroid Build Coastguard Worker
762*35238bceSAndroid Build Coastguard Worker m_to = 0;
763*35238bceSAndroid Build Coastguard Worker }
764*35238bceSAndroid Build Coastguard Worker
765*35238bceSAndroid Build Coastguard Worker /* Returning to default clear values. */
766*35238bceSAndroid Build Coastguard Worker gl.clearColor(0.f, 0.f, 0.f, 0.f);
767*35238bceSAndroid Build Coastguard Worker gl.clearDepth(1.f);
768*35238bceSAndroid Build Coastguard Worker gl.clearStencil(0);
769*35238bceSAndroid Build Coastguard Worker
770*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
771*35238bceSAndroid Build Coastguard Worker while (gl.getError())
772*35238bceSAndroid Build Coastguard Worker ;
773*35238bceSAndroid Build Coastguard Worker }
774*35238bceSAndroid Build Coastguard Worker
775*35238bceSAndroid Build Coastguard Worker /** Tested targets. */
776*35238bceSAndroid Build Coastguard Worker const glw::GLenum TextureAttachmentTest::s_targets[] = {GL_TEXTURE_RECTANGLE, GL_TEXTURE_2D, GL_TEXTURE_2D_MULTISAMPLE,
777*35238bceSAndroid Build Coastguard Worker GL_TEXTURE_CUBE_MAP};
778*35238bceSAndroid Build Coastguard Worker
779*35238bceSAndroid Build Coastguard Worker /** Tested targets count. */
780*35238bceSAndroid Build Coastguard Worker const glw::GLuint TextureAttachmentTest::s_targets_count = sizeof(s_targets) / sizeof(s_targets[0]);
781*35238bceSAndroid Build Coastguard Worker
782*35238bceSAndroid Build Coastguard Worker const glw::GLfloat TextureAttachmentTest::s_reference_color[4] = {0.25, 0.5, 0.75, 1.0}; //!< Reference color.
783*35238bceSAndroid Build Coastguard Worker const glw::GLint TextureAttachmentTest::s_reference_color_integer[4] = {1, 2, 3,
784*35238bceSAndroid Build Coastguard Worker 4}; //!< Reference color for integer format.
785*35238bceSAndroid Build Coastguard Worker const glw::GLfloat TextureAttachmentTest::s_reference_depth = 0.5; //!< Reference depth value.
786*35238bceSAndroid Build Coastguard Worker const glw::GLint TextureAttachmentTest::s_reference_stencil = 7; //!< Reference stencil value.
787*35238bceSAndroid Build Coastguard Worker
788*35238bceSAndroid Build Coastguard Worker /******************************** Framebuffer Texture Layer Attachment Test Implementation ********************************/
789*35238bceSAndroid Build Coastguard Worker
790*35238bceSAndroid Build Coastguard Worker /** @brief Framebuffer Texture Layer Attachment Test constructor.
791*35238bceSAndroid Build Coastguard Worker *
792*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
793*35238bceSAndroid Build Coastguard Worker */
TextureLayerAttachmentTest(deqp::Context & context)794*35238bceSAndroid Build Coastguard Worker TextureLayerAttachmentTest::TextureLayerAttachmentTest(deqp::Context &context)
795*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "framebuffers_texture_layer_attachment", "Framebuffer Texture Layer Attachment Test")
796*35238bceSAndroid Build Coastguard Worker , m_fbo(0)
797*35238bceSAndroid Build Coastguard Worker , m_to(0)
798*35238bceSAndroid Build Coastguard Worker {
799*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
800*35238bceSAndroid Build Coastguard Worker }
801*35238bceSAndroid Build Coastguard Worker
802*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Framebuffer Texture Layer Attachment Test cases.
803*35238bceSAndroid Build Coastguard Worker *
804*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
805*35238bceSAndroid Build Coastguard Worker */
iterate()806*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult TextureLayerAttachmentTest::iterate()
807*35238bceSAndroid Build Coastguard Worker {
808*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
809*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
810*35238bceSAndroid Build Coastguard Worker
811*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
812*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
813*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
814*35238bceSAndroid Build Coastguard Worker
815*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
816*35238bceSAndroid Build Coastguard Worker {
817*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
818*35238bceSAndroid Build Coastguard Worker
819*35238bceSAndroid Build Coastguard Worker return STOP;
820*35238bceSAndroid Build Coastguard Worker }
821*35238bceSAndroid Build Coastguard Worker
822*35238bceSAndroid Build Coastguard Worker /* Running tests. */
823*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
824*35238bceSAndroid Build Coastguard Worker bool is_error = false;
825*35238bceSAndroid Build Coastguard Worker
826*35238bceSAndroid Build Coastguard Worker try
827*35238bceSAndroid Build Coastguard Worker {
828*35238bceSAndroid Build Coastguard Worker glw::GLint max_color_attachments = 8 /* Specification minimum OpenGL 4.5 Core Profile p. 627 */;
829*35238bceSAndroid Build Coastguard Worker
830*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
831*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
832*35238bceSAndroid Build Coastguard Worker
833*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < s_targets_count; ++i)
834*35238bceSAndroid Build Coastguard Worker {
835*35238bceSAndroid Build Coastguard Worker glw::GLuint layers_counts[] = {(GL_TEXTURE_CUBE_MAP_ARRAY == (glw::GLuint)s_targets[i]) ? 6u : 1u,
836*35238bceSAndroid Build Coastguard Worker (GL_TEXTURE_CUBE_MAP_ARRAY == (glw::GLuint)s_targets[i]) ? 192u : 192u,
837*35238bceSAndroid Build Coastguard Worker MaxTextureLayers(s_targets[i])};
838*35238bceSAndroid Build Coastguard Worker
839*35238bceSAndroid Build Coastguard Worker glw::GLuint layers_counts_count = sizeof(layers_counts) / sizeof(layers_counts[0]);
840*35238bceSAndroid Build Coastguard Worker
841*35238bceSAndroid Build Coastguard Worker for (glw::GLuint j = 1; j <= MaxTextureLevels(s_targets[i]); ++j)
842*35238bceSAndroid Build Coastguard Worker {
843*35238bceSAndroid Build Coastguard Worker for (glw::GLuint k = 0; k < layers_counts_count; ++k)
844*35238bceSAndroid Build Coastguard Worker {
845*35238bceSAndroid Build Coastguard Worker for (glw::GLint l = 0; l < max_color_attachments; ++l)
846*35238bceSAndroid Build Coastguard Worker {
847*35238bceSAndroid Build Coastguard Worker is_ok &= Test(GL_COLOR_ATTACHMENT0 + l, true, s_targets[i], GL_RGBA8, j, layers_counts[k]);
848*35238bceSAndroid Build Coastguard Worker Clean();
849*35238bceSAndroid Build Coastguard Worker }
850*35238bceSAndroid Build Coastguard Worker
851*35238bceSAndroid Build Coastguard Worker if (GL_TEXTURE_3D != s_targets[i])
852*35238bceSAndroid Build Coastguard Worker {
853*35238bceSAndroid Build Coastguard Worker is_ok &=
854*35238bceSAndroid Build Coastguard Worker Test(GL_DEPTH_ATTACHMENT, false, s_targets[i], GL_DEPTH_COMPONENT24, j, layers_counts[k]);
855*35238bceSAndroid Build Coastguard Worker Clean();
856*35238bceSAndroid Build Coastguard Worker
857*35238bceSAndroid Build Coastguard Worker is_ok &= Test(GL_DEPTH_STENCIL_ATTACHMENT, false, s_targets[i], GL_DEPTH24_STENCIL8, j,
858*35238bceSAndroid Build Coastguard Worker layers_counts[k]);
859*35238bceSAndroid Build Coastguard Worker Clean();
860*35238bceSAndroid Build Coastguard Worker
861*35238bceSAndroid Build Coastguard Worker is_ok &=
862*35238bceSAndroid Build Coastguard Worker Test(GL_STENCIL_ATTACHMENT, false, s_targets[i], GL_STENCIL_INDEX8, j, layers_counts[k]);
863*35238bceSAndroid Build Coastguard Worker Clean();
864*35238bceSAndroid Build Coastguard Worker }
865*35238bceSAndroid Build Coastguard Worker }
866*35238bceSAndroid Build Coastguard Worker }
867*35238bceSAndroid Build Coastguard Worker }
868*35238bceSAndroid Build Coastguard Worker }
869*35238bceSAndroid Build Coastguard Worker catch (...)
870*35238bceSAndroid Build Coastguard Worker {
871*35238bceSAndroid Build Coastguard Worker is_ok = false;
872*35238bceSAndroid Build Coastguard Worker is_error = true;
873*35238bceSAndroid Build Coastguard Worker }
874*35238bceSAndroid Build Coastguard Worker
875*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
876*35238bceSAndroid Build Coastguard Worker Clean();
877*35238bceSAndroid Build Coastguard Worker
878*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
879*35238bceSAndroid Build Coastguard Worker if (is_ok)
880*35238bceSAndroid Build Coastguard Worker {
881*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
882*35238bceSAndroid Build Coastguard Worker }
883*35238bceSAndroid Build Coastguard Worker else
884*35238bceSAndroid Build Coastguard Worker {
885*35238bceSAndroid Build Coastguard Worker if (is_error)
886*35238bceSAndroid Build Coastguard Worker {
887*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
888*35238bceSAndroid Build Coastguard Worker }
889*35238bceSAndroid Build Coastguard Worker else
890*35238bceSAndroid Build Coastguard Worker {
891*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
892*35238bceSAndroid Build Coastguard Worker }
893*35238bceSAndroid Build Coastguard Worker }
894*35238bceSAndroid Build Coastguard Worker
895*35238bceSAndroid Build Coastguard Worker return STOP;
896*35238bceSAndroid Build Coastguard Worker }
897*35238bceSAndroid Build Coastguard Worker
898*35238bceSAndroid Build Coastguard Worker /** @brief Test texture layer attachment.
899*35238bceSAndroid Build Coastguard Worker *
900*35238bceSAndroid Build Coastguard Worker * @param [in] attachment Framebuffer attachment.
901*35238bceSAndroid Build Coastguard Worker * @param [in] is_color_attachment Is color attachment tested.
902*35238bceSAndroid Build Coastguard Worker * @param [in] texture_target Texture target.
903*35238bceSAndroid Build Coastguard Worker * @param [in] internalformat Tested internal format.
904*35238bceSAndroid Build Coastguard Worker * @param [in] level Tested level.
905*35238bceSAndroid Build Coastguard Worker * @param [in] levels Number of levels.
906*35238bceSAndroid Build Coastguard Worker * @param [in] layers Number of layers.
907*35238bceSAndroid Build Coastguard Worker *
908*35238bceSAndroid Build Coastguard Worker * @return True if test succeeded, false otherwise.
909*35238bceSAndroid Build Coastguard Worker */
Test(glw::GLenum attachment,bool is_color_attachment,glw::GLenum texture_target,glw::GLenum internalformat,glw::GLuint levels,glw::GLint layers)910*35238bceSAndroid Build Coastguard Worker bool TextureLayerAttachmentTest::Test(glw::GLenum attachment, bool is_color_attachment, glw::GLenum texture_target,
911*35238bceSAndroid Build Coastguard Worker glw::GLenum internalformat, glw::GLuint levels, glw::GLint layers)
912*35238bceSAndroid Build Coastguard Worker {
913*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
914*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
915*35238bceSAndroid Build Coastguard Worker
916*35238bceSAndroid Build Coastguard Worker /* RBO creation. */
917*35238bceSAndroid Build Coastguard Worker gl.genTextures(1, &m_to);
918*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
919*35238bceSAndroid Build Coastguard Worker
920*35238bceSAndroid Build Coastguard Worker gl.bindTexture(texture_target, m_to);
921*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
922*35238bceSAndroid Build Coastguard Worker
923*35238bceSAndroid Build Coastguard Worker // Lower the layers count when multiple levels are requested to limit the amount of memory required
924*35238bceSAndroid Build Coastguard Worker layers = deMax32(1, (glw::GLint)((uint64_t)layers / (1ull << (uint64_t)(2 * (levels - 1)))));
925*35238bceSAndroid Build Coastguard Worker if (GL_TEXTURE_CUBE_MAP_ARRAY == texture_target)
926*35238bceSAndroid Build Coastguard Worker {
927*35238bceSAndroid Build Coastguard Worker layers = deMax32(6, (layers / 6) * 6);
928*35238bceSAndroid Build Coastguard Worker }
929*35238bceSAndroid Build Coastguard Worker
930*35238bceSAndroid Build Coastguard Worker if (GL_TEXTURE_2D_MULTISAMPLE_ARRAY == texture_target)
931*35238bceSAndroid Build Coastguard Worker {
932*35238bceSAndroid Build Coastguard Worker gl.texStorage3DMultisample(texture_target, 1, internalformat, (glw::GLuint)std::pow((double)2, (double)levels),
933*35238bceSAndroid Build Coastguard Worker (glw::GLuint)std::pow((double)2, (double)levels), layers, GL_FALSE);
934*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
935*35238bceSAndroid Build Coastguard Worker }
936*35238bceSAndroid Build Coastguard Worker else
937*35238bceSAndroid Build Coastguard Worker {
938*35238bceSAndroid Build Coastguard Worker gl.texStorage3D(texture_target, levels, internalformat, (glw::GLuint)std::pow((double)2, (double)levels),
939*35238bceSAndroid Build Coastguard Worker (glw::GLuint)std::pow((double)2, (double)levels), layers);
940*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
941*35238bceSAndroid Build Coastguard Worker }
942*35238bceSAndroid Build Coastguard Worker
943*35238bceSAndroid Build Coastguard Worker gl.bindTexture(texture_target, 0);
944*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer has failed");
945*35238bceSAndroid Build Coastguard Worker
946*35238bceSAndroid Build Coastguard Worker /* FBO creation. */
947*35238bceSAndroid Build Coastguard Worker gl.createFramebuffers(1, &m_fbo);
948*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateFramebuffers has failed");
949*35238bceSAndroid Build Coastguard Worker
950*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < levels; ++i)
951*35238bceSAndroid Build Coastguard Worker {
952*35238bceSAndroid Build Coastguard Worker glw::GLuint j = 0;
953*35238bceSAndroid Build Coastguard Worker glw::GLuint k = 1;
954*35238bceSAndroid Build Coastguard Worker
955*35238bceSAndroid Build Coastguard Worker /* 3D textures are mipmapped also in depth directio, so number of layers to be tested must be limited. */
956*35238bceSAndroid Build Coastguard Worker glw::GLuint layers_at_level = (GL_TEXTURE_3D == texture_target) ?
957*35238bceSAndroid Build Coastguard Worker (de::min(layers, layers / (glw::GLint)std::pow(2.0, (double)i))) :
958*35238bceSAndroid Build Coastguard Worker layers;
959*35238bceSAndroid Build Coastguard Worker
960*35238bceSAndroid Build Coastguard Worker while (j < layers_at_level) /* Only layers with Fibonacci number index are tested to reduce the test time. */
961*35238bceSAndroid Build Coastguard Worker {
962*35238bceSAndroid Build Coastguard Worker /* Attach texture layer. */
963*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferTextureLayer(m_fbo, attachment, m_to, i, j);
964*35238bceSAndroid Build Coastguard Worker
965*35238bceSAndroid Build Coastguard Worker if (!SubTestAttachmentError(attachment, texture_target, i, j, levels, layers))
966*35238bceSAndroid Build Coastguard Worker {
967*35238bceSAndroid Build Coastguard Worker return false;
968*35238bceSAndroid Build Coastguard Worker }
969*35238bceSAndroid Build Coastguard Worker
970*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
971*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
972*35238bceSAndroid Build Coastguard Worker
973*35238bceSAndroid Build Coastguard Worker if (is_color_attachment)
974*35238bceSAndroid Build Coastguard Worker {
975*35238bceSAndroid Build Coastguard Worker gl.drawBuffer(attachment);
976*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawBuffer has failed");
977*35238bceSAndroid Build Coastguard Worker
978*35238bceSAndroid Build Coastguard Worker gl.readBuffer(attachment);
979*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadBuffer has failed");
980*35238bceSAndroid Build Coastguard Worker }
981*35238bceSAndroid Build Coastguard Worker
982*35238bceSAndroid Build Coastguard Worker if (!SubTestStatus(attachment, texture_target, i, j, levels, layers))
983*35238bceSAndroid Build Coastguard Worker {
984*35238bceSAndroid Build Coastguard Worker return false;
985*35238bceSAndroid Build Coastguard Worker }
986*35238bceSAndroid Build Coastguard Worker
987*35238bceSAndroid Build Coastguard Worker if (GL_TEXTURE_2D_MULTISAMPLE_ARRAY != texture_target)
988*35238bceSAndroid Build Coastguard Worker {
989*35238bceSAndroid Build Coastguard Worker Clear();
990*35238bceSAndroid Build Coastguard Worker
991*35238bceSAndroid Build Coastguard Worker if (!SubTestContent(attachment, texture_target, internalformat, i, j, levels, layers))
992*35238bceSAndroid Build Coastguard Worker {
993*35238bceSAndroid Build Coastguard Worker return false;
994*35238bceSAndroid Build Coastguard Worker }
995*35238bceSAndroid Build Coastguard Worker }
996*35238bceSAndroid Build Coastguard Worker
997*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
998*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
999*35238bceSAndroid Build Coastguard Worker
1000*35238bceSAndroid Build Coastguard Worker /* Fibonacci number iteration. */
1001*35238bceSAndroid Build Coastguard Worker int l = j;
1002*35238bceSAndroid Build Coastguard Worker j = j + k;
1003*35238bceSAndroid Build Coastguard Worker k = l;
1004*35238bceSAndroid Build Coastguard Worker }
1005*35238bceSAndroid Build Coastguard Worker }
1006*35238bceSAndroid Build Coastguard Worker
1007*35238bceSAndroid Build Coastguard Worker return true;
1008*35238bceSAndroid Build Coastguard Worker }
1009*35238bceSAndroid Build Coastguard Worker
1010*35238bceSAndroid Build Coastguard Worker /** @brief Check error and log.
1011*35238bceSAndroid Build Coastguard Worker *
1012*35238bceSAndroid Build Coastguard Worker * @param [in] attachment Framebuffer attachment.
1013*35238bceSAndroid Build Coastguard Worker * @param [in] texture_target Texture target.
1014*35238bceSAndroid Build Coastguard Worker * @param [in] level Tested level.
1015*35238bceSAndroid Build Coastguard Worker * @param [in] layer Tested layer.
1016*35238bceSAndroid Build Coastguard Worker * @param [in] levels Number of levels.
1017*35238bceSAndroid Build Coastguard Worker * @param [in] layers Number of layers.
1018*35238bceSAndroid Build Coastguard Worker *
1019*35238bceSAndroid Build Coastguard Worker * @return True if no error, false otherwise.
1020*35238bceSAndroid Build Coastguard Worker */
SubTestAttachmentError(glw::GLenum attachment,glw::GLenum texture_target,glw::GLuint level,glw::GLint layer,glw::GLuint levels,glw::GLint layers)1021*35238bceSAndroid Build Coastguard Worker bool TextureLayerAttachmentTest::SubTestAttachmentError(glw::GLenum attachment, glw::GLenum texture_target,
1022*35238bceSAndroid Build Coastguard Worker glw::GLuint level, glw::GLint layer, glw::GLuint levels,
1023*35238bceSAndroid Build Coastguard Worker glw::GLint layers)
1024*35238bceSAndroid Build Coastguard Worker {
1025*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
1026*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
1027*35238bceSAndroid Build Coastguard Worker
1028*35238bceSAndroid Build Coastguard Worker /* Check and log. */
1029*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
1030*35238bceSAndroid Build Coastguard Worker {
1031*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
1032*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "NamedFramebufferTexture for " << glu::getFramebufferAttachmentStr(attachment)
1033*35238bceSAndroid Build Coastguard Worker << " attachment of " << glu::getTextureTargetStr(texture_target) << " texture at level " << level
1034*35238bceSAndroid Build Coastguard Worker << " and at layer " << layer << " where texture has " << levels << " levels and " << layers
1035*35238bceSAndroid Build Coastguard Worker << " layers failed with error value " << glu::getErrorStr(error) << "." << tcu::TestLog::EndMessage;
1036*35238bceSAndroid Build Coastguard Worker
1037*35238bceSAndroid Build Coastguard Worker return false;
1038*35238bceSAndroid Build Coastguard Worker }
1039*35238bceSAndroid Build Coastguard Worker
1040*35238bceSAndroid Build Coastguard Worker return true;
1041*35238bceSAndroid Build Coastguard Worker }
1042*35238bceSAndroid Build Coastguard Worker
1043*35238bceSAndroid Build Coastguard Worker /** @brief Check framebuffer completness.
1044*35238bceSAndroid Build Coastguard Worker *
1045*35238bceSAndroid Build Coastguard Worker * @param [in] attachment Framebuffer attachment.
1046*35238bceSAndroid Build Coastguard Worker * @param [in] texture_target Texture target.
1047*35238bceSAndroid Build Coastguard Worker * @param [in] level Tested level.
1048*35238bceSAndroid Build Coastguard Worker * @param [in] layer Tested layer.
1049*35238bceSAndroid Build Coastguard Worker * @param [in] levels Number of levels.
1050*35238bceSAndroid Build Coastguard Worker * @param [in] layers Number of layers.
1051*35238bceSAndroid Build Coastguard Worker *
1052*35238bceSAndroid Build Coastguard Worker * @return True if framebuffer is complete, false otherwise.
1053*35238bceSAndroid Build Coastguard Worker */
SubTestStatus(glw::GLenum attachment,glw::GLenum texture_target,glw::GLuint level,glw::GLint layer,glw::GLuint levels,glw::GLint layers)1054*35238bceSAndroid Build Coastguard Worker bool TextureLayerAttachmentTest::SubTestStatus(glw::GLenum attachment, glw::GLenum texture_target, glw::GLuint level,
1055*35238bceSAndroid Build Coastguard Worker glw::GLint layer, glw::GLuint levels, glw::GLint layers)
1056*35238bceSAndroid Build Coastguard Worker {
1057*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
1058*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
1059*35238bceSAndroid Build Coastguard Worker
1060*35238bceSAndroid Build Coastguard Worker /* Check framebuffer status. */
1061*35238bceSAndroid Build Coastguard Worker glw::GLenum status = gl.checkFramebufferStatus(GL_FRAMEBUFFER);
1062*35238bceSAndroid Build Coastguard Worker
1063*35238bceSAndroid Build Coastguard Worker if (GL_FRAMEBUFFER_COMPLETE != status)
1064*35238bceSAndroid Build Coastguard Worker {
1065*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
1066*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Named Framebuffer Texture Layer Attachment test failed because of framebuffer "
1067*35238bceSAndroid Build Coastguard Worker << glu::getFramebufferStatusStr(status) << " with " << glu::getTextureTargetStr(texture_target)
1068*35238bceSAndroid Build Coastguard Worker << " texture set up as " << glu::getFramebufferAttachmentStr(attachment) << " attachment and texture level "
1069*35238bceSAndroid Build Coastguard Worker << level << " and texture layer " << layer << " of texture with " << levels << " levels and " << layers
1070*35238bceSAndroid Build Coastguard Worker << " layers." << tcu::TestLog::EndMessage;
1071*35238bceSAndroid Build Coastguard Worker
1072*35238bceSAndroid Build Coastguard Worker return false;
1073*35238bceSAndroid Build Coastguard Worker }
1074*35238bceSAndroid Build Coastguard Worker
1075*35238bceSAndroid Build Coastguard Worker return true;
1076*35238bceSAndroid Build Coastguard Worker }
1077*35238bceSAndroid Build Coastguard Worker
1078*35238bceSAndroid Build Coastguard Worker /** @brief Check framebuffer cntent.
1079*35238bceSAndroid Build Coastguard Worker *
1080*35238bceSAndroid Build Coastguard Worker * @param [in] attachment Framebuffer attachment.
1081*35238bceSAndroid Build Coastguard Worker * @param [in] texture_target Texture target.
1082*35238bceSAndroid Build Coastguard Worker * @param [in] internalformat Tested internal format.
1083*35238bceSAndroid Build Coastguard Worker * @param [in] level Tested level.
1084*35238bceSAndroid Build Coastguard Worker * @param [in] layer Tested layer.
1085*35238bceSAndroid Build Coastguard Worker * @param [in] levels Number of levels.
1086*35238bceSAndroid Build Coastguard Worker * @param [in] layers Number of layers.
1087*35238bceSAndroid Build Coastguard Worker *
1088*35238bceSAndroid Build Coastguard Worker * @return True if framebuffer content is equal to the reference, false otherwise.
1089*35238bceSAndroid Build Coastguard Worker */
SubTestContent(glw::GLenum attachment,glw::GLenum texture_target,glw::GLenum internalformat,glw::GLuint level,glw::GLint layer,glw::GLuint levels,glw::GLint layers)1090*35238bceSAndroid Build Coastguard Worker bool TextureLayerAttachmentTest::SubTestContent(glw::GLenum attachment, glw::GLenum texture_target,
1091*35238bceSAndroid Build Coastguard Worker glw::GLenum internalformat, glw::GLuint level, glw::GLint layer,
1092*35238bceSAndroid Build Coastguard Worker glw::GLuint levels, glw::GLint layers)
1093*35238bceSAndroid Build Coastguard Worker {
1094*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
1095*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
1096*35238bceSAndroid Build Coastguard Worker
1097*35238bceSAndroid Build Coastguard Worker /* Check framebuffer's color content. */
1098*35238bceSAndroid Build Coastguard Worker if (GL_RGBA8 == internalformat)
1099*35238bceSAndroid Build Coastguard Worker {
1100*35238bceSAndroid Build Coastguard Worker glw::GLfloat color[4] = {0.f};
1101*35238bceSAndroid Build Coastguard Worker
1102*35238bceSAndroid Build Coastguard Worker gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_FLOAT, color);
1103*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
1104*35238bceSAndroid Build Coastguard Worker
1105*35238bceSAndroid Build Coastguard Worker for (int i = 0; i < 4 /* color components */; ++i)
1106*35238bceSAndroid Build Coastguard Worker {
1107*35238bceSAndroid Build Coastguard Worker if (de::abs(s_reference_color[i] - color[i]) > 0.0625 /* precision */)
1108*35238bceSAndroid Build Coastguard Worker {
1109*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
1110*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Named Framebuffer Texture Layer Attachment test failed with "
1111*35238bceSAndroid Build Coastguard Worker << glu::getTextureTargetStr(texture_target) << " texture set up as "
1112*35238bceSAndroid Build Coastguard Worker << glu::getFramebufferAttachmentStr(attachment) << " attachment and texture level " << level
1113*35238bceSAndroid Build Coastguard Worker << " and texture layer " << layer << " of texture with " << levels << " levels and " << layers
1114*35238bceSAndroid Build Coastguard Worker << " layers. The color content of the framebuffer was [" << color[0] << ", " << color[1] << ", "
1115*35238bceSAndroid Build Coastguard Worker << color[2] << ", " << color[3] << "], but [" << s_reference_color[0] << ", "
1116*35238bceSAndroid Build Coastguard Worker << s_reference_color[1] << ", " << s_reference_color[2] << ", " << s_reference_color[3]
1117*35238bceSAndroid Build Coastguard Worker << "] was expected." << tcu::TestLog::EndMessage;
1118*35238bceSAndroid Build Coastguard Worker return false;
1119*35238bceSAndroid Build Coastguard Worker }
1120*35238bceSAndroid Build Coastguard Worker }
1121*35238bceSAndroid Build Coastguard Worker }
1122*35238bceSAndroid Build Coastguard Worker
1123*35238bceSAndroid Build Coastguard Worker /* Check framebuffer's depth content. */
1124*35238bceSAndroid Build Coastguard Worker if ((GL_DEPTH_COMPONENT24 == internalformat) || (GL_DEPTH24_STENCIL8 == internalformat))
1125*35238bceSAndroid Build Coastguard Worker {
1126*35238bceSAndroid Build Coastguard Worker glw::GLfloat depth = 0.f;
1127*35238bceSAndroid Build Coastguard Worker
1128*35238bceSAndroid Build Coastguard Worker gl.readPixels(0, 0, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
1129*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
1130*35238bceSAndroid Build Coastguard Worker
1131*35238bceSAndroid Build Coastguard Worker if (de::abs(s_reference_depth - depth) > 0.0625 /* precision */)
1132*35238bceSAndroid Build Coastguard Worker {
1133*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
1134*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Named Framebuffer Texture Layer Attachment test failed "
1135*35238bceSAndroid Build Coastguard Worker << "with texture set up as " << glu::getFramebufferAttachmentStr(attachment)
1136*35238bceSAndroid Build Coastguard Worker << " attachment and texture level " << level << " and texture layer " << layer << " of texture with "
1137*35238bceSAndroid Build Coastguard Worker << levels << " levels and " << layers << " layers. The depth content of the framebuffer was [" << depth
1138*35238bceSAndroid Build Coastguard Worker << "], but [" << s_reference_depth << "] was expected." << tcu::TestLog::EndMessage;
1139*35238bceSAndroid Build Coastguard Worker
1140*35238bceSAndroid Build Coastguard Worker return false;
1141*35238bceSAndroid Build Coastguard Worker }
1142*35238bceSAndroid Build Coastguard Worker }
1143*35238bceSAndroid Build Coastguard Worker
1144*35238bceSAndroid Build Coastguard Worker /* Check framebuffer's stencil content. */
1145*35238bceSAndroid Build Coastguard Worker if ((GL_STENCIL_INDEX8 == internalformat) || (GL_DEPTH24_STENCIL8 == internalformat))
1146*35238bceSAndroid Build Coastguard Worker {
1147*35238bceSAndroid Build Coastguard Worker glw::GLint stencil = 0;
1148*35238bceSAndroid Build Coastguard Worker
1149*35238bceSAndroid Build Coastguard Worker gl.readPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_INT, &stencil);
1150*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
1151*35238bceSAndroid Build Coastguard Worker
1152*35238bceSAndroid Build Coastguard Worker if (s_reference_stencil != stencil)
1153*35238bceSAndroid Build Coastguard Worker {
1154*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
1155*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Named Framebuffer Texture Layer Attachment test failed "
1156*35238bceSAndroid Build Coastguard Worker << "with texture set up as " << glu::getFramebufferAttachmentStr(attachment)
1157*35238bceSAndroid Build Coastguard Worker << " attachment and texture level " << level << " and texture layer " << layer << " of texture with "
1158*35238bceSAndroid Build Coastguard Worker << levels << " levels and " << layers << " layers. The stencil content of the framebuffer was ["
1159*35238bceSAndroid Build Coastguard Worker << stencil << "], but [" << s_reference_stencil << "] was expected." << tcu::TestLog::EndMessage;
1160*35238bceSAndroid Build Coastguard Worker
1161*35238bceSAndroid Build Coastguard Worker return false;
1162*35238bceSAndroid Build Coastguard Worker }
1163*35238bceSAndroid Build Coastguard Worker }
1164*35238bceSAndroid Build Coastguard Worker
1165*35238bceSAndroid Build Coastguard Worker return true;
1166*35238bceSAndroid Build Coastguard Worker }
1167*35238bceSAndroid Build Coastguard Worker
1168*35238bceSAndroid Build Coastguard Worker /** @brief Clear framebuffer.
1169*35238bceSAndroid Build Coastguard Worker */
Clear()1170*35238bceSAndroid Build Coastguard Worker void TextureLayerAttachmentTest::Clear()
1171*35238bceSAndroid Build Coastguard Worker {
1172*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
1173*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
1174*35238bceSAndroid Build Coastguard Worker
1175*35238bceSAndroid Build Coastguard Worker /* Setup clear values. */
1176*35238bceSAndroid Build Coastguard Worker gl.clearColor(s_reference_color[0], s_reference_color[1], s_reference_color[2], s_reference_color[3]);
1177*35238bceSAndroid Build Coastguard Worker gl.clearDepth(s_reference_depth);
1178*35238bceSAndroid Build Coastguard Worker gl.clearStencil(s_reference_stencil);
1179*35238bceSAndroid Build Coastguard Worker
1180*35238bceSAndroid Build Coastguard Worker /* Clear rbo/fbo. */
1181*35238bceSAndroid Build Coastguard Worker gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
1182*35238bceSAndroid Build Coastguard Worker }
1183*35238bceSAndroid Build Coastguard Worker
1184*35238bceSAndroid Build Coastguard Worker /** @brief Query maximum number of texture levels.
1185*35238bceSAndroid Build Coastguard Worker *
1186*35238bceSAndroid Build Coastguard Worker * @return True if max number of texture levels, false otherwise.
1187*35238bceSAndroid Build Coastguard Worker */
MaxTextureLevels(glw::GLenum texture_target)1188*35238bceSAndroid Build Coastguard Worker glw::GLuint TextureLayerAttachmentTest::MaxTextureLevels(glw::GLenum texture_target)
1189*35238bceSAndroid Build Coastguard Worker {
1190*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
1191*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
1192*35238bceSAndroid Build Coastguard Worker
1193*35238bceSAndroid Build Coastguard Worker glw::GLint max_texture_size = 1024 /* Specification default. */;
1194*35238bceSAndroid Build Coastguard Worker
1195*35238bceSAndroid Build Coastguard Worker switch (texture_target)
1196*35238bceSAndroid Build Coastguard Worker {
1197*35238bceSAndroid Build Coastguard Worker case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
1198*35238bceSAndroid Build Coastguard Worker return 1;
1199*35238bceSAndroid Build Coastguard Worker
1200*35238bceSAndroid Build Coastguard Worker case GL_TEXTURE_2D_ARRAY:
1201*35238bceSAndroid Build Coastguard Worker
1202*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size);
1203*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
1204*35238bceSAndroid Build Coastguard Worker
1205*35238bceSAndroid Build Coastguard Worker return (glw::GLuint)std::log((double)max_texture_size);
1206*35238bceSAndroid Build Coastguard Worker
1207*35238bceSAndroid Build Coastguard Worker case GL_TEXTURE_CUBE_MAP_ARRAY:
1208*35238bceSAndroid Build Coastguard Worker
1209*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &max_texture_size);
1210*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
1211*35238bceSAndroid Build Coastguard Worker
1212*35238bceSAndroid Build Coastguard Worker return (glw::GLuint)std::log((double)max_texture_size);
1213*35238bceSAndroid Build Coastguard Worker
1214*35238bceSAndroid Build Coastguard Worker case GL_TEXTURE_3D:
1215*35238bceSAndroid Build Coastguard Worker
1216*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_3D_TEXTURE_SIZE, &max_texture_size);
1217*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
1218*35238bceSAndroid Build Coastguard Worker
1219*35238bceSAndroid Build Coastguard Worker return (glw::GLuint)std::log((double)max_texture_size);
1220*35238bceSAndroid Build Coastguard Worker default:
1221*35238bceSAndroid Build Coastguard Worker throw 0;
1222*35238bceSAndroid Build Coastguard Worker }
1223*35238bceSAndroid Build Coastguard Worker
1224*35238bceSAndroid Build Coastguard Worker /* For compiler warnings only. */
1225*35238bceSAndroid Build Coastguard Worker return 0;
1226*35238bceSAndroid Build Coastguard Worker }
1227*35238bceSAndroid Build Coastguard Worker
1228*35238bceSAndroid Build Coastguard Worker /** @brief Query maximum number of texture layers.
1229*35238bceSAndroid Build Coastguard Worker *
1230*35238bceSAndroid Build Coastguard Worker * @return True if max number of texture layers, false otherwise.
1231*35238bceSAndroid Build Coastguard Worker */
MaxTextureLayers(glw::GLenum texture_target)1232*35238bceSAndroid Build Coastguard Worker glw::GLuint TextureLayerAttachmentTest::MaxTextureLayers(glw::GLenum texture_target)
1233*35238bceSAndroid Build Coastguard Worker {
1234*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
1235*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
1236*35238bceSAndroid Build Coastguard Worker
1237*35238bceSAndroid Build Coastguard Worker glw::GLint max_texture_size = 1024 /* Specification default. */;
1238*35238bceSAndroid Build Coastguard Worker
1239*35238bceSAndroid Build Coastguard Worker switch (texture_target)
1240*35238bceSAndroid Build Coastguard Worker {
1241*35238bceSAndroid Build Coastguard Worker case GL_TEXTURE_3D:
1242*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_3D_TEXTURE_SIZE, &max_texture_size);
1243*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
1244*35238bceSAndroid Build Coastguard Worker
1245*35238bceSAndroid Build Coastguard Worker return max_texture_size;
1246*35238bceSAndroid Build Coastguard Worker
1247*35238bceSAndroid Build Coastguard Worker case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
1248*35238bceSAndroid Build Coastguard Worker case GL_TEXTURE_2D_ARRAY:
1249*35238bceSAndroid Build Coastguard Worker
1250*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &max_texture_size);
1251*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
1252*35238bceSAndroid Build Coastguard Worker
1253*35238bceSAndroid Build Coastguard Worker return max_texture_size;
1254*35238bceSAndroid Build Coastguard Worker
1255*35238bceSAndroid Build Coastguard Worker case GL_TEXTURE_CUBE_MAP_ARRAY:
1256*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &max_texture_size);
1257*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
1258*35238bceSAndroid Build Coastguard Worker
1259*35238bceSAndroid Build Coastguard Worker return (max_texture_size / 6) * 6; /* Make sure that max_texture_size is dividable by 6 */
1260*35238bceSAndroid Build Coastguard Worker
1261*35238bceSAndroid Build Coastguard Worker default:
1262*35238bceSAndroid Build Coastguard Worker throw 0;
1263*35238bceSAndroid Build Coastguard Worker }
1264*35238bceSAndroid Build Coastguard Worker
1265*35238bceSAndroid Build Coastguard Worker /* For compiler warnings only. */
1266*35238bceSAndroid Build Coastguard Worker return 0;
1267*35238bceSAndroid Build Coastguard Worker }
1268*35238bceSAndroid Build Coastguard Worker
1269*35238bceSAndroid Build Coastguard Worker /** @brief Clean up GL state.
1270*35238bceSAndroid Build Coastguard Worker */
Clean()1271*35238bceSAndroid Build Coastguard Worker void TextureLayerAttachmentTest::Clean()
1272*35238bceSAndroid Build Coastguard Worker {
1273*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
1274*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
1275*35238bceSAndroid Build Coastguard Worker
1276*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
1277*35238bceSAndroid Build Coastguard Worker if (m_fbo)
1278*35238bceSAndroid Build Coastguard Worker {
1279*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &m_fbo);
1280*35238bceSAndroid Build Coastguard Worker
1281*35238bceSAndroid Build Coastguard Worker m_fbo = 0;
1282*35238bceSAndroid Build Coastguard Worker }
1283*35238bceSAndroid Build Coastguard Worker
1284*35238bceSAndroid Build Coastguard Worker if (m_to)
1285*35238bceSAndroid Build Coastguard Worker {
1286*35238bceSAndroid Build Coastguard Worker gl.deleteTextures(1, &m_to);
1287*35238bceSAndroid Build Coastguard Worker
1288*35238bceSAndroid Build Coastguard Worker m_to = 0;
1289*35238bceSAndroid Build Coastguard Worker }
1290*35238bceSAndroid Build Coastguard Worker
1291*35238bceSAndroid Build Coastguard Worker /* Returning to default clear values. */
1292*35238bceSAndroid Build Coastguard Worker gl.clearColor(0.f, 0.f, 0.f, 0.f);
1293*35238bceSAndroid Build Coastguard Worker gl.clearDepth(1.f);
1294*35238bceSAndroid Build Coastguard Worker gl.clearStencil(0);
1295*35238bceSAndroid Build Coastguard Worker
1296*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
1297*35238bceSAndroid Build Coastguard Worker while (gl.getError())
1298*35238bceSAndroid Build Coastguard Worker ;
1299*35238bceSAndroid Build Coastguard Worker }
1300*35238bceSAndroid Build Coastguard Worker
1301*35238bceSAndroid Build Coastguard Worker const glw::GLenum TextureLayerAttachmentTest::s_targets[] = //!< Targets to be tested.
1302*35238bceSAndroid Build Coastguard Worker {GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_2D_ARRAY, GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_3D};
1303*35238bceSAndroid Build Coastguard Worker
1304*35238bceSAndroid Build Coastguard Worker const glw::GLuint TextureLayerAttachmentTest::s_targets_count =
1305*35238bceSAndroid Build Coastguard Worker sizeof(s_targets) / sizeof(s_targets[0]); //!< Number of tested targets.
1306*35238bceSAndroid Build Coastguard Worker
1307*35238bceSAndroid Build Coastguard Worker const glw::GLfloat TextureLayerAttachmentTest::s_reference_color[4] = {0.25, 0.5, 0.75, 1.0}; //!< Reference color.
1308*35238bceSAndroid Build Coastguard Worker const glw::GLint TextureLayerAttachmentTest::s_reference_color_integer[4] = {1, 2, 3, 4}; //!< Reference integer color.
1309*35238bceSAndroid Build Coastguard Worker const glw::GLfloat TextureLayerAttachmentTest::s_reference_depth = 0.5; //!< Reference depth.
1310*35238bceSAndroid Build Coastguard Worker const glw::GLint TextureLayerAttachmentTest::s_reference_stencil = 7; //!< Reference stencil index.
1311*35238bceSAndroid Build Coastguard Worker
1312*35238bceSAndroid Build Coastguard Worker /******************************** Named Framebuffer Read / Draw Buffer Test Implementation ********************************/
1313*35238bceSAndroid Build Coastguard Worker
1314*35238bceSAndroid Build Coastguard Worker /** @brief Named Framebuffer Read / Draw Buffer Test constructor.
1315*35238bceSAndroid Build Coastguard Worker *
1316*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
1317*35238bceSAndroid Build Coastguard Worker */
DrawReadBufferTest(deqp::Context & context)1318*35238bceSAndroid Build Coastguard Worker DrawReadBufferTest::DrawReadBufferTest(deqp::Context &context)
1319*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "framebuffers_read_draw_buffer", "Framebuffer Read and Draw Buffer Test")
1320*35238bceSAndroid Build Coastguard Worker {
1321*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
1322*35238bceSAndroid Build Coastguard Worker }
1323*35238bceSAndroid Build Coastguard Worker
1324*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Named Framebuffer Read / Draw Buffer Test cases.
1325*35238bceSAndroid Build Coastguard Worker *
1326*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
1327*35238bceSAndroid Build Coastguard Worker */
iterate()1328*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult DrawReadBufferTest::iterate()
1329*35238bceSAndroid Build Coastguard Worker {
1330*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
1331*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
1332*35238bceSAndroid Build Coastguard Worker
1333*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
1334*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
1335*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
1336*35238bceSAndroid Build Coastguard Worker
1337*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
1338*35238bceSAndroid Build Coastguard Worker {
1339*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
1340*35238bceSAndroid Build Coastguard Worker
1341*35238bceSAndroid Build Coastguard Worker return STOP;
1342*35238bceSAndroid Build Coastguard Worker }
1343*35238bceSAndroid Build Coastguard Worker
1344*35238bceSAndroid Build Coastguard Worker /* Running tests. */
1345*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
1346*35238bceSAndroid Build Coastguard Worker bool is_error = false;
1347*35238bceSAndroid Build Coastguard Worker
1348*35238bceSAndroid Build Coastguard Worker /* Framebuffers' objects */
1349*35238bceSAndroid Build Coastguard Worker glw::GLuint framebuffer = 0;
1350*35238bceSAndroid Build Coastguard Worker
1351*35238bceSAndroid Build Coastguard Worker /* Get number of color attachments. */
1352*35238bceSAndroid Build Coastguard Worker glw::GLint max_color_attachments = 8 /* Specification minimum OpenGL 4.5 Core Profile p. 627 */;
1353*35238bceSAndroid Build Coastguard Worker
1354*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
1355*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
1356*35238bceSAndroid Build Coastguard Worker
1357*35238bceSAndroid Build Coastguard Worker std::vector<glw::GLuint> renderbuffers(max_color_attachments);
1358*35238bceSAndroid Build Coastguard Worker
1359*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < max_color_attachments; ++i)
1360*35238bceSAndroid Build Coastguard Worker {
1361*35238bceSAndroid Build Coastguard Worker renderbuffers[i] = 0;
1362*35238bceSAndroid Build Coastguard Worker }
1363*35238bceSAndroid Build Coastguard Worker
1364*35238bceSAndroid Build Coastguard Worker try
1365*35238bceSAndroid Build Coastguard Worker {
1366*35238bceSAndroid Build Coastguard Worker /* Prepare framebuffer... */
1367*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(1, &framebuffer);
1368*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
1369*35238bceSAndroid Build Coastguard Worker
1370*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, framebuffer);
1371*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
1372*35238bceSAndroid Build Coastguard Worker
1373*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(max_color_attachments, &(renderbuffers[0]));
1374*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
1375*35238bceSAndroid Build Coastguard Worker
1376*35238bceSAndroid Build Coastguard Worker /* .. with renderbuffer color attachments. */
1377*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < max_color_attachments; ++i)
1378*35238bceSAndroid Build Coastguard Worker {
1379*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, renderbuffers[i]);
1380*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer has failed");
1381*35238bceSAndroid Build Coastguard Worker
1382*35238bceSAndroid Build Coastguard Worker gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA32F, 1, 1);
1383*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
1384*35238bceSAndroid Build Coastguard Worker
1385*35238bceSAndroid Build Coastguard Worker gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_RENDERBUFFER, renderbuffers[i]);
1386*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
1387*35238bceSAndroid Build Coastguard Worker }
1388*35238bceSAndroid Build Coastguard Worker
1389*35238bceSAndroid Build Coastguard Worker /* Check that framebuffer is complete. */
1390*35238bceSAndroid Build Coastguard Worker if (GL_FRAMEBUFFER_COMPLETE != gl.checkFramebufferStatus(GL_FRAMEBUFFER))
1391*35238bceSAndroid Build Coastguard Worker {
1392*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
1393*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Framebuffer is unexpectedly incomplete." << tcu::TestLog::EndMessage;
1394*35238bceSAndroid Build Coastguard Worker
1395*35238bceSAndroid Build Coastguard Worker throw 0;
1396*35238bceSAndroid Build Coastguard Worker }
1397*35238bceSAndroid Build Coastguard Worker
1398*35238bceSAndroid Build Coastguard Worker /* Clear each of the framebuffer's attachments with unique color using NamedFramebufferDrawBuffer for attachment selection. */
1399*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < max_color_attachments; ++i)
1400*35238bceSAndroid Build Coastguard Worker {
1401*35238bceSAndroid Build Coastguard Worker gl.clearColor((float)i / (float)max_color_attachments, (float)i / (float)max_color_attachments,
1402*35238bceSAndroid Build Coastguard Worker (float)i / (float)max_color_attachments, (float)i / (float)max_color_attachments);
1403*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor has failed");
1404*35238bceSAndroid Build Coastguard Worker
1405*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferDrawBuffer(framebuffer, GL_COLOR_ATTACHMENT0 + i);
1406*35238bceSAndroid Build Coastguard Worker
1407*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
1408*35238bceSAndroid Build Coastguard Worker {
1409*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
1410*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "NamedFramebufferDrawBuffer unexpectedly generated "
1411*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(error) << " error with GL_COLOR_ATTACHMENT" << i << ". Test fails."
1412*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
1413*35238bceSAndroid Build Coastguard Worker is_ok = false;
1414*35238bceSAndroid Build Coastguard Worker }
1415*35238bceSAndroid Build Coastguard Worker
1416*35238bceSAndroid Build Coastguard Worker gl.clear(GL_COLOR_BUFFER_BIT);
1417*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glClear has failed");
1418*35238bceSAndroid Build Coastguard Worker }
1419*35238bceSAndroid Build Coastguard Worker
1420*35238bceSAndroid Build Coastguard Worker /* Fetch framebuffer's content and compare it with reference using NamedFramebufferReadBuffer for attachment selection. */
1421*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < max_color_attachments; ++i)
1422*35238bceSAndroid Build Coastguard Worker {
1423*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferReadBuffer(framebuffer, GL_COLOR_ATTACHMENT0 + i);
1424*35238bceSAndroid Build Coastguard Worker
1425*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
1426*35238bceSAndroid Build Coastguard Worker {
1427*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
1428*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "NamedFramebufferReadBuffer unexpectedly generated "
1429*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(error) << " error with GL_COLOR_ATTACHMENT" << i << ". Test fails."
1430*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
1431*35238bceSAndroid Build Coastguard Worker is_ok = false;
1432*35238bceSAndroid Build Coastguard Worker }
1433*35238bceSAndroid Build Coastguard Worker
1434*35238bceSAndroid Build Coastguard Worker glw::GLfloat rgba[4] = {-1.f, -1.f, -1.f, -1.f};
1435*35238bceSAndroid Build Coastguard Worker
1436*35238bceSAndroid Build Coastguard Worker gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_FLOAT, rgba);
1437*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
1438*35238bceSAndroid Build Coastguard Worker
1439*35238bceSAndroid Build Coastguard Worker float expected_value = (float)i / (float)max_color_attachments;
1440*35238bceSAndroid Build Coastguard Worker
1441*35238bceSAndroid Build Coastguard Worker for (glw::GLuint j = 0; j < 4 /* number of components */; ++j)
1442*35238bceSAndroid Build Coastguard Worker {
1443*35238bceSAndroid Build Coastguard Worker if (de::abs(expected_value - rgba[j]) > 0.0001 /* Precision */)
1444*35238bceSAndroid Build Coastguard Worker {
1445*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
1446*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message
1447*35238bceSAndroid Build Coastguard Worker << "Named Framebuffer Draw And Read Buffer failed because resulting color value was ["
1448*35238bceSAndroid Build Coastguard Worker << rgba[0] << ", " << rgba[1] << ", " << rgba[2] << ", " << rgba[3] << "] but ["
1449*35238bceSAndroid Build Coastguard Worker << expected_value << ", " << expected_value << ", " << expected_value << ", " << expected_value
1450*35238bceSAndroid Build Coastguard Worker << "] had been expected." << tcu::TestLog::EndMessage;
1451*35238bceSAndroid Build Coastguard Worker
1452*35238bceSAndroid Build Coastguard Worker is_ok = false;
1453*35238bceSAndroid Build Coastguard Worker
1454*35238bceSAndroid Build Coastguard Worker break;
1455*35238bceSAndroid Build Coastguard Worker }
1456*35238bceSAndroid Build Coastguard Worker }
1457*35238bceSAndroid Build Coastguard Worker }
1458*35238bceSAndroid Build Coastguard Worker
1459*35238bceSAndroid Build Coastguard Worker /* Check that NamedFramebufferDrawBuffer accepts GL_NONE as mode. */
1460*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferDrawBuffer(framebuffer, GL_NONE);
1461*35238bceSAndroid Build Coastguard Worker
1462*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
1463*35238bceSAndroid Build Coastguard Worker {
1464*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
1465*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "NamedFramebufferDrawBuffer unexpectedly generated "
1466*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(error) << " error with GL_NONE mode. Test fails." << tcu::TestLog::EndMessage;
1467*35238bceSAndroid Build Coastguard Worker is_ok = false;
1468*35238bceSAndroid Build Coastguard Worker }
1469*35238bceSAndroid Build Coastguard Worker
1470*35238bceSAndroid Build Coastguard Worker /* Check that NamedFramebufferReadBuffer accepts GL_NONE as mode. */
1471*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferReadBuffer(framebuffer, GL_NONE);
1472*35238bceSAndroid Build Coastguard Worker
1473*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
1474*35238bceSAndroid Build Coastguard Worker {
1475*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
1476*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "NamedFramebufferReadBuffer unexpectedly generated "
1477*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(error) << " error with GL_NONE mode. Test fails." << tcu::TestLog::EndMessage;
1478*35238bceSAndroid Build Coastguard Worker is_ok = false;
1479*35238bceSAndroid Build Coastguard Worker }
1480*35238bceSAndroid Build Coastguard Worker }
1481*35238bceSAndroid Build Coastguard Worker catch (...)
1482*35238bceSAndroid Build Coastguard Worker {
1483*35238bceSAndroid Build Coastguard Worker is_ok = false;
1484*35238bceSAndroid Build Coastguard Worker is_error = true;
1485*35238bceSAndroid Build Coastguard Worker }
1486*35238bceSAndroid Build Coastguard Worker
1487*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
1488*35238bceSAndroid Build Coastguard Worker if (framebuffer)
1489*35238bceSAndroid Build Coastguard Worker {
1490*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &framebuffer);
1491*35238bceSAndroid Build Coastguard Worker
1492*35238bceSAndroid Build Coastguard Worker framebuffer = 0;
1493*35238bceSAndroid Build Coastguard Worker }
1494*35238bceSAndroid Build Coastguard Worker
1495*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < max_color_attachments; ++i)
1496*35238bceSAndroid Build Coastguard Worker {
1497*35238bceSAndroid Build Coastguard Worker if (renderbuffers[i])
1498*35238bceSAndroid Build Coastguard Worker {
1499*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &(renderbuffers[i]));
1500*35238bceSAndroid Build Coastguard Worker }
1501*35238bceSAndroid Build Coastguard Worker }
1502*35238bceSAndroid Build Coastguard Worker
1503*35238bceSAndroid Build Coastguard Worker gl.clearColor(0.f, 0.f, 0.f, 0.f);
1504*35238bceSAndroid Build Coastguard Worker
1505*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
1506*35238bceSAndroid Build Coastguard Worker while (gl.getError())
1507*35238bceSAndroid Build Coastguard Worker ;
1508*35238bceSAndroid Build Coastguard Worker
1509*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
1510*35238bceSAndroid Build Coastguard Worker if (is_ok)
1511*35238bceSAndroid Build Coastguard Worker {
1512*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1513*35238bceSAndroid Build Coastguard Worker }
1514*35238bceSAndroid Build Coastguard Worker else
1515*35238bceSAndroid Build Coastguard Worker {
1516*35238bceSAndroid Build Coastguard Worker if (is_error)
1517*35238bceSAndroid Build Coastguard Worker {
1518*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
1519*35238bceSAndroid Build Coastguard Worker }
1520*35238bceSAndroid Build Coastguard Worker else
1521*35238bceSAndroid Build Coastguard Worker {
1522*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
1523*35238bceSAndroid Build Coastguard Worker }
1524*35238bceSAndroid Build Coastguard Worker }
1525*35238bceSAndroid Build Coastguard Worker
1526*35238bceSAndroid Build Coastguard Worker return STOP;
1527*35238bceSAndroid Build Coastguard Worker }
1528*35238bceSAndroid Build Coastguard Worker
1529*35238bceSAndroid Build Coastguard Worker /******************************** Named Framebuffer Draw Buffers Test Implementation ********************************/
1530*35238bceSAndroid Build Coastguard Worker
1531*35238bceSAndroid Build Coastguard Worker /** @brief Named Framebuffer Draw Buffers Test constructor.
1532*35238bceSAndroid Build Coastguard Worker *
1533*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
1534*35238bceSAndroid Build Coastguard Worker */
DrawBuffersTest(deqp::Context & context)1535*35238bceSAndroid Build Coastguard Worker DrawBuffersTest::DrawBuffersTest(deqp::Context &context)
1536*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "framebuffers_draw_buffers", "Framebuffer Draw Buffers Test")
1537*35238bceSAndroid Build Coastguard Worker {
1538*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
1539*35238bceSAndroid Build Coastguard Worker }
1540*35238bceSAndroid Build Coastguard Worker
1541*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Named Framebuffer Read / Draw Buffer Test cases.
1542*35238bceSAndroid Build Coastguard Worker *
1543*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
1544*35238bceSAndroid Build Coastguard Worker */
iterate()1545*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult DrawBuffersTest::iterate()
1546*35238bceSAndroid Build Coastguard Worker {
1547*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
1548*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
1549*35238bceSAndroid Build Coastguard Worker
1550*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
1551*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
1552*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
1553*35238bceSAndroid Build Coastguard Worker
1554*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
1555*35238bceSAndroid Build Coastguard Worker {
1556*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
1557*35238bceSAndroid Build Coastguard Worker
1558*35238bceSAndroid Build Coastguard Worker return STOP;
1559*35238bceSAndroid Build Coastguard Worker }
1560*35238bceSAndroid Build Coastguard Worker
1561*35238bceSAndroid Build Coastguard Worker /* Running tests. */
1562*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
1563*35238bceSAndroid Build Coastguard Worker bool is_error = false;
1564*35238bceSAndroid Build Coastguard Worker
1565*35238bceSAndroid Build Coastguard Worker /* Framebuffers' objects */
1566*35238bceSAndroid Build Coastguard Worker glw::GLuint framebuffer = 0;
1567*35238bceSAndroid Build Coastguard Worker
1568*35238bceSAndroid Build Coastguard Worker /* Get number of color attachments. */
1569*35238bceSAndroid Build Coastguard Worker glw::GLint max_color_attachments = 8 /* Specification minimum OpenGL 4.5 Core Profile p. 627 */;
1570*35238bceSAndroid Build Coastguard Worker
1571*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
1572*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
1573*35238bceSAndroid Build Coastguard Worker
1574*35238bceSAndroid Build Coastguard Worker std::vector<glw::GLuint> renderbuffers(max_color_attachments);
1575*35238bceSAndroid Build Coastguard Worker std::vector<glw::GLuint> color_attachments(max_color_attachments);
1576*35238bceSAndroid Build Coastguard Worker
1577*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < max_color_attachments; ++i)
1578*35238bceSAndroid Build Coastguard Worker {
1579*35238bceSAndroid Build Coastguard Worker renderbuffers[i] = 0;
1580*35238bceSAndroid Build Coastguard Worker color_attachments[i] = GL_COLOR_ATTACHMENT0 + i;
1581*35238bceSAndroid Build Coastguard Worker }
1582*35238bceSAndroid Build Coastguard Worker
1583*35238bceSAndroid Build Coastguard Worker try
1584*35238bceSAndroid Build Coastguard Worker {
1585*35238bceSAndroid Build Coastguard Worker /* Prepare framebuffer... */
1586*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(1, &framebuffer);
1587*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
1588*35238bceSAndroid Build Coastguard Worker
1589*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, framebuffer);
1590*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
1591*35238bceSAndroid Build Coastguard Worker
1592*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(max_color_attachments, &(renderbuffers[0]));
1593*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
1594*35238bceSAndroid Build Coastguard Worker
1595*35238bceSAndroid Build Coastguard Worker /* .. with renderbuffer color attachments. */
1596*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < max_color_attachments; ++i)
1597*35238bceSAndroid Build Coastguard Worker {
1598*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, renderbuffers[i]);
1599*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer has failed");
1600*35238bceSAndroid Build Coastguard Worker
1601*35238bceSAndroid Build Coastguard Worker gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA32F, 1, 1);
1602*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
1603*35238bceSAndroid Build Coastguard Worker
1604*35238bceSAndroid Build Coastguard Worker gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_RENDERBUFFER, renderbuffers[i]);
1605*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
1606*35238bceSAndroid Build Coastguard Worker }
1607*35238bceSAndroid Build Coastguard Worker
1608*35238bceSAndroid Build Coastguard Worker /* Check that framebuffer is complete. */
1609*35238bceSAndroid Build Coastguard Worker if (GL_FRAMEBUFFER_COMPLETE != gl.checkFramebufferStatus(GL_FRAMEBUFFER))
1610*35238bceSAndroid Build Coastguard Worker {
1611*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
1612*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Framebuffer is unexpectedly incomplete." << tcu::TestLog::EndMessage;
1613*35238bceSAndroid Build Coastguard Worker
1614*35238bceSAndroid Build Coastguard Worker throw 0;
1615*35238bceSAndroid Build Coastguard Worker }
1616*35238bceSAndroid Build Coastguard Worker
1617*35238bceSAndroid Build Coastguard Worker /* Set up all attachments as draw buffer. */
1618*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferDrawBuffers(framebuffer, max_color_attachments, &(color_attachments[0]));
1619*35238bceSAndroid Build Coastguard Worker
1620*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
1621*35238bceSAndroid Build Coastguard Worker {
1622*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
1623*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "NamedFramebufferDrawBuffers unexpectedly generated "
1624*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(error) << " error. Test fails." << tcu::TestLog::EndMessage;
1625*35238bceSAndroid Build Coastguard Worker is_ok = false;
1626*35238bceSAndroid Build Coastguard Worker }
1627*35238bceSAndroid Build Coastguard Worker
1628*35238bceSAndroid Build Coastguard Worker /* Clear each of the framebuffer's attachments with unique color using NamedFramebufferDrawBuffer for attachment selection. */
1629*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < max_color_attachments; ++i)
1630*35238bceSAndroid Build Coastguard Worker {
1631*35238bceSAndroid Build Coastguard Worker gl.clearColor(s_rgba[0], s_rgba[1], s_rgba[2], s_rgba[3]);
1632*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor has failed");
1633*35238bceSAndroid Build Coastguard Worker
1634*35238bceSAndroid Build Coastguard Worker gl.clear(GL_COLOR_BUFFER_BIT);
1635*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glClear has failed");
1636*35238bceSAndroid Build Coastguard Worker }
1637*35238bceSAndroid Build Coastguard Worker
1638*35238bceSAndroid Build Coastguard Worker /* Fetch framebuffer's content and compare it with reference using NamedFramebufferReadBuffer for attachment selection. */
1639*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < max_color_attachments; ++i)
1640*35238bceSAndroid Build Coastguard Worker {
1641*35238bceSAndroid Build Coastguard Worker gl.readBuffer(GL_COLOR_ATTACHMENT0 + i);
1642*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadBuffer has failed");
1643*35238bceSAndroid Build Coastguard Worker
1644*35238bceSAndroid Build Coastguard Worker glw::GLfloat rgba[4] = {-1.f, -1.f, -1.f, -1.f};
1645*35238bceSAndroid Build Coastguard Worker
1646*35238bceSAndroid Build Coastguard Worker gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_FLOAT, rgba);
1647*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
1648*35238bceSAndroid Build Coastguard Worker
1649*35238bceSAndroid Build Coastguard Worker for (glw::GLuint j = 0; j < 4 /* number of components */; ++j)
1650*35238bceSAndroid Build Coastguard Worker {
1651*35238bceSAndroid Build Coastguard Worker if (de::abs(s_rgba[j] - rgba[j]) > 0.0001 /* Precision */)
1652*35238bceSAndroid Build Coastguard Worker {
1653*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
1654*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message
1655*35238bceSAndroid Build Coastguard Worker << "Named Framebuffer Draw Buffers test have failed because resulting color value was ["
1656*35238bceSAndroid Build Coastguard Worker << rgba[0] << ", " << rgba[1] << ", " << rgba[2] << ", " << rgba[3] << "] but [" << s_rgba[0]
1657*35238bceSAndroid Build Coastguard Worker << ", " << s_rgba[1] << ", " << s_rgba[2] << ", " << s_rgba[3] << "] had been expected."
1658*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
1659*35238bceSAndroid Build Coastguard Worker
1660*35238bceSAndroid Build Coastguard Worker is_ok = false;
1661*35238bceSAndroid Build Coastguard Worker
1662*35238bceSAndroid Build Coastguard Worker break;
1663*35238bceSAndroid Build Coastguard Worker }
1664*35238bceSAndroid Build Coastguard Worker }
1665*35238bceSAndroid Build Coastguard Worker }
1666*35238bceSAndroid Build Coastguard Worker
1667*35238bceSAndroid Build Coastguard Worker /* Check that NamedFramebufferDrawBuffers accepts GL_NONE as mode. */
1668*35238bceSAndroid Build Coastguard Worker glw::GLenum none_bufs = GL_NONE;
1669*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferDrawBuffers(framebuffer, 1, &none_bufs);
1670*35238bceSAndroid Build Coastguard Worker
1671*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
1672*35238bceSAndroid Build Coastguard Worker {
1673*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
1674*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "NamedFramebufferDrawBuffers unexpectedly generated "
1675*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(error) << " error with GL_NONE mode. Test fails." << tcu::TestLog::EndMessage;
1676*35238bceSAndroid Build Coastguard Worker is_ok = false;
1677*35238bceSAndroid Build Coastguard Worker }
1678*35238bceSAndroid Build Coastguard Worker }
1679*35238bceSAndroid Build Coastguard Worker catch (...)
1680*35238bceSAndroid Build Coastguard Worker {
1681*35238bceSAndroid Build Coastguard Worker is_ok = false;
1682*35238bceSAndroid Build Coastguard Worker is_error = true;
1683*35238bceSAndroid Build Coastguard Worker }
1684*35238bceSAndroid Build Coastguard Worker
1685*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
1686*35238bceSAndroid Build Coastguard Worker if (framebuffer)
1687*35238bceSAndroid Build Coastguard Worker {
1688*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &framebuffer);
1689*35238bceSAndroid Build Coastguard Worker
1690*35238bceSAndroid Build Coastguard Worker framebuffer = 0;
1691*35238bceSAndroid Build Coastguard Worker }
1692*35238bceSAndroid Build Coastguard Worker
1693*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < max_color_attachments; ++i)
1694*35238bceSAndroid Build Coastguard Worker {
1695*35238bceSAndroid Build Coastguard Worker if (renderbuffers[i])
1696*35238bceSAndroid Build Coastguard Worker {
1697*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &(renderbuffers[i]));
1698*35238bceSAndroid Build Coastguard Worker }
1699*35238bceSAndroid Build Coastguard Worker }
1700*35238bceSAndroid Build Coastguard Worker
1701*35238bceSAndroid Build Coastguard Worker gl.clearColor(0.f, 0.f, 0.f, 0.f);
1702*35238bceSAndroid Build Coastguard Worker
1703*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
1704*35238bceSAndroid Build Coastguard Worker while (gl.getError())
1705*35238bceSAndroid Build Coastguard Worker ;
1706*35238bceSAndroid Build Coastguard Worker
1707*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
1708*35238bceSAndroid Build Coastguard Worker if (is_ok)
1709*35238bceSAndroid Build Coastguard Worker {
1710*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1711*35238bceSAndroid Build Coastguard Worker }
1712*35238bceSAndroid Build Coastguard Worker else
1713*35238bceSAndroid Build Coastguard Worker {
1714*35238bceSAndroid Build Coastguard Worker if (is_error)
1715*35238bceSAndroid Build Coastguard Worker {
1716*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
1717*35238bceSAndroid Build Coastguard Worker }
1718*35238bceSAndroid Build Coastguard Worker else
1719*35238bceSAndroid Build Coastguard Worker {
1720*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
1721*35238bceSAndroid Build Coastguard Worker }
1722*35238bceSAndroid Build Coastguard Worker }
1723*35238bceSAndroid Build Coastguard Worker
1724*35238bceSAndroid Build Coastguard Worker return STOP;
1725*35238bceSAndroid Build Coastguard Worker }
1726*35238bceSAndroid Build Coastguard Worker
1727*35238bceSAndroid Build Coastguard Worker const glw::GLfloat DrawBuffersTest::s_rgba[4] = {0.f, 0.25f, 0.5f, 0.75f};
1728*35238bceSAndroid Build Coastguard Worker
1729*35238bceSAndroid Build Coastguard Worker /******************************** Named Framebuffer Invalidate Data Test Implementation ********************************/
1730*35238bceSAndroid Build Coastguard Worker
1731*35238bceSAndroid Build Coastguard Worker /** @brief Named Framebuffer Invalidate Data Test constructor.
1732*35238bceSAndroid Build Coastguard Worker *
1733*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
1734*35238bceSAndroid Build Coastguard Worker */
InvalidateDataTest(deqp::Context & context)1735*35238bceSAndroid Build Coastguard Worker InvalidateDataTest::InvalidateDataTest(deqp::Context &context)
1736*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "framebuffers_invalidate_data", "Framebuffer Invalidate Data Test")
1737*35238bceSAndroid Build Coastguard Worker {
1738*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
1739*35238bceSAndroid Build Coastguard Worker }
1740*35238bceSAndroid Build Coastguard Worker
1741*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Named Framebuffer Read / Draw Buffer Test cases.
1742*35238bceSAndroid Build Coastguard Worker *
1743*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
1744*35238bceSAndroid Build Coastguard Worker */
iterate()1745*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult InvalidateDataTest::iterate()
1746*35238bceSAndroid Build Coastguard Worker {
1747*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
1748*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
1749*35238bceSAndroid Build Coastguard Worker
1750*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
1751*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
1752*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
1753*35238bceSAndroid Build Coastguard Worker
1754*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
1755*35238bceSAndroid Build Coastguard Worker {
1756*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
1757*35238bceSAndroid Build Coastguard Worker
1758*35238bceSAndroid Build Coastguard Worker return STOP;
1759*35238bceSAndroid Build Coastguard Worker }
1760*35238bceSAndroid Build Coastguard Worker
1761*35238bceSAndroid Build Coastguard Worker /* Running tests. */
1762*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
1763*35238bceSAndroid Build Coastguard Worker bool is_error = false;
1764*35238bceSAndroid Build Coastguard Worker
1765*35238bceSAndroid Build Coastguard Worker /* Framebuffers' objects */
1766*35238bceSAndroid Build Coastguard Worker glw::GLuint framebuffer = 0;
1767*35238bceSAndroid Build Coastguard Worker
1768*35238bceSAndroid Build Coastguard Worker /* Get number of color attachments. */
1769*35238bceSAndroid Build Coastguard Worker glw::GLint max_color_attachments = 8 /* Specification minimum OpenGL 4.5 Core Profile p. 627 */;
1770*35238bceSAndroid Build Coastguard Worker
1771*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
1772*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
1773*35238bceSAndroid Build Coastguard Worker
1774*35238bceSAndroid Build Coastguard Worker std::vector<glw::GLuint> renderbuffers(max_color_attachments);
1775*35238bceSAndroid Build Coastguard Worker std::vector<glw::GLuint> color_attachments(max_color_attachments);
1776*35238bceSAndroid Build Coastguard Worker static const glw::GLenum default_attachments[] = {GL_COLOR, GL_DEPTH, GL_STENCIL};
1777*35238bceSAndroid Build Coastguard Worker static const glw::GLuint default_attachments_count = sizeof(default_attachments) / sizeof(default_attachments[0]);
1778*35238bceSAndroid Build Coastguard Worker
1779*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < max_color_attachments; ++i)
1780*35238bceSAndroid Build Coastguard Worker {
1781*35238bceSAndroid Build Coastguard Worker renderbuffers[i] = 0;
1782*35238bceSAndroid Build Coastguard Worker color_attachments[i] = GL_COLOR_ATTACHMENT0 + i;
1783*35238bceSAndroid Build Coastguard Worker }
1784*35238bceSAndroid Build Coastguard Worker
1785*35238bceSAndroid Build Coastguard Worker try
1786*35238bceSAndroid Build Coastguard Worker {
1787*35238bceSAndroid Build Coastguard Worker /* Invalidate Default Framebuffer data */
1788*35238bceSAndroid Build Coastguard Worker gl.invalidateNamedFramebufferData(0, default_attachments_count, &(default_attachments[0]));
1789*35238bceSAndroid Build Coastguard Worker is_ok &= CheckErrorAndLog(default_attachments, default_attachments_count);
1790*35238bceSAndroid Build Coastguard Worker
1791*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < default_attachments_count; ++i)
1792*35238bceSAndroid Build Coastguard Worker {
1793*35238bceSAndroid Build Coastguard Worker gl.invalidateNamedFramebufferData(0, 1, &(default_attachments[i]));
1794*35238bceSAndroid Build Coastguard Worker is_ok &= CheckErrorAndLog(default_attachments[i]);
1795*35238bceSAndroid Build Coastguard Worker }
1796*35238bceSAndroid Build Coastguard Worker
1797*35238bceSAndroid Build Coastguard Worker /* Prepare framebuffer... */
1798*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(1, &framebuffer);
1799*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
1800*35238bceSAndroid Build Coastguard Worker
1801*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, framebuffer);
1802*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
1803*35238bceSAndroid Build Coastguard Worker
1804*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(max_color_attachments, &(renderbuffers[0]));
1805*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
1806*35238bceSAndroid Build Coastguard Worker
1807*35238bceSAndroid Build Coastguard Worker /* .. with renderbuffer color attachments. */
1808*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < max_color_attachments; ++i)
1809*35238bceSAndroid Build Coastguard Worker {
1810*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, renderbuffers[i]);
1811*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer has failed");
1812*35238bceSAndroid Build Coastguard Worker
1813*35238bceSAndroid Build Coastguard Worker gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA32F, 1, 1);
1814*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
1815*35238bceSAndroid Build Coastguard Worker
1816*35238bceSAndroid Build Coastguard Worker gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_RENDERBUFFER, renderbuffers[i]);
1817*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
1818*35238bceSAndroid Build Coastguard Worker }
1819*35238bceSAndroid Build Coastguard Worker
1820*35238bceSAndroid Build Coastguard Worker /* Check that framebuffer is complete. */
1821*35238bceSAndroid Build Coastguard Worker if (GL_FRAMEBUFFER_COMPLETE != gl.checkFramebufferStatus(GL_FRAMEBUFFER))
1822*35238bceSAndroid Build Coastguard Worker {
1823*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
1824*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Framebuffer is unexpectedly incomplete." << tcu::TestLog::EndMessage;
1825*35238bceSAndroid Build Coastguard Worker
1826*35238bceSAndroid Build Coastguard Worker throw 0;
1827*35238bceSAndroid Build Coastguard Worker }
1828*35238bceSAndroid Build Coastguard Worker
1829*35238bceSAndroid Build Coastguard Worker gl.invalidateNamedFramebufferData(framebuffer, max_color_attachments, &(color_attachments[0]));
1830*35238bceSAndroid Build Coastguard Worker is_ok &= CheckErrorAndLog(&(color_attachments[0]), max_color_attachments);
1831*35238bceSAndroid Build Coastguard Worker
1832*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < max_color_attachments; ++i)
1833*35238bceSAndroid Build Coastguard Worker {
1834*35238bceSAndroid Build Coastguard Worker gl.invalidateNamedFramebufferData(framebuffer, 1, &(color_attachments[i]));
1835*35238bceSAndroid Build Coastguard Worker is_ok &= CheckErrorAndLog(color_attachments[i]);
1836*35238bceSAndroid Build Coastguard Worker }
1837*35238bceSAndroid Build Coastguard Worker }
1838*35238bceSAndroid Build Coastguard Worker catch (...)
1839*35238bceSAndroid Build Coastguard Worker {
1840*35238bceSAndroid Build Coastguard Worker is_ok = false;
1841*35238bceSAndroid Build Coastguard Worker is_error = true;
1842*35238bceSAndroid Build Coastguard Worker }
1843*35238bceSAndroid Build Coastguard Worker
1844*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
1845*35238bceSAndroid Build Coastguard Worker if (framebuffer)
1846*35238bceSAndroid Build Coastguard Worker {
1847*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &framebuffer);
1848*35238bceSAndroid Build Coastguard Worker
1849*35238bceSAndroid Build Coastguard Worker framebuffer = 0;
1850*35238bceSAndroid Build Coastguard Worker }
1851*35238bceSAndroid Build Coastguard Worker
1852*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < max_color_attachments; ++i)
1853*35238bceSAndroid Build Coastguard Worker {
1854*35238bceSAndroid Build Coastguard Worker if (renderbuffers[i])
1855*35238bceSAndroid Build Coastguard Worker {
1856*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &(renderbuffers[i]));
1857*35238bceSAndroid Build Coastguard Worker }
1858*35238bceSAndroid Build Coastguard Worker }
1859*35238bceSAndroid Build Coastguard Worker
1860*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
1861*35238bceSAndroid Build Coastguard Worker while (gl.getError())
1862*35238bceSAndroid Build Coastguard Worker ;
1863*35238bceSAndroid Build Coastguard Worker
1864*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
1865*35238bceSAndroid Build Coastguard Worker if (is_ok)
1866*35238bceSAndroid Build Coastguard Worker {
1867*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1868*35238bceSAndroid Build Coastguard Worker }
1869*35238bceSAndroid Build Coastguard Worker else
1870*35238bceSAndroid Build Coastguard Worker {
1871*35238bceSAndroid Build Coastguard Worker if (is_error)
1872*35238bceSAndroid Build Coastguard Worker {
1873*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
1874*35238bceSAndroid Build Coastguard Worker }
1875*35238bceSAndroid Build Coastguard Worker else
1876*35238bceSAndroid Build Coastguard Worker {
1877*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
1878*35238bceSAndroid Build Coastguard Worker }
1879*35238bceSAndroid Build Coastguard Worker }
1880*35238bceSAndroid Build Coastguard Worker
1881*35238bceSAndroid Build Coastguard Worker return STOP;
1882*35238bceSAndroid Build Coastguard Worker }
1883*35238bceSAndroid Build Coastguard Worker
1884*35238bceSAndroid Build Coastguard Worker /** @brief Check error and log.
1885*35238bceSAndroid Build Coastguard Worker *
1886*35238bceSAndroid Build Coastguard Worker * @param [in] attachment Framebuffer attachment.
1887*35238bceSAndroid Build Coastguard Worker *
1888*35238bceSAndroid Build Coastguard Worker * @return True if no error, false otherwise.
1889*35238bceSAndroid Build Coastguard Worker */
CheckErrorAndLog(const glw::GLenum attachment)1890*35238bceSAndroid Build Coastguard Worker bool InvalidateDataTest::CheckErrorAndLog(const glw::GLenum attachment)
1891*35238bceSAndroid Build Coastguard Worker {
1892*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
1893*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
1894*35238bceSAndroid Build Coastguard Worker
1895*35238bceSAndroid Build Coastguard Worker /* Check error. */
1896*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
1897*35238bceSAndroid Build Coastguard Worker {
1898*35238bceSAndroid Build Coastguard Worker /* There is an error. Log. */
1899*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
1900*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "InvalidateDataTest unexpectedly generated " << glu::getErrorStr(error)
1901*35238bceSAndroid Build Coastguard Worker << " error for attachment " << glu::getFramebufferAttachmentStr(attachment) << ". Test fails."
1902*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
1903*35238bceSAndroid Build Coastguard Worker
1904*35238bceSAndroid Build Coastguard Worker return false;
1905*35238bceSAndroid Build Coastguard Worker }
1906*35238bceSAndroid Build Coastguard Worker
1907*35238bceSAndroid Build Coastguard Worker return true;
1908*35238bceSAndroid Build Coastguard Worker }
1909*35238bceSAndroid Build Coastguard Worker
1910*35238bceSAndroid Build Coastguard Worker /** @brief Check error and log.
1911*35238bceSAndroid Build Coastguard Worker *
1912*35238bceSAndroid Build Coastguard Worker * @param [in] attachments Framebuffer attachments.
1913*35238bceSAndroid Build Coastguard Worker * @param [in] attachments_count Framebuffer attachments count.
1914*35238bceSAndroid Build Coastguard Worker *
1915*35238bceSAndroid Build Coastguard Worker * @return True if no error, false otherwise.
1916*35238bceSAndroid Build Coastguard Worker */
CheckErrorAndLog(const glw::GLenum attachments[],glw::GLuint count)1917*35238bceSAndroid Build Coastguard Worker bool InvalidateDataTest::CheckErrorAndLog(const glw::GLenum attachments[], glw::GLuint count)
1918*35238bceSAndroid Build Coastguard Worker {
1919*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
1920*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
1921*35238bceSAndroid Build Coastguard Worker
1922*35238bceSAndroid Build Coastguard Worker /* Check error. */
1923*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
1924*35238bceSAndroid Build Coastguard Worker {
1925*35238bceSAndroid Build Coastguard Worker /* There is an error. Log. */
1926*35238bceSAndroid Build Coastguard Worker std::string attachments_names = "";
1927*35238bceSAndroid Build Coastguard Worker
1928*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < count; ++i)
1929*35238bceSAndroid Build Coastguard Worker {
1930*35238bceSAndroid Build Coastguard Worker attachments_names.append(glu::getFramebufferAttachmentStr(attachments[i]).toString());
1931*35238bceSAndroid Build Coastguard Worker
1932*35238bceSAndroid Build Coastguard Worker if ((count - 1) != i)
1933*35238bceSAndroid Build Coastguard Worker {
1934*35238bceSAndroid Build Coastguard Worker attachments_names.append(", ");
1935*35238bceSAndroid Build Coastguard Worker }
1936*35238bceSAndroid Build Coastguard Worker }
1937*35238bceSAndroid Build Coastguard Worker
1938*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog() << tcu::TestLog::Message << "InvalidateDataTest unexpectedly generated "
1939*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(error) << " error for following attachments ["
1940*35238bceSAndroid Build Coastguard Worker << attachments_names << "]. Test fails." << tcu::TestLog::EndMessage;
1941*35238bceSAndroid Build Coastguard Worker
1942*35238bceSAndroid Build Coastguard Worker return false;
1943*35238bceSAndroid Build Coastguard Worker }
1944*35238bceSAndroid Build Coastguard Worker
1945*35238bceSAndroid Build Coastguard Worker return true;
1946*35238bceSAndroid Build Coastguard Worker }
1947*35238bceSAndroid Build Coastguard Worker
1948*35238bceSAndroid Build Coastguard Worker /******************************** Named Framebuffer Invalidate Sub Data Test Implementation ********************************/
1949*35238bceSAndroid Build Coastguard Worker
1950*35238bceSAndroid Build Coastguard Worker /** @brief Named Framebuffer Invalidate Sub Data Test constructor.
1951*35238bceSAndroid Build Coastguard Worker *
1952*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
1953*35238bceSAndroid Build Coastguard Worker */
InvalidateSubDataTest(deqp::Context & context)1954*35238bceSAndroid Build Coastguard Worker InvalidateSubDataTest::InvalidateSubDataTest(deqp::Context &context)
1955*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "framebuffers_invalidate_subdata", "Framebuffer Invalidate Sub Data Test")
1956*35238bceSAndroid Build Coastguard Worker {
1957*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
1958*35238bceSAndroid Build Coastguard Worker }
1959*35238bceSAndroid Build Coastguard Worker
1960*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Named Framebuffer Read / Draw Buffer Test cases.
1961*35238bceSAndroid Build Coastguard Worker *
1962*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
1963*35238bceSAndroid Build Coastguard Worker */
iterate()1964*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult InvalidateSubDataTest::iterate()
1965*35238bceSAndroid Build Coastguard Worker {
1966*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
1967*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
1968*35238bceSAndroid Build Coastguard Worker
1969*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
1970*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
1971*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
1972*35238bceSAndroid Build Coastguard Worker
1973*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
1974*35238bceSAndroid Build Coastguard Worker {
1975*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
1976*35238bceSAndroid Build Coastguard Worker
1977*35238bceSAndroid Build Coastguard Worker return STOP;
1978*35238bceSAndroid Build Coastguard Worker }
1979*35238bceSAndroid Build Coastguard Worker
1980*35238bceSAndroid Build Coastguard Worker /* Running tests. */
1981*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
1982*35238bceSAndroid Build Coastguard Worker bool is_error = false;
1983*35238bceSAndroid Build Coastguard Worker
1984*35238bceSAndroid Build Coastguard Worker /* Framebuffers' objects */
1985*35238bceSAndroid Build Coastguard Worker glw::GLuint framebuffer = 0;
1986*35238bceSAndroid Build Coastguard Worker
1987*35238bceSAndroid Build Coastguard Worker /* Get number of color attachments. */
1988*35238bceSAndroid Build Coastguard Worker glw::GLint max_color_attachments = 8 /* Specification minimum OpenGL 4.5 Core Profile p. 627 */;
1989*35238bceSAndroid Build Coastguard Worker
1990*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
1991*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
1992*35238bceSAndroid Build Coastguard Worker
1993*35238bceSAndroid Build Coastguard Worker std::vector<glw::GLuint> renderbuffers(max_color_attachments);
1994*35238bceSAndroid Build Coastguard Worker std::vector<glw::GLuint> color_attachments(max_color_attachments);
1995*35238bceSAndroid Build Coastguard Worker static const glw::GLenum default_attachments[] = {GL_COLOR, GL_DEPTH, GL_STENCIL};
1996*35238bceSAndroid Build Coastguard Worker static const glw::GLuint default_attachments_count = sizeof(default_attachments) / sizeof(default_attachments[0]);
1997*35238bceSAndroid Build Coastguard Worker
1998*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < max_color_attachments; ++i)
1999*35238bceSAndroid Build Coastguard Worker {
2000*35238bceSAndroid Build Coastguard Worker renderbuffers[i] = 0;
2001*35238bceSAndroid Build Coastguard Worker color_attachments[i] = GL_COLOR_ATTACHMENT0 + i;
2002*35238bceSAndroid Build Coastguard Worker }
2003*35238bceSAndroid Build Coastguard Worker
2004*35238bceSAndroid Build Coastguard Worker try
2005*35238bceSAndroid Build Coastguard Worker {
2006*35238bceSAndroid Build Coastguard Worker /* Invalidate Default Framebuffer data */
2007*35238bceSAndroid Build Coastguard Worker gl.invalidateNamedFramebufferSubData(0, default_attachments_count, &(default_attachments[0]), 0, 0, 1, 1);
2008*35238bceSAndroid Build Coastguard Worker is_ok &= CheckErrorAndLog(default_attachments, default_attachments_count);
2009*35238bceSAndroid Build Coastguard Worker
2010*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < default_attachments_count; ++i)
2011*35238bceSAndroid Build Coastguard Worker {
2012*35238bceSAndroid Build Coastguard Worker gl.invalidateNamedFramebufferSubData(0, 1, &(default_attachments[i]), 0, 0, 1, 1);
2013*35238bceSAndroid Build Coastguard Worker is_ok &= CheckErrorAndLog(default_attachments[i]);
2014*35238bceSAndroid Build Coastguard Worker }
2015*35238bceSAndroid Build Coastguard Worker
2016*35238bceSAndroid Build Coastguard Worker /* Prepare framebuffer... */
2017*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(1, &framebuffer);
2018*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
2019*35238bceSAndroid Build Coastguard Worker
2020*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, framebuffer);
2021*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
2022*35238bceSAndroid Build Coastguard Worker
2023*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(max_color_attachments, &(renderbuffers[0]));
2024*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
2025*35238bceSAndroid Build Coastguard Worker
2026*35238bceSAndroid Build Coastguard Worker /* .. with renderbuffer color attachments. */
2027*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < max_color_attachments; ++i)
2028*35238bceSAndroid Build Coastguard Worker {
2029*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, renderbuffers[i]);
2030*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer has failed");
2031*35238bceSAndroid Build Coastguard Worker
2032*35238bceSAndroid Build Coastguard Worker gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA32F, 4, 4);
2033*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
2034*35238bceSAndroid Build Coastguard Worker
2035*35238bceSAndroid Build Coastguard Worker gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_RENDERBUFFER, renderbuffers[i]);
2036*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
2037*35238bceSAndroid Build Coastguard Worker }
2038*35238bceSAndroid Build Coastguard Worker
2039*35238bceSAndroid Build Coastguard Worker /* Check that framebuffer is complete. */
2040*35238bceSAndroid Build Coastguard Worker if (GL_FRAMEBUFFER_COMPLETE != gl.checkFramebufferStatus(GL_FRAMEBUFFER))
2041*35238bceSAndroid Build Coastguard Worker {
2042*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
2043*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Framebuffer is unexpectedly incomplete." << tcu::TestLog::EndMessage;
2044*35238bceSAndroid Build Coastguard Worker
2045*35238bceSAndroid Build Coastguard Worker throw 0;
2046*35238bceSAndroid Build Coastguard Worker }
2047*35238bceSAndroid Build Coastguard Worker
2048*35238bceSAndroid Build Coastguard Worker gl.invalidateNamedFramebufferSubData(framebuffer, max_color_attachments, &(color_attachments[0]), 1, 1, 2, 2);
2049*35238bceSAndroid Build Coastguard Worker is_ok &= CheckErrorAndLog(&(color_attachments[0]), max_color_attachments);
2050*35238bceSAndroid Build Coastguard Worker
2051*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < max_color_attachments; ++i)
2052*35238bceSAndroid Build Coastguard Worker {
2053*35238bceSAndroid Build Coastguard Worker gl.invalidateNamedFramebufferSubData(framebuffer, 1, &(color_attachments[i]), 1, 1, 2, 2);
2054*35238bceSAndroid Build Coastguard Worker is_ok &= CheckErrorAndLog(color_attachments[i]);
2055*35238bceSAndroid Build Coastguard Worker }
2056*35238bceSAndroid Build Coastguard Worker }
2057*35238bceSAndroid Build Coastguard Worker catch (...)
2058*35238bceSAndroid Build Coastguard Worker {
2059*35238bceSAndroid Build Coastguard Worker is_ok = false;
2060*35238bceSAndroid Build Coastguard Worker is_error = true;
2061*35238bceSAndroid Build Coastguard Worker }
2062*35238bceSAndroid Build Coastguard Worker
2063*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
2064*35238bceSAndroid Build Coastguard Worker if (framebuffer)
2065*35238bceSAndroid Build Coastguard Worker {
2066*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &framebuffer);
2067*35238bceSAndroid Build Coastguard Worker
2068*35238bceSAndroid Build Coastguard Worker framebuffer = 0;
2069*35238bceSAndroid Build Coastguard Worker }
2070*35238bceSAndroid Build Coastguard Worker
2071*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < max_color_attachments; ++i)
2072*35238bceSAndroid Build Coastguard Worker {
2073*35238bceSAndroid Build Coastguard Worker if (renderbuffers[i])
2074*35238bceSAndroid Build Coastguard Worker {
2075*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &(renderbuffers[i]));
2076*35238bceSAndroid Build Coastguard Worker }
2077*35238bceSAndroid Build Coastguard Worker }
2078*35238bceSAndroid Build Coastguard Worker
2079*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
2080*35238bceSAndroid Build Coastguard Worker while (gl.getError())
2081*35238bceSAndroid Build Coastguard Worker ;
2082*35238bceSAndroid Build Coastguard Worker
2083*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
2084*35238bceSAndroid Build Coastguard Worker if (is_ok)
2085*35238bceSAndroid Build Coastguard Worker {
2086*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
2087*35238bceSAndroid Build Coastguard Worker }
2088*35238bceSAndroid Build Coastguard Worker else
2089*35238bceSAndroid Build Coastguard Worker {
2090*35238bceSAndroid Build Coastguard Worker if (is_error)
2091*35238bceSAndroid Build Coastguard Worker {
2092*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
2093*35238bceSAndroid Build Coastguard Worker }
2094*35238bceSAndroid Build Coastguard Worker else
2095*35238bceSAndroid Build Coastguard Worker {
2096*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
2097*35238bceSAndroid Build Coastguard Worker }
2098*35238bceSAndroid Build Coastguard Worker }
2099*35238bceSAndroid Build Coastguard Worker
2100*35238bceSAndroid Build Coastguard Worker return STOP;
2101*35238bceSAndroid Build Coastguard Worker }
2102*35238bceSAndroid Build Coastguard Worker
2103*35238bceSAndroid Build Coastguard Worker /** @brief Check error and log.
2104*35238bceSAndroid Build Coastguard Worker *
2105*35238bceSAndroid Build Coastguard Worker * @param [in] attachment Framebuffer attachment.
2106*35238bceSAndroid Build Coastguard Worker *
2107*35238bceSAndroid Build Coastguard Worker * @return True if no error, false otherwise.
2108*35238bceSAndroid Build Coastguard Worker */
CheckErrorAndLog(const glw::GLenum attachment)2109*35238bceSAndroid Build Coastguard Worker bool InvalidateSubDataTest::CheckErrorAndLog(const glw::GLenum attachment)
2110*35238bceSAndroid Build Coastguard Worker {
2111*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
2112*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
2113*35238bceSAndroid Build Coastguard Worker
2114*35238bceSAndroid Build Coastguard Worker /* Check error. */
2115*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
2116*35238bceSAndroid Build Coastguard Worker {
2117*35238bceSAndroid Build Coastguard Worker /* There is an error. Log. */
2118*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
2119*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "InvalidateSubDataTest unexpectedly generated " << glu::getErrorStr(error)
2120*35238bceSAndroid Build Coastguard Worker << " error for attachment " << glu::getFramebufferAttachmentStr(attachment) << ". Test fails."
2121*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
2122*35238bceSAndroid Build Coastguard Worker
2123*35238bceSAndroid Build Coastguard Worker return false;
2124*35238bceSAndroid Build Coastguard Worker }
2125*35238bceSAndroid Build Coastguard Worker
2126*35238bceSAndroid Build Coastguard Worker return true;
2127*35238bceSAndroid Build Coastguard Worker }
2128*35238bceSAndroid Build Coastguard Worker
2129*35238bceSAndroid Build Coastguard Worker /** @brief Check error and log.
2130*35238bceSAndroid Build Coastguard Worker *
2131*35238bceSAndroid Build Coastguard Worker * @param [in] attachments Framebuffer attachments.
2132*35238bceSAndroid Build Coastguard Worker * @param [in] attachments_count Framebuffer attachments count.
2133*35238bceSAndroid Build Coastguard Worker *
2134*35238bceSAndroid Build Coastguard Worker * @return True if no error, false otherwise.
2135*35238bceSAndroid Build Coastguard Worker */
CheckErrorAndLog(const glw::GLenum attachments[],glw::GLuint count)2136*35238bceSAndroid Build Coastguard Worker bool InvalidateSubDataTest::CheckErrorAndLog(const glw::GLenum attachments[], glw::GLuint count)
2137*35238bceSAndroid Build Coastguard Worker {
2138*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
2139*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
2140*35238bceSAndroid Build Coastguard Worker
2141*35238bceSAndroid Build Coastguard Worker /* Check error. */
2142*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
2143*35238bceSAndroid Build Coastguard Worker {
2144*35238bceSAndroid Build Coastguard Worker /* There is an error. Log. */
2145*35238bceSAndroid Build Coastguard Worker std::string attachments_names = "";
2146*35238bceSAndroid Build Coastguard Worker
2147*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < count; ++i)
2148*35238bceSAndroid Build Coastguard Worker {
2149*35238bceSAndroid Build Coastguard Worker attachments_names.append(glu::getFramebufferAttachmentStr(attachments[i]).toString());
2150*35238bceSAndroid Build Coastguard Worker
2151*35238bceSAndroid Build Coastguard Worker if ((count - 1) != i)
2152*35238bceSAndroid Build Coastguard Worker {
2153*35238bceSAndroid Build Coastguard Worker attachments_names.append(", ");
2154*35238bceSAndroid Build Coastguard Worker }
2155*35238bceSAndroid Build Coastguard Worker }
2156*35238bceSAndroid Build Coastguard Worker
2157*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog() << tcu::TestLog::Message << "InvalidateSubDataTest unexpectedly generated "
2158*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(error) << " error for following attachments ["
2159*35238bceSAndroid Build Coastguard Worker << attachments_names << "]. Test fails." << tcu::TestLog::EndMessage;
2160*35238bceSAndroid Build Coastguard Worker
2161*35238bceSAndroid Build Coastguard Worker return false;
2162*35238bceSAndroid Build Coastguard Worker }
2163*35238bceSAndroid Build Coastguard Worker
2164*35238bceSAndroid Build Coastguard Worker return true;
2165*35238bceSAndroid Build Coastguard Worker }
2166*35238bceSAndroid Build Coastguard Worker
2167*35238bceSAndroid Build Coastguard Worker /******************************** Clear Named Framebuffer Test Implementation ********************************/
2168*35238bceSAndroid Build Coastguard Worker
2169*35238bceSAndroid Build Coastguard Worker /** @brief Clear Named Framebuffer Test constructor.
2170*35238bceSAndroid Build Coastguard Worker *
2171*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
2172*35238bceSAndroid Build Coastguard Worker */
ClearTest(deqp::Context & context)2173*35238bceSAndroid Build Coastguard Worker ClearTest::ClearTest(deqp::Context &context)
2174*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "framebuffers_clear", "Clear Named Framebuffer Test")
2175*35238bceSAndroid Build Coastguard Worker , m_fbo(0)
2176*35238bceSAndroid Build Coastguard Worker , m_renderbuffers(0)
2177*35238bceSAndroid Build Coastguard Worker , m_renderbuffers_count(0)
2178*35238bceSAndroid Build Coastguard Worker {
2179*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
2180*35238bceSAndroid Build Coastguard Worker }
2181*35238bceSAndroid Build Coastguard Worker
2182*35238bceSAndroid Build Coastguard Worker /** @brief Compare two floats (template specialization).
2183*35238bceSAndroid Build Coastguard Worker *
2184*35238bceSAndroid Build Coastguard Worker * @param [in] first First float to be compared.
2185*35238bceSAndroid Build Coastguard Worker * @param [in] second Second float to be compared.
2186*35238bceSAndroid Build Coastguard Worker *
2187*35238bceSAndroid Build Coastguard Worker * @return True if floats are equal within +-(1.f/64.f) precision range, false otherwise.
2188*35238bceSAndroid Build Coastguard Worker */
2189*35238bceSAndroid Build Coastguard Worker template <>
Compare(const glw::GLfloat first,const glw::GLfloat second)2190*35238bceSAndroid Build Coastguard Worker bool ClearTest::Compare<glw::GLfloat>(const glw::GLfloat first, const glw::GLfloat second)
2191*35238bceSAndroid Build Coastguard Worker {
2192*35238bceSAndroid Build Coastguard Worker return (de::abs(first - second) < (1.f / 64.f) /* Precission. */);
2193*35238bceSAndroid Build Coastguard Worker }
2194*35238bceSAndroid Build Coastguard Worker
2195*35238bceSAndroid Build Coastguard Worker /** @brief Compare two objects (template general specialization).
2196*35238bceSAndroid Build Coastguard Worker *
2197*35238bceSAndroid Build Coastguard Worker * @param [in] first First objetc to be compared.
2198*35238bceSAndroid Build Coastguard Worker * @param [in] second Second object to be compared.
2199*35238bceSAndroid Build Coastguard Worker *
2200*35238bceSAndroid Build Coastguard Worker * @return True if floats are equal, false otherwise.
2201*35238bceSAndroid Build Coastguard Worker */
2202*35238bceSAndroid Build Coastguard Worker template <typename T>
Compare(const T first,const T second)2203*35238bceSAndroid Build Coastguard Worker bool ClearTest::Compare(const T first, const T second)
2204*35238bceSAndroid Build Coastguard Worker {
2205*35238bceSAndroid Build Coastguard Worker return (first == second);
2206*35238bceSAndroid Build Coastguard Worker }
2207*35238bceSAndroid Build Coastguard Worker
2208*35238bceSAndroid Build Coastguard Worker /** @brief Clear color buffer (float specialization), check errors and log.
2209*35238bceSAndroid Build Coastguard Worker *
2210*35238bceSAndroid Build Coastguard Worker * @param [in] buffer Buffer to be cleared.
2211*35238bceSAndroid Build Coastguard Worker * @param [in] drawbuffer Drawbuffer to be cleared.
2212*35238bceSAndroid Build Coastguard Worker * @param [in] value Value to be cleared with.
2213*35238bceSAndroid Build Coastguard Worker *
2214*35238bceSAndroid Build Coastguard Worker * @return True if succeeded without errors, false otherwise.
2215*35238bceSAndroid Build Coastguard Worker */
2216*35238bceSAndroid Build Coastguard Worker template <>
ClearColor(glw::GLenum buffer,glw::GLint drawbuffer,glw::GLfloat value)2217*35238bceSAndroid Build Coastguard Worker bool ClearTest::ClearColor<glw::GLfloat>(glw::GLenum buffer, glw::GLint drawbuffer, glw::GLfloat value)
2218*35238bceSAndroid Build Coastguard Worker {
2219*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
2220*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
2221*35238bceSAndroid Build Coastguard Worker
2222*35238bceSAndroid Build Coastguard Worker glw::GLfloat value_vector[4] = {value, 0, 0, 0};
2223*35238bceSAndroid Build Coastguard Worker
2224*35238bceSAndroid Build Coastguard Worker gl.clearNamedFramebufferfv(m_fbo, buffer, drawbuffer, value_vector);
2225*35238bceSAndroid Build Coastguard Worker
2226*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
2227*35238bceSAndroid Build Coastguard Worker {
2228*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
2229*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "ClearNamedFramebufferfv unexpectedly generated " << glu::getErrorStr(error)
2230*35238bceSAndroid Build Coastguard Worker << " error. Test fails." << tcu::TestLog::EndMessage;
2231*35238bceSAndroid Build Coastguard Worker
2232*35238bceSAndroid Build Coastguard Worker return false;
2233*35238bceSAndroid Build Coastguard Worker }
2234*35238bceSAndroid Build Coastguard Worker
2235*35238bceSAndroid Build Coastguard Worker return true;
2236*35238bceSAndroid Build Coastguard Worker }
2237*35238bceSAndroid Build Coastguard Worker
2238*35238bceSAndroid Build Coastguard Worker /** @brief Clear color buffer (int specialization), check errors and log.
2239*35238bceSAndroid Build Coastguard Worker *
2240*35238bceSAndroid Build Coastguard Worker * @param [in] buffer Buffer to be cleared.
2241*35238bceSAndroid Build Coastguard Worker * @param [in] drawbuffer Drawbuffer to be cleared.
2242*35238bceSAndroid Build Coastguard Worker * @param [in] value Value to be cleared with.
2243*35238bceSAndroid Build Coastguard Worker *
2244*35238bceSAndroid Build Coastguard Worker * @return True if succeeded without errors, false otherwise.
2245*35238bceSAndroid Build Coastguard Worker */
2246*35238bceSAndroid Build Coastguard Worker template <>
ClearColor(glw::GLenum buffer,glw::GLint drawbuffer,glw::GLint value)2247*35238bceSAndroid Build Coastguard Worker bool ClearTest::ClearColor<glw::GLint>(glw::GLenum buffer, glw::GLint drawbuffer, glw::GLint value)
2248*35238bceSAndroid Build Coastguard Worker {
2249*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
2250*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
2251*35238bceSAndroid Build Coastguard Worker
2252*35238bceSAndroid Build Coastguard Worker glw::GLint value_vector[4] = {value, 0, 0, 0};
2253*35238bceSAndroid Build Coastguard Worker
2254*35238bceSAndroid Build Coastguard Worker gl.clearNamedFramebufferiv(m_fbo, buffer, drawbuffer, value_vector);
2255*35238bceSAndroid Build Coastguard Worker
2256*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
2257*35238bceSAndroid Build Coastguard Worker {
2258*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
2259*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "ClearNamedFramebufferiv unexpectedly generated " << glu::getErrorStr(error)
2260*35238bceSAndroid Build Coastguard Worker << " error. Test fails." << tcu::TestLog::EndMessage;
2261*35238bceSAndroid Build Coastguard Worker
2262*35238bceSAndroid Build Coastguard Worker return false;
2263*35238bceSAndroid Build Coastguard Worker }
2264*35238bceSAndroid Build Coastguard Worker
2265*35238bceSAndroid Build Coastguard Worker return true;
2266*35238bceSAndroid Build Coastguard Worker }
2267*35238bceSAndroid Build Coastguard Worker
2268*35238bceSAndroid Build Coastguard Worker /** @brief Clear color buffer (uint specialization), check errors and log.
2269*35238bceSAndroid Build Coastguard Worker *
2270*35238bceSAndroid Build Coastguard Worker * @param [in] buffer Buffer to be cleared.
2271*35238bceSAndroid Build Coastguard Worker * @param [in] drawbuffer Drawbuffer to be cleared.
2272*35238bceSAndroid Build Coastguard Worker * @param [in] value Value to be cleared with.
2273*35238bceSAndroid Build Coastguard Worker *
2274*35238bceSAndroid Build Coastguard Worker * @return True if succeeded without errors, false otherwise.
2275*35238bceSAndroid Build Coastguard Worker */
2276*35238bceSAndroid Build Coastguard Worker template <>
ClearColor(glw::GLenum buffer,glw::GLint drawbuffer,glw::GLuint value)2277*35238bceSAndroid Build Coastguard Worker bool ClearTest::ClearColor<glw::GLuint>(glw::GLenum buffer, glw::GLint drawbuffer, glw::GLuint value)
2278*35238bceSAndroid Build Coastguard Worker {
2279*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
2280*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
2281*35238bceSAndroid Build Coastguard Worker
2282*35238bceSAndroid Build Coastguard Worker glw::GLuint value_vector[4] = {value, 0, 0, 0};
2283*35238bceSAndroid Build Coastguard Worker
2284*35238bceSAndroid Build Coastguard Worker gl.clearNamedFramebufferuiv(m_fbo, buffer, drawbuffer, value_vector);
2285*35238bceSAndroid Build Coastguard Worker
2286*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
2287*35238bceSAndroid Build Coastguard Worker {
2288*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
2289*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "ClearNamedFramebufferuiv unexpectedly generated " << glu::getErrorStr(error)
2290*35238bceSAndroid Build Coastguard Worker << " error. Test fails." << tcu::TestLog::EndMessage;
2291*35238bceSAndroid Build Coastguard Worker
2292*35238bceSAndroid Build Coastguard Worker return false;
2293*35238bceSAndroid Build Coastguard Worker }
2294*35238bceSAndroid Build Coastguard Worker
2295*35238bceSAndroid Build Coastguard Worker return true;
2296*35238bceSAndroid Build Coastguard Worker }
2297*35238bceSAndroid Build Coastguard Worker
2298*35238bceSAndroid Build Coastguard Worker /** @brief Format of the buffer (float specialization).
2299*35238bceSAndroid Build Coastguard Worker *
2300*35238bceSAndroid Build Coastguard Worker * @return Format.
2301*35238bceSAndroid Build Coastguard Worker */
2302*35238bceSAndroid Build Coastguard Worker template <>
Format()2303*35238bceSAndroid Build Coastguard Worker glw::GLenum ClearTest::Format<GLfloat>()
2304*35238bceSAndroid Build Coastguard Worker {
2305*35238bceSAndroid Build Coastguard Worker return GL_RED;
2306*35238bceSAndroid Build Coastguard Worker }
2307*35238bceSAndroid Build Coastguard Worker
2308*35238bceSAndroid Build Coastguard Worker /** @brief Format of the buffer (int and uint specialization).
2309*35238bceSAndroid Build Coastguard Worker *
2310*35238bceSAndroid Build Coastguard Worker * @return Format.
2311*35238bceSAndroid Build Coastguard Worker */
2312*35238bceSAndroid Build Coastguard Worker template <typename T>
Format()2313*35238bceSAndroid Build Coastguard Worker glw::GLenum ClearTest::Format()
2314*35238bceSAndroid Build Coastguard Worker {
2315*35238bceSAndroid Build Coastguard Worker return GL_RED_INTEGER;
2316*35238bceSAndroid Build Coastguard Worker }
2317*35238bceSAndroid Build Coastguard Worker
2318*35238bceSAndroid Build Coastguard Worker /** @brief Type of the buffer (float specialization).
2319*35238bceSAndroid Build Coastguard Worker *
2320*35238bceSAndroid Build Coastguard Worker * @return Type.
2321*35238bceSAndroid Build Coastguard Worker */
2322*35238bceSAndroid Build Coastguard Worker template <>
Type()2323*35238bceSAndroid Build Coastguard Worker glw::GLenum ClearTest::Type<glw::GLfloat>()
2324*35238bceSAndroid Build Coastguard Worker {
2325*35238bceSAndroid Build Coastguard Worker return GL_FLOAT;
2326*35238bceSAndroid Build Coastguard Worker }
2327*35238bceSAndroid Build Coastguard Worker
2328*35238bceSAndroid Build Coastguard Worker /** @brief Type of the buffer (int specialization).
2329*35238bceSAndroid Build Coastguard Worker *
2330*35238bceSAndroid Build Coastguard Worker * @return Type.
2331*35238bceSAndroid Build Coastguard Worker */
2332*35238bceSAndroid Build Coastguard Worker template <>
Type()2333*35238bceSAndroid Build Coastguard Worker glw::GLenum ClearTest::Type<glw::GLint>()
2334*35238bceSAndroid Build Coastguard Worker {
2335*35238bceSAndroid Build Coastguard Worker return GL_INT;
2336*35238bceSAndroid Build Coastguard Worker }
2337*35238bceSAndroid Build Coastguard Worker
2338*35238bceSAndroid Build Coastguard Worker /** @brief Type of the buffer (uint specialization).
2339*35238bceSAndroid Build Coastguard Worker *
2340*35238bceSAndroid Build Coastguard Worker * @return Type.
2341*35238bceSAndroid Build Coastguard Worker */
2342*35238bceSAndroid Build Coastguard Worker template <>
Type()2343*35238bceSAndroid Build Coastguard Worker glw::GLenum ClearTest::Type<glw::GLuint>()
2344*35238bceSAndroid Build Coastguard Worker {
2345*35238bceSAndroid Build Coastguard Worker return GL_UNSIGNED_INT;
2346*35238bceSAndroid Build Coastguard Worker }
2347*35238bceSAndroid Build Coastguard Worker
2348*35238bceSAndroid Build Coastguard Worker /** @brief Test DSA Clear function (color).
2349*35238bceSAndroid Build Coastguard Worker *
2350*35238bceSAndroid Build Coastguard Worker * @param [in] buffer Buffer to be cleared.
2351*35238bceSAndroid Build Coastguard Worker * @param [in] attachment Attachment to be tested.
2352*35238bceSAndroid Build Coastguard Worker * @param [in] value Value to be cleared with.
2353*35238bceSAndroid Build Coastguard Worker *
2354*35238bceSAndroid Build Coastguard Worker * @return True if test succeeded, false otherwise.
2355*35238bceSAndroid Build Coastguard Worker */
2356*35238bceSAndroid Build Coastguard Worker template <typename T>
TestClearColor(glw::GLenum buffer,glw::GLenum attachment,T value)2357*35238bceSAndroid Build Coastguard Worker bool ClearTest::TestClearColor(glw::GLenum buffer, glw::GLenum attachment, T value)
2358*35238bceSAndroid Build Coastguard Worker {
2359*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
2360*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
2361*35238bceSAndroid Build Coastguard Worker
2362*35238bceSAndroid Build Coastguard Worker gl.drawBuffer(attachment);
2363*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawBuffer has failed");
2364*35238bceSAndroid Build Coastguard Worker
2365*35238bceSAndroid Build Coastguard Worker /* Clear. */
2366*35238bceSAndroid Build Coastguard Worker if (ClearColor<T>(buffer, 0, value))
2367*35238bceSAndroid Build Coastguard Worker {
2368*35238bceSAndroid Build Coastguard Worker /* Fetching framebuffer content. */
2369*35238bceSAndroid Build Coastguard Worker T pixel = (T)0;
2370*35238bceSAndroid Build Coastguard Worker
2371*35238bceSAndroid Build Coastguard Worker gl.readBuffer(attachment);
2372*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadBuffer has failed");
2373*35238bceSAndroid Build Coastguard Worker
2374*35238bceSAndroid Build Coastguard Worker gl.readPixels(0, 0, 1, 1, Format<T>(), Type<T>(), &pixel);
2375*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixel has failed");
2376*35238bceSAndroid Build Coastguard Worker
2377*35238bceSAndroid Build Coastguard Worker /* Comparison with reference value. */
2378*35238bceSAndroid Build Coastguard Worker if (Compare(pixel, value))
2379*35238bceSAndroid Build Coastguard Worker {
2380*35238bceSAndroid Build Coastguard Worker return true;
2381*35238bceSAndroid Build Coastguard Worker }
2382*35238bceSAndroid Build Coastguard Worker
2383*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
2384*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "ClearNamedFramebuffer did not cleared color attachment "
2385*35238bceSAndroid Build Coastguard Worker << glu::getFramebufferAttachmentStr(attachment) << " of the framebuffer." << tcu::TestLog::EndMessage;
2386*35238bceSAndroid Build Coastguard Worker }
2387*35238bceSAndroid Build Coastguard Worker
2388*35238bceSAndroid Build Coastguard Worker return false;
2389*35238bceSAndroid Build Coastguard Worker }
2390*35238bceSAndroid Build Coastguard Worker
2391*35238bceSAndroid Build Coastguard Worker /** @brief Test DSA Clear function (depth/stencil).
2392*35238bceSAndroid Build Coastguard Worker *
2393*35238bceSAndroid Build Coastguard Worker * @param [in] stencil Stencil value to be cleared with.
2394*35238bceSAndroid Build Coastguard Worker * @param [in] depth Depth value to be cleared with.
2395*35238bceSAndroid Build Coastguard Worker *
2396*35238bceSAndroid Build Coastguard Worker * @return True if test succeeded, false otherwise.
2397*35238bceSAndroid Build Coastguard Worker */
TestClearDepthAndStencil(glw::GLfloat depth,glw::GLint stencil)2398*35238bceSAndroid Build Coastguard Worker bool ClearTest::TestClearDepthAndStencil(glw::GLfloat depth, glw::GLint stencil)
2399*35238bceSAndroid Build Coastguard Worker {
2400*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
2401*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
2402*35238bceSAndroid Build Coastguard Worker
2403*35238bceSAndroid Build Coastguard Worker /* Clearing depth and stencil. */
2404*35238bceSAndroid Build Coastguard Worker gl.clearNamedFramebufferfi(m_fbo, GL_DEPTH_STENCIL, 0, depth, stencil);
2405*35238bceSAndroid Build Coastguard Worker
2406*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
2407*35238bceSAndroid Build Coastguard Worker {
2408*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
2409*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "ClearNamedFramebufferufi unexpectedly generated " << glu::getErrorStr(error)
2410*35238bceSAndroid Build Coastguard Worker << " error. Test fails." << tcu::TestLog::EndMessage;
2411*35238bceSAndroid Build Coastguard Worker
2412*35238bceSAndroid Build Coastguard Worker return false;
2413*35238bceSAndroid Build Coastguard Worker }
2414*35238bceSAndroid Build Coastguard Worker
2415*35238bceSAndroid Build Coastguard Worker /* Clear. */
2416*35238bceSAndroid Build Coastguard Worker /* Fetching framebuffer content. */
2417*35238bceSAndroid Build Coastguard Worker glw::GLfloat the_depth = 0.f;
2418*35238bceSAndroid Build Coastguard Worker glw::GLint the_stencil = 0;
2419*35238bceSAndroid Build Coastguard Worker
2420*35238bceSAndroid Build Coastguard Worker gl.readPixels(0, 0, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &the_depth);
2421*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixel has failed");
2422*35238bceSAndroid Build Coastguard Worker
2423*35238bceSAndroid Build Coastguard Worker gl.readPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_INT, &the_stencil);
2424*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixel has failed");
2425*35238bceSAndroid Build Coastguard Worker
2426*35238bceSAndroid Build Coastguard Worker /* Comparison with reference value. */
2427*35238bceSAndroid Build Coastguard Worker if (Compare(the_depth, depth) || Compare(the_stencil, stencil))
2428*35238bceSAndroid Build Coastguard Worker {
2429*35238bceSAndroid Build Coastguard Worker return true;
2430*35238bceSAndroid Build Coastguard Worker }
2431*35238bceSAndroid Build Coastguard Worker
2432*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
2433*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message
2434*35238bceSAndroid Build Coastguard Worker << "ClearNamedFramebufferfi did not cleared depth/stencil attachment of the framebuffer."
2435*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
2436*35238bceSAndroid Build Coastguard Worker
2437*35238bceSAndroid Build Coastguard Worker return true;
2438*35238bceSAndroid Build Coastguard Worker }
2439*35238bceSAndroid Build Coastguard Worker
2440*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Clear Named Framebuffer Test cases.
2441*35238bceSAndroid Build Coastguard Worker *
2442*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
2443*35238bceSAndroid Build Coastguard Worker */
iterate()2444*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult ClearTest::iterate()
2445*35238bceSAndroid Build Coastguard Worker {
2446*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
2447*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
2448*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
2449*35238bceSAndroid Build Coastguard Worker
2450*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
2451*35238bceSAndroid Build Coastguard Worker {
2452*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
2453*35238bceSAndroid Build Coastguard Worker
2454*35238bceSAndroid Build Coastguard Worker return STOP;
2455*35238bceSAndroid Build Coastguard Worker }
2456*35238bceSAndroid Build Coastguard Worker
2457*35238bceSAndroid Build Coastguard Worker /* Running tests. */
2458*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
2459*35238bceSAndroid Build Coastguard Worker bool is_error = false;
2460*35238bceSAndroid Build Coastguard Worker
2461*35238bceSAndroid Build Coastguard Worker try
2462*35238bceSAndroid Build Coastguard Worker {
2463*35238bceSAndroid Build Coastguard Worker /* Fixed point color test. */
2464*35238bceSAndroid Build Coastguard Worker PrepareFramebuffer(GL_COLOR, GL_R8);
2465*35238bceSAndroid Build Coastguard Worker
2466*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < (glw::GLint)m_renderbuffers_count; ++i)
2467*35238bceSAndroid Build Coastguard Worker {
2468*35238bceSAndroid Build Coastguard Worker is_ok &= TestClearColor<glw::GLfloat>(GL_COLOR, GL_COLOR_ATTACHMENT0 + i, 0.5);
2469*35238bceSAndroid Build Coastguard Worker }
2470*35238bceSAndroid Build Coastguard Worker
2471*35238bceSAndroid Build Coastguard Worker Clean();
2472*35238bceSAndroid Build Coastguard Worker
2473*35238bceSAndroid Build Coastguard Worker /* Floating point color test. */
2474*35238bceSAndroid Build Coastguard Worker PrepareFramebuffer(GL_COLOR, GL_R32F);
2475*35238bceSAndroid Build Coastguard Worker
2476*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < (glw::GLint)m_renderbuffers_count; ++i)
2477*35238bceSAndroid Build Coastguard Worker {
2478*35238bceSAndroid Build Coastguard Worker is_ok &= TestClearColor<glw::GLfloat>(GL_COLOR, GL_COLOR_ATTACHMENT0 + i, 0.5);
2479*35238bceSAndroid Build Coastguard Worker }
2480*35238bceSAndroid Build Coastguard Worker
2481*35238bceSAndroid Build Coastguard Worker Clean();
2482*35238bceSAndroid Build Coastguard Worker
2483*35238bceSAndroid Build Coastguard Worker /* Signed integer color test. */
2484*35238bceSAndroid Build Coastguard Worker PrepareFramebuffer(GL_COLOR, GL_R8I);
2485*35238bceSAndroid Build Coastguard Worker
2486*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < (glw::GLint)m_renderbuffers_count; ++i)
2487*35238bceSAndroid Build Coastguard Worker {
2488*35238bceSAndroid Build Coastguard Worker is_ok &= TestClearColor<glw::GLint>(GL_COLOR, GL_COLOR_ATTACHMENT0 + i, -16);
2489*35238bceSAndroid Build Coastguard Worker }
2490*35238bceSAndroid Build Coastguard Worker
2491*35238bceSAndroid Build Coastguard Worker Clean();
2492*35238bceSAndroid Build Coastguard Worker
2493*35238bceSAndroid Build Coastguard Worker /* Unsigned integer color test. */
2494*35238bceSAndroid Build Coastguard Worker PrepareFramebuffer(GL_COLOR, GL_R8UI);
2495*35238bceSAndroid Build Coastguard Worker
2496*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < (glw::GLint)m_renderbuffers_count; ++i)
2497*35238bceSAndroid Build Coastguard Worker {
2498*35238bceSAndroid Build Coastguard Worker is_ok &= TestClearColor<glw::GLuint>(GL_COLOR, GL_COLOR_ATTACHMENT0 + i, 16);
2499*35238bceSAndroid Build Coastguard Worker }
2500*35238bceSAndroid Build Coastguard Worker
2501*35238bceSAndroid Build Coastguard Worker Clean();
2502*35238bceSAndroid Build Coastguard Worker
2503*35238bceSAndroid Build Coastguard Worker /* Depth / stencil test. */
2504*35238bceSAndroid Build Coastguard Worker PrepareFramebuffer(GL_DEPTH_STENCIL, GL_DEPTH24_STENCIL8);
2505*35238bceSAndroid Build Coastguard Worker
2506*35238bceSAndroid Build Coastguard Worker is_ok &= TestClearDepthAndStencil(1, 1);
2507*35238bceSAndroid Build Coastguard Worker
2508*35238bceSAndroid Build Coastguard Worker Clean();
2509*35238bceSAndroid Build Coastguard Worker }
2510*35238bceSAndroid Build Coastguard Worker catch (...)
2511*35238bceSAndroid Build Coastguard Worker {
2512*35238bceSAndroid Build Coastguard Worker is_ok = false;
2513*35238bceSAndroid Build Coastguard Worker is_error = true;
2514*35238bceSAndroid Build Coastguard Worker }
2515*35238bceSAndroid Build Coastguard Worker
2516*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
2517*35238bceSAndroid Build Coastguard Worker Clean();
2518*35238bceSAndroid Build Coastguard Worker
2519*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
2520*35238bceSAndroid Build Coastguard Worker if (is_ok)
2521*35238bceSAndroid Build Coastguard Worker {
2522*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
2523*35238bceSAndroid Build Coastguard Worker }
2524*35238bceSAndroid Build Coastguard Worker else
2525*35238bceSAndroid Build Coastguard Worker {
2526*35238bceSAndroid Build Coastguard Worker if (is_error)
2527*35238bceSAndroid Build Coastguard Worker {
2528*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
2529*35238bceSAndroid Build Coastguard Worker }
2530*35238bceSAndroid Build Coastguard Worker else
2531*35238bceSAndroid Build Coastguard Worker {
2532*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
2533*35238bceSAndroid Build Coastguard Worker }
2534*35238bceSAndroid Build Coastguard Worker }
2535*35238bceSAndroid Build Coastguard Worker
2536*35238bceSAndroid Build Coastguard Worker return STOP;
2537*35238bceSAndroid Build Coastguard Worker }
2538*35238bceSAndroid Build Coastguard Worker
2539*35238bceSAndroid Build Coastguard Worker /** @brief Prepare framebuffer.
2540*35238bceSAndroid Build Coastguard Worker *
2541*35238bceSAndroid Build Coastguard Worker * @param [in] buffer Buffer to be prepared.
2542*35238bceSAndroid Build Coastguard Worker * @param [in] internalformat Internal format to be prepared
2543*35238bceSAndroid Build Coastguard Worker */
PrepareFramebuffer(glw::GLenum buffer,glw::GLenum internalformat)2544*35238bceSAndroid Build Coastguard Worker void ClearTest::PrepareFramebuffer(glw::GLenum buffer, glw::GLenum internalformat)
2545*35238bceSAndroid Build Coastguard Worker {
2546*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
2547*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
2548*35238bceSAndroid Build Coastguard Worker
2549*35238bceSAndroid Build Coastguard Worker /* Check that ther is no other fbo. */
2550*35238bceSAndroid Build Coastguard Worker if ((0 != m_fbo) || (DE_NULL != m_renderbuffers))
2551*35238bceSAndroid Build Coastguard Worker {
2552*35238bceSAndroid Build Coastguard Worker throw 0;
2553*35238bceSAndroid Build Coastguard Worker }
2554*35238bceSAndroid Build Coastguard Worker
2555*35238bceSAndroid Build Coastguard Worker /* Prepare framebuffer... */
2556*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(1, &m_fbo);
2557*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
2558*35238bceSAndroid Build Coastguard Worker
2559*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
2560*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
2561*35238bceSAndroid Build Coastguard Worker
2562*35238bceSAndroid Build Coastguard Worker if (buffer == GL_COLOR)
2563*35238bceSAndroid Build Coastguard Worker {
2564*35238bceSAndroid Build Coastguard Worker glw::GLint max_color_attachments =
2565*35238bceSAndroid Build Coastguard Worker 8; /* OpenGL 4.5 specification default (see Implementation Dependent Values tables). */
2566*35238bceSAndroid Build Coastguard Worker
2567*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
2568*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
2569*35238bceSAndroid Build Coastguard Worker
2570*35238bceSAndroid Build Coastguard Worker m_renderbuffers = new glw::GLuint[max_color_attachments];
2571*35238bceSAndroid Build Coastguard Worker
2572*35238bceSAndroid Build Coastguard Worker if (m_renderbuffers)
2573*35238bceSAndroid Build Coastguard Worker {
2574*35238bceSAndroid Build Coastguard Worker /* ... with renderbuffer color attachments. */
2575*35238bceSAndroid Build Coastguard Worker
2576*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(max_color_attachments, m_renderbuffers);
2577*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
2578*35238bceSAndroid Build Coastguard Worker
2579*35238bceSAndroid Build Coastguard Worker m_renderbuffers_count = max_color_attachments;
2580*35238bceSAndroid Build Coastguard Worker
2581*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < max_color_attachments; ++i)
2582*35238bceSAndroid Build Coastguard Worker {
2583*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, m_renderbuffers[i]);
2584*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer has failed");
2585*35238bceSAndroid Build Coastguard Worker
2586*35238bceSAndroid Build Coastguard Worker gl.renderbufferStorage(GL_RENDERBUFFER, internalformat, 1, 1);
2587*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
2588*35238bceSAndroid Build Coastguard Worker
2589*35238bceSAndroid Build Coastguard Worker gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_RENDERBUFFER,
2590*35238bceSAndroid Build Coastguard Worker m_renderbuffers[i]);
2591*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
2592*35238bceSAndroid Build Coastguard Worker }
2593*35238bceSAndroid Build Coastguard Worker }
2594*35238bceSAndroid Build Coastguard Worker }
2595*35238bceSAndroid Build Coastguard Worker
2596*35238bceSAndroid Build Coastguard Worker if (buffer == GL_DEPTH_STENCIL)
2597*35238bceSAndroid Build Coastguard Worker {
2598*35238bceSAndroid Build Coastguard Worker /* ... with depth and stencil attachments. */
2599*35238bceSAndroid Build Coastguard Worker
2600*35238bceSAndroid Build Coastguard Worker m_renderbuffers = new glw::GLuint[1];
2601*35238bceSAndroid Build Coastguard Worker
2602*35238bceSAndroid Build Coastguard Worker if (m_renderbuffers)
2603*35238bceSAndroid Build Coastguard Worker {
2604*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(1, m_renderbuffers);
2605*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
2606*35238bceSAndroid Build Coastguard Worker
2607*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, m_renderbuffers[0]);
2608*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer has failed");
2609*35238bceSAndroid Build Coastguard Worker
2610*35238bceSAndroid Build Coastguard Worker m_renderbuffers_count = 1;
2611*35238bceSAndroid Build Coastguard Worker
2612*35238bceSAndroid Build Coastguard Worker gl.renderbufferStorage(GL_RENDERBUFFER, internalformat, 1, 1);
2613*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
2614*35238bceSAndroid Build Coastguard Worker
2615*35238bceSAndroid Build Coastguard Worker gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
2616*35238bceSAndroid Build Coastguard Worker m_renderbuffers[0]);
2617*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
2618*35238bceSAndroid Build Coastguard Worker }
2619*35238bceSAndroid Build Coastguard Worker }
2620*35238bceSAndroid Build Coastguard Worker
2621*35238bceSAndroid Build Coastguard Worker /* Check that framebuffer is complete. */
2622*35238bceSAndroid Build Coastguard Worker if (GL_FRAMEBUFFER_COMPLETE != gl.checkFramebufferStatus(GL_FRAMEBUFFER))
2623*35238bceSAndroid Build Coastguard Worker {
2624*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
2625*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Framebuffer is unexpectedly incomplete." << tcu::TestLog::EndMessage;
2626*35238bceSAndroid Build Coastguard Worker
2627*35238bceSAndroid Build Coastguard Worker throw 0;
2628*35238bceSAndroid Build Coastguard Worker }
2629*35238bceSAndroid Build Coastguard Worker }
2630*35238bceSAndroid Build Coastguard Worker
2631*35238bceSAndroid Build Coastguard Worker /** @brief Clean up GL state.
2632*35238bceSAndroid Build Coastguard Worker */
Clean()2633*35238bceSAndroid Build Coastguard Worker void ClearTest::Clean()
2634*35238bceSAndroid Build Coastguard Worker {
2635*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
2636*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
2637*35238bceSAndroid Build Coastguard Worker
2638*35238bceSAndroid Build Coastguard Worker /* Releasing objects. */
2639*35238bceSAndroid Build Coastguard Worker if (m_fbo)
2640*35238bceSAndroid Build Coastguard Worker {
2641*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &m_fbo);
2642*35238bceSAndroid Build Coastguard Worker
2643*35238bceSAndroid Build Coastguard Worker m_fbo = 0;
2644*35238bceSAndroid Build Coastguard Worker }
2645*35238bceSAndroid Build Coastguard Worker
2646*35238bceSAndroid Build Coastguard Worker if (DE_NULL != m_renderbuffers)
2647*35238bceSAndroid Build Coastguard Worker {
2648*35238bceSAndroid Build Coastguard Worker if (m_renderbuffers_count)
2649*35238bceSAndroid Build Coastguard Worker {
2650*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(m_renderbuffers_count, m_renderbuffers);
2651*35238bceSAndroid Build Coastguard Worker }
2652*35238bceSAndroid Build Coastguard Worker
2653*35238bceSAndroid Build Coastguard Worker delete[] m_renderbuffers;
2654*35238bceSAndroid Build Coastguard Worker
2655*35238bceSAndroid Build Coastguard Worker m_renderbuffers = DE_NULL;
2656*35238bceSAndroid Build Coastguard Worker m_renderbuffers_count = 0;
2657*35238bceSAndroid Build Coastguard Worker }
2658*35238bceSAndroid Build Coastguard Worker
2659*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
2660*35238bceSAndroid Build Coastguard Worker while (gl.getError())
2661*35238bceSAndroid Build Coastguard Worker ;
2662*35238bceSAndroid Build Coastguard Worker }
2663*35238bceSAndroid Build Coastguard Worker
2664*35238bceSAndroid Build Coastguard Worker /******************************** Blit Named Framebuffer Test Implementation ********************************/
2665*35238bceSAndroid Build Coastguard Worker
2666*35238bceSAndroid Build Coastguard Worker /** @brief Named Framebuffer blit Test constructor.
2667*35238bceSAndroid Build Coastguard Worker *
2668*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
2669*35238bceSAndroid Build Coastguard Worker */
BlitTest(deqp::Context & context)2670*35238bceSAndroid Build Coastguard Worker BlitTest::BlitTest(deqp::Context &context)
2671*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "framebuffers_blit", "Framebuffer Blit Test")
2672*35238bceSAndroid Build Coastguard Worker , m_fbo_src(0)
2673*35238bceSAndroid Build Coastguard Worker , m_rbo_color_src(0)
2674*35238bceSAndroid Build Coastguard Worker , m_rbo_depth_stencil_src(0)
2675*35238bceSAndroid Build Coastguard Worker , m_fbo_dst(0)
2676*35238bceSAndroid Build Coastguard Worker , m_rbo_color_dst(0)
2677*35238bceSAndroid Build Coastguard Worker , m_rbo_depth_stencil_dst(0)
2678*35238bceSAndroid Build Coastguard Worker {
2679*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
2680*35238bceSAndroid Build Coastguard Worker }
2681*35238bceSAndroid Build Coastguard Worker
2682*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Named Framebuffer Blit Test cases.
2683*35238bceSAndroid Build Coastguard Worker *
2684*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
2685*35238bceSAndroid Build Coastguard Worker */
iterate()2686*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult BlitTest::iterate()
2687*35238bceSAndroid Build Coastguard Worker {
2688*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
2689*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
2690*35238bceSAndroid Build Coastguard Worker
2691*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
2692*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
2693*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
2694*35238bceSAndroid Build Coastguard Worker
2695*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
2696*35238bceSAndroid Build Coastguard Worker {
2697*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
2698*35238bceSAndroid Build Coastguard Worker
2699*35238bceSAndroid Build Coastguard Worker return STOP;
2700*35238bceSAndroid Build Coastguard Worker }
2701*35238bceSAndroid Build Coastguard Worker
2702*35238bceSAndroid Build Coastguard Worker /* Running tests. */
2703*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
2704*35238bceSAndroid Build Coastguard Worker bool is_error = false;
2705*35238bceSAndroid Build Coastguard Worker
2706*35238bceSAndroid Build Coastguard Worker try
2707*35238bceSAndroid Build Coastguard Worker {
2708*35238bceSAndroid Build Coastguard Worker PrepareFramebuffers();
2709*35238bceSAndroid Build Coastguard Worker
2710*35238bceSAndroid Build Coastguard Worker is_ok = Test();
2711*35238bceSAndroid Build Coastguard Worker }
2712*35238bceSAndroid Build Coastguard Worker catch (...)
2713*35238bceSAndroid Build Coastguard Worker {
2714*35238bceSAndroid Build Coastguard Worker is_ok = false;
2715*35238bceSAndroid Build Coastguard Worker is_error = true;
2716*35238bceSAndroid Build Coastguard Worker }
2717*35238bceSAndroid Build Coastguard Worker
2718*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
2719*35238bceSAndroid Build Coastguard Worker Clean();
2720*35238bceSAndroid Build Coastguard Worker
2721*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
2722*35238bceSAndroid Build Coastguard Worker while (gl.getError())
2723*35238bceSAndroid Build Coastguard Worker ;
2724*35238bceSAndroid Build Coastguard Worker
2725*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
2726*35238bceSAndroid Build Coastguard Worker if (is_ok)
2727*35238bceSAndroid Build Coastguard Worker {
2728*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
2729*35238bceSAndroid Build Coastguard Worker }
2730*35238bceSAndroid Build Coastguard Worker else
2731*35238bceSAndroid Build Coastguard Worker {
2732*35238bceSAndroid Build Coastguard Worker if (is_error)
2733*35238bceSAndroid Build Coastguard Worker {
2734*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
2735*35238bceSAndroid Build Coastguard Worker }
2736*35238bceSAndroid Build Coastguard Worker else
2737*35238bceSAndroid Build Coastguard Worker {
2738*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
2739*35238bceSAndroid Build Coastguard Worker }
2740*35238bceSAndroid Build Coastguard Worker }
2741*35238bceSAndroid Build Coastguard Worker
2742*35238bceSAndroid Build Coastguard Worker return STOP;
2743*35238bceSAndroid Build Coastguard Worker }
2744*35238bceSAndroid Build Coastguard Worker
2745*35238bceSAndroid Build Coastguard Worker /** @brief Prepare framebuffer.
2746*35238bceSAndroid Build Coastguard Worker */
PrepareFramebuffers()2747*35238bceSAndroid Build Coastguard Worker void BlitTest::PrepareFramebuffers()
2748*35238bceSAndroid Build Coastguard Worker {
2749*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
2750*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
2751*35238bceSAndroid Build Coastguard Worker
2752*35238bceSAndroid Build Coastguard Worker /* Prepare source framebuffer */
2753*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(1, &m_fbo_src);
2754*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
2755*35238bceSAndroid Build Coastguard Worker
2756*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_src);
2757*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
2758*35238bceSAndroid Build Coastguard Worker
2759*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(1, &m_rbo_color_src);
2760*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
2761*35238bceSAndroid Build Coastguard Worker
2762*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo_color_src);
2763*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
2764*35238bceSAndroid Build Coastguard Worker
2765*35238bceSAndroid Build Coastguard Worker gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 2, 2);
2766*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
2767*35238bceSAndroid Build Coastguard Worker
2768*35238bceSAndroid Build Coastguard Worker gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo_color_src);
2769*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
2770*35238bceSAndroid Build Coastguard Worker
2771*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(1, &m_rbo_depth_stencil_src);
2772*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
2773*35238bceSAndroid Build Coastguard Worker
2774*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo_depth_stencil_src);
2775*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
2776*35238bceSAndroid Build Coastguard Worker
2777*35238bceSAndroid Build Coastguard Worker gl.renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 2, 2);
2778*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
2779*35238bceSAndroid Build Coastguard Worker
2780*35238bceSAndroid Build Coastguard Worker gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_rbo_depth_stencil_src);
2781*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
2782*35238bceSAndroid Build Coastguard Worker
2783*35238bceSAndroid Build Coastguard Worker /* Check that framebuffer is complete. */
2784*35238bceSAndroid Build Coastguard Worker if (GL_FRAMEBUFFER_COMPLETE != gl.checkFramebufferStatus(GL_FRAMEBUFFER))
2785*35238bceSAndroid Build Coastguard Worker {
2786*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
2787*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Framebuffer is unexpectedly incomplete." << tcu::TestLog::EndMessage;
2788*35238bceSAndroid Build Coastguard Worker
2789*35238bceSAndroid Build Coastguard Worker throw 0;
2790*35238bceSAndroid Build Coastguard Worker }
2791*35238bceSAndroid Build Coastguard Worker
2792*35238bceSAndroid Build Coastguard Worker /* Prepare destination framebuffer */
2793*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(1, &m_fbo_dst);
2794*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
2795*35238bceSAndroid Build Coastguard Worker
2796*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_dst);
2797*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
2798*35238bceSAndroid Build Coastguard Worker
2799*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(1, &m_rbo_color_dst);
2800*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
2801*35238bceSAndroid Build Coastguard Worker
2802*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo_color_dst);
2803*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
2804*35238bceSAndroid Build Coastguard Worker
2805*35238bceSAndroid Build Coastguard Worker gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 3, 2);
2806*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
2807*35238bceSAndroid Build Coastguard Worker
2808*35238bceSAndroid Build Coastguard Worker gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo_color_dst);
2809*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
2810*35238bceSAndroid Build Coastguard Worker
2811*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(1, &m_rbo_depth_stencil_dst);
2812*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
2813*35238bceSAndroid Build Coastguard Worker
2814*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo_depth_stencil_dst);
2815*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
2816*35238bceSAndroid Build Coastguard Worker
2817*35238bceSAndroid Build Coastguard Worker gl.renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 3, 2);
2818*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
2819*35238bceSAndroid Build Coastguard Worker
2820*35238bceSAndroid Build Coastguard Worker gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_rbo_depth_stencil_dst);
2821*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
2822*35238bceSAndroid Build Coastguard Worker
2823*35238bceSAndroid Build Coastguard Worker /* Check that framebuffer is complete. */
2824*35238bceSAndroid Build Coastguard Worker if (GL_FRAMEBUFFER_COMPLETE != gl.checkFramebufferStatus(GL_FRAMEBUFFER))
2825*35238bceSAndroid Build Coastguard Worker {
2826*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
2827*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Framebuffer is unexpectedly incomplete." << tcu::TestLog::EndMessage;
2828*35238bceSAndroid Build Coastguard Worker
2829*35238bceSAndroid Build Coastguard Worker throw 0;
2830*35238bceSAndroid Build Coastguard Worker }
2831*35238bceSAndroid Build Coastguard Worker }
2832*35238bceSAndroid Build Coastguard Worker
2833*35238bceSAndroid Build Coastguard Worker /** @brief Do the blit test.
2834*35238bceSAndroid Build Coastguard Worker */
Test()2835*35238bceSAndroid Build Coastguard Worker bool BlitTest::Test()
2836*35238bceSAndroid Build Coastguard Worker {
2837*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
2838*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
2839*35238bceSAndroid Build Coastguard Worker
2840*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_src);
2841*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
2842*35238bceSAndroid Build Coastguard Worker
2843*35238bceSAndroid Build Coastguard Worker ClearFramebuffer(1.f, 0.f, 0.f, 0.5f, 1);
2844*35238bceSAndroid Build Coastguard Worker
2845*35238bceSAndroid Build Coastguard Worker gl.blitNamedFramebuffer(m_fbo_src, m_fbo_dst, 0, 0, 1, 1, 0, 0, 1, 1,
2846*35238bceSAndroid Build Coastguard Worker GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST);
2847*35238bceSAndroid Build Coastguard Worker
2848*35238bceSAndroid Build Coastguard Worker if (CheckErrorAndLog())
2849*35238bceSAndroid Build Coastguard Worker {
2850*35238bceSAndroid Build Coastguard Worker ClearFramebuffer(0.f, 1.f, 0.f, 0.25f, 2);
2851*35238bceSAndroid Build Coastguard Worker
2852*35238bceSAndroid Build Coastguard Worker gl.blitNamedFramebuffer(m_fbo_src, m_fbo_dst, 0, 0, 1, 1, 1, 0, 2, 1, GL_COLOR_BUFFER_BIT, GL_LINEAR);
2853*35238bceSAndroid Build Coastguard Worker gl.blitNamedFramebuffer(m_fbo_src, m_fbo_dst, 0, 0, 1, 1, 1, 0, 2, 1,
2854*35238bceSAndroid Build Coastguard Worker GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST);
2855*35238bceSAndroid Build Coastguard Worker
2856*35238bceSAndroid Build Coastguard Worker if (CheckErrorAndLog())
2857*35238bceSAndroid Build Coastguard Worker {
2858*35238bceSAndroid Build Coastguard Worker ClearFramebuffer(0.f, 0.f, 1.f, 0.125f, 3);
2859*35238bceSAndroid Build Coastguard Worker
2860*35238bceSAndroid Build Coastguard Worker gl.blitNamedFramebuffer(m_fbo_src, m_fbo_dst, 0, 0, 2, 2, 2, 0, 3, 1,
2861*35238bceSAndroid Build Coastguard Worker GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST);
2862*35238bceSAndroid Build Coastguard Worker
2863*35238bceSAndroid Build Coastguard Worker if (CheckErrorAndLog())
2864*35238bceSAndroid Build Coastguard Worker {
2865*35238bceSAndroid Build Coastguard Worker ClearFramebuffer(1.f, 1.f, 0.f, 0.0625f, 4);
2866*35238bceSAndroid Build Coastguard Worker
2867*35238bceSAndroid Build Coastguard Worker gl.blitNamedFramebuffer(m_fbo_src, m_fbo_dst, 0, 0, 1, 1, 0, 1, 3, 2,
2868*35238bceSAndroid Build Coastguard Worker GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST);
2869*35238bceSAndroid Build Coastguard Worker
2870*35238bceSAndroid Build Coastguard Worker if (CheckErrorAndLog())
2871*35238bceSAndroid Build Coastguard Worker {
2872*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_dst);
2873*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
2874*35238bceSAndroid Build Coastguard Worker
2875*35238bceSAndroid Build Coastguard Worker if (CheckColor() && CheckDepth() && CheckStencil())
2876*35238bceSAndroid Build Coastguard Worker {
2877*35238bceSAndroid Build Coastguard Worker return true;
2878*35238bceSAndroid Build Coastguard Worker }
2879*35238bceSAndroid Build Coastguard Worker }
2880*35238bceSAndroid Build Coastguard Worker }
2881*35238bceSAndroid Build Coastguard Worker }
2882*35238bceSAndroid Build Coastguard Worker }
2883*35238bceSAndroid Build Coastguard Worker
2884*35238bceSAndroid Build Coastguard Worker return false;
2885*35238bceSAndroid Build Coastguard Worker }
2886*35238bceSAndroid Build Coastguard Worker
2887*35238bceSAndroid Build Coastguard Worker /** @brief Check error and log.
2888*35238bceSAndroid Build Coastguard Worker *
2889*35238bceSAndroid Build Coastguard Worker * @return true if no error, false otherwise.
2890*35238bceSAndroid Build Coastguard Worker */
CheckErrorAndLog()2891*35238bceSAndroid Build Coastguard Worker bool BlitTest::CheckErrorAndLog()
2892*35238bceSAndroid Build Coastguard Worker {
2893*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
2894*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
2895*35238bceSAndroid Build Coastguard Worker
2896*35238bceSAndroid Build Coastguard Worker /* Error query. */
2897*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
2898*35238bceSAndroid Build Coastguard Worker {
2899*35238bceSAndroid Build Coastguard Worker /* Log. */
2900*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog() << tcu::TestLog::Message << "BlitNamedFramebuffer unexpectedly generated "
2901*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(error) << " error." << tcu::TestLog::EndMessage;
2902*35238bceSAndroid Build Coastguard Worker
2903*35238bceSAndroid Build Coastguard Worker /* Returning result. */
2904*35238bceSAndroid Build Coastguard Worker return false;
2905*35238bceSAndroid Build Coastguard Worker }
2906*35238bceSAndroid Build Coastguard Worker
2907*35238bceSAndroid Build Coastguard Worker /* Returning result. */
2908*35238bceSAndroid Build Coastguard Worker return true;
2909*35238bceSAndroid Build Coastguard Worker }
2910*35238bceSAndroid Build Coastguard Worker
2911*35238bceSAndroid Build Coastguard Worker /** @brief Check color and log.
2912*35238bceSAndroid Build Coastguard Worker *
2913*35238bceSAndroid Build Coastguard Worker * @return true if color matches reference, false otherwise.
2914*35238bceSAndroid Build Coastguard Worker */
CheckColor()2915*35238bceSAndroid Build Coastguard Worker bool BlitTest::CheckColor()
2916*35238bceSAndroid Build Coastguard Worker {
2917*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
2918*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
2919*35238bceSAndroid Build Coastguard Worker
2920*35238bceSAndroid Build Coastguard Worker /* Reference values. */
2921*35238bceSAndroid Build Coastguard Worker static const glw::GLfloat reference[2][3][4] = {{{1.f, 0.f, 0.f, 1.f}, {0.f, 1.f, 0.f, 1.f}, {0.f, 0.f, 1.f, 1.f}},
2922*35238bceSAndroid Build Coastguard Worker {{1.f, 1.f, 0.f, 1.f}, {1.f, 1.f, 0.f, 1.f}, {1.f, 1.f, 0.f, 1.f}}};
2923*35238bceSAndroid Build Coastguard Worker
2924*35238bceSAndroid Build Coastguard Worker /* Copy buffer. */
2925*35238bceSAndroid Build Coastguard Worker glw::GLfloat color[2][3][4] = {{{0}}};
2926*35238bceSAndroid Build Coastguard Worker
2927*35238bceSAndroid Build Coastguard Worker /* Reading from GL. */
2928*35238bceSAndroid Build Coastguard Worker gl.readPixels(0, 0, 3, 2, GL_RGBA, GL_FLOAT, color);
2929*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
2930*35238bceSAndroid Build Coastguard Worker
2931*35238bceSAndroid Build Coastguard Worker /* Comparison against the reference. */
2932*35238bceSAndroid Build Coastguard Worker for (glw::GLuint j = 0; j < 2; ++j)
2933*35238bceSAndroid Build Coastguard Worker {
2934*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < 3; ++i)
2935*35238bceSAndroid Build Coastguard Worker {
2936*35238bceSAndroid Build Coastguard Worker for (glw::GLuint k = 0; k < 4; ++k)
2937*35238bceSAndroid Build Coastguard Worker {
2938*35238bceSAndroid Build Coastguard Worker if (de::abs(reference[j][i][k] - color[j][i][k]) > (1.f / 64.f) /* Precision. */)
2939*35238bceSAndroid Build Coastguard Worker {
2940*35238bceSAndroid Build Coastguard Worker /* Log. */
2941*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
2942*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Blitted framebuffer color buffer contains [[" << color[0][0][0]
2943*35238bceSAndroid Build Coastguard Worker << ", " << color[0][0][1] << ", " << color[0][0][2] << ", " << color[0][0][3] << "], ["
2944*35238bceSAndroid Build Coastguard Worker << color[0][1][0] << ", " << color[0][1][1] << ", " << color[0][1][2] << ", " << color[0][1][3]
2945*35238bceSAndroid Build Coastguard Worker << "], [" << color[0][2][0] << ", " << color[0][2][1] << ", " << color[0][2][2] << ", "
2946*35238bceSAndroid Build Coastguard Worker << color[0][2][3] << "],\n[" << color[1][0][0] << ", " << color[1][0][1] << ", "
2947*35238bceSAndroid Build Coastguard Worker << color[1][0][2] << ", " << color[1][0][3] << "], [" << color[1][1][0] << ", "
2948*35238bceSAndroid Build Coastguard Worker << color[1][1][1] << ", " << color[1][1][2] << ", " << color[1][1][3] << "], ["
2949*35238bceSAndroid Build Coastguard Worker << color[1][2][0] << ", " << color[1][2][1] << ", " << color[1][2][2] << ", " << color[1][2][3]
2950*35238bceSAndroid Build Coastguard Worker << "]], but\n"
2951*35238bceSAndroid Build Coastguard Worker << reference[0][0][0] << ", " << reference[0][0][1] << ", " << reference[0][0][2] << ", "
2952*35238bceSAndroid Build Coastguard Worker << reference[0][0][3] << "], [" << reference[0][1][0] << ", " << reference[0][1][1] << ", "
2953*35238bceSAndroid Build Coastguard Worker << reference[0][1][2] << ", " << reference[0][1][3] << "], [" << reference[0][2][0] << ", "
2954*35238bceSAndroid Build Coastguard Worker << reference[0][2][1] << ", " << reference[0][2][2] << ", " << reference[0][2][3] << "],\n["
2955*35238bceSAndroid Build Coastguard Worker << reference[1][0][0] << ", " << reference[1][0][1] << ", " << reference[1][0][2] << ", "
2956*35238bceSAndroid Build Coastguard Worker << reference[1][0][3] << "], [" << reference[1][1][0] << ", " << reference[1][1][1] << ", "
2957*35238bceSAndroid Build Coastguard Worker << reference[1][1][2] << ", " << reference[1][1][3] << "], [" << reference[1][2][0] << ", "
2958*35238bceSAndroid Build Coastguard Worker << reference[1][2][1] << ", " << reference[1][2][2] << ", " << reference[1][2][3]
2959*35238bceSAndroid Build Coastguard Worker << "]] was expected.\n"
2960*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
2961*35238bceSAndroid Build Coastguard Worker
2962*35238bceSAndroid Build Coastguard Worker return false;
2963*35238bceSAndroid Build Coastguard Worker }
2964*35238bceSAndroid Build Coastguard Worker }
2965*35238bceSAndroid Build Coastguard Worker }
2966*35238bceSAndroid Build Coastguard Worker }
2967*35238bceSAndroid Build Coastguard Worker
2968*35238bceSAndroid Build Coastguard Worker return true;
2969*35238bceSAndroid Build Coastguard Worker }
2970*35238bceSAndroid Build Coastguard Worker
2971*35238bceSAndroid Build Coastguard Worker /** @brief Check depth and log.
2972*35238bceSAndroid Build Coastguard Worker *
2973*35238bceSAndroid Build Coastguard Worker * @return true if depth matches reference, false otherwise.
2974*35238bceSAndroid Build Coastguard Worker */
CheckDepth()2975*35238bceSAndroid Build Coastguard Worker bool BlitTest::CheckDepth()
2976*35238bceSAndroid Build Coastguard Worker {
2977*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
2978*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
2979*35238bceSAndroid Build Coastguard Worker
2980*35238bceSAndroid Build Coastguard Worker /* Reference values. */
2981*35238bceSAndroid Build Coastguard Worker static const glw::GLfloat reference[2][3] = {{0.5, 0.25, 0.125}, {0.0625, 0.0625, 0.0625}};
2982*35238bceSAndroid Build Coastguard Worker
2983*35238bceSAndroid Build Coastguard Worker /* Copy buffer. */
2984*35238bceSAndroid Build Coastguard Worker glw::GLfloat depth[2][3] = {{0}};
2985*35238bceSAndroid Build Coastguard Worker
2986*35238bceSAndroid Build Coastguard Worker /* Reading from GL. */
2987*35238bceSAndroid Build Coastguard Worker gl.readPixels(0, 0, 3, 2, GL_DEPTH_COMPONENT, GL_FLOAT, depth);
2988*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
2989*35238bceSAndroid Build Coastguard Worker
2990*35238bceSAndroid Build Coastguard Worker /* Comparison against the reference. */
2991*35238bceSAndroid Build Coastguard Worker for (glw::GLuint j = 0; j < 2; ++j)
2992*35238bceSAndroid Build Coastguard Worker {
2993*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < 3; ++i)
2994*35238bceSAndroid Build Coastguard Worker {
2995*35238bceSAndroid Build Coastguard Worker if (de::abs(reference[j][i] - depth[j][i]) > (1.f / 64.f) /* Precision. */)
2996*35238bceSAndroid Build Coastguard Worker {
2997*35238bceSAndroid Build Coastguard Worker /* Log. */
2998*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
2999*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Blitted framebuffer depth buffer contains [" << depth[0][0] << ", "
3000*35238bceSAndroid Build Coastguard Worker << depth[0][1] << ", " << depth[0][2] << ", \n"
3001*35238bceSAndroid Build Coastguard Worker << depth[1][0] << ", " << depth[1][1] << ", " << depth[1][2] << "], but " << reference[0][0] << ", "
3002*35238bceSAndroid Build Coastguard Worker << reference[0][1] << ", " << reference[0][2] << ", \n"
3003*35238bceSAndroid Build Coastguard Worker << reference[1][0] << ", " << reference[1][1] << ", " << reference[1][2] << "] was expected."
3004*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
3005*35238bceSAndroid Build Coastguard Worker
3006*35238bceSAndroid Build Coastguard Worker return false;
3007*35238bceSAndroid Build Coastguard Worker }
3008*35238bceSAndroid Build Coastguard Worker }
3009*35238bceSAndroid Build Coastguard Worker }
3010*35238bceSAndroid Build Coastguard Worker
3011*35238bceSAndroid Build Coastguard Worker return true;
3012*35238bceSAndroid Build Coastguard Worker }
3013*35238bceSAndroid Build Coastguard Worker
3014*35238bceSAndroid Build Coastguard Worker /** @brief Check stencil and log.
3015*35238bceSAndroid Build Coastguard Worker *
3016*35238bceSAndroid Build Coastguard Worker * @return true if stencil matches reference, false otherwise.
3017*35238bceSAndroid Build Coastguard Worker */
CheckStencil()3018*35238bceSAndroid Build Coastguard Worker bool BlitTest::CheckStencil()
3019*35238bceSAndroid Build Coastguard Worker {
3020*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
3021*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
3022*35238bceSAndroid Build Coastguard Worker
3023*35238bceSAndroid Build Coastguard Worker /* Reference values. */
3024*35238bceSAndroid Build Coastguard Worker static const glw::GLint reference[2][3] = {{1, 2, 3}, {4, 4, 4}};
3025*35238bceSAndroid Build Coastguard Worker
3026*35238bceSAndroid Build Coastguard Worker /* Copy buffer. */
3027*35238bceSAndroid Build Coastguard Worker glw::GLint stencil[2][3] = {{0}};
3028*35238bceSAndroid Build Coastguard Worker
3029*35238bceSAndroid Build Coastguard Worker /* Reading from GL. */
3030*35238bceSAndroid Build Coastguard Worker gl.readPixels(0, 0, 3, 2, GL_STENCIL_INDEX, GL_INT, stencil);
3031*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
3032*35238bceSAndroid Build Coastguard Worker
3033*35238bceSAndroid Build Coastguard Worker /* Comparison against the reference. */
3034*35238bceSAndroid Build Coastguard Worker for (glw::GLuint j = 0; j < 2; ++j)
3035*35238bceSAndroid Build Coastguard Worker {
3036*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < 3; ++i)
3037*35238bceSAndroid Build Coastguard Worker {
3038*35238bceSAndroid Build Coastguard Worker if (reference[j][i] != stencil[j][i])
3039*35238bceSAndroid Build Coastguard Worker {
3040*35238bceSAndroid Build Coastguard Worker /* Log. */
3041*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
3042*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Blitted framebuffer stencil buffer contains [" << stencil[0][0] << ", "
3043*35238bceSAndroid Build Coastguard Worker << stencil[0][1] << ", " << stencil[0][2] << ", \n"
3044*35238bceSAndroid Build Coastguard Worker << stencil[1][0] << ", " << stencil[1][1] << ", " << stencil[1][2] << "], but " << reference[0][0]
3045*35238bceSAndroid Build Coastguard Worker << ", " << reference[0][1] << ", " << reference[0][2] << ", \n"
3046*35238bceSAndroid Build Coastguard Worker << reference[1][0] << ", " << reference[1][1] << ", " << reference[1][2] << "] was expected."
3047*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
3048*35238bceSAndroid Build Coastguard Worker
3049*35238bceSAndroid Build Coastguard Worker return false;
3050*35238bceSAndroid Build Coastguard Worker }
3051*35238bceSAndroid Build Coastguard Worker }
3052*35238bceSAndroid Build Coastguard Worker }
3053*35238bceSAndroid Build Coastguard Worker
3054*35238bceSAndroid Build Coastguard Worker return true;
3055*35238bceSAndroid Build Coastguard Worker }
3056*35238bceSAndroid Build Coastguard Worker
3057*35238bceSAndroid Build Coastguard Worker /** @brief Clear framebuffer.
3058*35238bceSAndroid Build Coastguard Worker *
3059*35238bceSAndroid Build Coastguard Worker * @param [in] red Color component.
3060*35238bceSAndroid Build Coastguard Worker * @param [in] green Color component.
3061*35238bceSAndroid Build Coastguard Worker * @param [in] blue Color component.
3062*35238bceSAndroid Build Coastguard Worker * @param [in] alpha Color component.
3063*35238bceSAndroid Build Coastguard Worker * @param [in] depth Depth component.
3064*35238bceSAndroid Build Coastguard Worker * @param [in] stencil Stencil index.
3065*35238bceSAndroid Build Coastguard Worker */
ClearFramebuffer(glw::GLfloat red,glw::GLfloat green,glw::GLfloat blue,glw::GLfloat depth,glw::GLint stencil)3066*35238bceSAndroid Build Coastguard Worker void BlitTest::ClearFramebuffer(glw::GLfloat red, glw::GLfloat green, glw::GLfloat blue, glw::GLfloat depth,
3067*35238bceSAndroid Build Coastguard Worker glw::GLint stencil)
3068*35238bceSAndroid Build Coastguard Worker {
3069*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
3070*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
3071*35238bceSAndroid Build Coastguard Worker
3072*35238bceSAndroid Build Coastguard Worker /* Setup clear values. */
3073*35238bceSAndroid Build Coastguard Worker gl.clearColor(red, green, blue, 1.f);
3074*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor has failed");
3075*35238bceSAndroid Build Coastguard Worker
3076*35238bceSAndroid Build Coastguard Worker gl.clearDepth(depth);
3077*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor has failed");
3078*35238bceSAndroid Build Coastguard Worker
3079*35238bceSAndroid Build Coastguard Worker gl.clearStencil(stencil);
3080*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor has failed");
3081*35238bceSAndroid Build Coastguard Worker
3082*35238bceSAndroid Build Coastguard Worker /* Clearing. */
3083*35238bceSAndroid Build Coastguard Worker gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
3084*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor has failed");
3085*35238bceSAndroid Build Coastguard Worker }
3086*35238bceSAndroid Build Coastguard Worker
3087*35238bceSAndroid Build Coastguard Worker /** @brief Clean up GL state.
3088*35238bceSAndroid Build Coastguard Worker */
Clean()3089*35238bceSAndroid Build Coastguard Worker void BlitTest::Clean()
3090*35238bceSAndroid Build Coastguard Worker {
3091*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
3092*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
3093*35238bceSAndroid Build Coastguard Worker
3094*35238bceSAndroid Build Coastguard Worker /* Releasing objects. */
3095*35238bceSAndroid Build Coastguard Worker if (m_fbo_src)
3096*35238bceSAndroid Build Coastguard Worker {
3097*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &m_fbo_src);
3098*35238bceSAndroid Build Coastguard Worker
3099*35238bceSAndroid Build Coastguard Worker m_fbo_src = 0;
3100*35238bceSAndroid Build Coastguard Worker }
3101*35238bceSAndroid Build Coastguard Worker
3102*35238bceSAndroid Build Coastguard Worker if (m_fbo_dst)
3103*35238bceSAndroid Build Coastguard Worker {
3104*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &m_fbo_dst);
3105*35238bceSAndroid Build Coastguard Worker
3106*35238bceSAndroid Build Coastguard Worker m_fbo_dst = 0;
3107*35238bceSAndroid Build Coastguard Worker }
3108*35238bceSAndroid Build Coastguard Worker
3109*35238bceSAndroid Build Coastguard Worker if (m_rbo_color_src)
3110*35238bceSAndroid Build Coastguard Worker {
3111*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &m_rbo_color_src);
3112*35238bceSAndroid Build Coastguard Worker
3113*35238bceSAndroid Build Coastguard Worker m_rbo_color_src = 0;
3114*35238bceSAndroid Build Coastguard Worker }
3115*35238bceSAndroid Build Coastguard Worker
3116*35238bceSAndroid Build Coastguard Worker if (m_rbo_color_dst)
3117*35238bceSAndroid Build Coastguard Worker {
3118*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &m_rbo_color_dst);
3119*35238bceSAndroid Build Coastguard Worker
3120*35238bceSAndroid Build Coastguard Worker m_rbo_color_dst = 0;
3121*35238bceSAndroid Build Coastguard Worker }
3122*35238bceSAndroid Build Coastguard Worker
3123*35238bceSAndroid Build Coastguard Worker if (m_rbo_depth_stencil_src)
3124*35238bceSAndroid Build Coastguard Worker {
3125*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &m_rbo_depth_stencil_src);
3126*35238bceSAndroid Build Coastguard Worker
3127*35238bceSAndroid Build Coastguard Worker m_rbo_depth_stencil_src = 0;
3128*35238bceSAndroid Build Coastguard Worker }
3129*35238bceSAndroid Build Coastguard Worker
3130*35238bceSAndroid Build Coastguard Worker if (m_rbo_depth_stencil_dst)
3131*35238bceSAndroid Build Coastguard Worker {
3132*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &m_rbo_depth_stencil_dst);
3133*35238bceSAndroid Build Coastguard Worker
3134*35238bceSAndroid Build Coastguard Worker m_rbo_depth_stencil_dst = 0;
3135*35238bceSAndroid Build Coastguard Worker }
3136*35238bceSAndroid Build Coastguard Worker
3137*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
3138*35238bceSAndroid Build Coastguard Worker while (gl.getError())
3139*35238bceSAndroid Build Coastguard Worker ;
3140*35238bceSAndroid Build Coastguard Worker }
3141*35238bceSAndroid Build Coastguard Worker
3142*35238bceSAndroid Build Coastguard Worker /******************************** Framebuffer Check Status Test Implementation ********************************/
3143*35238bceSAndroid Build Coastguard Worker
3144*35238bceSAndroid Build Coastguard Worker /** @brief Check Status Test constructor.
3145*35238bceSAndroid Build Coastguard Worker *
3146*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
3147*35238bceSAndroid Build Coastguard Worker */
CheckStatusTest(deqp::Context & context)3148*35238bceSAndroid Build Coastguard Worker CheckStatusTest::CheckStatusTest(deqp::Context &context)
3149*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "framebuffers_check_status", "Framebuffer Check Status Test")
3150*35238bceSAndroid Build Coastguard Worker {
3151*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
3152*35238bceSAndroid Build Coastguard Worker }
3153*35238bceSAndroid Build Coastguard Worker
3154*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Check Status Test cases.
3155*35238bceSAndroid Build Coastguard Worker *
3156*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
3157*35238bceSAndroid Build Coastguard Worker */
iterate()3158*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult CheckStatusTest::iterate()
3159*35238bceSAndroid Build Coastguard Worker {
3160*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
3161*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
3162*35238bceSAndroid Build Coastguard Worker
3163*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
3164*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
3165*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
3166*35238bceSAndroid Build Coastguard Worker
3167*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
3168*35238bceSAndroid Build Coastguard Worker {
3169*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
3170*35238bceSAndroid Build Coastguard Worker
3171*35238bceSAndroid Build Coastguard Worker return STOP;
3172*35238bceSAndroid Build Coastguard Worker }
3173*35238bceSAndroid Build Coastguard Worker
3174*35238bceSAndroid Build Coastguard Worker /* Running tests. */
3175*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
3176*35238bceSAndroid Build Coastguard Worker bool maybe_ok = true;
3177*35238bceSAndroid Build Coastguard Worker bool is_error = false;
3178*35238bceSAndroid Build Coastguard Worker
3179*35238bceSAndroid Build Coastguard Worker try
3180*35238bceSAndroid Build Coastguard Worker {
3181*35238bceSAndroid Build Coastguard Worker /* The specification is not clear about framebuffer completness. OpenGL 4.5 core profile
3182*35238bceSAndroid Build Coastguard Worker specification in chapter 9.4.2 says:
3183*35238bceSAndroid Build Coastguard Worker "The framebuffer object bound to target is said to be framebuffer complete if all
3184*35238bceSAndroid Build Coastguard Worker the following conditions are true [...]"
3185*35238bceSAndroid Build Coastguard Worker It does not say that framebuffer is incomplete when any of the conditions are not met.
3186*35238bceSAndroid Build Coastguard Worker Due to this wording, except for obvious cases (incomplete attachment and missing attachments)
3187*35238bceSAndroid Build Coastguard Worker other tests ar optional and may result in QP_TEST_RESULT_COMPATIBILITY_WARNING when fail. */
3188*35238bceSAndroid Build Coastguard Worker is_ok &= IncompleteAttachmentTestCase();
3189*35238bceSAndroid Build Coastguard Worker is_ok &= MissingAttachmentTestCase();
3190*35238bceSAndroid Build Coastguard Worker
3191*35238bceSAndroid Build Coastguard Worker maybe_ok &= IncompleteMultisampleRenderbufferTestCase();
3192*35238bceSAndroid Build Coastguard Worker maybe_ok &= IncompleteMultisampleTextureTestCase();
3193*35238bceSAndroid Build Coastguard Worker maybe_ok &= IncompleteLayerTargetsTestCase();
3194*35238bceSAndroid Build Coastguard Worker }
3195*35238bceSAndroid Build Coastguard Worker catch (...)
3196*35238bceSAndroid Build Coastguard Worker {
3197*35238bceSAndroid Build Coastguard Worker is_ok = false;
3198*35238bceSAndroid Build Coastguard Worker is_error = true;
3199*35238bceSAndroid Build Coastguard Worker }
3200*35238bceSAndroid Build Coastguard Worker
3201*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
3202*35238bceSAndroid Build Coastguard Worker while (gl.getError())
3203*35238bceSAndroid Build Coastguard Worker ;
3204*35238bceSAndroid Build Coastguard Worker
3205*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
3206*35238bceSAndroid Build Coastguard Worker if (is_ok)
3207*35238bceSAndroid Build Coastguard Worker {
3208*35238bceSAndroid Build Coastguard Worker if (maybe_ok)
3209*35238bceSAndroid Build Coastguard Worker {
3210*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
3211*35238bceSAndroid Build Coastguard Worker }
3212*35238bceSAndroid Build Coastguard Worker else
3213*35238bceSAndroid Build Coastguard Worker {
3214*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_COMPATIBILITY_WARNING, "Pass with Compatibility Warning");
3215*35238bceSAndroid Build Coastguard Worker }
3216*35238bceSAndroid Build Coastguard Worker }
3217*35238bceSAndroid Build Coastguard Worker else
3218*35238bceSAndroid Build Coastguard Worker {
3219*35238bceSAndroid Build Coastguard Worker if (is_error)
3220*35238bceSAndroid Build Coastguard Worker {
3221*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
3222*35238bceSAndroid Build Coastguard Worker }
3223*35238bceSAndroid Build Coastguard Worker else
3224*35238bceSAndroid Build Coastguard Worker {
3225*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
3226*35238bceSAndroid Build Coastguard Worker }
3227*35238bceSAndroid Build Coastguard Worker }
3228*35238bceSAndroid Build Coastguard Worker
3229*35238bceSAndroid Build Coastguard Worker return STOP;
3230*35238bceSAndroid Build Coastguard Worker }
3231*35238bceSAndroid Build Coastguard Worker
3232*35238bceSAndroid Build Coastguard Worker /** Incomplete Attachment Test Case
3233*35238bceSAndroid Build Coastguard Worker *
3234*35238bceSAndroid Build Coastguard Worker * @return True if test case succeeded, false otherwise.
3235*35238bceSAndroid Build Coastguard Worker */
IncompleteAttachmentTestCase()3236*35238bceSAndroid Build Coastguard Worker bool CheckStatusTest::IncompleteAttachmentTestCase()
3237*35238bceSAndroid Build Coastguard Worker {
3238*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
3239*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
3240*35238bceSAndroid Build Coastguard Worker
3241*35238bceSAndroid Build Coastguard Worker /* Test result */
3242*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
3243*35238bceSAndroid Build Coastguard Worker bool is_error = false;
3244*35238bceSAndroid Build Coastguard Worker
3245*35238bceSAndroid Build Coastguard Worker /* Test objects. */
3246*35238bceSAndroid Build Coastguard Worker glw::GLuint fbo = 0;
3247*35238bceSAndroid Build Coastguard Worker glw::GLuint rbo = 0;
3248*35238bceSAndroid Build Coastguard Worker
3249*35238bceSAndroid Build Coastguard Worker try
3250*35238bceSAndroid Build Coastguard Worker {
3251*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(1, &fbo);
3252*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
3253*35238bceSAndroid Build Coastguard Worker
3254*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, fbo);
3255*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
3256*35238bceSAndroid Build Coastguard Worker
3257*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(1, &rbo);
3258*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
3259*35238bceSAndroid Build Coastguard Worker
3260*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, rbo);
3261*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
3262*35238bceSAndroid Build Coastguard Worker
3263*35238bceSAndroid Build Coastguard Worker gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo);
3264*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
3265*35238bceSAndroid Build Coastguard Worker
3266*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
3267*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
3268*35238bceSAndroid Build Coastguard Worker
3269*35238bceSAndroid Build Coastguard Worker glw::GLenum status = 0;
3270*35238bceSAndroid Build Coastguard Worker
3271*35238bceSAndroid Build Coastguard Worker /* Check that framebuffer is complete. */
3272*35238bceSAndroid Build Coastguard Worker if (GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT != (status = gl.checkNamedFramebufferStatus(fbo, GL_FRAMEBUFFER)))
3273*35238bceSAndroid Build Coastguard Worker {
3274*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
3275*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message
3276*35238bceSAndroid Build Coastguard Worker << "CheckNamedFramebufferStatus did not return FRAMEBUFFER_INCOMPLETE_ATTACHMENT value. "
3277*35238bceSAndroid Build Coastguard Worker << glu::getFramebufferStatusStr(status) << " was observed instead." << tcu::TestLog::EndMessage;
3278*35238bceSAndroid Build Coastguard Worker
3279*35238bceSAndroid Build Coastguard Worker is_ok = false;
3280*35238bceSAndroid Build Coastguard Worker }
3281*35238bceSAndroid Build Coastguard Worker }
3282*35238bceSAndroid Build Coastguard Worker catch (...)
3283*35238bceSAndroid Build Coastguard Worker {
3284*35238bceSAndroid Build Coastguard Worker is_ok = false;
3285*35238bceSAndroid Build Coastguard Worker is_error = true;
3286*35238bceSAndroid Build Coastguard Worker }
3287*35238bceSAndroid Build Coastguard Worker
3288*35238bceSAndroid Build Coastguard Worker /* Releasing obnjects. */
3289*35238bceSAndroid Build Coastguard Worker if (fbo)
3290*35238bceSAndroid Build Coastguard Worker {
3291*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &fbo);
3292*35238bceSAndroid Build Coastguard Worker }
3293*35238bceSAndroid Build Coastguard Worker
3294*35238bceSAndroid Build Coastguard Worker if (rbo)
3295*35238bceSAndroid Build Coastguard Worker {
3296*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &rbo);
3297*35238bceSAndroid Build Coastguard Worker }
3298*35238bceSAndroid Build Coastguard Worker
3299*35238bceSAndroid Build Coastguard Worker if (is_error)
3300*35238bceSAndroid Build Coastguard Worker {
3301*35238bceSAndroid Build Coastguard Worker throw 0;
3302*35238bceSAndroid Build Coastguard Worker }
3303*35238bceSAndroid Build Coastguard Worker
3304*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
3305*35238bceSAndroid Build Coastguard Worker while (gl.getError())
3306*35238bceSAndroid Build Coastguard Worker ;
3307*35238bceSAndroid Build Coastguard Worker
3308*35238bceSAndroid Build Coastguard Worker return is_ok;
3309*35238bceSAndroid Build Coastguard Worker }
3310*35238bceSAndroid Build Coastguard Worker
3311*35238bceSAndroid Build Coastguard Worker /** Missing Attachment Test Case
3312*35238bceSAndroid Build Coastguard Worker *
3313*35238bceSAndroid Build Coastguard Worker * @return True if test case succeeded, false otherwise.
3314*35238bceSAndroid Build Coastguard Worker */
MissingAttachmentTestCase()3315*35238bceSAndroid Build Coastguard Worker bool CheckStatusTest::MissingAttachmentTestCase()
3316*35238bceSAndroid Build Coastguard Worker {
3317*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
3318*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
3319*35238bceSAndroid Build Coastguard Worker
3320*35238bceSAndroid Build Coastguard Worker /* Test result */
3321*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
3322*35238bceSAndroid Build Coastguard Worker bool is_error = false;
3323*35238bceSAndroid Build Coastguard Worker
3324*35238bceSAndroid Build Coastguard Worker /* Test objects. */
3325*35238bceSAndroid Build Coastguard Worker glw::GLuint fbo = 0;
3326*35238bceSAndroid Build Coastguard Worker
3327*35238bceSAndroid Build Coastguard Worker try
3328*35238bceSAndroid Build Coastguard Worker {
3329*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(1, &fbo);
3330*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
3331*35238bceSAndroid Build Coastguard Worker
3332*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, fbo);
3333*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
3334*35238bceSAndroid Build Coastguard Worker
3335*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
3336*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
3337*35238bceSAndroid Build Coastguard Worker
3338*35238bceSAndroid Build Coastguard Worker glw::GLenum status = 0;
3339*35238bceSAndroid Build Coastguard Worker
3340*35238bceSAndroid Build Coastguard Worker /* Check that framebuffer is complete. */
3341*35238bceSAndroid Build Coastguard Worker if (GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT !=
3342*35238bceSAndroid Build Coastguard Worker (status = gl.checkNamedFramebufferStatus(fbo, GL_FRAMEBUFFER)))
3343*35238bceSAndroid Build Coastguard Worker {
3344*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
3345*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message
3346*35238bceSAndroid Build Coastguard Worker << "CheckNamedFramebufferStatus did not return FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT value. "
3347*35238bceSAndroid Build Coastguard Worker << glu::getFramebufferStatusStr(status) << " was observed instead." << tcu::TestLog::EndMessage;
3348*35238bceSAndroid Build Coastguard Worker
3349*35238bceSAndroid Build Coastguard Worker is_ok = false;
3350*35238bceSAndroid Build Coastguard Worker }
3351*35238bceSAndroid Build Coastguard Worker }
3352*35238bceSAndroid Build Coastguard Worker catch (...)
3353*35238bceSAndroid Build Coastguard Worker {
3354*35238bceSAndroid Build Coastguard Worker is_ok = false;
3355*35238bceSAndroid Build Coastguard Worker is_error = true;
3356*35238bceSAndroid Build Coastguard Worker }
3357*35238bceSAndroid Build Coastguard Worker
3358*35238bceSAndroid Build Coastguard Worker /* Releasing obnjects. */
3359*35238bceSAndroid Build Coastguard Worker if (fbo)
3360*35238bceSAndroid Build Coastguard Worker {
3361*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &fbo);
3362*35238bceSAndroid Build Coastguard Worker }
3363*35238bceSAndroid Build Coastguard Worker
3364*35238bceSAndroid Build Coastguard Worker if (is_error)
3365*35238bceSAndroid Build Coastguard Worker {
3366*35238bceSAndroid Build Coastguard Worker throw 0;
3367*35238bceSAndroid Build Coastguard Worker }
3368*35238bceSAndroid Build Coastguard Worker
3369*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
3370*35238bceSAndroid Build Coastguard Worker while (gl.getError())
3371*35238bceSAndroid Build Coastguard Worker ;
3372*35238bceSAndroid Build Coastguard Worker
3373*35238bceSAndroid Build Coastguard Worker return is_ok;
3374*35238bceSAndroid Build Coastguard Worker }
3375*35238bceSAndroid Build Coastguard Worker
3376*35238bceSAndroid Build Coastguard Worker /** Incomplete Multisample Renderbuffer Test Case
3377*35238bceSAndroid Build Coastguard Worker *
3378*35238bceSAndroid Build Coastguard Worker * @return True if test case succeeded, false otherwise.
3379*35238bceSAndroid Build Coastguard Worker */
IncompleteMultisampleRenderbufferTestCase()3380*35238bceSAndroid Build Coastguard Worker bool CheckStatusTest::IncompleteMultisampleRenderbufferTestCase()
3381*35238bceSAndroid Build Coastguard Worker {
3382*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
3383*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
3384*35238bceSAndroid Build Coastguard Worker
3385*35238bceSAndroid Build Coastguard Worker /* Test result */
3386*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
3387*35238bceSAndroid Build Coastguard Worker bool is_error = false;
3388*35238bceSAndroid Build Coastguard Worker
3389*35238bceSAndroid Build Coastguard Worker /* Test objects. */
3390*35238bceSAndroid Build Coastguard Worker glw::GLuint fbo = 0;
3391*35238bceSAndroid Build Coastguard Worker glw::GLuint rbo[2] = {0};
3392*35238bceSAndroid Build Coastguard Worker
3393*35238bceSAndroid Build Coastguard Worker try
3394*35238bceSAndroid Build Coastguard Worker {
3395*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(1, &fbo);
3396*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
3397*35238bceSAndroid Build Coastguard Worker
3398*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, fbo);
3399*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
3400*35238bceSAndroid Build Coastguard Worker
3401*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(2, rbo);
3402*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
3403*35238bceSAndroid Build Coastguard Worker
3404*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, rbo[0]);
3405*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
3406*35238bceSAndroid Build Coastguard Worker
3407*35238bceSAndroid Build Coastguard Worker gl.renderbufferStorageMultisample(GL_RENDERBUFFER, 1, GL_R8, 1, 1);
3408*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
3409*35238bceSAndroid Build Coastguard Worker
3410*35238bceSAndroid Build Coastguard Worker gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[0]);
3411*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
3412*35238bceSAndroid Build Coastguard Worker
3413*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, rbo[1]);
3414*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
3415*35238bceSAndroid Build Coastguard Worker
3416*35238bceSAndroid Build Coastguard Worker gl.renderbufferStorageMultisample(GL_RENDERBUFFER, 2, GL_R8, 1, 1);
3417*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
3418*35238bceSAndroid Build Coastguard Worker
3419*35238bceSAndroid Build Coastguard Worker gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_RENDERBUFFER, rbo[1]);
3420*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
3421*35238bceSAndroid Build Coastguard Worker
3422*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
3423*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
3424*35238bceSAndroid Build Coastguard Worker
3425*35238bceSAndroid Build Coastguard Worker glw::GLenum status = 0;
3426*35238bceSAndroid Build Coastguard Worker
3427*35238bceSAndroid Build Coastguard Worker /* Check that framebuffer is complete. */
3428*35238bceSAndroid Build Coastguard Worker if (GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE != (status = gl.checkNamedFramebufferStatus(fbo, GL_FRAMEBUFFER)))
3429*35238bceSAndroid Build Coastguard Worker {
3430*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
3431*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message
3432*35238bceSAndroid Build Coastguard Worker << "CheckNamedFramebufferStatus did not return FRAMEBUFFER_INCOMPLETE_MULTISAMPLE value. "
3433*35238bceSAndroid Build Coastguard Worker << glu::getFramebufferStatusStr(status) << " was observed instead." << tcu::TestLog::EndMessage;
3434*35238bceSAndroid Build Coastguard Worker
3435*35238bceSAndroid Build Coastguard Worker is_ok = false;
3436*35238bceSAndroid Build Coastguard Worker }
3437*35238bceSAndroid Build Coastguard Worker }
3438*35238bceSAndroid Build Coastguard Worker catch (...)
3439*35238bceSAndroid Build Coastguard Worker {
3440*35238bceSAndroid Build Coastguard Worker is_ok = false;
3441*35238bceSAndroid Build Coastguard Worker is_error = true;
3442*35238bceSAndroid Build Coastguard Worker }
3443*35238bceSAndroid Build Coastguard Worker
3444*35238bceSAndroid Build Coastguard Worker /* Releasing obnjects. */
3445*35238bceSAndroid Build Coastguard Worker if (fbo)
3446*35238bceSAndroid Build Coastguard Worker {
3447*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &fbo);
3448*35238bceSAndroid Build Coastguard Worker }
3449*35238bceSAndroid Build Coastguard Worker
3450*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < 2; ++i)
3451*35238bceSAndroid Build Coastguard Worker {
3452*35238bceSAndroid Build Coastguard Worker if (rbo[i])
3453*35238bceSAndroid Build Coastguard Worker {
3454*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &rbo[i]);
3455*35238bceSAndroid Build Coastguard Worker }
3456*35238bceSAndroid Build Coastguard Worker }
3457*35238bceSAndroid Build Coastguard Worker
3458*35238bceSAndroid Build Coastguard Worker if (is_error)
3459*35238bceSAndroid Build Coastguard Worker {
3460*35238bceSAndroid Build Coastguard Worker throw 0;
3461*35238bceSAndroid Build Coastguard Worker }
3462*35238bceSAndroid Build Coastguard Worker
3463*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
3464*35238bceSAndroid Build Coastguard Worker while (gl.getError())
3465*35238bceSAndroid Build Coastguard Worker ;
3466*35238bceSAndroid Build Coastguard Worker
3467*35238bceSAndroid Build Coastguard Worker return is_ok;
3468*35238bceSAndroid Build Coastguard Worker }
3469*35238bceSAndroid Build Coastguard Worker
3470*35238bceSAndroid Build Coastguard Worker /** Incomplete Multisample Texture Test Case
3471*35238bceSAndroid Build Coastguard Worker *
3472*35238bceSAndroid Build Coastguard Worker * @return True if test case succeeded, false otherwise.
3473*35238bceSAndroid Build Coastguard Worker */
IncompleteMultisampleTextureTestCase()3474*35238bceSAndroid Build Coastguard Worker bool CheckStatusTest::IncompleteMultisampleTextureTestCase()
3475*35238bceSAndroid Build Coastguard Worker {
3476*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
3477*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
3478*35238bceSAndroid Build Coastguard Worker
3479*35238bceSAndroid Build Coastguard Worker /* Test result */
3480*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
3481*35238bceSAndroid Build Coastguard Worker bool is_error = false;
3482*35238bceSAndroid Build Coastguard Worker
3483*35238bceSAndroid Build Coastguard Worker /* Test objects. */
3484*35238bceSAndroid Build Coastguard Worker glw::GLuint fbo = 0;
3485*35238bceSAndroid Build Coastguard Worker glw::GLuint rbo = 0;
3486*35238bceSAndroid Build Coastguard Worker glw::GLuint to[2] = {0};
3487*35238bceSAndroid Build Coastguard Worker
3488*35238bceSAndroid Build Coastguard Worker try
3489*35238bceSAndroid Build Coastguard Worker {
3490*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(1, &fbo);
3491*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
3492*35238bceSAndroid Build Coastguard Worker
3493*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, fbo);
3494*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
3495*35238bceSAndroid Build Coastguard Worker
3496*35238bceSAndroid Build Coastguard Worker gl.genTextures(2, to);
3497*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
3498*35238bceSAndroid Build Coastguard Worker
3499*35238bceSAndroid Build Coastguard Worker gl.bindTexture(GL_TEXTURE_2D_MULTISAMPLE, to[0]);
3500*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
3501*35238bceSAndroid Build Coastguard Worker
3502*35238bceSAndroid Build Coastguard Worker gl.texStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 2, GL_R8, 1, 1, GL_FALSE);
3503*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2DMultisample has failed");
3504*35238bceSAndroid Build Coastguard Worker
3505*35238bceSAndroid Build Coastguard Worker gl.framebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, to[0], 0);
3506*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
3507*35238bceSAndroid Build Coastguard Worker
3508*35238bceSAndroid Build Coastguard Worker gl.bindTexture(GL_TEXTURE_2D_MULTISAMPLE, to[1]);
3509*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
3510*35238bceSAndroid Build Coastguard Worker
3511*35238bceSAndroid Build Coastguard Worker gl.texStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_R8, 1, 1, GL_TRUE);
3512*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2DMultisample has failed");
3513*35238bceSAndroid Build Coastguard Worker
3514*35238bceSAndroid Build Coastguard Worker gl.framebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, to[1], 0);
3515*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
3516*35238bceSAndroid Build Coastguard Worker
3517*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(1, &rbo);
3518*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
3519*35238bceSAndroid Build Coastguard Worker
3520*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, rbo);
3521*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
3522*35238bceSAndroid Build Coastguard Worker
3523*35238bceSAndroid Build Coastguard Worker gl.renderbufferStorageMultisample(GL_RENDERBUFFER, 1, GL_R8, 1, 1);
3524*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
3525*35238bceSAndroid Build Coastguard Worker
3526*35238bceSAndroid Build Coastguard Worker gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_RENDERBUFFER, rbo);
3527*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
3528*35238bceSAndroid Build Coastguard Worker
3529*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
3530*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
3531*35238bceSAndroid Build Coastguard Worker
3532*35238bceSAndroid Build Coastguard Worker glw::GLenum status = 0;
3533*35238bceSAndroid Build Coastguard Worker
3534*35238bceSAndroid Build Coastguard Worker /* Check that framebuffer is complete. */
3535*35238bceSAndroid Build Coastguard Worker if (GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE != (status = gl.checkNamedFramebufferStatus(fbo, GL_FRAMEBUFFER)))
3536*35238bceSAndroid Build Coastguard Worker {
3537*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
3538*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message
3539*35238bceSAndroid Build Coastguard Worker << "CheckNamedFramebufferStatus did not return FRAMEBUFFER_INCOMPLETE_MULTISAMPLE value. "
3540*35238bceSAndroid Build Coastguard Worker << glu::getFramebufferStatusStr(status) << " was observed instead." << tcu::TestLog::EndMessage;
3541*35238bceSAndroid Build Coastguard Worker
3542*35238bceSAndroid Build Coastguard Worker is_ok = false;
3543*35238bceSAndroid Build Coastguard Worker }
3544*35238bceSAndroid Build Coastguard Worker }
3545*35238bceSAndroid Build Coastguard Worker catch (...)
3546*35238bceSAndroid Build Coastguard Worker {
3547*35238bceSAndroid Build Coastguard Worker is_ok = false;
3548*35238bceSAndroid Build Coastguard Worker is_error = true;
3549*35238bceSAndroid Build Coastguard Worker }
3550*35238bceSAndroid Build Coastguard Worker
3551*35238bceSAndroid Build Coastguard Worker /* Releasing obnjects. */
3552*35238bceSAndroid Build Coastguard Worker if (fbo)
3553*35238bceSAndroid Build Coastguard Worker {
3554*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &fbo);
3555*35238bceSAndroid Build Coastguard Worker }
3556*35238bceSAndroid Build Coastguard Worker
3557*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < 2; ++i)
3558*35238bceSAndroid Build Coastguard Worker {
3559*35238bceSAndroid Build Coastguard Worker if (to[i])
3560*35238bceSAndroid Build Coastguard Worker {
3561*35238bceSAndroid Build Coastguard Worker gl.deleteTextures(1, &to[i]);
3562*35238bceSAndroid Build Coastguard Worker }
3563*35238bceSAndroid Build Coastguard Worker }
3564*35238bceSAndroid Build Coastguard Worker
3565*35238bceSAndroid Build Coastguard Worker if (rbo)
3566*35238bceSAndroid Build Coastguard Worker {
3567*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &rbo);
3568*35238bceSAndroid Build Coastguard Worker }
3569*35238bceSAndroid Build Coastguard Worker
3570*35238bceSAndroid Build Coastguard Worker if (is_error)
3571*35238bceSAndroid Build Coastguard Worker {
3572*35238bceSAndroid Build Coastguard Worker throw 0;
3573*35238bceSAndroid Build Coastguard Worker }
3574*35238bceSAndroid Build Coastguard Worker
3575*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
3576*35238bceSAndroid Build Coastguard Worker while (gl.getError())
3577*35238bceSAndroid Build Coastguard Worker ;
3578*35238bceSAndroid Build Coastguard Worker
3579*35238bceSAndroid Build Coastguard Worker return is_ok;
3580*35238bceSAndroid Build Coastguard Worker }
3581*35238bceSAndroid Build Coastguard Worker
3582*35238bceSAndroid Build Coastguard Worker /** Incomplete Layer Targets Test Case
3583*35238bceSAndroid Build Coastguard Worker *
3584*35238bceSAndroid Build Coastguard Worker * @return True if test case succeeded, false otherwise.
3585*35238bceSAndroid Build Coastguard Worker */
IncompleteLayerTargetsTestCase()3586*35238bceSAndroid Build Coastguard Worker bool CheckStatusTest::IncompleteLayerTargetsTestCase()
3587*35238bceSAndroid Build Coastguard Worker {
3588*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
3589*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
3590*35238bceSAndroid Build Coastguard Worker
3591*35238bceSAndroid Build Coastguard Worker /* Test result */
3592*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
3593*35238bceSAndroid Build Coastguard Worker bool is_error = false;
3594*35238bceSAndroid Build Coastguard Worker
3595*35238bceSAndroid Build Coastguard Worker /* Test objects. */
3596*35238bceSAndroid Build Coastguard Worker glw::GLuint fbo = 0;
3597*35238bceSAndroid Build Coastguard Worker glw::GLuint to[2] = {0};
3598*35238bceSAndroid Build Coastguard Worker
3599*35238bceSAndroid Build Coastguard Worker try
3600*35238bceSAndroid Build Coastguard Worker {
3601*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(1, &fbo);
3602*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
3603*35238bceSAndroid Build Coastguard Worker
3604*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, fbo);
3605*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
3606*35238bceSAndroid Build Coastguard Worker
3607*35238bceSAndroid Build Coastguard Worker gl.genTextures(2, to);
3608*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
3609*35238bceSAndroid Build Coastguard Worker
3610*35238bceSAndroid Build Coastguard Worker gl.bindTexture(GL_TEXTURE_3D, to[0]);
3611*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
3612*35238bceSAndroid Build Coastguard Worker
3613*35238bceSAndroid Build Coastguard Worker gl.texStorage3D(GL_TEXTURE_3D, 1, GL_R8, 2, 2, 2);
3614*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2DMultisample has failed");
3615*35238bceSAndroid Build Coastguard Worker
3616*35238bceSAndroid Build Coastguard Worker gl.framebufferTexture3D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_3D, to[0], 0, 0);
3617*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
3618*35238bceSAndroid Build Coastguard Worker
3619*35238bceSAndroid Build Coastguard Worker gl.bindTexture(GL_TEXTURE_2D, to[1]);
3620*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
3621*35238bceSAndroid Build Coastguard Worker
3622*35238bceSAndroid Build Coastguard Worker gl.texStorage2D(GL_TEXTURE_2D, 1, GL_R8, 1, 1);
3623*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2DMultisample has failed");
3624*35238bceSAndroid Build Coastguard Worker
3625*35238bceSAndroid Build Coastguard Worker gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, to[1], 0);
3626*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
3627*35238bceSAndroid Build Coastguard Worker
3628*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
3629*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
3630*35238bceSAndroid Build Coastguard Worker
3631*35238bceSAndroid Build Coastguard Worker glw::GLenum status = 0;
3632*35238bceSAndroid Build Coastguard Worker
3633*35238bceSAndroid Build Coastguard Worker /* Check that framebuffer is complete. */
3634*35238bceSAndroid Build Coastguard Worker if (GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS != (status = gl.checkNamedFramebufferStatus(fbo, GL_FRAMEBUFFER)))
3635*35238bceSAndroid Build Coastguard Worker {
3636*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
3637*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message
3638*35238bceSAndroid Build Coastguard Worker << "CheckNamedFramebufferStatus did not return FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS value. "
3639*35238bceSAndroid Build Coastguard Worker << glu::getFramebufferStatusStr(status) << " was observed instead." << tcu::TestLog::EndMessage;
3640*35238bceSAndroid Build Coastguard Worker
3641*35238bceSAndroid Build Coastguard Worker is_ok = false;
3642*35238bceSAndroid Build Coastguard Worker }
3643*35238bceSAndroid Build Coastguard Worker }
3644*35238bceSAndroid Build Coastguard Worker catch (...)
3645*35238bceSAndroid Build Coastguard Worker {
3646*35238bceSAndroid Build Coastguard Worker is_ok = false;
3647*35238bceSAndroid Build Coastguard Worker is_error = true;
3648*35238bceSAndroid Build Coastguard Worker }
3649*35238bceSAndroid Build Coastguard Worker
3650*35238bceSAndroid Build Coastguard Worker /* Releasing obnjects. */
3651*35238bceSAndroid Build Coastguard Worker if (fbo)
3652*35238bceSAndroid Build Coastguard Worker {
3653*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &fbo);
3654*35238bceSAndroid Build Coastguard Worker }
3655*35238bceSAndroid Build Coastguard Worker
3656*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < 2; ++i)
3657*35238bceSAndroid Build Coastguard Worker {
3658*35238bceSAndroid Build Coastguard Worker if (to[i])
3659*35238bceSAndroid Build Coastguard Worker {
3660*35238bceSAndroid Build Coastguard Worker gl.deleteTextures(1, &to[i]);
3661*35238bceSAndroid Build Coastguard Worker }
3662*35238bceSAndroid Build Coastguard Worker }
3663*35238bceSAndroid Build Coastguard Worker
3664*35238bceSAndroid Build Coastguard Worker if (is_error)
3665*35238bceSAndroid Build Coastguard Worker {
3666*35238bceSAndroid Build Coastguard Worker throw 0;
3667*35238bceSAndroid Build Coastguard Worker }
3668*35238bceSAndroid Build Coastguard Worker
3669*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
3670*35238bceSAndroid Build Coastguard Worker while (gl.getError())
3671*35238bceSAndroid Build Coastguard Worker ;
3672*35238bceSAndroid Build Coastguard Worker
3673*35238bceSAndroid Build Coastguard Worker return is_ok;
3674*35238bceSAndroid Build Coastguard Worker }
3675*35238bceSAndroid Build Coastguard Worker
3676*35238bceSAndroid Build Coastguard Worker /******************************** Get Named Framebuffer Parameters Test Implementation ********************************/
3677*35238bceSAndroid Build Coastguard Worker
3678*35238bceSAndroid Build Coastguard Worker /** @brief Get Named Framebuffer Parameters Test constructor.
3679*35238bceSAndroid Build Coastguard Worker *
3680*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
3681*35238bceSAndroid Build Coastguard Worker */
GetParametersTest(deqp::Context & context)3682*35238bceSAndroid Build Coastguard Worker GetParametersTest::GetParametersTest(deqp::Context &context)
3683*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "framebuffers_get_parameters", "Get Named Framebuffer Parameters Test")
3684*35238bceSAndroid Build Coastguard Worker , m_fbo(0)
3685*35238bceSAndroid Build Coastguard Worker , m_rbo(0)
3686*35238bceSAndroid Build Coastguard Worker {
3687*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
3688*35238bceSAndroid Build Coastguard Worker }
3689*35238bceSAndroid Build Coastguard Worker
3690*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Check Status Test cases.
3691*35238bceSAndroid Build Coastguard Worker *
3692*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
3693*35238bceSAndroid Build Coastguard Worker */
iterate()3694*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult GetParametersTest::iterate()
3695*35238bceSAndroid Build Coastguard Worker {
3696*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
3697*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
3698*35238bceSAndroid Build Coastguard Worker
3699*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
3700*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
3701*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
3702*35238bceSAndroid Build Coastguard Worker
3703*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
3704*35238bceSAndroid Build Coastguard Worker {
3705*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
3706*35238bceSAndroid Build Coastguard Worker
3707*35238bceSAndroid Build Coastguard Worker return STOP;
3708*35238bceSAndroid Build Coastguard Worker }
3709*35238bceSAndroid Build Coastguard Worker
3710*35238bceSAndroid Build Coastguard Worker /* Running tests. */
3711*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
3712*35238bceSAndroid Build Coastguard Worker bool is_error = false;
3713*35238bceSAndroid Build Coastguard Worker
3714*35238bceSAndroid Build Coastguard Worker try
3715*35238bceSAndroid Build Coastguard Worker {
3716*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
3717*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
3718*35238bceSAndroid Build Coastguard Worker
3719*35238bceSAndroid Build Coastguard Worker is_ok &= TestDefaultFramebuffer();
3720*35238bceSAndroid Build Coastguard Worker
3721*35238bceSAndroid Build Coastguard Worker PrepareFramebuffer();
3722*35238bceSAndroid Build Coastguard Worker
3723*35238bceSAndroid Build Coastguard Worker is_ok &= TestCustomFramebuffer();
3724*35238bceSAndroid Build Coastguard Worker }
3725*35238bceSAndroid Build Coastguard Worker catch (...)
3726*35238bceSAndroid Build Coastguard Worker {
3727*35238bceSAndroid Build Coastguard Worker is_ok = false;
3728*35238bceSAndroid Build Coastguard Worker is_error = true;
3729*35238bceSAndroid Build Coastguard Worker }
3730*35238bceSAndroid Build Coastguard Worker
3731*35238bceSAndroid Build Coastguard Worker /* Clean up. */
3732*35238bceSAndroid Build Coastguard Worker Clean();
3733*35238bceSAndroid Build Coastguard Worker
3734*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
3735*35238bceSAndroid Build Coastguard Worker if (is_ok)
3736*35238bceSAndroid Build Coastguard Worker {
3737*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
3738*35238bceSAndroid Build Coastguard Worker }
3739*35238bceSAndroid Build Coastguard Worker else
3740*35238bceSAndroid Build Coastguard Worker {
3741*35238bceSAndroid Build Coastguard Worker if (is_error)
3742*35238bceSAndroid Build Coastguard Worker {
3743*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
3744*35238bceSAndroid Build Coastguard Worker }
3745*35238bceSAndroid Build Coastguard Worker else
3746*35238bceSAndroid Build Coastguard Worker {
3747*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
3748*35238bceSAndroid Build Coastguard Worker }
3749*35238bceSAndroid Build Coastguard Worker }
3750*35238bceSAndroid Build Coastguard Worker
3751*35238bceSAndroid Build Coastguard Worker return STOP;
3752*35238bceSAndroid Build Coastguard Worker }
3753*35238bceSAndroid Build Coastguard Worker
3754*35238bceSAndroid Build Coastguard Worker /** @brief Prepare framebuffer.
3755*35238bceSAndroid Build Coastguard Worker */
PrepareFramebuffer()3756*35238bceSAndroid Build Coastguard Worker void GetParametersTest::PrepareFramebuffer()
3757*35238bceSAndroid Build Coastguard Worker {
3758*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
3759*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
3760*35238bceSAndroid Build Coastguard Worker
3761*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(1, &m_fbo);
3762*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
3763*35238bceSAndroid Build Coastguard Worker
3764*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
3765*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
3766*35238bceSAndroid Build Coastguard Worker
3767*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(1, &m_rbo);
3768*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
3769*35238bceSAndroid Build Coastguard Worker
3770*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo);
3771*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
3772*35238bceSAndroid Build Coastguard Worker
3773*35238bceSAndroid Build Coastguard Worker gl.renderbufferStorage(GL_RENDERBUFFER, GL_R8, 1, 2);
3774*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
3775*35238bceSAndroid Build Coastguard Worker
3776*35238bceSAndroid Build Coastguard Worker gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo);
3777*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
3778*35238bceSAndroid Build Coastguard Worker
3779*35238bceSAndroid Build Coastguard Worker /* Check that framebuffer is complete. */
3780*35238bceSAndroid Build Coastguard Worker if (GL_FRAMEBUFFER_COMPLETE != glCheckFramebufferStatus(GL_FRAMEBUFFER))
3781*35238bceSAndroid Build Coastguard Worker {
3782*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
3783*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Unexpectedly framebuffer was incomplete." << tcu::TestLog::EndMessage;
3784*35238bceSAndroid Build Coastguard Worker
3785*35238bceSAndroid Build Coastguard Worker throw 0;
3786*35238bceSAndroid Build Coastguard Worker }
3787*35238bceSAndroid Build Coastguard Worker }
3788*35238bceSAndroid Build Coastguard Worker
3789*35238bceSAndroid Build Coastguard Worker /** Default framebuffer Test Case
3790*35238bceSAndroid Build Coastguard Worker *
3791*35238bceSAndroid Build Coastguard Worker * @return True if test case succeeded, false otherwise.
3792*35238bceSAndroid Build Coastguard Worker */
TestDefaultFramebuffer()3793*35238bceSAndroid Build Coastguard Worker bool GetParametersTest::TestDefaultFramebuffer()
3794*35238bceSAndroid Build Coastguard Worker {
3795*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
3796*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
3797*35238bceSAndroid Build Coastguard Worker
3798*35238bceSAndroid Build Coastguard Worker /* Result. */
3799*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
3800*35238bceSAndroid Build Coastguard Worker
3801*35238bceSAndroid Build Coastguard Worker static const glw::GLenum pnames[] = {GL_DOUBLEBUFFER,
3802*35238bceSAndroid Build Coastguard Worker GL_IMPLEMENTATION_COLOR_READ_FORMAT,
3803*35238bceSAndroid Build Coastguard Worker GL_IMPLEMENTATION_COLOR_READ_TYPE,
3804*35238bceSAndroid Build Coastguard Worker GL_SAMPLES,
3805*35238bceSAndroid Build Coastguard Worker GL_SAMPLE_BUFFERS,
3806*35238bceSAndroid Build Coastguard Worker GL_STEREO};
3807*35238bceSAndroid Build Coastguard Worker
3808*35238bceSAndroid Build Coastguard Worker static const glw::GLchar *pnames_strings[] = {"GL_DOUBLEBUFFER",
3809*35238bceSAndroid Build Coastguard Worker "GL_IMPLEMENTATION_COLOR_READ_FORMAT",
3810*35238bceSAndroid Build Coastguard Worker "GL_IMPLEMENTATION_COLOR_READ_TYPE",
3811*35238bceSAndroid Build Coastguard Worker "GL_SAMPLES",
3812*35238bceSAndroid Build Coastguard Worker "GL_SAMPLE_BUFFERS",
3813*35238bceSAndroid Build Coastguard Worker "GL_STEREO"};
3814*35238bceSAndroid Build Coastguard Worker
3815*35238bceSAndroid Build Coastguard Worker glw::GLuint pnames_count = sizeof(pnames) / sizeof(pnames[0]);
3816*35238bceSAndroid Build Coastguard Worker
3817*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < pnames_count; ++i)
3818*35238bceSAndroid Build Coastguard Worker {
3819*35238bceSAndroid Build Coastguard Worker glw::GLint parameter_legacy = 0;
3820*35238bceSAndroid Build Coastguard Worker glw::GLint parameter_dsa = 0;
3821*35238bceSAndroid Build Coastguard Worker
3822*35238bceSAndroid Build Coastguard Worker gl.getFramebufferParameteriv(GL_FRAMEBUFFER, pnames[i], ¶meter_legacy);
3823*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetFramebufferParameteriv has failed");
3824*35238bceSAndroid Build Coastguard Worker
3825*35238bceSAndroid Build Coastguard Worker gl.getNamedFramebufferParameteriv(0, pnames[i], ¶meter_dsa);
3826*35238bceSAndroid Build Coastguard Worker
3827*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
3828*35238bceSAndroid Build Coastguard Worker {
3829*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
3830*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "GetNamedFramebufferParameteriv unexpectedly generated "
3831*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(error) << " error when called with " << pnames_strings[i]
3832*35238bceSAndroid Build Coastguard Worker << " parameter name for default framebuffer." << tcu::TestLog::EndMessage;
3833*35238bceSAndroid Build Coastguard Worker
3834*35238bceSAndroid Build Coastguard Worker is_ok = false;
3835*35238bceSAndroid Build Coastguard Worker
3836*35238bceSAndroid Build Coastguard Worker continue;
3837*35238bceSAndroid Build Coastguard Worker }
3838*35238bceSAndroid Build Coastguard Worker
3839*35238bceSAndroid Build Coastguard Worker if (parameter_legacy != parameter_dsa)
3840*35238bceSAndroid Build Coastguard Worker {
3841*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
3842*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "GetNamedFramebufferParameteriv returned " << parameter_dsa << ", but "
3843*35238bceSAndroid Build Coastguard Worker << parameter_legacy << " was expected for " << pnames_strings[i] << " parameter name of default object."
3844*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
3845*35238bceSAndroid Build Coastguard Worker
3846*35238bceSAndroid Build Coastguard Worker is_ok = false;
3847*35238bceSAndroid Build Coastguard Worker }
3848*35238bceSAndroid Build Coastguard Worker }
3849*35238bceSAndroid Build Coastguard Worker
3850*35238bceSAndroid Build Coastguard Worker return is_ok;
3851*35238bceSAndroid Build Coastguard Worker }
3852*35238bceSAndroid Build Coastguard Worker
3853*35238bceSAndroid Build Coastguard Worker /** Framebuffer Object Test Case
3854*35238bceSAndroid Build Coastguard Worker *
3855*35238bceSAndroid Build Coastguard Worker * @return True if test case succeeded, false otherwise.
3856*35238bceSAndroid Build Coastguard Worker */
TestCustomFramebuffer()3857*35238bceSAndroid Build Coastguard Worker bool GetParametersTest::TestCustomFramebuffer()
3858*35238bceSAndroid Build Coastguard Worker {
3859*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
3860*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
3861*35238bceSAndroid Build Coastguard Worker
3862*35238bceSAndroid Build Coastguard Worker /* Result. */
3863*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
3864*35238bceSAndroid Build Coastguard Worker
3865*35238bceSAndroid Build Coastguard Worker static const glw::GLenum pnames[] = {GL_DOUBLEBUFFER,
3866*35238bceSAndroid Build Coastguard Worker GL_IMPLEMENTATION_COLOR_READ_FORMAT,
3867*35238bceSAndroid Build Coastguard Worker GL_IMPLEMENTATION_COLOR_READ_TYPE,
3868*35238bceSAndroid Build Coastguard Worker GL_SAMPLES,
3869*35238bceSAndroid Build Coastguard Worker GL_SAMPLE_BUFFERS,
3870*35238bceSAndroid Build Coastguard Worker GL_STEREO,
3871*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_DEFAULT_WIDTH,
3872*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_DEFAULT_HEIGHT,
3873*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_DEFAULT_LAYERS,
3874*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_DEFAULT_SAMPLES,
3875*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS};
3876*35238bceSAndroid Build Coastguard Worker
3877*35238bceSAndroid Build Coastguard Worker static const glw::GLchar *pnames_strings[] = {"GL_DOUBLEBUFFER",
3878*35238bceSAndroid Build Coastguard Worker "GL_IMPLEMENTATION_COLOR_READ_FORMAT",
3879*35238bceSAndroid Build Coastguard Worker "GL_IMPLEMENTATION_COLOR_READ_TYPE",
3880*35238bceSAndroid Build Coastguard Worker "GL_SAMPLES",
3881*35238bceSAndroid Build Coastguard Worker "GL_SAMPLE_BUFFERS",
3882*35238bceSAndroid Build Coastguard Worker "GL_STEREO",
3883*35238bceSAndroid Build Coastguard Worker "FRAMEBUFFER_DEFAULT_WIDTH",
3884*35238bceSAndroid Build Coastguard Worker "FRAMEBUFFER_DEFAULT_HEIGHT",
3885*35238bceSAndroid Build Coastguard Worker "FRAMEBUFFER_DEFAULT_LAYERS",
3886*35238bceSAndroid Build Coastguard Worker "FRAMEBUFFER_DEFAULT_SAMPLES",
3887*35238bceSAndroid Build Coastguard Worker "FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS"};
3888*35238bceSAndroid Build Coastguard Worker
3889*35238bceSAndroid Build Coastguard Worker glw::GLuint pnames_count = sizeof(pnames) / sizeof(pnames[0]);
3890*35238bceSAndroid Build Coastguard Worker
3891*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < pnames_count; ++i)
3892*35238bceSAndroid Build Coastguard Worker {
3893*35238bceSAndroid Build Coastguard Worker glw::GLint parameter_legacy = 0;
3894*35238bceSAndroid Build Coastguard Worker glw::GLint parameter_dsa = 0;
3895*35238bceSAndroid Build Coastguard Worker
3896*35238bceSAndroid Build Coastguard Worker gl.getFramebufferParameteriv(GL_FRAMEBUFFER, pnames[i], ¶meter_legacy);
3897*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetFramebufferParameteriv has failed");
3898*35238bceSAndroid Build Coastguard Worker
3899*35238bceSAndroid Build Coastguard Worker gl.getNamedFramebufferParameteriv(m_fbo, pnames[i], ¶meter_dsa);
3900*35238bceSAndroid Build Coastguard Worker
3901*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
3902*35238bceSAndroid Build Coastguard Worker {
3903*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
3904*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "GetNamedFramebufferParameteriv unexpectedly generated "
3905*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(error) << " error when called with " << pnames_strings[i]
3906*35238bceSAndroid Build Coastguard Worker << " parameter name for framebuffer object." << tcu::TestLog::EndMessage;
3907*35238bceSAndroid Build Coastguard Worker
3908*35238bceSAndroid Build Coastguard Worker is_ok = false;
3909*35238bceSAndroid Build Coastguard Worker
3910*35238bceSAndroid Build Coastguard Worker continue;
3911*35238bceSAndroid Build Coastguard Worker }
3912*35238bceSAndroid Build Coastguard Worker
3913*35238bceSAndroid Build Coastguard Worker if (parameter_legacy != parameter_dsa)
3914*35238bceSAndroid Build Coastguard Worker {
3915*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
3916*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "GetNamedFramebufferParameteriv returned " << parameter_dsa << ", but "
3917*35238bceSAndroid Build Coastguard Worker << parameter_legacy << " was expected for " << pnames_strings[i]
3918*35238bceSAndroid Build Coastguard Worker << " parameter name of framebuffer object." << tcu::TestLog::EndMessage;
3919*35238bceSAndroid Build Coastguard Worker
3920*35238bceSAndroid Build Coastguard Worker is_ok = false;
3921*35238bceSAndroid Build Coastguard Worker }
3922*35238bceSAndroid Build Coastguard Worker }
3923*35238bceSAndroid Build Coastguard Worker
3924*35238bceSAndroid Build Coastguard Worker return is_ok;
3925*35238bceSAndroid Build Coastguard Worker }
3926*35238bceSAndroid Build Coastguard Worker
3927*35238bceSAndroid Build Coastguard Worker /** @brief Clean up GL state.
3928*35238bceSAndroid Build Coastguard Worker */
Clean()3929*35238bceSAndroid Build Coastguard Worker void GetParametersTest::Clean()
3930*35238bceSAndroid Build Coastguard Worker {
3931*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
3932*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
3933*35238bceSAndroid Build Coastguard Worker
3934*35238bceSAndroid Build Coastguard Worker /* Releasing obnjects. */
3935*35238bceSAndroid Build Coastguard Worker if (m_fbo)
3936*35238bceSAndroid Build Coastguard Worker {
3937*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &m_fbo);
3938*35238bceSAndroid Build Coastguard Worker
3939*35238bceSAndroid Build Coastguard Worker m_fbo = 0;
3940*35238bceSAndroid Build Coastguard Worker }
3941*35238bceSAndroid Build Coastguard Worker
3942*35238bceSAndroid Build Coastguard Worker if (m_rbo)
3943*35238bceSAndroid Build Coastguard Worker {
3944*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &m_rbo);
3945*35238bceSAndroid Build Coastguard Worker
3946*35238bceSAndroid Build Coastguard Worker m_rbo = 0;
3947*35238bceSAndroid Build Coastguard Worker }
3948*35238bceSAndroid Build Coastguard Worker
3949*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
3950*35238bceSAndroid Build Coastguard Worker while (gl.getError())
3951*35238bceSAndroid Build Coastguard Worker ;
3952*35238bceSAndroid Build Coastguard Worker }
3953*35238bceSAndroid Build Coastguard Worker
3954*35238bceSAndroid Build Coastguard Worker /******************************** Get Named Framebuffer Attachment Parameters Test Implementation ********************************/
3955*35238bceSAndroid Build Coastguard Worker
3956*35238bceSAndroid Build Coastguard Worker /** @brief Get Named Framebuffer Parameters Test constructor.
3957*35238bceSAndroid Build Coastguard Worker *
3958*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
3959*35238bceSAndroid Build Coastguard Worker */
GetAttachmentParametersTest(deqp::Context & context)3960*35238bceSAndroid Build Coastguard Worker GetAttachmentParametersTest::GetAttachmentParametersTest(deqp::Context &context)
3961*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "framebuffers_get_attachment_parameters",
3962*35238bceSAndroid Build Coastguard Worker "Get Named Framebuffer Attachment Parameters Test")
3963*35238bceSAndroid Build Coastguard Worker , m_fbo(0)
3964*35238bceSAndroid Build Coastguard Worker {
3965*35238bceSAndroid Build Coastguard Worker memset(m_rbo, 0, sizeof(m_rbo));
3966*35238bceSAndroid Build Coastguard Worker memset(m_to, 0, sizeof(m_to));
3967*35238bceSAndroid Build Coastguard Worker }
3968*35238bceSAndroid Build Coastguard Worker
3969*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Get Named Framebuffer Attachment Parameters Test cases.
3970*35238bceSAndroid Build Coastguard Worker *
3971*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
3972*35238bceSAndroid Build Coastguard Worker */
iterate()3973*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult GetAttachmentParametersTest::iterate()
3974*35238bceSAndroid Build Coastguard Worker {
3975*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
3976*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
3977*35238bceSAndroid Build Coastguard Worker
3978*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
3979*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
3980*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
3981*35238bceSAndroid Build Coastguard Worker
3982*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
3983*35238bceSAndroid Build Coastguard Worker {
3984*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
3985*35238bceSAndroid Build Coastguard Worker
3986*35238bceSAndroid Build Coastguard Worker return STOP;
3987*35238bceSAndroid Build Coastguard Worker }
3988*35238bceSAndroid Build Coastguard Worker
3989*35238bceSAndroid Build Coastguard Worker /* Running tests. */
3990*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
3991*35238bceSAndroid Build Coastguard Worker bool is_error = false;
3992*35238bceSAndroid Build Coastguard Worker
3993*35238bceSAndroid Build Coastguard Worker try
3994*35238bceSAndroid Build Coastguard Worker {
3995*35238bceSAndroid Build Coastguard Worker /* Default framebuffer. */
3996*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
3997*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
3998*35238bceSAndroid Build Coastguard Worker
3999*35238bceSAndroid Build Coastguard Worker is_ok &= TestDefaultFramebuffer();
4000*35238bceSAndroid Build Coastguard Worker
4001*35238bceSAndroid Build Coastguard Worker /* Framebuffer object with renderbuffer attachments (depth only). */
4002*35238bceSAndroid Build Coastguard Worker CreateRenderbufferFramebuffer(true, false);
4003*35238bceSAndroid Build Coastguard Worker
4004*35238bceSAndroid Build Coastguard Worker is_ok &= TestRenderbufferFramebuffer(false);
4005*35238bceSAndroid Build Coastguard Worker
4006*35238bceSAndroid Build Coastguard Worker Clean();
4007*35238bceSAndroid Build Coastguard Worker
4008*35238bceSAndroid Build Coastguard Worker /* Framebuffer object with renderbuffer attachments (stencil only). */
4009*35238bceSAndroid Build Coastguard Worker CreateRenderbufferFramebuffer(false, true);
4010*35238bceSAndroid Build Coastguard Worker
4011*35238bceSAndroid Build Coastguard Worker is_ok &= TestRenderbufferFramebuffer(false);
4012*35238bceSAndroid Build Coastguard Worker
4013*35238bceSAndroid Build Coastguard Worker Clean();
4014*35238bceSAndroid Build Coastguard Worker
4015*35238bceSAndroid Build Coastguard Worker /* Framebuffer object with renderbuffer attachments (depth-stencil merged). */
4016*35238bceSAndroid Build Coastguard Worker CreateRenderbufferFramebuffer(true, true);
4017*35238bceSAndroid Build Coastguard Worker
4018*35238bceSAndroid Build Coastguard Worker is_ok &= TestRenderbufferFramebuffer(true);
4019*35238bceSAndroid Build Coastguard Worker
4020*35238bceSAndroid Build Coastguard Worker Clean();
4021*35238bceSAndroid Build Coastguard Worker
4022*35238bceSAndroid Build Coastguard Worker /* Framebuffer object with texture attachments (depth only). */
4023*35238bceSAndroid Build Coastguard Worker CreateTextureFramebuffer(true, false);
4024*35238bceSAndroid Build Coastguard Worker
4025*35238bceSAndroid Build Coastguard Worker is_ok &= TestTextureFramebuffer(false);
4026*35238bceSAndroid Build Coastguard Worker
4027*35238bceSAndroid Build Coastguard Worker Clean();
4028*35238bceSAndroid Build Coastguard Worker
4029*35238bceSAndroid Build Coastguard Worker /* Framebuffer object with texture attachments (stencil only). */
4030*35238bceSAndroid Build Coastguard Worker CreateTextureFramebuffer(false, true);
4031*35238bceSAndroid Build Coastguard Worker
4032*35238bceSAndroid Build Coastguard Worker is_ok &= TestTextureFramebuffer(false);
4033*35238bceSAndroid Build Coastguard Worker
4034*35238bceSAndroid Build Coastguard Worker Clean();
4035*35238bceSAndroid Build Coastguard Worker
4036*35238bceSAndroid Build Coastguard Worker /* Framebuffer object with texture attachments (depth-stencil merged). */
4037*35238bceSAndroid Build Coastguard Worker CreateTextureFramebuffer(true, true);
4038*35238bceSAndroid Build Coastguard Worker
4039*35238bceSAndroid Build Coastguard Worker is_ok &= TestTextureFramebuffer(true);
4040*35238bceSAndroid Build Coastguard Worker
4041*35238bceSAndroid Build Coastguard Worker Clean();
4042*35238bceSAndroid Build Coastguard Worker }
4043*35238bceSAndroid Build Coastguard Worker catch (...)
4044*35238bceSAndroid Build Coastguard Worker {
4045*35238bceSAndroid Build Coastguard Worker is_ok = false;
4046*35238bceSAndroid Build Coastguard Worker is_error = true;
4047*35238bceSAndroid Build Coastguard Worker }
4048*35238bceSAndroid Build Coastguard Worker
4049*35238bceSAndroid Build Coastguard Worker /* Clean up. */
4050*35238bceSAndroid Build Coastguard Worker Clean();
4051*35238bceSAndroid Build Coastguard Worker
4052*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
4053*35238bceSAndroid Build Coastguard Worker if (is_ok)
4054*35238bceSAndroid Build Coastguard Worker {
4055*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
4056*35238bceSAndroid Build Coastguard Worker }
4057*35238bceSAndroid Build Coastguard Worker else
4058*35238bceSAndroid Build Coastguard Worker {
4059*35238bceSAndroid Build Coastguard Worker if (is_error)
4060*35238bceSAndroid Build Coastguard Worker {
4061*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
4062*35238bceSAndroid Build Coastguard Worker }
4063*35238bceSAndroid Build Coastguard Worker else
4064*35238bceSAndroid Build Coastguard Worker {
4065*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
4066*35238bceSAndroid Build Coastguard Worker }
4067*35238bceSAndroid Build Coastguard Worker }
4068*35238bceSAndroid Build Coastguard Worker
4069*35238bceSAndroid Build Coastguard Worker return STOP;
4070*35238bceSAndroid Build Coastguard Worker }
4071*35238bceSAndroid Build Coastguard Worker
4072*35238bceSAndroid Build Coastguard Worker /** Create framebuffer with renderbuffer
4073*35238bceSAndroid Build Coastguard Worker *
4074*35238bceSAndroid Build Coastguard Worker * @param [in] depth Prepare framebuffer with depth buffer.
4075*35238bceSAndroid Build Coastguard Worker * @param [in] stencil Prepare framebuffer with stencil buffer.
4076*35238bceSAndroid Build Coastguard Worker *
4077*35238bceSAndroid Build Coastguard Worker * @note If both depth and stencil, the joined dept_stencil buffer will be created.
4078*35238bceSAndroid Build Coastguard Worker */
CreateRenderbufferFramebuffer(bool depth,bool stencil)4079*35238bceSAndroid Build Coastguard Worker void GetAttachmentParametersTest::CreateRenderbufferFramebuffer(bool depth, bool stencil)
4080*35238bceSAndroid Build Coastguard Worker {
4081*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
4082*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
4083*35238bceSAndroid Build Coastguard Worker
4084*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(1, &m_fbo);
4085*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
4086*35238bceSAndroid Build Coastguard Worker
4087*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
4088*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
4089*35238bceSAndroid Build Coastguard Worker
4090*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(2, m_rbo);
4091*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
4092*35238bceSAndroid Build Coastguard Worker
4093*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo[0]);
4094*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
4095*35238bceSAndroid Build Coastguard Worker
4096*35238bceSAndroid Build Coastguard Worker gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 1, 2);
4097*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
4098*35238bceSAndroid Build Coastguard Worker
4099*35238bceSAndroid Build Coastguard Worker gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo[0]);
4100*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
4101*35238bceSAndroid Build Coastguard Worker
4102*35238bceSAndroid Build Coastguard Worker if (depth && (!stencil))
4103*35238bceSAndroid Build Coastguard Worker {
4104*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo[1]);
4105*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
4106*35238bceSAndroid Build Coastguard Worker
4107*35238bceSAndroid Build Coastguard Worker gl.renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, 1, 2);
4108*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
4109*35238bceSAndroid Build Coastguard Worker
4110*35238bceSAndroid Build Coastguard Worker gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_rbo[1]);
4111*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
4112*35238bceSAndroid Build Coastguard Worker }
4113*35238bceSAndroid Build Coastguard Worker
4114*35238bceSAndroid Build Coastguard Worker if ((!depth) && stencil)
4115*35238bceSAndroid Build Coastguard Worker {
4116*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo[1]);
4117*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
4118*35238bceSAndroid Build Coastguard Worker
4119*35238bceSAndroid Build Coastguard Worker gl.renderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, 1, 2);
4120*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
4121*35238bceSAndroid Build Coastguard Worker
4122*35238bceSAndroid Build Coastguard Worker gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_rbo[1]);
4123*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
4124*35238bceSAndroid Build Coastguard Worker }
4125*35238bceSAndroid Build Coastguard Worker
4126*35238bceSAndroid Build Coastguard Worker if (depth && stencil)
4127*35238bceSAndroid Build Coastguard Worker {
4128*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo[1]);
4129*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
4130*35238bceSAndroid Build Coastguard Worker
4131*35238bceSAndroid Build Coastguard Worker gl.renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 1, 2);
4132*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
4133*35238bceSAndroid Build Coastguard Worker
4134*35238bceSAndroid Build Coastguard Worker gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_rbo[1]);
4135*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
4136*35238bceSAndroid Build Coastguard Worker }
4137*35238bceSAndroid Build Coastguard Worker
4138*35238bceSAndroid Build Coastguard Worker /* Check that framebuffer is complete. */
4139*35238bceSAndroid Build Coastguard Worker if (GL_FRAMEBUFFER_COMPLETE != glCheckFramebufferStatus(GL_FRAMEBUFFER))
4140*35238bceSAndroid Build Coastguard Worker {
4141*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
4142*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Unexpectedly framebuffer was incomplete." << tcu::TestLog::EndMessage;
4143*35238bceSAndroid Build Coastguard Worker
4144*35238bceSAndroid Build Coastguard Worker throw 0;
4145*35238bceSAndroid Build Coastguard Worker }
4146*35238bceSAndroid Build Coastguard Worker }
4147*35238bceSAndroid Build Coastguard Worker
4148*35238bceSAndroid Build Coastguard Worker /** Create framebuffer with tetxure
4149*35238bceSAndroid Build Coastguard Worker *
4150*35238bceSAndroid Build Coastguard Worker * @param [in] depth Prepare framebuffer with depth buffer.
4151*35238bceSAndroid Build Coastguard Worker * @param [in] stencil Prepare framebuffer with stencil buffer.
4152*35238bceSAndroid Build Coastguard Worker *
4153*35238bceSAndroid Build Coastguard Worker * @note If both depth and stencil, the joined dept_stencil buffer will be created.
4154*35238bceSAndroid Build Coastguard Worker */
CreateTextureFramebuffer(bool depth,bool stencil)4155*35238bceSAndroid Build Coastguard Worker void GetAttachmentParametersTest::CreateTextureFramebuffer(bool depth, bool stencil)
4156*35238bceSAndroid Build Coastguard Worker {
4157*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
4158*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
4159*35238bceSAndroid Build Coastguard Worker
4160*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(1, &m_fbo);
4161*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
4162*35238bceSAndroid Build Coastguard Worker
4163*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
4164*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
4165*35238bceSAndroid Build Coastguard Worker
4166*35238bceSAndroid Build Coastguard Worker gl.genTextures(2, m_to);
4167*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
4168*35238bceSAndroid Build Coastguard Worker
4169*35238bceSAndroid Build Coastguard Worker gl.bindTexture(GL_TEXTURE_2D, m_to[0]);
4170*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
4171*35238bceSAndroid Build Coastguard Worker
4172*35238bceSAndroid Build Coastguard Worker gl.texStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 1, 2);
4173*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
4174*35238bceSAndroid Build Coastguard Worker
4175*35238bceSAndroid Build Coastguard Worker gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_to[0], 0);
4176*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
4177*35238bceSAndroid Build Coastguard Worker
4178*35238bceSAndroid Build Coastguard Worker if (depth && (!stencil))
4179*35238bceSAndroid Build Coastguard Worker {
4180*35238bceSAndroid Build Coastguard Worker gl.bindTexture(GL_TEXTURE_2D, m_to[1]);
4181*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
4182*35238bceSAndroid Build Coastguard Worker
4183*35238bceSAndroid Build Coastguard Worker gl.texStorage2D(GL_TEXTURE_2D, 1, GL_DEPTH_COMPONENT24, 1, 2);
4184*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
4185*35238bceSAndroid Build Coastguard Worker
4186*35238bceSAndroid Build Coastguard Worker gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_to[1], 0);
4187*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
4188*35238bceSAndroid Build Coastguard Worker }
4189*35238bceSAndroid Build Coastguard Worker
4190*35238bceSAndroid Build Coastguard Worker if ((!depth) && stencil)
4191*35238bceSAndroid Build Coastguard Worker {
4192*35238bceSAndroid Build Coastguard Worker gl.bindTexture(GL_TEXTURE_2D, m_to[1]);
4193*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
4194*35238bceSAndroid Build Coastguard Worker
4195*35238bceSAndroid Build Coastguard Worker gl.texStorage2D(GL_TEXTURE_2D, 1, GL_STENCIL_INDEX8, 1, 2);
4196*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
4197*35238bceSAndroid Build Coastguard Worker
4198*35238bceSAndroid Build Coastguard Worker gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_to[1], 0);
4199*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
4200*35238bceSAndroid Build Coastguard Worker }
4201*35238bceSAndroid Build Coastguard Worker
4202*35238bceSAndroid Build Coastguard Worker if (depth && stencil)
4203*35238bceSAndroid Build Coastguard Worker {
4204*35238bceSAndroid Build Coastguard Worker gl.bindTexture(GL_TEXTURE_2D, m_to[1]);
4205*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
4206*35238bceSAndroid Build Coastguard Worker
4207*35238bceSAndroid Build Coastguard Worker gl.texStorage2D(GL_TEXTURE_2D, 1, GL_DEPTH24_STENCIL8, 1, 2);
4208*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
4209*35238bceSAndroid Build Coastguard Worker
4210*35238bceSAndroid Build Coastguard Worker gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_to[1], 0);
4211*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
4212*35238bceSAndroid Build Coastguard Worker }
4213*35238bceSAndroid Build Coastguard Worker
4214*35238bceSAndroid Build Coastguard Worker /* Check that framebuffer is complete. */
4215*35238bceSAndroid Build Coastguard Worker if (GL_FRAMEBUFFER_COMPLETE != glCheckFramebufferStatus(GL_FRAMEBUFFER))
4216*35238bceSAndroid Build Coastguard Worker {
4217*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
4218*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Unexpectedly framebuffer was incomplete." << tcu::TestLog::EndMessage;
4219*35238bceSAndroid Build Coastguard Worker
4220*35238bceSAndroid Build Coastguard Worker throw 0;
4221*35238bceSAndroid Build Coastguard Worker }
4222*35238bceSAndroid Build Coastguard Worker }
4223*35238bceSAndroid Build Coastguard Worker
4224*35238bceSAndroid Build Coastguard Worker /** Test default framebuffer.
4225*35238bceSAndroid Build Coastguard Worker *
4226*35238bceSAndroid Build Coastguard Worker * @return True if test succeeded, false otherwise.
4227*35238bceSAndroid Build Coastguard Worker */
TestDefaultFramebuffer()4228*35238bceSAndroid Build Coastguard Worker bool GetAttachmentParametersTest::TestDefaultFramebuffer()
4229*35238bceSAndroid Build Coastguard Worker {
4230*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
4231*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
4232*35238bceSAndroid Build Coastguard Worker
4233*35238bceSAndroid Build Coastguard Worker /* Result. */
4234*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
4235*35238bceSAndroid Build Coastguard Worker
4236*35238bceSAndroid Build Coastguard Worker static const glw::GLenum attachments[] = {GL_FRONT_LEFT, GL_FRONT_RIGHT, GL_BACK_LEFT,
4237*35238bceSAndroid Build Coastguard Worker GL_BACK_RIGHT, GL_DEPTH, GL_STENCIL};
4238*35238bceSAndroid Build Coastguard Worker
4239*35238bceSAndroid Build Coastguard Worker static const glw::GLchar *attachments_strings[] = {"GL_FRONT_LEFT", "GL_FRONT_RIGHT", "GL_BACK_LEFT",
4240*35238bceSAndroid Build Coastguard Worker "GL_BACK_RIGHT", "GL_DEPTH", "GL_STENCIL"};
4241*35238bceSAndroid Build Coastguard Worker
4242*35238bceSAndroid Build Coastguard Worker static const glw::GLuint attachments_count = sizeof(attachments) / sizeof(attachments[0]);
4243*35238bceSAndroid Build Coastguard Worker
4244*35238bceSAndroid Build Coastguard Worker for (glw::GLuint j = 0; j < attachments_count; ++j)
4245*35238bceSAndroid Build Coastguard Worker {
4246*35238bceSAndroid Build Coastguard Worker glw::GLint parameter_legacy = 0;
4247*35238bceSAndroid Build Coastguard Worker glw::GLint parameter_dsa = 0;
4248*35238bceSAndroid Build Coastguard Worker
4249*35238bceSAndroid Build Coastguard Worker gl.getFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, attachments[j], GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
4250*35238bceSAndroid Build Coastguard Worker ¶meter_legacy);
4251*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetFramebufferParameteriv has failed");
4252*35238bceSAndroid Build Coastguard Worker
4253*35238bceSAndroid Build Coastguard Worker gl.getNamedFramebufferAttachmentParameteriv(0, attachments[j], GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
4254*35238bceSAndroid Build Coastguard Worker ¶meter_dsa);
4255*35238bceSAndroid Build Coastguard Worker
4256*35238bceSAndroid Build Coastguard Worker /* Error check. */
4257*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
4258*35238bceSAndroid Build Coastguard Worker {
4259*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
4260*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "GetNamedFramebufferAttachmentParameteriv unexpectedly generated "
4261*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(error)
4262*35238bceSAndroid Build Coastguard Worker << " error when called with GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE parameter name for "
4263*35238bceSAndroid Build Coastguard Worker << attachments_strings[j] << " attachment of default framebuffer." << tcu::TestLog::EndMessage;
4264*35238bceSAndroid Build Coastguard Worker
4265*35238bceSAndroid Build Coastguard Worker is_ok = false;
4266*35238bceSAndroid Build Coastguard Worker
4267*35238bceSAndroid Build Coastguard Worker continue;
4268*35238bceSAndroid Build Coastguard Worker }
4269*35238bceSAndroid Build Coastguard Worker
4270*35238bceSAndroid Build Coastguard Worker if (parameter_legacy != parameter_dsa)
4271*35238bceSAndroid Build Coastguard Worker {
4272*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
4273*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "GetNamedFramebufferAttachmentParameteriv returned " << parameter_dsa
4274*35238bceSAndroid Build Coastguard Worker << ", but " << parameter_legacy
4275*35238bceSAndroid Build Coastguard Worker << " was expected for GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE parameter name of default framebuffer."
4276*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
4277*35238bceSAndroid Build Coastguard Worker
4278*35238bceSAndroid Build Coastguard Worker is_ok = false;
4279*35238bceSAndroid Build Coastguard Worker
4280*35238bceSAndroid Build Coastguard Worker continue;
4281*35238bceSAndroid Build Coastguard Worker }
4282*35238bceSAndroid Build Coastguard Worker
4283*35238bceSAndroid Build Coastguard Worker if (parameter_dsa != GL_NONE)
4284*35238bceSAndroid Build Coastguard Worker {
4285*35238bceSAndroid Build Coastguard Worker static const glw::GLenum optional_pnames[] = {
4286*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE, GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE,
4287*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE, GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE,
4288*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE,
4289*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING};
4290*35238bceSAndroid Build Coastguard Worker
4291*35238bceSAndroid Build Coastguard Worker static const glw::GLchar *optional_pnames_strings[] = {
4292*35238bceSAndroid Build Coastguard Worker "GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE", "GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",
4293*35238bceSAndroid Build Coastguard Worker "GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE", "GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",
4294*35238bceSAndroid Build Coastguard Worker "GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE", "GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",
4295*35238bceSAndroid Build Coastguard Worker "GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE", "GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING"};
4296*35238bceSAndroid Build Coastguard Worker
4297*35238bceSAndroid Build Coastguard Worker static const glw::GLuint optional_pnames_count = sizeof(optional_pnames) / sizeof(optional_pnames[0]);
4298*35238bceSAndroid Build Coastguard Worker
4299*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < optional_pnames_count; ++i)
4300*35238bceSAndroid Build Coastguard Worker {
4301*35238bceSAndroid Build Coastguard Worker glw::GLint optional_parameter_legacy = 0;
4302*35238bceSAndroid Build Coastguard Worker glw::GLint optional_parameter_dsa = 0;
4303*35238bceSAndroid Build Coastguard Worker
4304*35238bceSAndroid Build Coastguard Worker gl.getFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, attachments[j], optional_pnames[i],
4305*35238bceSAndroid Build Coastguard Worker &optional_parameter_legacy);
4306*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetFramebufferParameteriv has failed");
4307*35238bceSAndroid Build Coastguard Worker
4308*35238bceSAndroid Build Coastguard Worker gl.getNamedFramebufferAttachmentParameteriv(0, attachments[j], optional_pnames[i],
4309*35238bceSAndroid Build Coastguard Worker &optional_parameter_dsa);
4310*35238bceSAndroid Build Coastguard Worker
4311*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
4312*35238bceSAndroid Build Coastguard Worker {
4313*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
4314*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "GetNamedFramebufferAttachmentParameteriv unexpectedly generated "
4315*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(error) << " error when called with " << optional_pnames_strings[i]
4316*35238bceSAndroid Build Coastguard Worker << " parameter name for " << attachments_strings[j]
4317*35238bceSAndroid Build Coastguard Worker << " attachment of default framebuffer. The GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE was "
4318*35238bceSAndroid Build Coastguard Worker << parameter_legacy << "." << tcu::TestLog::EndMessage;
4319*35238bceSAndroid Build Coastguard Worker
4320*35238bceSAndroid Build Coastguard Worker is_ok = false;
4321*35238bceSAndroid Build Coastguard Worker
4322*35238bceSAndroid Build Coastguard Worker continue;
4323*35238bceSAndroid Build Coastguard Worker }
4324*35238bceSAndroid Build Coastguard Worker
4325*35238bceSAndroid Build Coastguard Worker if (optional_parameter_legacy != optional_parameter_dsa)
4326*35238bceSAndroid Build Coastguard Worker {
4327*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
4328*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "GetNamedFramebufferAttachmentParameteriv returned "
4329*35238bceSAndroid Build Coastguard Worker << optional_parameter_dsa << ", but " << optional_parameter_legacy << " was expected for "
4330*35238bceSAndroid Build Coastguard Worker << optional_pnames_strings << " parameter name for " << attachments_strings[j]
4331*35238bceSAndroid Build Coastguard Worker << " attachment of default framebuffer." << tcu::TestLog::EndMessage;
4332*35238bceSAndroid Build Coastguard Worker
4333*35238bceSAndroid Build Coastguard Worker is_ok = false;
4334*35238bceSAndroid Build Coastguard Worker
4335*35238bceSAndroid Build Coastguard Worker continue;
4336*35238bceSAndroid Build Coastguard Worker }
4337*35238bceSAndroid Build Coastguard Worker }
4338*35238bceSAndroid Build Coastguard Worker }
4339*35238bceSAndroid Build Coastguard Worker }
4340*35238bceSAndroid Build Coastguard Worker
4341*35238bceSAndroid Build Coastguard Worker return is_ok;
4342*35238bceSAndroid Build Coastguard Worker }
4343*35238bceSAndroid Build Coastguard Worker
4344*35238bceSAndroid Build Coastguard Worker /** Test framebuffer object (with renderbuffer).
4345*35238bceSAndroid Build Coastguard Worker *
4346*35238bceSAndroid Build Coastguard Worker * @param [in] depth_stencil Has framebuffer depth_stencil attachment.
4347*35238bceSAndroid Build Coastguard Worker *
4348*35238bceSAndroid Build Coastguard Worker * @return True if test succeeded, false otherwise.
4349*35238bceSAndroid Build Coastguard Worker */
TestRenderbufferFramebuffer(bool depth_stencil)4350*35238bceSAndroid Build Coastguard Worker bool GetAttachmentParametersTest::TestRenderbufferFramebuffer(bool depth_stencil)
4351*35238bceSAndroid Build Coastguard Worker {
4352*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
4353*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
4354*35238bceSAndroid Build Coastguard Worker
4355*35238bceSAndroid Build Coastguard Worker /* Result. */
4356*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
4357*35238bceSAndroid Build Coastguard Worker
4358*35238bceSAndroid Build Coastguard Worker static const glw::GLenum attachments[] = {GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT, GL_DEPTH_STENCIL_ATTACHMENT,
4359*35238bceSAndroid Build Coastguard Worker GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1};
4360*35238bceSAndroid Build Coastguard Worker
4361*35238bceSAndroid Build Coastguard Worker static const glw::GLchar *attachments_strings[] = {"GL_DEPTH_ATTACHMENT", "GL_STENCIL_ATTACHMENT",
4362*35238bceSAndroid Build Coastguard Worker "GL_DEPTH_STENCIL_ATTACHMENT", "GL_COLOR_ATTACHMENT0",
4363*35238bceSAndroid Build Coastguard Worker "GL_COLOR_ATTACHMENT1"};
4364*35238bceSAndroid Build Coastguard Worker
4365*35238bceSAndroid Build Coastguard Worker static const glw::GLuint attachments_count = sizeof(attachments) / sizeof(attachments[0]);
4366*35238bceSAndroid Build Coastguard Worker
4367*35238bceSAndroid Build Coastguard Worker for (glw::GLuint j = 0; j < attachments_count; ++j)
4368*35238bceSAndroid Build Coastguard Worker {
4369*35238bceSAndroid Build Coastguard Worker glw::GLint parameter_legacy = 0;
4370*35238bceSAndroid Build Coastguard Worker glw::GLint parameter_dsa = 0;
4371*35238bceSAndroid Build Coastguard Worker
4372*35238bceSAndroid Build Coastguard Worker /* Omit DEPTH_STENCIL_ATTACHMENT attachment if the renderbuffer is not depth-stencil. */
4373*35238bceSAndroid Build Coastguard Worker if (attachments[j] == GL_DEPTH_STENCIL_ATTACHMENT)
4374*35238bceSAndroid Build Coastguard Worker {
4375*35238bceSAndroid Build Coastguard Worker if (!depth_stencil)
4376*35238bceSAndroid Build Coastguard Worker {
4377*35238bceSAndroid Build Coastguard Worker continue;
4378*35238bceSAndroid Build Coastguard Worker }
4379*35238bceSAndroid Build Coastguard Worker }
4380*35238bceSAndroid Build Coastguard Worker
4381*35238bceSAndroid Build Coastguard Worker gl.getFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, attachments[j], GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
4382*35238bceSAndroid Build Coastguard Worker ¶meter_legacy);
4383*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetFramebufferParameteriv has failed");
4384*35238bceSAndroid Build Coastguard Worker
4385*35238bceSAndroid Build Coastguard Worker gl.getNamedFramebufferAttachmentParameteriv(m_fbo, attachments[j], GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
4386*35238bceSAndroid Build Coastguard Worker ¶meter_dsa);
4387*35238bceSAndroid Build Coastguard Worker
4388*35238bceSAndroid Build Coastguard Worker /* Error check. */
4389*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
4390*35238bceSAndroid Build Coastguard Worker {
4391*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
4392*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "GetNamedFramebufferAttachmentParameteriv unexpectedly generated "
4393*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(error)
4394*35238bceSAndroid Build Coastguard Worker << " error when called with GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE parameter name for "
4395*35238bceSAndroid Build Coastguard Worker << attachments_strings[j] << " attachment of renderbuffer framebuffer object."
4396*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
4397*35238bceSAndroid Build Coastguard Worker
4398*35238bceSAndroid Build Coastguard Worker is_ok = false;
4399*35238bceSAndroid Build Coastguard Worker
4400*35238bceSAndroid Build Coastguard Worker continue;
4401*35238bceSAndroid Build Coastguard Worker }
4402*35238bceSAndroid Build Coastguard Worker
4403*35238bceSAndroid Build Coastguard Worker if (parameter_legacy != parameter_dsa)
4404*35238bceSAndroid Build Coastguard Worker {
4405*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
4406*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "GetNamedFramebufferAttachmentParameteriv returned " << parameter_dsa
4407*35238bceSAndroid Build Coastguard Worker << ", but " << parameter_legacy
4408*35238bceSAndroid Build Coastguard Worker << " was expected for GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE parameter "
4409*35238bceSAndroid Build Coastguard Worker "name of renderbuffer framebuffer object."
4410*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
4411*35238bceSAndroid Build Coastguard Worker
4412*35238bceSAndroid Build Coastguard Worker is_ok = false;
4413*35238bceSAndroid Build Coastguard Worker
4414*35238bceSAndroid Build Coastguard Worker continue;
4415*35238bceSAndroid Build Coastguard Worker }
4416*35238bceSAndroid Build Coastguard Worker
4417*35238bceSAndroid Build Coastguard Worker if (parameter_dsa != GL_NONE)
4418*35238bceSAndroid Build Coastguard Worker {
4419*35238bceSAndroid Build Coastguard Worker static const glw::GLenum optional_pnames[] = {
4420*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE,
4421*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE, GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE,
4422*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE,
4423*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE, GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE,
4424*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING};
4425*35238bceSAndroid Build Coastguard Worker
4426*35238bceSAndroid Build Coastguard Worker static const glw::GLchar *optional_pnames_strings[] = {
4427*35238bceSAndroid Build Coastguard Worker "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME", "GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE",
4428*35238bceSAndroid Build Coastguard Worker "GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE", "GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",
4429*35238bceSAndroid Build Coastguard Worker "GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE", "GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",
4430*35238bceSAndroid Build Coastguard Worker "GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE", "GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",
4431*35238bceSAndroid Build Coastguard Worker "GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING"};
4432*35238bceSAndroid Build Coastguard Worker
4433*35238bceSAndroid Build Coastguard Worker static const glw::GLuint optional_pnames_count = sizeof(optional_pnames) / sizeof(optional_pnames[0]);
4434*35238bceSAndroid Build Coastguard Worker
4435*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < optional_pnames_count; ++i)
4436*35238bceSAndroid Build Coastguard Worker {
4437*35238bceSAndroid Build Coastguard Worker /* Omit FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE pname when DEPTH_STENCIL_ATTACHMENT attachment is used. */
4438*35238bceSAndroid Build Coastguard Worker if (attachments[j] == GL_DEPTH_STENCIL_ATTACHMENT)
4439*35238bceSAndroid Build Coastguard Worker {
4440*35238bceSAndroid Build Coastguard Worker if (optional_pnames[i] == GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE)
4441*35238bceSAndroid Build Coastguard Worker {
4442*35238bceSAndroid Build Coastguard Worker continue;
4443*35238bceSAndroid Build Coastguard Worker }
4444*35238bceSAndroid Build Coastguard Worker }
4445*35238bceSAndroid Build Coastguard Worker
4446*35238bceSAndroid Build Coastguard Worker glw::GLint optional_parameter_legacy = 0;
4447*35238bceSAndroid Build Coastguard Worker glw::GLint optional_parameter_dsa = 0;
4448*35238bceSAndroid Build Coastguard Worker
4449*35238bceSAndroid Build Coastguard Worker gl.getFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, attachments[j], optional_pnames[i],
4450*35238bceSAndroid Build Coastguard Worker &optional_parameter_legacy);
4451*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetFramebufferParameteriv has failed");
4452*35238bceSAndroid Build Coastguard Worker
4453*35238bceSAndroid Build Coastguard Worker gl.getNamedFramebufferAttachmentParameteriv(m_fbo, attachments[j], optional_pnames[i],
4454*35238bceSAndroid Build Coastguard Worker &optional_parameter_dsa);
4455*35238bceSAndroid Build Coastguard Worker
4456*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
4457*35238bceSAndroid Build Coastguard Worker {
4458*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
4459*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "GetNamedFramebufferAttachmentParameteriv unexpectedly generated "
4460*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(error) << " error when called with " << optional_pnames_strings[i]
4461*35238bceSAndroid Build Coastguard Worker << " parameter name for " << attachments_strings[j]
4462*35238bceSAndroid Build Coastguard Worker << " attachment of renderbuffer framebuffer object. The GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE "
4463*35238bceSAndroid Build Coastguard Worker "was "
4464*35238bceSAndroid Build Coastguard Worker << parameter_legacy << "." << tcu::TestLog::EndMessage;
4465*35238bceSAndroid Build Coastguard Worker
4466*35238bceSAndroid Build Coastguard Worker is_ok = false;
4467*35238bceSAndroid Build Coastguard Worker
4468*35238bceSAndroid Build Coastguard Worker continue;
4469*35238bceSAndroid Build Coastguard Worker }
4470*35238bceSAndroid Build Coastguard Worker
4471*35238bceSAndroid Build Coastguard Worker if (optional_parameter_legacy != optional_parameter_dsa)
4472*35238bceSAndroid Build Coastguard Worker {
4473*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
4474*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "GetNamedFramebufferAttachmentParameteriv returned "
4475*35238bceSAndroid Build Coastguard Worker << optional_parameter_dsa << ", but " << optional_parameter_legacy << " was expected for "
4476*35238bceSAndroid Build Coastguard Worker << optional_pnames_strings << " parameter name for " << attachments_strings[j]
4477*35238bceSAndroid Build Coastguard Worker << " attachment of renderbuffer framebuffer object." << tcu::TestLog::EndMessage;
4478*35238bceSAndroid Build Coastguard Worker
4479*35238bceSAndroid Build Coastguard Worker is_ok = false;
4480*35238bceSAndroid Build Coastguard Worker
4481*35238bceSAndroid Build Coastguard Worker continue;
4482*35238bceSAndroid Build Coastguard Worker }
4483*35238bceSAndroid Build Coastguard Worker }
4484*35238bceSAndroid Build Coastguard Worker }
4485*35238bceSAndroid Build Coastguard Worker }
4486*35238bceSAndroid Build Coastguard Worker
4487*35238bceSAndroid Build Coastguard Worker return is_ok;
4488*35238bceSAndroid Build Coastguard Worker }
4489*35238bceSAndroid Build Coastguard Worker
4490*35238bceSAndroid Build Coastguard Worker /** Test framebuffer object (with texture).
4491*35238bceSAndroid Build Coastguard Worker *
4492*35238bceSAndroid Build Coastguard Worker * @param [in] depth_stencil Has framebuffer depth_stencil attachment.
4493*35238bceSAndroid Build Coastguard Worker *
4494*35238bceSAndroid Build Coastguard Worker * @return True if test succeeded, false otherwise.
4495*35238bceSAndroid Build Coastguard Worker */
TestTextureFramebuffer(bool depth_stencil)4496*35238bceSAndroid Build Coastguard Worker bool GetAttachmentParametersTest::TestTextureFramebuffer(bool depth_stencil)
4497*35238bceSAndroid Build Coastguard Worker {
4498*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
4499*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
4500*35238bceSAndroid Build Coastguard Worker
4501*35238bceSAndroid Build Coastguard Worker /* Result. */
4502*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
4503*35238bceSAndroid Build Coastguard Worker
4504*35238bceSAndroid Build Coastguard Worker static const glw::GLenum attachments[] = {GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT, GL_DEPTH_STENCIL_ATTACHMENT,
4505*35238bceSAndroid Build Coastguard Worker GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1};
4506*35238bceSAndroid Build Coastguard Worker
4507*35238bceSAndroid Build Coastguard Worker static const glw::GLchar *attachments_strings[] = {"GL_DEPTH_ATTACHMENT", "GL_STENCIL_ATTACHMENT",
4508*35238bceSAndroid Build Coastguard Worker "GL_DEPTH_STENCIL_ATTACHMENT", "GL_COLOR_ATTACHMENT0",
4509*35238bceSAndroid Build Coastguard Worker "GL_COLOR_ATTACHMENT1"};
4510*35238bceSAndroid Build Coastguard Worker
4511*35238bceSAndroid Build Coastguard Worker static const glw::GLuint attachments_count = sizeof(attachments) / sizeof(attachments[0]);
4512*35238bceSAndroid Build Coastguard Worker
4513*35238bceSAndroid Build Coastguard Worker for (glw::GLuint j = 0; j < attachments_count; ++j)
4514*35238bceSAndroid Build Coastguard Worker {
4515*35238bceSAndroid Build Coastguard Worker /* Omit DEPTH_STENCIL_ATTACHMENT attachment if the renderbuffer is not depth-stencil. */
4516*35238bceSAndroid Build Coastguard Worker if (attachments[j] == GL_DEPTH_STENCIL_ATTACHMENT)
4517*35238bceSAndroid Build Coastguard Worker {
4518*35238bceSAndroid Build Coastguard Worker if (!depth_stencil)
4519*35238bceSAndroid Build Coastguard Worker {
4520*35238bceSAndroid Build Coastguard Worker continue;
4521*35238bceSAndroid Build Coastguard Worker }
4522*35238bceSAndroid Build Coastguard Worker }
4523*35238bceSAndroid Build Coastguard Worker
4524*35238bceSAndroid Build Coastguard Worker glw::GLint parameter_legacy = 0;
4525*35238bceSAndroid Build Coastguard Worker glw::GLint parameter_dsa = 0;
4526*35238bceSAndroid Build Coastguard Worker
4527*35238bceSAndroid Build Coastguard Worker gl.getFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, attachments[j], GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
4528*35238bceSAndroid Build Coastguard Worker ¶meter_legacy);
4529*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetFramebufferParameteriv has failed");
4530*35238bceSAndroid Build Coastguard Worker
4531*35238bceSAndroid Build Coastguard Worker gl.getNamedFramebufferAttachmentParameteriv(m_fbo, attachments[j], GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
4532*35238bceSAndroid Build Coastguard Worker ¶meter_dsa);
4533*35238bceSAndroid Build Coastguard Worker
4534*35238bceSAndroid Build Coastguard Worker /* Error check. */
4535*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
4536*35238bceSAndroid Build Coastguard Worker {
4537*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
4538*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "GetNamedFramebufferAttachmentParameteriv unexpectedly generated "
4539*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(error)
4540*35238bceSAndroid Build Coastguard Worker << " error when called with GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE parameter name for "
4541*35238bceSAndroid Build Coastguard Worker << attachments_strings[j] << " attachment of texture framebuffer object." << tcu::TestLog::EndMessage;
4542*35238bceSAndroid Build Coastguard Worker
4543*35238bceSAndroid Build Coastguard Worker is_ok = false;
4544*35238bceSAndroid Build Coastguard Worker
4545*35238bceSAndroid Build Coastguard Worker continue;
4546*35238bceSAndroid Build Coastguard Worker }
4547*35238bceSAndroid Build Coastguard Worker
4548*35238bceSAndroid Build Coastguard Worker if (parameter_legacy != parameter_dsa)
4549*35238bceSAndroid Build Coastguard Worker {
4550*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
4551*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "GetNamedFramebufferAttachmentParameteriv returned " << parameter_dsa
4552*35238bceSAndroid Build Coastguard Worker << ", but " << parameter_legacy
4553*35238bceSAndroid Build Coastguard Worker << " was expected for GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE parameter "
4554*35238bceSAndroid Build Coastguard Worker "name of texture framebuffer object."
4555*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
4556*35238bceSAndroid Build Coastguard Worker
4557*35238bceSAndroid Build Coastguard Worker is_ok = false;
4558*35238bceSAndroid Build Coastguard Worker
4559*35238bceSAndroid Build Coastguard Worker continue;
4560*35238bceSAndroid Build Coastguard Worker }
4561*35238bceSAndroid Build Coastguard Worker
4562*35238bceSAndroid Build Coastguard Worker if (parameter_dsa != GL_NONE)
4563*35238bceSAndroid Build Coastguard Worker {
4564*35238bceSAndroid Build Coastguard Worker static const glw::GLenum optional_pnames[] = {GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME,
4565*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL,
4566*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE,
4567*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_LAYERED,
4568*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER,
4569*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE,
4570*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE,
4571*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE,
4572*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE,
4573*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE,
4574*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE,
4575*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE,
4576*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING};
4577*35238bceSAndroid Build Coastguard Worker
4578*35238bceSAndroid Build Coastguard Worker static const glw::GLchar *optional_pnames_strings[] = {"GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",
4579*35238bceSAndroid Build Coastguard Worker "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",
4580*35238bceSAndroid Build Coastguard Worker "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",
4581*35238bceSAndroid Build Coastguard Worker "GL_FRAMEBUFFER_ATTACHMENT_LAYERED",
4582*35238bceSAndroid Build Coastguard Worker "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",
4583*35238bceSAndroid Build Coastguard Worker "GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE",
4584*35238bceSAndroid Build Coastguard Worker "GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",
4585*35238bceSAndroid Build Coastguard Worker "GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",
4586*35238bceSAndroid Build Coastguard Worker "GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",
4587*35238bceSAndroid Build Coastguard Worker "GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",
4588*35238bceSAndroid Build Coastguard Worker "GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",
4589*35238bceSAndroid Build Coastguard Worker "GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",
4590*35238bceSAndroid Build Coastguard Worker "GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING"};
4591*35238bceSAndroid Build Coastguard Worker
4592*35238bceSAndroid Build Coastguard Worker static const glw::GLuint optional_pnames_count = sizeof(optional_pnames) / sizeof(optional_pnames[0]);
4593*35238bceSAndroid Build Coastguard Worker
4594*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < optional_pnames_count; ++i)
4595*35238bceSAndroid Build Coastguard Worker {
4596*35238bceSAndroid Build Coastguard Worker /* Omit FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE pname when DEPTH_STENCIL_ATTACHMENT attachment is used. */
4597*35238bceSAndroid Build Coastguard Worker if (attachments[j] == GL_DEPTH_STENCIL_ATTACHMENT)
4598*35238bceSAndroid Build Coastguard Worker {
4599*35238bceSAndroid Build Coastguard Worker if (optional_pnames[i] == GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE)
4600*35238bceSAndroid Build Coastguard Worker {
4601*35238bceSAndroid Build Coastguard Worker continue;
4602*35238bceSAndroid Build Coastguard Worker }
4603*35238bceSAndroid Build Coastguard Worker }
4604*35238bceSAndroid Build Coastguard Worker
4605*35238bceSAndroid Build Coastguard Worker glw::GLint optional_parameter_legacy = 0;
4606*35238bceSAndroid Build Coastguard Worker glw::GLint optional_parameter_dsa = 0;
4607*35238bceSAndroid Build Coastguard Worker
4608*35238bceSAndroid Build Coastguard Worker gl.getFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, attachments[j], optional_pnames[i],
4609*35238bceSAndroid Build Coastguard Worker &optional_parameter_legacy);
4610*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetFramebufferParameteriv has failed");
4611*35238bceSAndroid Build Coastguard Worker
4612*35238bceSAndroid Build Coastguard Worker gl.getNamedFramebufferAttachmentParameteriv(m_fbo, attachments[j], optional_pnames[i],
4613*35238bceSAndroid Build Coastguard Worker &optional_parameter_dsa);
4614*35238bceSAndroid Build Coastguard Worker
4615*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
4616*35238bceSAndroid Build Coastguard Worker {
4617*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
4618*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "GetNamedFramebufferAttachmentParameteriv unexpectedly generated "
4619*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(error) << " error when called with " << optional_pnames_strings[i]
4620*35238bceSAndroid Build Coastguard Worker << " parameter name for " << attachments_strings[j]
4621*35238bceSAndroid Build Coastguard Worker << " attachment of texture framebuffer object. The GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE was "
4622*35238bceSAndroid Build Coastguard Worker << parameter_legacy << "." << tcu::TestLog::EndMessage;
4623*35238bceSAndroid Build Coastguard Worker
4624*35238bceSAndroid Build Coastguard Worker is_ok = false;
4625*35238bceSAndroid Build Coastguard Worker
4626*35238bceSAndroid Build Coastguard Worker continue;
4627*35238bceSAndroid Build Coastguard Worker }
4628*35238bceSAndroid Build Coastguard Worker
4629*35238bceSAndroid Build Coastguard Worker if (optional_parameter_legacy != optional_parameter_dsa)
4630*35238bceSAndroid Build Coastguard Worker {
4631*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
4632*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "GetNamedFramebufferAttachmentParameteriv returned "
4633*35238bceSAndroid Build Coastguard Worker << optional_parameter_dsa << ", but " << optional_parameter_legacy << " was expected for "
4634*35238bceSAndroid Build Coastguard Worker << optional_pnames_strings << " parameter name for " << attachments_strings[j]
4635*35238bceSAndroid Build Coastguard Worker << " attachment of texture framebuffer object." << tcu::TestLog::EndMessage;
4636*35238bceSAndroid Build Coastguard Worker
4637*35238bceSAndroid Build Coastguard Worker is_ok = false;
4638*35238bceSAndroid Build Coastguard Worker
4639*35238bceSAndroid Build Coastguard Worker continue;
4640*35238bceSAndroid Build Coastguard Worker }
4641*35238bceSAndroid Build Coastguard Worker }
4642*35238bceSAndroid Build Coastguard Worker }
4643*35238bceSAndroid Build Coastguard Worker }
4644*35238bceSAndroid Build Coastguard Worker
4645*35238bceSAndroid Build Coastguard Worker return is_ok;
4646*35238bceSAndroid Build Coastguard Worker }
4647*35238bceSAndroid Build Coastguard Worker
4648*35238bceSAndroid Build Coastguard Worker /** @brief Clean up GL state.
4649*35238bceSAndroid Build Coastguard Worker */
Clean()4650*35238bceSAndroid Build Coastguard Worker void GetAttachmentParametersTest::Clean()
4651*35238bceSAndroid Build Coastguard Worker {
4652*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
4653*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
4654*35238bceSAndroid Build Coastguard Worker
4655*35238bceSAndroid Build Coastguard Worker /* Releasing obnjects. */
4656*35238bceSAndroid Build Coastguard Worker if (m_fbo)
4657*35238bceSAndroid Build Coastguard Worker {
4658*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &m_fbo);
4659*35238bceSAndroid Build Coastguard Worker
4660*35238bceSAndroid Build Coastguard Worker m_fbo = 0;
4661*35238bceSAndroid Build Coastguard Worker }
4662*35238bceSAndroid Build Coastguard Worker
4663*35238bceSAndroid Build Coastguard Worker /* Releasing renderbuffers. */
4664*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < 2; ++i)
4665*35238bceSAndroid Build Coastguard Worker {
4666*35238bceSAndroid Build Coastguard Worker if (m_rbo[i])
4667*35238bceSAndroid Build Coastguard Worker {
4668*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &m_rbo[i]);
4669*35238bceSAndroid Build Coastguard Worker
4670*35238bceSAndroid Build Coastguard Worker m_rbo[i] = 0;
4671*35238bceSAndroid Build Coastguard Worker }
4672*35238bceSAndroid Build Coastguard Worker }
4673*35238bceSAndroid Build Coastguard Worker
4674*35238bceSAndroid Build Coastguard Worker /* Releasing textures. */
4675*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < 2; ++i)
4676*35238bceSAndroid Build Coastguard Worker {
4677*35238bceSAndroid Build Coastguard Worker if (m_to[i])
4678*35238bceSAndroid Build Coastguard Worker {
4679*35238bceSAndroid Build Coastguard Worker gl.deleteTextures(1, &m_to[i]);
4680*35238bceSAndroid Build Coastguard Worker
4681*35238bceSAndroid Build Coastguard Worker m_to[i] = 0;
4682*35238bceSAndroid Build Coastguard Worker }
4683*35238bceSAndroid Build Coastguard Worker }
4684*35238bceSAndroid Build Coastguard Worker
4685*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
4686*35238bceSAndroid Build Coastguard Worker while (gl.getError())
4687*35238bceSAndroid Build Coastguard Worker ;
4688*35238bceSAndroid Build Coastguard Worker }
4689*35238bceSAndroid Build Coastguard Worker
4690*35238bceSAndroid Build Coastguard Worker /******************************** Framebuffer Creation Errors Test Implementation ********************************/
4691*35238bceSAndroid Build Coastguard Worker
4692*35238bceSAndroid Build Coastguard Worker /** @brief Creation Errors Test constructor.
4693*35238bceSAndroid Build Coastguard Worker *
4694*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
4695*35238bceSAndroid Build Coastguard Worker */
CreationErrorsTest(deqp::Context & context)4696*35238bceSAndroid Build Coastguard Worker CreationErrorsTest::CreationErrorsTest(deqp::Context &context)
4697*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "framebuffers_creation_errors", "Framebuffer Objects Creation Errors Test")
4698*35238bceSAndroid Build Coastguard Worker {
4699*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
4700*35238bceSAndroid Build Coastguard Worker }
4701*35238bceSAndroid Build Coastguard Worker
4702*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Creation Test cases.
4703*35238bceSAndroid Build Coastguard Worker *
4704*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
4705*35238bceSAndroid Build Coastguard Worker */
iterate()4706*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult CreationErrorsTest::iterate()
4707*35238bceSAndroid Build Coastguard Worker {
4708*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
4709*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
4710*35238bceSAndroid Build Coastguard Worker
4711*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
4712*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
4713*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
4714*35238bceSAndroid Build Coastguard Worker
4715*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
4716*35238bceSAndroid Build Coastguard Worker {
4717*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
4718*35238bceSAndroid Build Coastguard Worker
4719*35238bceSAndroid Build Coastguard Worker return STOP;
4720*35238bceSAndroid Build Coastguard Worker }
4721*35238bceSAndroid Build Coastguard Worker
4722*35238bceSAndroid Build Coastguard Worker /* Running tests. */
4723*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
4724*35238bceSAndroid Build Coastguard Worker
4725*35238bceSAndroid Build Coastguard Worker /* Framebuffer object */
4726*35238bceSAndroid Build Coastguard Worker glw::GLuint framebuffer = 0;
4727*35238bceSAndroid Build Coastguard Worker
4728*35238bceSAndroid Build Coastguard Worker /* Check direct state creation of negative numbers of framebuffers. */
4729*35238bceSAndroid Build Coastguard Worker gl.createFramebuffers(-1, &framebuffer);
4730*35238bceSAndroid Build Coastguard Worker
4731*35238bceSAndroid Build Coastguard Worker glw::GLenum error = GL_NO_ERROR;
4732*35238bceSAndroid Build Coastguard Worker
4733*35238bceSAndroid Build Coastguard Worker if (GL_INVALID_VALUE != (error = gl.getError()))
4734*35238bceSAndroid Build Coastguard Worker {
4735*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
4736*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "CreateFramebuffers generated " << glu::getErrorStr(error)
4737*35238bceSAndroid Build Coastguard Worker << " error when called with negative number of framebuffers, but GL_INVALID_VALUE was expected."
4738*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
4739*35238bceSAndroid Build Coastguard Worker
4740*35238bceSAndroid Build Coastguard Worker is_ok = false;
4741*35238bceSAndroid Build Coastguard Worker }
4742*35238bceSAndroid Build Coastguard Worker
4743*35238bceSAndroid Build Coastguard Worker /* Cleanup (sanity). */
4744*35238bceSAndroid Build Coastguard Worker if (framebuffer)
4745*35238bceSAndroid Build Coastguard Worker {
4746*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &framebuffer);
4747*35238bceSAndroid Build Coastguard Worker }
4748*35238bceSAndroid Build Coastguard Worker
4749*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
4750*35238bceSAndroid Build Coastguard Worker while (gl.getError())
4751*35238bceSAndroid Build Coastguard Worker ;
4752*35238bceSAndroid Build Coastguard Worker
4753*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
4754*35238bceSAndroid Build Coastguard Worker if (is_ok)
4755*35238bceSAndroid Build Coastguard Worker {
4756*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
4757*35238bceSAndroid Build Coastguard Worker }
4758*35238bceSAndroid Build Coastguard Worker else
4759*35238bceSAndroid Build Coastguard Worker {
4760*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
4761*35238bceSAndroid Build Coastguard Worker }
4762*35238bceSAndroid Build Coastguard Worker
4763*35238bceSAndroid Build Coastguard Worker return STOP;
4764*35238bceSAndroid Build Coastguard Worker }
4765*35238bceSAndroid Build Coastguard Worker
4766*35238bceSAndroid Build Coastguard Worker /******************************** Renderbuffer Attachment Errors Test Implementation ********************************/
4767*35238bceSAndroid Build Coastguard Worker
4768*35238bceSAndroid Build Coastguard Worker /** @brief Renderbuffer Attachment Errors Test constructor.
4769*35238bceSAndroid Build Coastguard Worker *
4770*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
4771*35238bceSAndroid Build Coastguard Worker */
RenderbufferAttachmentErrorsTest(deqp::Context & context)4772*35238bceSAndroid Build Coastguard Worker RenderbufferAttachmentErrorsTest::RenderbufferAttachmentErrorsTest(deqp::Context &context)
4773*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "framebuffers_renderbuffer_attachment_errors", "Renderbuffer Attachment Errors Test")
4774*35238bceSAndroid Build Coastguard Worker , m_fbo_valid(0)
4775*35238bceSAndroid Build Coastguard Worker , m_rbo_valid(0)
4776*35238bceSAndroid Build Coastguard Worker , m_fbo_invalid(0)
4777*35238bceSAndroid Build Coastguard Worker , m_rbo_invalid(0)
4778*35238bceSAndroid Build Coastguard Worker , m_color_attachment_invalid(0)
4779*35238bceSAndroid Build Coastguard Worker , m_attachment_invalid(0)
4780*35238bceSAndroid Build Coastguard Worker , m_renderbuffer_target_invalid(0)
4781*35238bceSAndroid Build Coastguard Worker {
4782*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
4783*35238bceSAndroid Build Coastguard Worker }
4784*35238bceSAndroid Build Coastguard Worker
4785*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Renderbuffer Attachment Errors Test cases.
4786*35238bceSAndroid Build Coastguard Worker *
4787*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
4788*35238bceSAndroid Build Coastguard Worker */
iterate()4789*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult RenderbufferAttachmentErrorsTest::iterate()
4790*35238bceSAndroid Build Coastguard Worker {
4791*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
4792*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
4793*35238bceSAndroid Build Coastguard Worker
4794*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
4795*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
4796*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
4797*35238bceSAndroid Build Coastguard Worker
4798*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
4799*35238bceSAndroid Build Coastguard Worker {
4800*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
4801*35238bceSAndroid Build Coastguard Worker
4802*35238bceSAndroid Build Coastguard Worker return STOP;
4803*35238bceSAndroid Build Coastguard Worker }
4804*35238bceSAndroid Build Coastguard Worker
4805*35238bceSAndroid Build Coastguard Worker /* Running tests. */
4806*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
4807*35238bceSAndroid Build Coastguard Worker bool is_error = false;
4808*35238bceSAndroid Build Coastguard Worker
4809*35238bceSAndroid Build Coastguard Worker try
4810*35238bceSAndroid Build Coastguard Worker {
4811*35238bceSAndroid Build Coastguard Worker /* Prepare objects. */
4812*35238bceSAndroid Build Coastguard Worker PrepareObjects();
4813*35238bceSAndroid Build Coastguard Worker
4814*35238bceSAndroid Build Coastguard Worker /* Invalid Framebuffer ID. */
4815*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferRenderbuffer(m_fbo_invalid, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo_valid);
4816*35238bceSAndroid Build Coastguard Worker
4817*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, false, true, false, true, true);
4818*35238bceSAndroid Build Coastguard Worker
4819*35238bceSAndroid Build Coastguard Worker /* Invalid color attachment. */
4820*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferRenderbuffer(m_fbo_valid, m_color_attachment_invalid, GL_RENDERBUFFER, m_rbo_valid);
4821*35238bceSAndroid Build Coastguard Worker
4822*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, true, false, true, true, true);
4823*35238bceSAndroid Build Coastguard Worker
4824*35238bceSAndroid Build Coastguard Worker /* Invalid attachment. */
4825*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferRenderbuffer(m_fbo_valid, m_attachment_invalid, GL_RENDERBUFFER, m_rbo_valid);
4826*35238bceSAndroid Build Coastguard Worker
4827*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, true, false, false, true, true);
4828*35238bceSAndroid Build Coastguard Worker
4829*35238bceSAndroid Build Coastguard Worker /* Invalid Renderbuffer Target. */
4830*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferRenderbuffer(m_fbo_valid, GL_COLOR_ATTACHMENT0, m_renderbuffer_target_invalid, m_rbo_valid);
4831*35238bceSAndroid Build Coastguard Worker
4832*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, true, true, false, false, true);
4833*35238bceSAndroid Build Coastguard Worker
4834*35238bceSAndroid Build Coastguard Worker /* Invalid Renderbuffer ID. */
4835*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferRenderbuffer(m_fbo_valid, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo_invalid);
4836*35238bceSAndroid Build Coastguard Worker
4837*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, true, true, false, true, false);
4838*35238bceSAndroid Build Coastguard Worker }
4839*35238bceSAndroid Build Coastguard Worker catch (...)
4840*35238bceSAndroid Build Coastguard Worker {
4841*35238bceSAndroid Build Coastguard Worker is_ok = false;
4842*35238bceSAndroid Build Coastguard Worker is_error = true;
4843*35238bceSAndroid Build Coastguard Worker }
4844*35238bceSAndroid Build Coastguard Worker
4845*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
4846*35238bceSAndroid Build Coastguard Worker Clean();
4847*35238bceSAndroid Build Coastguard Worker
4848*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
4849*35238bceSAndroid Build Coastguard Worker if (is_ok)
4850*35238bceSAndroid Build Coastguard Worker {
4851*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
4852*35238bceSAndroid Build Coastguard Worker }
4853*35238bceSAndroid Build Coastguard Worker else
4854*35238bceSAndroid Build Coastguard Worker {
4855*35238bceSAndroid Build Coastguard Worker if (is_error)
4856*35238bceSAndroid Build Coastguard Worker {
4857*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
4858*35238bceSAndroid Build Coastguard Worker }
4859*35238bceSAndroid Build Coastguard Worker else
4860*35238bceSAndroid Build Coastguard Worker {
4861*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
4862*35238bceSAndroid Build Coastguard Worker }
4863*35238bceSAndroid Build Coastguard Worker }
4864*35238bceSAndroid Build Coastguard Worker
4865*35238bceSAndroid Build Coastguard Worker return STOP;
4866*35238bceSAndroid Build Coastguard Worker }
4867*35238bceSAndroid Build Coastguard Worker
4868*35238bceSAndroid Build Coastguard Worker /** Prepare test objects.
4869*35238bceSAndroid Build Coastguard Worker */
PrepareObjects()4870*35238bceSAndroid Build Coastguard Worker void RenderbufferAttachmentErrorsTest::PrepareObjects()
4871*35238bceSAndroid Build Coastguard Worker {
4872*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
4873*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
4874*35238bceSAndroid Build Coastguard Worker
4875*35238bceSAndroid Build Coastguard Worker /* Valid objects. */
4876*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(1, &m_fbo_valid);
4877*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
4878*35238bceSAndroid Build Coastguard Worker
4879*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_valid);
4880*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
4881*35238bceSAndroid Build Coastguard Worker
4882*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(1, &m_rbo_valid);
4883*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
4884*35238bceSAndroid Build Coastguard Worker
4885*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo_valid);
4886*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
4887*35238bceSAndroid Build Coastguard Worker
4888*35238bceSAndroid Build Coastguard Worker /* Invalid objects. */
4889*35238bceSAndroid Build Coastguard Worker while (gl.isFramebuffer(++m_fbo_invalid))
4890*35238bceSAndroid Build Coastguard Worker ;
4891*35238bceSAndroid Build Coastguard Worker while (gl.isRenderbuffer(++m_rbo_invalid))
4892*35238bceSAndroid Build Coastguard Worker ;
4893*35238bceSAndroid Build Coastguard Worker
4894*35238bceSAndroid Build Coastguard Worker /* Max color attachments query. */
4895*35238bceSAndroid Build Coastguard Worker glw::GLint max_color_attachments = 8; /* Spec default. */
4896*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
4897*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
4898*35238bceSAndroid Build Coastguard Worker
4899*35238bceSAndroid Build Coastguard Worker /* Invalid color attachment */
4900*35238bceSAndroid Build Coastguard Worker m_color_attachment_invalid = GL_COLOR_ATTACHMENT0 + max_color_attachments;
4901*35238bceSAndroid Build Coastguard Worker
4902*35238bceSAndroid Build Coastguard Worker /* Invalid attachment. */
4903*35238bceSAndroid Build Coastguard Worker bool is_attachment = true;
4904*35238bceSAndroid Build Coastguard Worker
4905*35238bceSAndroid Build Coastguard Worker while (is_attachment)
4906*35238bceSAndroid Build Coastguard Worker {
4907*35238bceSAndroid Build Coastguard Worker ++m_attachment_invalid;
4908*35238bceSAndroid Build Coastguard Worker
4909*35238bceSAndroid Build Coastguard Worker is_attachment = false;
4910*35238bceSAndroid Build Coastguard Worker
4911*35238bceSAndroid Build Coastguard Worker if ((GL_DEPTH_ATTACHMENT == m_attachment_invalid) || (GL_STENCIL_ATTACHMENT == m_attachment_invalid) ||
4912*35238bceSAndroid Build Coastguard Worker (GL_DEPTH_STENCIL_ATTACHMENT == m_attachment_invalid))
4913*35238bceSAndroid Build Coastguard Worker {
4914*35238bceSAndroid Build Coastguard Worker is_attachment = true;
4915*35238bceSAndroid Build Coastguard Worker }
4916*35238bceSAndroid Build Coastguard Worker
4917*35238bceSAndroid Build Coastguard Worker if (GL_COLOR_ATTACHMENT0 < m_attachment_invalid)
4918*35238bceSAndroid Build Coastguard Worker {
4919*35238bceSAndroid Build Coastguard Worker /* If this unlikely happen this mean that we cannot create invalid attachment which is not DEPTH_ATTACHMENT, STENCIL_ATTACHMENT, DEPTH_STENCIL_ATTACHMENT and
4920*35238bceSAndroid Build Coastguard Worker GL_COLOR_ATTACHMENTm where m IS any positive integer number (for m < MAX_COLOR_ATTACHMENTS attachments are valid, and for m >= MAX_COLOR_ATTACHMENTS is invalid, but
4921*35238bceSAndroid Build Coastguard Worker INVALID_OPERATION shall be generated instead of INVALID_ENUM. Such a situation may need change in the test or in the specification. */
4922*35238bceSAndroid Build Coastguard Worker throw 0;
4923*35238bceSAndroid Build Coastguard Worker }
4924*35238bceSAndroid Build Coastguard Worker }
4925*35238bceSAndroid Build Coastguard Worker
4926*35238bceSAndroid Build Coastguard Worker /* Invalid renderbuffer target. */
4927*35238bceSAndroid Build Coastguard Worker m_renderbuffer_target_invalid = GL_RENDERBUFFER + 1;
4928*35238bceSAndroid Build Coastguard Worker }
4929*35238bceSAndroid Build Coastguard Worker
4930*35238bceSAndroid Build Coastguard Worker /** Check if error is equal to the expected, log if not.
4931*35238bceSAndroid Build Coastguard Worker *
4932*35238bceSAndroid Build Coastguard Worker * @param [in] expected_error Error to be expected.
4933*35238bceSAndroid Build Coastguard Worker * @param [in] framebuffer Framebuffer name to be logged.
4934*35238bceSAndroid Build Coastguard Worker * @param [in] attachment Attachment name to be logged.
4935*35238bceSAndroid Build Coastguard Worker * @param [in] renderbuffertarget Renderbuffertarget name to be logged.
4936*35238bceSAndroid Build Coastguard Worker * @param [in] renderbuffer Renderbuffer name to be logged.
4937*35238bceSAndroid Build Coastguard Worker *
4938*35238bceSAndroid Build Coastguard Worker * @return True if test succeeded, false otherwise.
4939*35238bceSAndroid Build Coastguard Worker */
ExpectError(glw::GLenum expected_error,bool framebuffer,bool attachment,bool color_attachment,bool renderbuffertarget,bool renderbuffer)4940*35238bceSAndroid Build Coastguard Worker bool RenderbufferAttachmentErrorsTest::ExpectError(glw::GLenum expected_error, bool framebuffer, bool attachment,
4941*35238bceSAndroid Build Coastguard Worker bool color_attachment, bool renderbuffertarget, bool renderbuffer)
4942*35238bceSAndroid Build Coastguard Worker {
4943*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
4944*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
4945*35238bceSAndroid Build Coastguard Worker
4946*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
4947*35238bceSAndroid Build Coastguard Worker
4948*35238bceSAndroid Build Coastguard Worker glw::GLenum error = GL_NO_ERROR;
4949*35238bceSAndroid Build Coastguard Worker
4950*35238bceSAndroid Build Coastguard Worker if (expected_error != (error = gl.getError()))
4951*35238bceSAndroid Build Coastguard Worker {
4952*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
4953*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "NamedFramebufferRenderbuffer called with "
4954*35238bceSAndroid Build Coastguard Worker << (framebuffer ? "valid" : "invalid") << " framebuffer, " << (attachment ? "valid" : "invalid")
4955*35238bceSAndroid Build Coastguard Worker << (color_attachment ? " color" : "") << " attachment, " << (renderbuffertarget ? "valid" : "invalid")
4956*35238bceSAndroid Build Coastguard Worker << " renderbuffer target, " << (renderbuffer ? "valid" : "invalid")
4957*35238bceSAndroid Build Coastguard Worker << " renderbuffer was expected to generate " << glu::getErrorStr(expected_error) << ", but "
4958*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(error) << " was observed instead." << tcu::TestLog::EndMessage;
4959*35238bceSAndroid Build Coastguard Worker
4960*35238bceSAndroid Build Coastguard Worker is_ok = false;
4961*35238bceSAndroid Build Coastguard Worker }
4962*35238bceSAndroid Build Coastguard Worker
4963*35238bceSAndroid Build Coastguard Worker /* Clean additional possible errors. */
4964*35238bceSAndroid Build Coastguard Worker while (gl.getError())
4965*35238bceSAndroid Build Coastguard Worker ;
4966*35238bceSAndroid Build Coastguard Worker
4967*35238bceSAndroid Build Coastguard Worker return is_ok;
4968*35238bceSAndroid Build Coastguard Worker }
4969*35238bceSAndroid Build Coastguard Worker
4970*35238bceSAndroid Build Coastguard Worker /** @brief Clean up GL state.
4971*35238bceSAndroid Build Coastguard Worker */
Clean()4972*35238bceSAndroid Build Coastguard Worker void RenderbufferAttachmentErrorsTest::Clean()
4973*35238bceSAndroid Build Coastguard Worker {
4974*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
4975*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
4976*35238bceSAndroid Build Coastguard Worker
4977*35238bceSAndroid Build Coastguard Worker /* Release GL objects. */
4978*35238bceSAndroid Build Coastguard Worker if (m_fbo_valid)
4979*35238bceSAndroid Build Coastguard Worker {
4980*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &m_fbo_valid);
4981*35238bceSAndroid Build Coastguard Worker m_fbo_valid = 0;
4982*35238bceSAndroid Build Coastguard Worker }
4983*35238bceSAndroid Build Coastguard Worker
4984*35238bceSAndroid Build Coastguard Worker if (m_rbo_valid)
4985*35238bceSAndroid Build Coastguard Worker {
4986*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &m_rbo_valid);
4987*35238bceSAndroid Build Coastguard Worker m_rbo_valid = 0;
4988*35238bceSAndroid Build Coastguard Worker }
4989*35238bceSAndroid Build Coastguard Worker
4990*35238bceSAndroid Build Coastguard Worker /* Set initial values - all test shall have the same environment. */
4991*35238bceSAndroid Build Coastguard Worker m_fbo_invalid = 0;
4992*35238bceSAndroid Build Coastguard Worker m_rbo_invalid = 0;
4993*35238bceSAndroid Build Coastguard Worker m_attachment_invalid = 0;
4994*35238bceSAndroid Build Coastguard Worker m_color_attachment_invalid = 0;
4995*35238bceSAndroid Build Coastguard Worker m_renderbuffer_target_invalid = 0;
4996*35238bceSAndroid Build Coastguard Worker
4997*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
4998*35238bceSAndroid Build Coastguard Worker while (gl.getError())
4999*35238bceSAndroid Build Coastguard Worker ;
5000*35238bceSAndroid Build Coastguard Worker }
5001*35238bceSAndroid Build Coastguard Worker
5002*35238bceSAndroid Build Coastguard Worker /******************************** Texture Attachment Errors Test Implementation ********************************/
5003*35238bceSAndroid Build Coastguard Worker
5004*35238bceSAndroid Build Coastguard Worker /** @brief Texture Attachment Errors Test constructor.
5005*35238bceSAndroid Build Coastguard Worker *
5006*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
5007*35238bceSAndroid Build Coastguard Worker */
TextureAttachmentErrorsTest(deqp::Context & context)5008*35238bceSAndroid Build Coastguard Worker TextureAttachmentErrorsTest::TextureAttachmentErrorsTest(deqp::Context &context)
5009*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "framebuffers_texture_attachment_errors", "Texture Attachment Errors Test")
5010*35238bceSAndroid Build Coastguard Worker , m_fbo_valid(0)
5011*35238bceSAndroid Build Coastguard Worker , m_to_valid(0)
5012*35238bceSAndroid Build Coastguard Worker , m_to_3d_valid(0)
5013*35238bceSAndroid Build Coastguard Worker , m_to_array_valid(0)
5014*35238bceSAndroid Build Coastguard Worker , m_to_cubearray_valid(0)
5015*35238bceSAndroid Build Coastguard Worker , m_tbo_valid(0)
5016*35238bceSAndroid Build Coastguard Worker , m_fbo_invalid(0)
5017*35238bceSAndroid Build Coastguard Worker , m_to_invalid(0)
5018*35238bceSAndroid Build Coastguard Worker , m_to_layer_invalid(0)
5019*35238bceSAndroid Build Coastguard Worker , m_color_attachment_invalid(0)
5020*35238bceSAndroid Build Coastguard Worker , m_attachment_invalid(0)
5021*35238bceSAndroid Build Coastguard Worker , m_level_invalid(0)
5022*35238bceSAndroid Build Coastguard Worker , m_max_3d_texture_size(2048) /* OpenGL 4.5 Core Profile default values (Table 23.53). */
5023*35238bceSAndroid Build Coastguard Worker , m_max_3d_texture_depth(2048) /* == m_max_3d_texture_size or value of GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV. */
5024*35238bceSAndroid Build Coastguard Worker , m_max_array_texture_layers(2048) /* OpenGL 4.5 Core Profile default values (Table 23.53). */
5025*35238bceSAndroid Build Coastguard Worker , m_max_cube_map_texture_size(16384) /* OpenGL 4.5 Core Profile default values (Table 23.53). */
5026*35238bceSAndroid Build Coastguard Worker {
5027*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
5028*35238bceSAndroid Build Coastguard Worker }
5029*35238bceSAndroid Build Coastguard Worker
5030*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Texture Attachment Errors Test cases.
5031*35238bceSAndroid Build Coastguard Worker *
5032*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
5033*35238bceSAndroid Build Coastguard Worker */
iterate()5034*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult TextureAttachmentErrorsTest::iterate()
5035*35238bceSAndroid Build Coastguard Worker {
5036*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
5037*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
5038*35238bceSAndroid Build Coastguard Worker
5039*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
5040*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
5041*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
5042*35238bceSAndroid Build Coastguard Worker
5043*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
5044*35238bceSAndroid Build Coastguard Worker {
5045*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
5046*35238bceSAndroid Build Coastguard Worker
5047*35238bceSAndroid Build Coastguard Worker return STOP;
5048*35238bceSAndroid Build Coastguard Worker }
5049*35238bceSAndroid Build Coastguard Worker
5050*35238bceSAndroid Build Coastguard Worker /* Running tests. */
5051*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
5052*35238bceSAndroid Build Coastguard Worker bool is_error = false;
5053*35238bceSAndroid Build Coastguard Worker
5054*35238bceSAndroid Build Coastguard Worker try
5055*35238bceSAndroid Build Coastguard Worker {
5056*35238bceSAndroid Build Coastguard Worker /* Prepare objects. */
5057*35238bceSAndroid Build Coastguard Worker PrepareObjects();
5058*35238bceSAndroid Build Coastguard Worker
5059*35238bceSAndroid Build Coastguard Worker /********** NamedFramebufferTexture **************/
5060*35238bceSAndroid Build Coastguard Worker
5061*35238bceSAndroid Build Coastguard Worker /* Invalid Framebuffer ID. */
5062*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferTexture(m_fbo_invalid, GL_COLOR_ATTACHMENT0, m_to_valid, 0);
5063*35238bceSAndroid Build Coastguard Worker
5064*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferTexture", false, true, false, true, true, "", true);
5065*35238bceSAndroid Build Coastguard Worker
5066*35238bceSAndroid Build Coastguard Worker /* Invalid Color Attachment. */
5067*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferTexture(m_fbo_valid, m_color_attachment_invalid, m_to_valid, 0);
5068*35238bceSAndroid Build Coastguard Worker
5069*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferTexture", true, false, true, true, true, "", true);
5070*35238bceSAndroid Build Coastguard Worker
5071*35238bceSAndroid Build Coastguard Worker /* Invalid Attachment. */
5072*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferTexture(m_fbo_valid, m_attachment_invalid, m_to_valid, 0);
5073*35238bceSAndroid Build Coastguard Worker
5074*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, "NamedFramebufferTexture", true, false, false, true, true, "", true);
5075*35238bceSAndroid Build Coastguard Worker
5076*35238bceSAndroid Build Coastguard Worker /* Invalid Texture ID. */
5077*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferTexture(m_fbo_valid, GL_COLOR_ATTACHMENT0, m_to_invalid, 0);
5078*35238bceSAndroid Build Coastguard Worker
5079*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_VALUE, "NamedFramebufferTexture", true, true, false, false, true, "", true);
5080*35238bceSAndroid Build Coastguard Worker
5081*35238bceSAndroid Build Coastguard Worker /* Invalid Level. */
5082*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferTexture(m_fbo_valid, GL_COLOR_ATTACHMENT0, m_to_valid, m_level_invalid);
5083*35238bceSAndroid Build Coastguard Worker
5084*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_VALUE, "NamedFramebufferTexture", true, true, false, true, false, "", true);
5085*35238bceSAndroid Build Coastguard Worker
5086*35238bceSAndroid Build Coastguard Worker /* Buffer texture. */
5087*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferTexture(m_fbo_valid, GL_COLOR_ATTACHMENT0, m_tbo_valid, 0);
5088*35238bceSAndroid Build Coastguard Worker
5089*35238bceSAndroid Build Coastguard Worker is_ok &=
5090*35238bceSAndroid Build Coastguard Worker ExpectError(GL_INVALID_OPERATION, "NamedFramebufferTexture", true, true, false, true, true, "buffer", true);
5091*35238bceSAndroid Build Coastguard Worker
5092*35238bceSAndroid Build Coastguard Worker /********** NamedFramebufferTextureLayer **************/
5093*35238bceSAndroid Build Coastguard Worker
5094*35238bceSAndroid Build Coastguard Worker /* Invalid Framebuffer ID. */
5095*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferTextureLayer(m_fbo_invalid, GL_COLOR_ATTACHMENT0, m_to_array_valid, 0, 0);
5096*35238bceSAndroid Build Coastguard Worker
5097*35238bceSAndroid Build Coastguard Worker is_ok &=
5098*35238bceSAndroid Build Coastguard Worker ExpectError(GL_INVALID_OPERATION, "NamedFramebufferTextureLayer", false, true, false, true, true, "", true);
5099*35238bceSAndroid Build Coastguard Worker
5100*35238bceSAndroid Build Coastguard Worker /* Invalid Color Attachment. */
5101*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferTextureLayer(m_fbo_valid, m_color_attachment_invalid, m_to_array_valid, 0, 0);
5102*35238bceSAndroid Build Coastguard Worker
5103*35238bceSAndroid Build Coastguard Worker is_ok &=
5104*35238bceSAndroid Build Coastguard Worker ExpectError(GL_INVALID_OPERATION, "NamedFramebufferTextureLayer", true, false, true, true, true, "", true);
5105*35238bceSAndroid Build Coastguard Worker
5106*35238bceSAndroid Build Coastguard Worker /* Invalid Attachment. */
5107*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferTextureLayer(m_fbo_valid, m_attachment_invalid, m_to_array_valid, 0, 0);
5108*35238bceSAndroid Build Coastguard Worker
5109*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, "NamedFramebufferTextureLayer", true, false, false, true, true, "", true);
5110*35238bceSAndroid Build Coastguard Worker
5111*35238bceSAndroid Build Coastguard Worker /* Invalid Texture ID. */
5112*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferTextureLayer(m_fbo_valid, GL_COLOR_ATTACHMENT0, m_to_invalid, 0, 0);
5113*35238bceSAndroid Build Coastguard Worker
5114*35238bceSAndroid Build Coastguard Worker is_ok &=
5115*35238bceSAndroid Build Coastguard Worker ExpectError(GL_INVALID_OPERATION, "NamedFramebufferTextureLayer", true, true, false, false, true, "", true);
5116*35238bceSAndroid Build Coastguard Worker
5117*35238bceSAndroid Build Coastguard Worker /* Invalid Level. */
5118*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferTextureLayer(m_fbo_valid, GL_COLOR_ATTACHMENT0, m_to_array_valid, m_level_invalid, 0);
5119*35238bceSAndroid Build Coastguard Worker
5120*35238bceSAndroid Build Coastguard Worker is_ok &=
5121*35238bceSAndroid Build Coastguard Worker ExpectError(GL_INVALID_VALUE, "NamedFramebufferTextureLayer", true, true, false, true, false, "", true);
5122*35238bceSAndroid Build Coastguard Worker
5123*35238bceSAndroid Build Coastguard Worker /* Buffer texture. */
5124*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferTextureLayer(m_fbo_valid, GL_COLOR_ATTACHMENT0, m_tbo_valid, 0, 0);
5125*35238bceSAndroid Build Coastguard Worker
5126*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferTextureLayer", true, true, false, true, true,
5127*35238bceSAndroid Build Coastguard Worker "buffer", true);
5128*35238bceSAndroid Build Coastguard Worker
5129*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_VALUE error is generated by NamedFramebufferTextureLayer if texture is a three-dimensional
5130*35238bceSAndroid Build Coastguard Worker texture, and layer is larger than the value of MAX_3D_TEXTURE_SIZE or GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV (if available) minus one. */
5131*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferTextureLayer(m_fbo_valid, GL_COLOR_ATTACHMENT0, m_to_3d_valid, 0, m_max_3d_texture_depth);
5132*35238bceSAndroid Build Coastguard Worker
5133*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_VALUE, "NamedFramebufferTextureLayer", true, true, false, true, true,
5134*35238bceSAndroid Build Coastguard Worker "3D texture", false);
5135*35238bceSAndroid Build Coastguard Worker
5136*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_VALUE error is generated by NamedFramebufferTextureLayer if texture is an array texture,
5137*35238bceSAndroid Build Coastguard Worker and layer is larger than the value of MAX_ARRAY_TEXTURE_LAYERS minus one. */
5138*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferTextureLayer(m_fbo_valid, GL_COLOR_ATTACHMENT0, m_to_array_valid, 0,
5139*35238bceSAndroid Build Coastguard Worker m_max_array_texture_layers);
5140*35238bceSAndroid Build Coastguard Worker
5141*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_VALUE, "NamedFramebufferTextureLayer", true, true, false, true, true, "array",
5142*35238bceSAndroid Build Coastguard Worker false);
5143*35238bceSAndroid Build Coastguard Worker
5144*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_VALUE error is generated by NamedFramebufferTextureLayer if texture is a cube map array texture,
5145*35238bceSAndroid Build Coastguard Worker and (layer / 6) is larger than the value of MAX_CUBE_MAP_TEXTURE_SIZE minus one (see section 9.8).
5146*35238bceSAndroid Build Coastguard Worker Check that INVALID_VALUE error is generated by NamedFramebufferTextureLayer if texture is non-zero
5147*35238bceSAndroid Build Coastguard Worker and layer is negative. */
5148*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferTextureLayer(m_fbo_valid, GL_COLOR_ATTACHMENT0, m_to_cubearray_valid, 0,
5149*35238bceSAndroid Build Coastguard Worker m_max_cube_map_texture_size);
5150*35238bceSAndroid Build Coastguard Worker
5151*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_VALUE, "NamedFramebufferTextureLayer", true, true, false, true, true,
5152*35238bceSAndroid Build Coastguard Worker "cuba map array", false);
5153*35238bceSAndroid Build Coastguard Worker
5154*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_OPERATION error is generated by NamedFramebufferTextureLayer if texture is non-zero
5155*35238bceSAndroid Build Coastguard Worker and is not the name of a three-dimensional, two-dimensional multisample array, one- or two-dimensional array,
5156*35238bceSAndroid Build Coastguard Worker or cube map array texture. */
5157*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferTextureLayer(m_fbo_valid, GL_COLOR_ATTACHMENT0, m_to_layer_invalid, 0, 0);
5158*35238bceSAndroid Build Coastguard Worker
5159*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferTextureLayer", true, true, false, false, true,
5160*35238bceSAndroid Build Coastguard Worker "rectangle", true);
5161*35238bceSAndroid Build Coastguard Worker }
5162*35238bceSAndroid Build Coastguard Worker catch (...)
5163*35238bceSAndroid Build Coastguard Worker {
5164*35238bceSAndroid Build Coastguard Worker is_ok = false;
5165*35238bceSAndroid Build Coastguard Worker is_error = true;
5166*35238bceSAndroid Build Coastguard Worker }
5167*35238bceSAndroid Build Coastguard Worker
5168*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
5169*35238bceSAndroid Build Coastguard Worker Clean();
5170*35238bceSAndroid Build Coastguard Worker
5171*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
5172*35238bceSAndroid Build Coastguard Worker if (is_ok)
5173*35238bceSAndroid Build Coastguard Worker {
5174*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
5175*35238bceSAndroid Build Coastguard Worker }
5176*35238bceSAndroid Build Coastguard Worker else
5177*35238bceSAndroid Build Coastguard Worker {
5178*35238bceSAndroid Build Coastguard Worker if (is_error)
5179*35238bceSAndroid Build Coastguard Worker {
5180*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
5181*35238bceSAndroid Build Coastguard Worker }
5182*35238bceSAndroid Build Coastguard Worker else
5183*35238bceSAndroid Build Coastguard Worker {
5184*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
5185*35238bceSAndroid Build Coastguard Worker }
5186*35238bceSAndroid Build Coastguard Worker }
5187*35238bceSAndroid Build Coastguard Worker
5188*35238bceSAndroid Build Coastguard Worker return STOP;
5189*35238bceSAndroid Build Coastguard Worker }
5190*35238bceSAndroid Build Coastguard Worker
5191*35238bceSAndroid Build Coastguard Worker /** Prepare test GL objects.
5192*35238bceSAndroid Build Coastguard Worker */
PrepareObjects()5193*35238bceSAndroid Build Coastguard Worker void TextureAttachmentErrorsTest::PrepareObjects()
5194*35238bceSAndroid Build Coastguard Worker {
5195*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
5196*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
5197*35238bceSAndroid Build Coastguard Worker
5198*35238bceSAndroid Build Coastguard Worker /* Valid objects. */
5199*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(1, &m_fbo_valid);
5200*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
5201*35238bceSAndroid Build Coastguard Worker
5202*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_valid);
5203*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
5204*35238bceSAndroid Build Coastguard Worker
5205*35238bceSAndroid Build Coastguard Worker gl.genTextures(1, &m_to_valid);
5206*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
5207*35238bceSAndroid Build Coastguard Worker
5208*35238bceSAndroid Build Coastguard Worker gl.bindTexture(GL_TEXTURE_2D, m_to_valid);
5209*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
5210*35238bceSAndroid Build Coastguard Worker
5211*35238bceSAndroid Build Coastguard Worker gl.genTextures(1, &m_tbo_valid);
5212*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
5213*35238bceSAndroid Build Coastguard Worker
5214*35238bceSAndroid Build Coastguard Worker gl.bindTexture(GL_TEXTURE_BUFFER, m_tbo_valid);
5215*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
5216*35238bceSAndroid Build Coastguard Worker
5217*35238bceSAndroid Build Coastguard Worker gl.genTextures(1, &m_to_3d_valid);
5218*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
5219*35238bceSAndroid Build Coastguard Worker
5220*35238bceSAndroid Build Coastguard Worker gl.bindTexture(GL_TEXTURE_3D, m_to_3d_valid);
5221*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
5222*35238bceSAndroid Build Coastguard Worker
5223*35238bceSAndroid Build Coastguard Worker gl.genTextures(1, &m_to_array_valid);
5224*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
5225*35238bceSAndroid Build Coastguard Worker
5226*35238bceSAndroid Build Coastguard Worker gl.bindTexture(GL_TEXTURE_2D_ARRAY, m_to_array_valid);
5227*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
5228*35238bceSAndroid Build Coastguard Worker
5229*35238bceSAndroid Build Coastguard Worker gl.genTextures(1, &m_to_cubearray_valid);
5230*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
5231*35238bceSAndroid Build Coastguard Worker
5232*35238bceSAndroid Build Coastguard Worker gl.bindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, m_to_cubearray_valid);
5233*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
5234*35238bceSAndroid Build Coastguard Worker
5235*35238bceSAndroid Build Coastguard Worker gl.genTextures(1, &m_to_layer_invalid);
5236*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
5237*35238bceSAndroid Build Coastguard Worker
5238*35238bceSAndroid Build Coastguard Worker gl.bindTexture(GL_TEXTURE_RECTANGLE, m_to_layer_invalid);
5239*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
5240*35238bceSAndroid Build Coastguard Worker
5241*35238bceSAndroid Build Coastguard Worker /* Invalid objects. */
5242*35238bceSAndroid Build Coastguard Worker while (gl.isFramebuffer(++m_fbo_invalid))
5243*35238bceSAndroid Build Coastguard Worker ;
5244*35238bceSAndroid Build Coastguard Worker while (gl.isTexture(++m_to_invalid))
5245*35238bceSAndroid Build Coastguard Worker ;
5246*35238bceSAndroid Build Coastguard Worker
5247*35238bceSAndroid Build Coastguard Worker /* Max color attachments query. */
5248*35238bceSAndroid Build Coastguard Worker glw::GLint max_color_attachments = 8; /* Spec default. */
5249*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
5250*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
5251*35238bceSAndroid Build Coastguard Worker
5252*35238bceSAndroid Build Coastguard Worker /* Invalid color attachment */
5253*35238bceSAndroid Build Coastguard Worker m_color_attachment_invalid = GL_COLOR_ATTACHMENT0 + max_color_attachments;
5254*35238bceSAndroid Build Coastguard Worker
5255*35238bceSAndroid Build Coastguard Worker /* Invalid attachment. */
5256*35238bceSAndroid Build Coastguard Worker bool is_attachment = true;
5257*35238bceSAndroid Build Coastguard Worker
5258*35238bceSAndroid Build Coastguard Worker while (is_attachment)
5259*35238bceSAndroid Build Coastguard Worker {
5260*35238bceSAndroid Build Coastguard Worker ++m_attachment_invalid;
5261*35238bceSAndroid Build Coastguard Worker
5262*35238bceSAndroid Build Coastguard Worker is_attachment = false;
5263*35238bceSAndroid Build Coastguard Worker
5264*35238bceSAndroid Build Coastguard Worker if ((GL_DEPTH_ATTACHMENT == m_attachment_invalid) || (GL_STENCIL_ATTACHMENT == m_attachment_invalid) ||
5265*35238bceSAndroid Build Coastguard Worker (GL_DEPTH_STENCIL_ATTACHMENT == m_attachment_invalid))
5266*35238bceSAndroid Build Coastguard Worker {
5267*35238bceSAndroid Build Coastguard Worker is_attachment = true;
5268*35238bceSAndroid Build Coastguard Worker }
5269*35238bceSAndroid Build Coastguard Worker
5270*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < max_color_attachments; ++i)
5271*35238bceSAndroid Build Coastguard Worker {
5272*35238bceSAndroid Build Coastguard Worker if (GL_COLOR_ATTACHMENT0 == m_attachment_invalid)
5273*35238bceSAndroid Build Coastguard Worker {
5274*35238bceSAndroid Build Coastguard Worker is_attachment = true;
5275*35238bceSAndroid Build Coastguard Worker }
5276*35238bceSAndroid Build Coastguard Worker }
5277*35238bceSAndroid Build Coastguard Worker }
5278*35238bceSAndroid Build Coastguard Worker
5279*35238bceSAndroid Build Coastguard Worker /* Maximum values */
5280*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_3D_TEXTURE_SIZE, &m_max_3d_texture_size);
5281*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &m_max_array_texture_layers);
5282*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &m_max_cube_map_texture_size);
5283*35238bceSAndroid Build Coastguard Worker
5284*35238bceSAndroid Build Coastguard Worker if (m_context.getContextInfo().isExtensionSupported("GL_NV_deep_texture3D"))
5285*35238bceSAndroid Build Coastguard Worker {
5286*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV, &m_max_3d_texture_depth);
5287*35238bceSAndroid Build Coastguard Worker }
5288*35238bceSAndroid Build Coastguard Worker else
5289*35238bceSAndroid Build Coastguard Worker {
5290*35238bceSAndroid Build Coastguard Worker m_max_3d_texture_depth = m_max_3d_texture_size;
5291*35238bceSAndroid Build Coastguard Worker }
5292*35238bceSAndroid Build Coastguard Worker
5293*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
5294*35238bceSAndroid Build Coastguard Worker
5295*35238bceSAndroid Build Coastguard Worker /* Invalid level. */
5296*35238bceSAndroid Build Coastguard Worker m_level_invalid = -1;
5297*35238bceSAndroid Build Coastguard Worker }
5298*35238bceSAndroid Build Coastguard Worker
5299*35238bceSAndroid Build Coastguard Worker /** Check if error is equal to the expected, log if not.
5300*35238bceSAndroid Build Coastguard Worker *
5301*35238bceSAndroid Build Coastguard Worker * @param [in] expected_error Error to be expected.
5302*35238bceSAndroid Build Coastguard Worker * @param [in] framebuffer Framebuffer name to be logged.
5303*35238bceSAndroid Build Coastguard Worker * @param [in] attachment Attachment name to be logged.
5304*35238bceSAndroid Build Coastguard Worker * @param [in] texture Texture name to be logged.
5305*35238bceSAndroid Build Coastguard Worker * @param [in] level Level # to be logged.
5306*35238bceSAndroid Build Coastguard Worker * @param [in] buffer_texture Is this buffer texture (special logging case).
5307*35238bceSAndroid Build Coastguard Worker *
5308*35238bceSAndroid Build Coastguard Worker * @return True if test succeeded, false otherwise.
5309*35238bceSAndroid Build Coastguard Worker */
ExpectError(glw::GLenum expected_error,const glw::GLchar * function_name,bool framebuffer,bool attachment,bool color_attachment,bool texture,bool level,const glw::GLchar * texture_type,bool layer)5310*35238bceSAndroid Build Coastguard Worker bool TextureAttachmentErrorsTest::ExpectError(glw::GLenum expected_error, const glw::GLchar *function_name,
5311*35238bceSAndroid Build Coastguard Worker bool framebuffer, bool attachment, bool color_attachment, bool texture,
5312*35238bceSAndroid Build Coastguard Worker bool level, const glw::GLchar *texture_type, bool layer)
5313*35238bceSAndroid Build Coastguard Worker {
5314*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
5315*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
5316*35238bceSAndroid Build Coastguard Worker
5317*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
5318*35238bceSAndroid Build Coastguard Worker
5319*35238bceSAndroid Build Coastguard Worker glw::GLenum error = GL_NO_ERROR;
5320*35238bceSAndroid Build Coastguard Worker
5321*35238bceSAndroid Build Coastguard Worker if (expected_error != (error = gl.getError()))
5322*35238bceSAndroid Build Coastguard Worker {
5323*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
5324*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << function_name << " called with " << (framebuffer ? "valid" : "invalid")
5325*35238bceSAndroid Build Coastguard Worker << " framebuffer, " << (attachment ? "valid" : "invalid") << (color_attachment ? " color" : "")
5326*35238bceSAndroid Build Coastguard Worker << " attachment, " << (texture ? "valid " : "invalid ") << texture_type << " texture, "
5327*35238bceSAndroid Build Coastguard Worker << (level ? "valid" : "invalid") << " level" << (layer ? "" : ", with invalid layer number")
5328*35238bceSAndroid Build Coastguard Worker << " was expected to generate " << glu::getErrorStr(expected_error) << ", but " << glu::getErrorStr(error)
5329*35238bceSAndroid Build Coastguard Worker << " was observed instead." << tcu::TestLog::EndMessage;
5330*35238bceSAndroid Build Coastguard Worker
5331*35238bceSAndroid Build Coastguard Worker is_ok = false;
5332*35238bceSAndroid Build Coastguard Worker }
5333*35238bceSAndroid Build Coastguard Worker
5334*35238bceSAndroid Build Coastguard Worker /* Clean additional possible errors. */
5335*35238bceSAndroid Build Coastguard Worker while (gl.getError())
5336*35238bceSAndroid Build Coastguard Worker ;
5337*35238bceSAndroid Build Coastguard Worker
5338*35238bceSAndroid Build Coastguard Worker return is_ok;
5339*35238bceSAndroid Build Coastguard Worker }
5340*35238bceSAndroid Build Coastguard Worker
5341*35238bceSAndroid Build Coastguard Worker /** @brief Clean up GL state.
5342*35238bceSAndroid Build Coastguard Worker */
Clean()5343*35238bceSAndroid Build Coastguard Worker void TextureAttachmentErrorsTest::Clean()
5344*35238bceSAndroid Build Coastguard Worker {
5345*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
5346*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
5347*35238bceSAndroid Build Coastguard Worker
5348*35238bceSAndroid Build Coastguard Worker /* Release GL objects. */
5349*35238bceSAndroid Build Coastguard Worker if (m_fbo_valid)
5350*35238bceSAndroid Build Coastguard Worker {
5351*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &m_fbo_valid);
5352*35238bceSAndroid Build Coastguard Worker m_fbo_valid = 0;
5353*35238bceSAndroid Build Coastguard Worker }
5354*35238bceSAndroid Build Coastguard Worker
5355*35238bceSAndroid Build Coastguard Worker if (m_to_valid)
5356*35238bceSAndroid Build Coastguard Worker {
5357*35238bceSAndroid Build Coastguard Worker gl.deleteTextures(1, &m_to_valid);
5358*35238bceSAndroid Build Coastguard Worker m_to_valid = 0;
5359*35238bceSAndroid Build Coastguard Worker }
5360*35238bceSAndroid Build Coastguard Worker
5361*35238bceSAndroid Build Coastguard Worker if (m_tbo_valid)
5362*35238bceSAndroid Build Coastguard Worker {
5363*35238bceSAndroid Build Coastguard Worker gl.deleteTextures(1, &m_tbo_valid);
5364*35238bceSAndroid Build Coastguard Worker m_tbo_valid = 0;
5365*35238bceSAndroid Build Coastguard Worker }
5366*35238bceSAndroid Build Coastguard Worker
5367*35238bceSAndroid Build Coastguard Worker if (m_to_3d_valid)
5368*35238bceSAndroid Build Coastguard Worker {
5369*35238bceSAndroid Build Coastguard Worker gl.deleteTextures(1, &m_to_3d_valid);
5370*35238bceSAndroid Build Coastguard Worker m_to_3d_valid = 0;
5371*35238bceSAndroid Build Coastguard Worker }
5372*35238bceSAndroid Build Coastguard Worker
5373*35238bceSAndroid Build Coastguard Worker if (m_to_array_valid)
5374*35238bceSAndroid Build Coastguard Worker {
5375*35238bceSAndroid Build Coastguard Worker gl.deleteTextures(1, &m_to_array_valid);
5376*35238bceSAndroid Build Coastguard Worker m_to_array_valid = 0;
5377*35238bceSAndroid Build Coastguard Worker }
5378*35238bceSAndroid Build Coastguard Worker
5379*35238bceSAndroid Build Coastguard Worker if (m_to_cubearray_valid)
5380*35238bceSAndroid Build Coastguard Worker {
5381*35238bceSAndroid Build Coastguard Worker gl.deleteTextures(1, &m_to_cubearray_valid);
5382*35238bceSAndroid Build Coastguard Worker m_to_cubearray_valid = 0;
5383*35238bceSAndroid Build Coastguard Worker }
5384*35238bceSAndroid Build Coastguard Worker
5385*35238bceSAndroid Build Coastguard Worker if (m_to_layer_invalid)
5386*35238bceSAndroid Build Coastguard Worker {
5387*35238bceSAndroid Build Coastguard Worker gl.deleteTextures(1, &m_to_layer_invalid);
5388*35238bceSAndroid Build Coastguard Worker m_to_layer_invalid = 0;
5389*35238bceSAndroid Build Coastguard Worker }
5390*35238bceSAndroid Build Coastguard Worker
5391*35238bceSAndroid Build Coastguard Worker /* Set initial values - all test shall have the same environment. */
5392*35238bceSAndroid Build Coastguard Worker m_fbo_invalid = 0;
5393*35238bceSAndroid Build Coastguard Worker m_to_invalid = 0;
5394*35238bceSAndroid Build Coastguard Worker m_attachment_invalid = 0;
5395*35238bceSAndroid Build Coastguard Worker m_level_invalid = 0;
5396*35238bceSAndroid Build Coastguard Worker
5397*35238bceSAndroid Build Coastguard Worker m_max_3d_texture_size = 2048;
5398*35238bceSAndroid Build Coastguard Worker m_max_3d_texture_depth = m_max_3d_texture_size;
5399*35238bceSAndroid Build Coastguard Worker m_max_array_texture_layers = 2048;
5400*35238bceSAndroid Build Coastguard Worker m_max_cube_map_texture_size = 16384;
5401*35238bceSAndroid Build Coastguard Worker
5402*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
5403*35238bceSAndroid Build Coastguard Worker while (gl.getError())
5404*35238bceSAndroid Build Coastguard Worker ;
5405*35238bceSAndroid Build Coastguard Worker }
5406*35238bceSAndroid Build Coastguard Worker
5407*35238bceSAndroid Build Coastguard Worker /******************************** Draw Read Buffers Errors Test Implementation ********************************/
5408*35238bceSAndroid Build Coastguard Worker
5409*35238bceSAndroid Build Coastguard Worker /** @brief Draw Read Buffers Errors Test constructor.
5410*35238bceSAndroid Build Coastguard Worker *
5411*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
5412*35238bceSAndroid Build Coastguard Worker */
DrawReadBuffersErrorsTest(deqp::Context & context)5413*35238bceSAndroid Build Coastguard Worker DrawReadBuffersErrorsTest::DrawReadBuffersErrorsTest(deqp::Context &context)
5414*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "framebuffers_draw_read_buffers_errors", "Draw Read Buffers Errors Test Test")
5415*35238bceSAndroid Build Coastguard Worker , m_fbo_valid(0)
5416*35238bceSAndroid Build Coastguard Worker , m_fbo_invalid(0)
5417*35238bceSAndroid Build Coastguard Worker , m_attachment_color(GL_COLOR_ATTACHMENT0)
5418*35238bceSAndroid Build Coastguard Worker , m_attachment_back_left(GL_BACK_LEFT)
5419*35238bceSAndroid Build Coastguard Worker , m_attachment_right(GL_RIGHT)
5420*35238bceSAndroid Build Coastguard Worker , m_attachment_left(GL_LEFT)
5421*35238bceSAndroid Build Coastguard Worker , m_attachment_front(GL_FRONT)
5422*35238bceSAndroid Build Coastguard Worker , m_attachment_front_and_back(GL_FRONT_AND_BACK)
5423*35238bceSAndroid Build Coastguard Worker , m_attachment_back(GL_BACK)
5424*35238bceSAndroid Build Coastguard Worker , m_attachment_invalid(0)
5425*35238bceSAndroid Build Coastguard Worker , m_max_color_attachments(8) /* GL 4.5 default, updated later */
5426*35238bceSAndroid Build Coastguard Worker {
5427*35238bceSAndroid Build Coastguard Worker m_attachments_invalid[0] = 0;
5428*35238bceSAndroid Build Coastguard Worker m_attachments_invalid[1] = 0;
5429*35238bceSAndroid Build Coastguard Worker
5430*35238bceSAndroid Build Coastguard Worker m_attachments_back_invalid[0] = GL_BACK_LEFT;
5431*35238bceSAndroid Build Coastguard Worker m_attachments_back_invalid[1] = GL_BACK;
5432*35238bceSAndroid Build Coastguard Worker
5433*35238bceSAndroid Build Coastguard Worker m_attachments_too_many_count = 0;
5434*35238bceSAndroid Build Coastguard Worker
5435*35238bceSAndroid Build Coastguard Worker m_attachments_too_many = DE_NULL;
5436*35238bceSAndroid Build Coastguard Worker }
5437*35238bceSAndroid Build Coastguard Worker
5438*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Draw Read Buffers Errors Test cases.
5439*35238bceSAndroid Build Coastguard Worker *
5440*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
5441*35238bceSAndroid Build Coastguard Worker */
iterate()5442*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult DrawReadBuffersErrorsTest::iterate()
5443*35238bceSAndroid Build Coastguard Worker {
5444*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
5445*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
5446*35238bceSAndroid Build Coastguard Worker
5447*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
5448*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
5449*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
5450*35238bceSAndroid Build Coastguard Worker
5451*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
5452*35238bceSAndroid Build Coastguard Worker {
5453*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
5454*35238bceSAndroid Build Coastguard Worker
5455*35238bceSAndroid Build Coastguard Worker return STOP;
5456*35238bceSAndroid Build Coastguard Worker }
5457*35238bceSAndroid Build Coastguard Worker
5458*35238bceSAndroid Build Coastguard Worker /* Running tests. */
5459*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
5460*35238bceSAndroid Build Coastguard Worker bool is_error = false;
5461*35238bceSAndroid Build Coastguard Worker
5462*35238bceSAndroid Build Coastguard Worker try
5463*35238bceSAndroid Build Coastguard Worker {
5464*35238bceSAndroid Build Coastguard Worker /* Prepare objects. */
5465*35238bceSAndroid Build Coastguard Worker PrepareObjects();
5466*35238bceSAndroid Build Coastguard Worker
5467*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_OPERATION error is generated by
5468*35238bceSAndroid Build Coastguard Worker NamedFramebufferDrawBuffer if framebuffer is not zero or the name of an
5469*35238bceSAndroid Build Coastguard Worker existing framebuffer object. */
5470*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferDrawBuffer(m_fbo_invalid, m_attachment_color);
5471*35238bceSAndroid Build Coastguard Worker
5472*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferDrawBuffer",
5473*35238bceSAndroid Build Coastguard Worker "framebuffer is not zero or the name of an existing framebuffer object.");
5474*35238bceSAndroid Build Coastguard Worker
5475*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_ENUM is generated by NamedFramebufferDrawBuffer if
5476*35238bceSAndroid Build Coastguard Worker buf is not an accepted value. */
5477*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferDrawBuffer(m_fbo_valid, m_attachment_invalid);
5478*35238bceSAndroid Build Coastguard Worker
5479*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, "NamedFramebufferDrawBuffer", "buf is not an accepted value.");
5480*35238bceSAndroid Build Coastguard Worker
5481*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_OPERATION is generated by NamedFramebufferDrawBuffer
5482*35238bceSAndroid Build Coastguard Worker if the GL is bound to a draw framebuffer object and the ith argument is
5483*35238bceSAndroid Build Coastguard Worker a value other than COLOR_ATTACHMENTi or NONE. */
5484*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferDrawBuffer(m_fbo_valid, m_attachment_back_left);
5485*35238bceSAndroid Build Coastguard Worker
5486*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferDrawBuffer",
5487*35238bceSAndroid Build Coastguard Worker "the GL is bound to a draw framebuffer object and the ith argument is a value other than "
5488*35238bceSAndroid Build Coastguard Worker "COLOR_ATTACHMENTi or NONE.");
5489*35238bceSAndroid Build Coastguard Worker
5490*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_OPERATION error is generated by
5491*35238bceSAndroid Build Coastguard Worker NamedFramebufferDrawBuffers if framebuffer is not zero or the name of an
5492*35238bceSAndroid Build Coastguard Worker existing framebuffer object. */
5493*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferDrawBuffers(m_fbo_invalid, 1, &m_attachment_color);
5494*35238bceSAndroid Build Coastguard Worker
5495*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferDrawBuffers",
5496*35238bceSAndroid Build Coastguard Worker "framebuffer is not zero or the name of an existing framebuffer object.");
5497*35238bceSAndroid Build Coastguard Worker
5498*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_VALUE is generated by NamedFramebufferDrawBuffers if n
5499*35238bceSAndroid Build Coastguard Worker is less than 0. */
5500*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferDrawBuffers(m_fbo_valid, -1, &m_attachment_color);
5501*35238bceSAndroid Build Coastguard Worker
5502*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_VALUE, "NamedFramebufferDrawBuffers", "n is less than 0.");
5503*35238bceSAndroid Build Coastguard Worker
5504*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_VALUE is generated by NamedFramebufferDrawBuffers if
5505*35238bceSAndroid Build Coastguard Worker n is greater than MAX_DRAW_BUFFERS. */
5506*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferDrawBuffers(m_fbo_valid, m_attachments_too_many_count, m_attachments_too_many);
5507*35238bceSAndroid Build Coastguard Worker
5508*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_VALUE, "NamedFramebufferDrawBuffers", "n is greater than MAX_DRAW_BUFFERS.");
5509*35238bceSAndroid Build Coastguard Worker
5510*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_ENUM is generated by NamedFramebufferDrawBuffers if
5511*35238bceSAndroid Build Coastguard Worker one of the values in bufs is not an accepted value. */
5512*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferDrawBuffers(m_fbo_valid, 1, &m_attachment_invalid);
5513*35238bceSAndroid Build Coastguard Worker
5514*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, "NamedFramebufferDrawBuffers",
5515*35238bceSAndroid Build Coastguard Worker "one of the values in bufs is not an accepted value.");
5516*35238bceSAndroid Build Coastguard Worker
5517*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_OPERATION is generated by NamedFramebufferDrawBuffers
5518*35238bceSAndroid Build Coastguard Worker if a symbolic constant other than GL_NONE appears more than once in
5519*35238bceSAndroid Build Coastguard Worker bufs. */
5520*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferDrawBuffers(m_fbo_valid, 2, m_attachments_invalid);
5521*35238bceSAndroid Build Coastguard Worker
5522*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferDrawBuffers",
5523*35238bceSAndroid Build Coastguard Worker "a symbolic constant other than GL_NONE appears more than once in bufs.");
5524*35238bceSAndroid Build Coastguard Worker
5525*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_ENUM error is generated by NamedFramebufferDrawBuffers if any value in bufs is FRONT, LEFT, RIGHT, or FRONT_AND_BACK.
5526*35238bceSAndroid Build Coastguard Worker This restriction applies to both the default framebuffer and framebuffer objects, and exists because these constants may themselves
5527*35238bceSAndroid Build Coastguard Worker refer to multiple buffers, as shown in table 17.4. */
5528*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferDrawBuffers(m_fbo_valid, 1, &m_attachment_front);
5529*35238bceSAndroid Build Coastguard Worker
5530*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, "NamedFramebufferDrawBuffers",
5531*35238bceSAndroid Build Coastguard Worker "a framebuffer object is tested and a value in bufs is FRONT.");
5532*35238bceSAndroid Build Coastguard Worker
5533*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferDrawBuffers(m_fbo_valid, 1, &m_attachment_left);
5534*35238bceSAndroid Build Coastguard Worker
5535*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, "NamedFramebufferDrawBuffers",
5536*35238bceSAndroid Build Coastguard Worker "a framebuffer object is tested and a value in bufs is LEFT.");
5537*35238bceSAndroid Build Coastguard Worker
5538*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferDrawBuffers(m_fbo_valid, 1, &m_attachment_right);
5539*35238bceSAndroid Build Coastguard Worker
5540*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, "NamedFramebufferDrawBuffers",
5541*35238bceSAndroid Build Coastguard Worker "a framebuffer object is tested and a value in bufs is RIGHT.");
5542*35238bceSAndroid Build Coastguard Worker
5543*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferDrawBuffers(m_fbo_valid, 1, &m_attachment_front_and_back);
5544*35238bceSAndroid Build Coastguard Worker
5545*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, "NamedFramebufferDrawBuffers",
5546*35238bceSAndroid Build Coastguard Worker "a framebuffer object is tested and a value in bufs is FRONT_AND_BACK.");
5547*35238bceSAndroid Build Coastguard Worker
5548*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferDrawBuffers(0, 1, &m_attachment_front);
5549*35238bceSAndroid Build Coastguard Worker
5550*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, "NamedFramebufferDrawBuffers",
5551*35238bceSAndroid Build Coastguard Worker "a default framebuffer is tested and a value in bufs is FRONT.");
5552*35238bceSAndroid Build Coastguard Worker
5553*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferDrawBuffers(0, 1, &m_attachment_left);
5554*35238bceSAndroid Build Coastguard Worker
5555*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, "NamedFramebufferDrawBuffers",
5556*35238bceSAndroid Build Coastguard Worker "a default framebuffer is tested and a value in bufs is LEFT.");
5557*35238bceSAndroid Build Coastguard Worker
5558*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferDrawBuffers(0, 1, &m_attachment_right);
5559*35238bceSAndroid Build Coastguard Worker
5560*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, "NamedFramebufferDrawBuffers",
5561*35238bceSAndroid Build Coastguard Worker "a default framebuffer is tested and a value in bufs is RIGHT.");
5562*35238bceSAndroid Build Coastguard Worker
5563*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferDrawBuffers(0, 1, &m_attachment_front_and_back);
5564*35238bceSAndroid Build Coastguard Worker
5565*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, "NamedFramebufferDrawBuffers",
5566*35238bceSAndroid Build Coastguard Worker "a default framebuffer is tested and a value in bufs is FRONT_AND_BACK.");
5567*35238bceSAndroid Build Coastguard Worker
5568*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_OPERATION is generated by NamedFramebufferDrawBuffers
5569*35238bceSAndroid Build Coastguard Worker if any value in bufs is BACK, and n is not one. */
5570*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferDrawBuffers(0, 2, m_attachments_back_invalid);
5571*35238bceSAndroid Build Coastguard Worker
5572*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferDrawBuffers",
5573*35238bceSAndroid Build Coastguard Worker "any value in bufs is BACK, and n is not one.");
5574*35238bceSAndroid Build Coastguard Worker
5575*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_OPERATION is generated by NamedFramebufferDrawBuffers if
5576*35238bceSAndroid Build Coastguard Worker the API call refers to a framebuffer object and one or more of the
5577*35238bceSAndroid Build Coastguard Worker values in bufs is anything other than NONE or one of the
5578*35238bceSAndroid Build Coastguard Worker COLOR_ATTACHMENTn tokens. */
5579*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferDrawBuffers(m_fbo_valid, 1, &m_attachment_back_left);
5580*35238bceSAndroid Build Coastguard Worker
5581*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferDrawBuffers",
5582*35238bceSAndroid Build Coastguard Worker "the API call refers to a framebuffer object and one or more of the values in bufs is "
5583*35238bceSAndroid Build Coastguard Worker "anything other than NONE or one of the COLOR_ATTACHMENTn tokens.");
5584*35238bceSAndroid Build Coastguard Worker
5585*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_OPERATION is generated by NamedFramebufferDrawBuffers if
5586*35238bceSAndroid Build Coastguard Worker the API call refers to the default framebuffer and one or more of the
5587*35238bceSAndroid Build Coastguard Worker values in bufs is one of the COLOR_ATTACHMENTn tokens. */
5588*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferDrawBuffers(0, 1, &m_attachment_color);
5589*35238bceSAndroid Build Coastguard Worker
5590*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferDrawBuffers",
5591*35238bceSAndroid Build Coastguard Worker "the API call refers to the default framebuffer and one or more of the values in bufs is "
5592*35238bceSAndroid Build Coastguard Worker "one of the COLOR_ATTACHMENTn tokens.");
5593*35238bceSAndroid Build Coastguard Worker
5594*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_OPERATION is generated by NamedFramebufferReadBuffer
5595*35238bceSAndroid Build Coastguard Worker if framebuffer is not zero or the name of an existing framebuffer
5596*35238bceSAndroid Build Coastguard Worker object. */
5597*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferReadBuffer(m_fbo_invalid, m_attachment_color);
5598*35238bceSAndroid Build Coastguard Worker
5599*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferReadBuffer",
5600*35238bceSAndroid Build Coastguard Worker "framebuffer is not zero or the name of an existing framebuffer object.");
5601*35238bceSAndroid Build Coastguard Worker
5602*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_ENUM is generated by NamedFramebufferReadBuffer if
5603*35238bceSAndroid Build Coastguard Worker src is not one of the accepted values (tables 17.4 and 17.5 of OpenGL 4.5 Core Profile Specification). */
5604*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferReadBuffer(m_fbo_valid, m_attachment_invalid);
5605*35238bceSAndroid Build Coastguard Worker
5606*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(
5607*35238bceSAndroid Build Coastguard Worker GL_INVALID_ENUM, "NamedFramebufferReadBuffer",
5608*35238bceSAndroid Build Coastguard Worker "src is not one of the accepted values (tables 17.4 and 17.5 of OpenGL 4.5 Core Profile Specification).");
5609*35238bceSAndroid Build Coastguard Worker
5610*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_OPERATION error is generated by NamedFramebufferReadBuffer if the default framebuffer is
5611*35238bceSAndroid Build Coastguard Worker affected and src is a value (other than NONE) that does not indicate any of the
5612*35238bceSAndroid Build Coastguard Worker color buffers allocated to the default framebuffer. */
5613*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferReadBuffer(0, GL_COLOR_ATTACHMENT0);
5614*35238bceSAndroid Build Coastguard Worker
5615*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferReadBuffer",
5616*35238bceSAndroid Build Coastguard Worker "the default framebuffer is affected and src is a value (other than NONE) that does not "
5617*35238bceSAndroid Build Coastguard Worker "indicate any of the color buffers allocated to the default framebuffer.");
5618*35238bceSAndroid Build Coastguard Worker
5619*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_OPERATION error is generated by NamedFramebufferReadBuffer if a framebuffer object is
5620*35238bceSAndroid Build Coastguard Worker affected, and src is one of the constants from table 17.4 (other than NONE, or COLOR_ATTACHMENTm where m
5621*35238bceSAndroid Build Coastguard Worker is greater than or equal to the value of MAX_COLOR_ATTACHMENTS). */
5622*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferReadBuffer(m_fbo_valid, m_attachment_front_and_back);
5623*35238bceSAndroid Build Coastguard Worker
5624*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferReadBuffer",
5625*35238bceSAndroid Build Coastguard Worker "a framebuffer object is affected, and src is one of the constants from table 17.4.");
5626*35238bceSAndroid Build Coastguard Worker
5627*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferReadBuffer(m_fbo_valid, GL_COLOR_ATTACHMENT0 + m_max_color_attachments);
5628*35238bceSAndroid Build Coastguard Worker
5629*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferReadBuffer",
5630*35238bceSAndroid Build Coastguard Worker "a framebuffer object is affected, and src is one of the COLOR_ATTACHMENTm where mis "
5631*35238bceSAndroid Build Coastguard Worker "greater than or equal to the value of MAX_COLOR_ATTACHMENTS.");
5632*35238bceSAndroid Build Coastguard Worker }
5633*35238bceSAndroid Build Coastguard Worker catch (...)
5634*35238bceSAndroid Build Coastguard Worker {
5635*35238bceSAndroid Build Coastguard Worker is_ok = false;
5636*35238bceSAndroid Build Coastguard Worker is_error = true;
5637*35238bceSAndroid Build Coastguard Worker }
5638*35238bceSAndroid Build Coastguard Worker
5639*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
5640*35238bceSAndroid Build Coastguard Worker Clean();
5641*35238bceSAndroid Build Coastguard Worker
5642*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
5643*35238bceSAndroid Build Coastguard Worker if (is_ok)
5644*35238bceSAndroid Build Coastguard Worker {
5645*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
5646*35238bceSAndroid Build Coastguard Worker }
5647*35238bceSAndroid Build Coastguard Worker else
5648*35238bceSAndroid Build Coastguard Worker {
5649*35238bceSAndroid Build Coastguard Worker if (is_error)
5650*35238bceSAndroid Build Coastguard Worker {
5651*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
5652*35238bceSAndroid Build Coastguard Worker }
5653*35238bceSAndroid Build Coastguard Worker else
5654*35238bceSAndroid Build Coastguard Worker {
5655*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
5656*35238bceSAndroid Build Coastguard Worker }
5657*35238bceSAndroid Build Coastguard Worker }
5658*35238bceSAndroid Build Coastguard Worker
5659*35238bceSAndroid Build Coastguard Worker return STOP;
5660*35238bceSAndroid Build Coastguard Worker }
5661*35238bceSAndroid Build Coastguard Worker
5662*35238bceSAndroid Build Coastguard Worker /** Check Prepare test's GL objects.
5663*35238bceSAndroid Build Coastguard Worker */
PrepareObjects()5664*35238bceSAndroid Build Coastguard Worker void DrawReadBuffersErrorsTest::PrepareObjects()
5665*35238bceSAndroid Build Coastguard Worker {
5666*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
5667*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
5668*35238bceSAndroid Build Coastguard Worker
5669*35238bceSAndroid Build Coastguard Worker /* Valid objects. */
5670*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(1, &m_fbo_valid);
5671*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
5672*35238bceSAndroid Build Coastguard Worker
5673*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_valid);
5674*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
5675*35238bceSAndroid Build Coastguard Worker
5676*35238bceSAndroid Build Coastguard Worker /* Invalid objects. */
5677*35238bceSAndroid Build Coastguard Worker while (gl.isFramebuffer(++m_fbo_invalid))
5678*35238bceSAndroid Build Coastguard Worker ;
5679*35238bceSAndroid Build Coastguard Worker
5680*35238bceSAndroid Build Coastguard Worker /* Invalid attachment. */
5681*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &m_max_color_attachments);
5682*35238bceSAndroid Build Coastguard Worker
5683*35238bceSAndroid Build Coastguard Worker bool is_attachment = true;
5684*35238bceSAndroid Build Coastguard Worker
5685*35238bceSAndroid Build Coastguard Worker while (is_attachment)
5686*35238bceSAndroid Build Coastguard Worker {
5687*35238bceSAndroid Build Coastguard Worker ++m_attachment_invalid;
5688*35238bceSAndroid Build Coastguard Worker
5689*35238bceSAndroid Build Coastguard Worker is_attachment = false;
5690*35238bceSAndroid Build Coastguard Worker
5691*35238bceSAndroid Build Coastguard Worker /* Valid attachments are those from tables 17.4, 17.5 and a 17.6 (valid for various functions and framebuffer types).
5692*35238bceSAndroid Build Coastguard Worker (see OpenGL 4.5 Core Profile Specification) */
5693*35238bceSAndroid Build Coastguard Worker switch (m_attachment_invalid)
5694*35238bceSAndroid Build Coastguard Worker {
5695*35238bceSAndroid Build Coastguard Worker case GL_NONE:
5696*35238bceSAndroid Build Coastguard Worker case GL_FRONT_LEFT:
5697*35238bceSAndroid Build Coastguard Worker case GL_FRONT_RIGHT:
5698*35238bceSAndroid Build Coastguard Worker case GL_BACK_LEFT:
5699*35238bceSAndroid Build Coastguard Worker case GL_BACK_RIGHT:
5700*35238bceSAndroid Build Coastguard Worker case GL_FRONT:
5701*35238bceSAndroid Build Coastguard Worker case GL_BACK:
5702*35238bceSAndroid Build Coastguard Worker case GL_LEFT:
5703*35238bceSAndroid Build Coastguard Worker case GL_RIGHT:
5704*35238bceSAndroid Build Coastguard Worker case GL_FRONT_AND_BACK:
5705*35238bceSAndroid Build Coastguard Worker is_attachment = true;
5706*35238bceSAndroid Build Coastguard Worker }
5707*35238bceSAndroid Build Coastguard Worker
5708*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < m_max_color_attachments; ++i)
5709*35238bceSAndroid Build Coastguard Worker {
5710*35238bceSAndroid Build Coastguard Worker if ((glw::GLenum)(GL_COLOR_ATTACHMENT0 + i) == m_attachment_invalid)
5711*35238bceSAndroid Build Coastguard Worker {
5712*35238bceSAndroid Build Coastguard Worker is_attachment = true;
5713*35238bceSAndroid Build Coastguard Worker break;
5714*35238bceSAndroid Build Coastguard Worker }
5715*35238bceSAndroid Build Coastguard Worker }
5716*35238bceSAndroid Build Coastguard Worker }
5717*35238bceSAndroid Build Coastguard Worker
5718*35238bceSAndroid Build Coastguard Worker m_attachments_invalid[0] = GL_COLOR_ATTACHMENT0;
5719*35238bceSAndroid Build Coastguard Worker m_attachments_invalid[1] = GL_COLOR_ATTACHMENT0;
5720*35238bceSAndroid Build Coastguard Worker
5721*35238bceSAndroid Build Coastguard Worker glw::GLint max_draw_buffers = 8; /* Spec default. */
5722*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_DRAW_BUFFERS, &max_draw_buffers);
5723*35238bceSAndroid Build Coastguard Worker
5724*35238bceSAndroid Build Coastguard Worker m_attachments_too_many_count = max_draw_buffers + 1;
5725*35238bceSAndroid Build Coastguard Worker
5726*35238bceSAndroid Build Coastguard Worker m_attachments_too_many = new glw::GLenum[m_attachments_too_many_count];
5727*35238bceSAndroid Build Coastguard Worker
5728*35238bceSAndroid Build Coastguard Worker m_attachments_too_many[0] = GL_COLOR_ATTACHMENT0;
5729*35238bceSAndroid Build Coastguard Worker
5730*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 1; i < m_attachments_too_many_count; ++i)
5731*35238bceSAndroid Build Coastguard Worker {
5732*35238bceSAndroid Build Coastguard Worker m_attachments_too_many[i] = GL_NONE;
5733*35238bceSAndroid Build Coastguard Worker }
5734*35238bceSAndroid Build Coastguard Worker }
5735*35238bceSAndroid Build Coastguard Worker
5736*35238bceSAndroid Build Coastguard Worker /** Check if error is equal to the expected, log if not.
5737*35238bceSAndroid Build Coastguard Worker *
5738*35238bceSAndroid Build Coastguard Worker * @param [in] expected_error Error to be expected.
5739*35238bceSAndroid Build Coastguard Worker * @param [in] function Function name which is being tested (to be logged).
5740*35238bceSAndroid Build Coastguard Worker * @param [in] conditions Conditions when the expected error shall occure (to be logged).
5741*35238bceSAndroid Build Coastguard Worker *
5742*35238bceSAndroid Build Coastguard Worker * @return True if there is no error, false otherwise.
5743*35238bceSAndroid Build Coastguard Worker */
ExpectError(glw::GLenum expected_error,const glw::GLchar * function,const glw::GLchar * conditions)5744*35238bceSAndroid Build Coastguard Worker bool DrawReadBuffersErrorsTest::ExpectError(glw::GLenum expected_error, const glw::GLchar *function,
5745*35238bceSAndroid Build Coastguard Worker const glw::GLchar *conditions)
5746*35238bceSAndroid Build Coastguard Worker {
5747*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
5748*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
5749*35238bceSAndroid Build Coastguard Worker
5750*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
5751*35238bceSAndroid Build Coastguard Worker
5752*35238bceSAndroid Build Coastguard Worker glw::GLenum error = GL_NO_ERROR;
5753*35238bceSAndroid Build Coastguard Worker
5754*35238bceSAndroid Build Coastguard Worker if (expected_error != (error = gl.getError()))
5755*35238bceSAndroid Build Coastguard Worker {
5756*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog() << tcu::TestLog::Message << function << " was expected to generate "
5757*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(expected_error) << ", but " << glu::getErrorStr(error)
5758*35238bceSAndroid Build Coastguard Worker << " was observed instead when " << conditions << tcu::TestLog::EndMessage;
5759*35238bceSAndroid Build Coastguard Worker
5760*35238bceSAndroid Build Coastguard Worker is_ok = false;
5761*35238bceSAndroid Build Coastguard Worker }
5762*35238bceSAndroid Build Coastguard Worker
5763*35238bceSAndroid Build Coastguard Worker /* Clean additional possible errors. */
5764*35238bceSAndroid Build Coastguard Worker while (gl.getError())
5765*35238bceSAndroid Build Coastguard Worker ;
5766*35238bceSAndroid Build Coastguard Worker
5767*35238bceSAndroid Build Coastguard Worker return is_ok;
5768*35238bceSAndroid Build Coastguard Worker }
5769*35238bceSAndroid Build Coastguard Worker
5770*35238bceSAndroid Build Coastguard Worker /** @brief Clean up GL state.
5771*35238bceSAndroid Build Coastguard Worker */
Clean()5772*35238bceSAndroid Build Coastguard Worker void DrawReadBuffersErrorsTest::Clean()
5773*35238bceSAndroid Build Coastguard Worker {
5774*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
5775*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
5776*35238bceSAndroid Build Coastguard Worker
5777*35238bceSAndroid Build Coastguard Worker /* Release GL objects. */
5778*35238bceSAndroid Build Coastguard Worker if (m_fbo_valid)
5779*35238bceSAndroid Build Coastguard Worker {
5780*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &m_fbo_valid);
5781*35238bceSAndroid Build Coastguard Worker m_fbo_valid = 0;
5782*35238bceSAndroid Build Coastguard Worker }
5783*35238bceSAndroid Build Coastguard Worker
5784*35238bceSAndroid Build Coastguard Worker /* Set initial values - all test shall have the same environment. */
5785*35238bceSAndroid Build Coastguard Worker m_fbo_invalid = 0;
5786*35238bceSAndroid Build Coastguard Worker m_attachment_invalid = 0;
5787*35238bceSAndroid Build Coastguard Worker m_attachments_invalid[0] = 0;
5788*35238bceSAndroid Build Coastguard Worker m_attachments_invalid[1] = 0;
5789*35238bceSAndroid Build Coastguard Worker
5790*35238bceSAndroid Build Coastguard Worker delete[] m_attachments_too_many;
5791*35238bceSAndroid Build Coastguard Worker
5792*35238bceSAndroid Build Coastguard Worker m_attachments_too_many = DE_NULL;
5793*35238bceSAndroid Build Coastguard Worker
5794*35238bceSAndroid Build Coastguard Worker m_attachments_too_many_count = 0;
5795*35238bceSAndroid Build Coastguard Worker
5796*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
5797*35238bceSAndroid Build Coastguard Worker while (gl.getError())
5798*35238bceSAndroid Build Coastguard Worker ;
5799*35238bceSAndroid Build Coastguard Worker }
5800*35238bceSAndroid Build Coastguard Worker
5801*35238bceSAndroid Build Coastguard Worker /******************************** Invalidate Data and SubData Errors Test Implementation ********************************/
5802*35238bceSAndroid Build Coastguard Worker
5803*35238bceSAndroid Build Coastguard Worker /** @brief Invalidate SubData Errors Test constructor.
5804*35238bceSAndroid Build Coastguard Worker *
5805*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
5806*35238bceSAndroid Build Coastguard Worker */
InvalidateDataAndSubDataErrorsTest(deqp::Context & context)5807*35238bceSAndroid Build Coastguard Worker InvalidateDataAndSubDataErrorsTest::InvalidateDataAndSubDataErrorsTest(deqp::Context &context)
5808*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "invalidate_data_and_subdata_errors", "Invalidate Data and SubData Errors Test")
5809*35238bceSAndroid Build Coastguard Worker , m_fbo_valid(0)
5810*35238bceSAndroid Build Coastguard Worker , m_rbo(0)
5811*35238bceSAndroid Build Coastguard Worker , m_fbo_invalid(0)
5812*35238bceSAndroid Build Coastguard Worker , m_fbo_attachment_valid(0)
5813*35238bceSAndroid Build Coastguard Worker , m_fbo_attachment_invalid(0)
5814*35238bceSAndroid Build Coastguard Worker , m_color_attachment_invalid(0)
5815*35238bceSAndroid Build Coastguard Worker , m_default_attachment_invalid(0)
5816*35238bceSAndroid Build Coastguard Worker
5817*35238bceSAndroid Build Coastguard Worker {
5818*35238bceSAndroid Build Coastguard Worker }
5819*35238bceSAndroid Build Coastguard Worker
5820*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Invalidate Data and SubData Errors Test cases.
5821*35238bceSAndroid Build Coastguard Worker *
5822*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
5823*35238bceSAndroid Build Coastguard Worker */
iterate()5824*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult InvalidateDataAndSubDataErrorsTest::iterate()
5825*35238bceSAndroid Build Coastguard Worker {
5826*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
5827*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
5828*35238bceSAndroid Build Coastguard Worker
5829*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
5830*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
5831*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
5832*35238bceSAndroid Build Coastguard Worker
5833*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
5834*35238bceSAndroid Build Coastguard Worker {
5835*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
5836*35238bceSAndroid Build Coastguard Worker
5837*35238bceSAndroid Build Coastguard Worker return STOP;
5838*35238bceSAndroid Build Coastguard Worker }
5839*35238bceSAndroid Build Coastguard Worker
5840*35238bceSAndroid Build Coastguard Worker /* Running tests. */
5841*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
5842*35238bceSAndroid Build Coastguard Worker bool is_error = false;
5843*35238bceSAndroid Build Coastguard Worker
5844*35238bceSAndroid Build Coastguard Worker try
5845*35238bceSAndroid Build Coastguard Worker {
5846*35238bceSAndroid Build Coastguard Worker /* Prepare objects. */
5847*35238bceSAndroid Build Coastguard Worker PrepareObjects();
5848*35238bceSAndroid Build Coastguard Worker
5849*35238bceSAndroid Build Coastguard Worker /******* InvalidateNamedFramebufferData *******/
5850*35238bceSAndroid Build Coastguard Worker
5851*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_OPERATION error is generated by InvalidateNamedFramebufferData if framebuffer is not zero or the name of an existing framebuffer object. */
5852*35238bceSAndroid Build Coastguard Worker gl.invalidateNamedFramebufferData(m_fbo_invalid, 1, &m_fbo_attachment_valid);
5853*35238bceSAndroid Build Coastguard Worker
5854*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "InvalidateNamedFramebufferData",
5855*35238bceSAndroid Build Coastguard Worker "framebuffer is not zero or the name of an existing framebuffer object.");
5856*35238bceSAndroid Build Coastguard Worker
5857*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_ENUM error is generated by InvalidateNamedFramebufferData if a framebuffer object is affected, and
5858*35238bceSAndroid Build Coastguard Worker any element of of attachments is not one of the values in table {COLOR_ATTACHMENTi, DEPTH_ATTACHMENT, STENCIL_ATTACHMENT, DEPTH_STENCIL_ATTACHMENT }. */
5859*35238bceSAndroid Build Coastguard Worker gl.invalidateNamedFramebufferData(m_fbo_valid, 1, &m_fbo_attachment_invalid);
5860*35238bceSAndroid Build Coastguard Worker
5861*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, "InvalidateNamedFramebufferData",
5862*35238bceSAndroid Build Coastguard Worker "a framebuffer object is affected, and any element of of attachments is not one of the "
5863*35238bceSAndroid Build Coastguard Worker "values in table { COLOR_ATTACHMENTi, DEPTH_ATTACHMENT, STENCIL_ATTACHMENT, "
5864*35238bceSAndroid Build Coastguard Worker "DEPTH_STENCIL_ATTACHMENT }.");
5865*35238bceSAndroid Build Coastguard Worker
5866*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_OPERATION error is generated by InvalidateNamedFramebufferData if attachments contains COLOR_ATTACHMENTm
5867*35238bceSAndroid Build Coastguard Worker where m is greater than or equal to the value of MAX_COLOR_ATTACHMENTS. */
5868*35238bceSAndroid Build Coastguard Worker gl.invalidateNamedFramebufferData(m_fbo_valid, 1, &m_color_attachment_invalid);
5869*35238bceSAndroid Build Coastguard Worker
5870*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "InvalidateNamedFramebufferData",
5871*35238bceSAndroid Build Coastguard Worker "attachments contains COLOR_ATTACHMENTm where m is greater than or equal to the value of "
5872*35238bceSAndroid Build Coastguard Worker "MAX_COLOR_ATTACHMENTS");
5873*35238bceSAndroid Build Coastguard Worker
5874*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_ENUM error is generated by
5875*35238bceSAndroid Build Coastguard Worker InvalidateNamedFramebufferData if the default framebuffer is affected,
5876*35238bceSAndroid Build Coastguard Worker and any elements of attachments are not one of:
5877*35238bceSAndroid Build Coastguard Worker - FRONT_LEFT, FRONT_RIGHT, BACK_LEFT, and BACK_RIGHT, identifying that
5878*35238bceSAndroid Build Coastguard Worker specific buffer,
5879*35238bceSAndroid Build Coastguard Worker - COLOR, which is treated as BACK_LEFT for a double-buffered context
5880*35238bceSAndroid Build Coastguard Worker and FRONT_LEFT for a single-buffered context,
5881*35238bceSAndroid Build Coastguard Worker - DEPTH, identifying the depth buffer,
5882*35238bceSAndroid Build Coastguard Worker - STENCIL, identifying the stencil buffer. */
5883*35238bceSAndroid Build Coastguard Worker gl.invalidateNamedFramebufferData(0, 1, &m_default_attachment_invalid);
5884*35238bceSAndroid Build Coastguard Worker
5885*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, "InvalidateNamedFramebufferData",
5886*35238bceSAndroid Build Coastguard Worker "the default framebuffer is affected, and any elements of attachments are not one of "
5887*35238bceSAndroid Build Coastguard Worker "FRONT_LEFT, FRONT_RIGHT, BACK_LEFT, BACK_RIGHT, COLOR, DEPTH, STENCIL.");
5888*35238bceSAndroid Build Coastguard Worker
5889*35238bceSAndroid Build Coastguard Worker /******* InvalidateNamedFramebufferSubData *******/
5890*35238bceSAndroid Build Coastguard Worker
5891*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_OPERATION error is generated by InvalidateNamedFramebufferSubData if framebuffer is not zero or the name of an existing framebuffer object. */
5892*35238bceSAndroid Build Coastguard Worker gl.invalidateNamedFramebufferSubData(m_fbo_invalid, 1, &m_fbo_attachment_valid, 0, 0, 1, 1);
5893*35238bceSAndroid Build Coastguard Worker
5894*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "InvalidateNamedFramebufferSubData",
5895*35238bceSAndroid Build Coastguard Worker "framebuffer is not zero or the name of an existing framebuffer object.");
5896*35238bceSAndroid Build Coastguard Worker
5897*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_VALUE error is generated by InvalidateNamedFramebufferSubData if numAttachments, width, or height is negative. */
5898*35238bceSAndroid Build Coastguard Worker gl.invalidateNamedFramebufferSubData(m_fbo_valid, -1, &m_fbo_attachment_valid, 0, 0, 1, 1);
5899*35238bceSAndroid Build Coastguard Worker
5900*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_VALUE, "InvalidateNamedFramebufferSubData", "numAttachments is negative.");
5901*35238bceSAndroid Build Coastguard Worker
5902*35238bceSAndroid Build Coastguard Worker gl.invalidateNamedFramebufferSubData(m_fbo_valid, 1, &m_fbo_attachment_valid, 0, 0, -1, 1);
5903*35238bceSAndroid Build Coastguard Worker
5904*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_VALUE, "InvalidateNamedFramebufferSubData", "width is negative.");
5905*35238bceSAndroid Build Coastguard Worker
5906*35238bceSAndroid Build Coastguard Worker gl.invalidateNamedFramebufferSubData(m_fbo_valid, 1, &m_fbo_attachment_valid, 0, 0, 1, -1);
5907*35238bceSAndroid Build Coastguard Worker
5908*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_VALUE, "InvalidateNamedFramebufferSubData", "height is negative.");
5909*35238bceSAndroid Build Coastguard Worker
5910*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_ENUM error is generated by InvalidateNamedFramebufferSubData if a framebuffer object is affected, and
5911*35238bceSAndroid Build Coastguard Worker any element of of attachments is not one of the values in table {COLOR_ATTACHMENTi, DEPTH_ATTACHMENT, STENCIL_ATTACHMENT, DEPTH_STENCIL_ATTACHMENT }. */
5912*35238bceSAndroid Build Coastguard Worker gl.invalidateNamedFramebufferSubData(m_fbo_valid, 1, &m_fbo_attachment_invalid, 0, 0, 1, 1);
5913*35238bceSAndroid Build Coastguard Worker
5914*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, "InvalidateNamedFramebufferSubData",
5915*35238bceSAndroid Build Coastguard Worker "a framebuffer object is affected, and any element of of attachments is not one of the "
5916*35238bceSAndroid Build Coastguard Worker "values in table { COLOR_ATTACHMENTi, DEPTH_ATTACHMENT, STENCIL_ATTACHMENT, "
5917*35238bceSAndroid Build Coastguard Worker "DEPTH_STENCIL_ATTACHMENT }.");
5918*35238bceSAndroid Build Coastguard Worker
5919*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_OPERATION error is generated by InvalidateNamedFramebufferSubData if attachments contains COLOR_ATTACHMENTm
5920*35238bceSAndroid Build Coastguard Worker where m is greater than or equal to the value of MAX_COLOR_ATTACHMENTS. */
5921*35238bceSAndroid Build Coastguard Worker gl.invalidateNamedFramebufferSubData(m_fbo_valid, 1, &m_color_attachment_invalid, 0, 0, 1, 1);
5922*35238bceSAndroid Build Coastguard Worker
5923*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "InvalidateNamedFramebufferSubData",
5924*35238bceSAndroid Build Coastguard Worker "attachments contains COLOR_ATTACHMENTm where m is greater than or equal to the value of "
5925*35238bceSAndroid Build Coastguard Worker "MAX_COLOR_ATTACHMENTS");
5926*35238bceSAndroid Build Coastguard Worker
5927*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_ENUM error is generated by InvalidateNamedFramebufferSubData if the default framebuffer is affected,
5928*35238bceSAndroid Build Coastguard Worker and any elements of attachments are not one of:
5929*35238bceSAndroid Build Coastguard Worker - FRONT_LEFT, FRONT_RIGHT, BACK_LEFT, and BACK_RIGHT, identifying that
5930*35238bceSAndroid Build Coastguard Worker specific buffer,
5931*35238bceSAndroid Build Coastguard Worker - COLOR, which is treated as BACK_LEFT for a double-buffered context
5932*35238bceSAndroid Build Coastguard Worker and FRONT_LEFT for a single-buffered context,
5933*35238bceSAndroid Build Coastguard Worker - DEPTH, identifying the depth buffer,
5934*35238bceSAndroid Build Coastguard Worker - STENCIL, identifying the stencil buffer. */
5935*35238bceSAndroid Build Coastguard Worker gl.invalidateNamedFramebufferSubData(0, 1, &m_default_attachment_invalid, 0, 0, 1, 1);
5936*35238bceSAndroid Build Coastguard Worker
5937*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, "InvalidateNamedFramebufferSubData",
5938*35238bceSAndroid Build Coastguard Worker "the default framebuffer is affected, and any elements of attachments are not one of "
5939*35238bceSAndroid Build Coastguard Worker "FRONT_LEFT, FRONT_RIGHT, BACK_LEFT, BACK_RIGHT, COLOR, DEPTH, STENCIL.");
5940*35238bceSAndroid Build Coastguard Worker }
5941*35238bceSAndroid Build Coastguard Worker catch (...)
5942*35238bceSAndroid Build Coastguard Worker {
5943*35238bceSAndroid Build Coastguard Worker is_ok = false;
5944*35238bceSAndroid Build Coastguard Worker is_error = true;
5945*35238bceSAndroid Build Coastguard Worker }
5946*35238bceSAndroid Build Coastguard Worker
5947*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
5948*35238bceSAndroid Build Coastguard Worker Clean();
5949*35238bceSAndroid Build Coastguard Worker
5950*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
5951*35238bceSAndroid Build Coastguard Worker if (is_ok)
5952*35238bceSAndroid Build Coastguard Worker {
5953*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
5954*35238bceSAndroid Build Coastguard Worker }
5955*35238bceSAndroid Build Coastguard Worker else
5956*35238bceSAndroid Build Coastguard Worker {
5957*35238bceSAndroid Build Coastguard Worker if (is_error)
5958*35238bceSAndroid Build Coastguard Worker {
5959*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
5960*35238bceSAndroid Build Coastguard Worker }
5961*35238bceSAndroid Build Coastguard Worker else
5962*35238bceSAndroid Build Coastguard Worker {
5963*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
5964*35238bceSAndroid Build Coastguard Worker }
5965*35238bceSAndroid Build Coastguard Worker }
5966*35238bceSAndroid Build Coastguard Worker
5967*35238bceSAndroid Build Coastguard Worker return STOP;
5968*35238bceSAndroid Build Coastguard Worker }
5969*35238bceSAndroid Build Coastguard Worker
5970*35238bceSAndroid Build Coastguard Worker /** Check Prepare test's GL objects.
5971*35238bceSAndroid Build Coastguard Worker */
PrepareObjects()5972*35238bceSAndroid Build Coastguard Worker void InvalidateDataAndSubDataErrorsTest::PrepareObjects()
5973*35238bceSAndroid Build Coastguard Worker {
5974*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
5975*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
5976*35238bceSAndroid Build Coastguard Worker
5977*35238bceSAndroid Build Coastguard Worker /* Valid attachments. */
5978*35238bceSAndroid Build Coastguard Worker m_fbo_attachment_valid = GL_COLOR_ATTACHMENT0;
5979*35238bceSAndroid Build Coastguard Worker
5980*35238bceSAndroid Build Coastguard Worker /* Valid objects. */
5981*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(1, &m_fbo_valid);
5982*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
5983*35238bceSAndroid Build Coastguard Worker
5984*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_valid);
5985*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
5986*35238bceSAndroid Build Coastguard Worker
5987*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(1, &m_rbo);
5988*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
5989*35238bceSAndroid Build Coastguard Worker
5990*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo);
5991*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer has failed");
5992*35238bceSAndroid Build Coastguard Worker
5993*35238bceSAndroid Build Coastguard Worker gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 1, 1);
5994*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
5995*35238bceSAndroid Build Coastguard Worker
5996*35238bceSAndroid Build Coastguard Worker gl.framebufferRenderbuffer(GL_FRAMEBUFFER, m_fbo_attachment_valid, GL_RENDERBUFFER, m_rbo);
5997*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
5998*35238bceSAndroid Build Coastguard Worker
5999*35238bceSAndroid Build Coastguard Worker if (GL_FRAMEBUFFER_COMPLETE != gl.checkFramebufferStatus(GL_FRAMEBUFFER))
6000*35238bceSAndroid Build Coastguard Worker {
6001*35238bceSAndroid Build Coastguard Worker throw 0;
6002*35238bceSAndroid Build Coastguard Worker }
6003*35238bceSAndroid Build Coastguard Worker
6004*35238bceSAndroid Build Coastguard Worker /* Invalid objects. */
6005*35238bceSAndroid Build Coastguard Worker while (gl.isFramebuffer(++m_fbo_invalid))
6006*35238bceSAndroid Build Coastguard Worker ;
6007*35238bceSAndroid Build Coastguard Worker
6008*35238bceSAndroid Build Coastguard Worker /* Invalid framebuffer object attachment. */
6009*35238bceSAndroid Build Coastguard Worker while (true)
6010*35238bceSAndroid Build Coastguard Worker {
6011*35238bceSAndroid Build Coastguard Worker if (GL_COLOR_ATTACHMENT0 < m_fbo_attachment_invalid)
6012*35238bceSAndroid Build Coastguard Worker {
6013*35238bceSAndroid Build Coastguard Worker /* If this unlikely happen this mean that we cannot create invalid attachment which is not DEPTH_ATTACHMENT, STENCIL_ATTACHMENT, DEPTH_STENCIL_ATTACHMENT and
6014*35238bceSAndroid Build Coastguard Worker GL_COLOR_ATTACHMENTm where m IS any number (for m < MAX_COLOR_ATTACHMENTS attachments are valid, and for m >= MAX_COLOR_ATTACHMENTS is invalid, but
6015*35238bceSAndroid Build Coastguard Worker INVALID_OPERATION shall be generated instead of INVALID_ENUM. Such a situation may need change in the test or in the specification. */
6016*35238bceSAndroid Build Coastguard Worker throw 0;
6017*35238bceSAndroid Build Coastguard Worker }
6018*35238bceSAndroid Build Coastguard Worker
6019*35238bceSAndroid Build Coastguard Worker switch (++m_fbo_attachment_invalid)
6020*35238bceSAndroid Build Coastguard Worker {
6021*35238bceSAndroid Build Coastguard Worker case GL_DEPTH_ATTACHMENT:
6022*35238bceSAndroid Build Coastguard Worker case GL_STENCIL_ATTACHMENT:
6023*35238bceSAndroid Build Coastguard Worker case GL_DEPTH_STENCIL_ATTACHMENT:
6024*35238bceSAndroid Build Coastguard Worker continue;
6025*35238bceSAndroid Build Coastguard Worker }
6026*35238bceSAndroid Build Coastguard Worker
6027*35238bceSAndroid Build Coastguard Worker break;
6028*35238bceSAndroid Build Coastguard Worker }
6029*35238bceSAndroid Build Coastguard Worker
6030*35238bceSAndroid Build Coastguard Worker /* Invalid color attachment. */
6031*35238bceSAndroid Build Coastguard Worker glw::GLint max_color_attachments = 8; /* Spec default. */
6032*35238bceSAndroid Build Coastguard Worker
6033*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
6034*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
6035*35238bceSAndroid Build Coastguard Worker
6036*35238bceSAndroid Build Coastguard Worker m_color_attachment_invalid = GL_COLOR_ATTACHMENT0 + max_color_attachments;
6037*35238bceSAndroid Build Coastguard Worker
6038*35238bceSAndroid Build Coastguard Worker /* Invalid default attachment. */
6039*35238bceSAndroid Build Coastguard Worker while (true)
6040*35238bceSAndroid Build Coastguard Worker {
6041*35238bceSAndroid Build Coastguard Worker switch (++m_default_attachment_invalid)
6042*35238bceSAndroid Build Coastguard Worker {
6043*35238bceSAndroid Build Coastguard Worker case GL_FRONT_LEFT:
6044*35238bceSAndroid Build Coastguard Worker case GL_FRONT_RIGHT:
6045*35238bceSAndroid Build Coastguard Worker case GL_BACK_LEFT:
6046*35238bceSAndroid Build Coastguard Worker case GL_BACK_RIGHT:
6047*35238bceSAndroid Build Coastguard Worker case GL_COLOR:
6048*35238bceSAndroid Build Coastguard Worker case GL_DEPTH:
6049*35238bceSAndroid Build Coastguard Worker case GL_STENCIL:
6050*35238bceSAndroid Build Coastguard Worker continue;
6051*35238bceSAndroid Build Coastguard Worker }
6052*35238bceSAndroid Build Coastguard Worker
6053*35238bceSAndroid Build Coastguard Worker break;
6054*35238bceSAndroid Build Coastguard Worker }
6055*35238bceSAndroid Build Coastguard Worker }
6056*35238bceSAndroid Build Coastguard Worker
6057*35238bceSAndroid Build Coastguard Worker /** Check if error is equal to the expected, log if not.
6058*35238bceSAndroid Build Coastguard Worker *
6059*35238bceSAndroid Build Coastguard Worker * @param [in] expected_error Error to be expected.
6060*35238bceSAndroid Build Coastguard Worker * @param [in] function Function name which is being tested (to be logged).
6061*35238bceSAndroid Build Coastguard Worker * @param [in] conditions Conditions when the expected error shall occure (to be logged).
6062*35238bceSAndroid Build Coastguard Worker *
6063*35238bceSAndroid Build Coastguard Worker * @return True if there is no error, false otherwise.
6064*35238bceSAndroid Build Coastguard Worker */
ExpectError(glw::GLenum expected_error,const glw::GLchar * function,const glw::GLchar * conditions)6065*35238bceSAndroid Build Coastguard Worker bool InvalidateDataAndSubDataErrorsTest::ExpectError(glw::GLenum expected_error, const glw::GLchar *function,
6066*35238bceSAndroid Build Coastguard Worker const glw::GLchar *conditions)
6067*35238bceSAndroid Build Coastguard Worker {
6068*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
6069*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
6070*35238bceSAndroid Build Coastguard Worker
6071*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
6072*35238bceSAndroid Build Coastguard Worker
6073*35238bceSAndroid Build Coastguard Worker glw::GLenum error = GL_NO_ERROR;
6074*35238bceSAndroid Build Coastguard Worker
6075*35238bceSAndroid Build Coastguard Worker if (expected_error != (error = gl.getError()))
6076*35238bceSAndroid Build Coastguard Worker {
6077*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog() << tcu::TestLog::Message << function << " was expected to generate "
6078*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(expected_error) << ", but " << glu::getErrorStr(error)
6079*35238bceSAndroid Build Coastguard Worker << " was observed instead when " << conditions << tcu::TestLog::EndMessage;
6080*35238bceSAndroid Build Coastguard Worker
6081*35238bceSAndroid Build Coastguard Worker is_ok = false;
6082*35238bceSAndroid Build Coastguard Worker }
6083*35238bceSAndroid Build Coastguard Worker
6084*35238bceSAndroid Build Coastguard Worker /* Clean additional possible errors. */
6085*35238bceSAndroid Build Coastguard Worker while (gl.getError())
6086*35238bceSAndroid Build Coastguard Worker ;
6087*35238bceSAndroid Build Coastguard Worker
6088*35238bceSAndroid Build Coastguard Worker return is_ok;
6089*35238bceSAndroid Build Coastguard Worker }
6090*35238bceSAndroid Build Coastguard Worker
6091*35238bceSAndroid Build Coastguard Worker /** @brief Clean up GL state.
6092*35238bceSAndroid Build Coastguard Worker */
Clean()6093*35238bceSAndroid Build Coastguard Worker void InvalidateDataAndSubDataErrorsTest::Clean()
6094*35238bceSAndroid Build Coastguard Worker {
6095*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
6096*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
6097*35238bceSAndroid Build Coastguard Worker
6098*35238bceSAndroid Build Coastguard Worker /* Release GL objects. */
6099*35238bceSAndroid Build Coastguard Worker if (m_fbo_valid)
6100*35238bceSAndroid Build Coastguard Worker {
6101*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &m_fbo_valid);
6102*35238bceSAndroid Build Coastguard Worker m_fbo_valid = 0;
6103*35238bceSAndroid Build Coastguard Worker }
6104*35238bceSAndroid Build Coastguard Worker
6105*35238bceSAndroid Build Coastguard Worker if (m_rbo)
6106*35238bceSAndroid Build Coastguard Worker {
6107*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &m_rbo);
6108*35238bceSAndroid Build Coastguard Worker
6109*35238bceSAndroid Build Coastguard Worker m_rbo = 0;
6110*35238bceSAndroid Build Coastguard Worker }
6111*35238bceSAndroid Build Coastguard Worker
6112*35238bceSAndroid Build Coastguard Worker /* Set initial values - all test shall have the same environment. */
6113*35238bceSAndroid Build Coastguard Worker m_fbo_invalid = 0;
6114*35238bceSAndroid Build Coastguard Worker m_fbo_attachment_valid = 0;
6115*35238bceSAndroid Build Coastguard Worker m_fbo_attachment_invalid = 0;
6116*35238bceSAndroid Build Coastguard Worker m_default_attachment_invalid = 0;
6117*35238bceSAndroid Build Coastguard Worker m_color_attachment_invalid = 0;
6118*35238bceSAndroid Build Coastguard Worker
6119*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
6120*35238bceSAndroid Build Coastguard Worker while (gl.getError())
6121*35238bceSAndroid Build Coastguard Worker ;
6122*35238bceSAndroid Build Coastguard Worker }
6123*35238bceSAndroid Build Coastguard Worker
6124*35238bceSAndroid Build Coastguard Worker /******************************** Clear Named Framebuffer Errors Test Implementation ********************************/
6125*35238bceSAndroid Build Coastguard Worker
6126*35238bceSAndroid Build Coastguard Worker /** @brief Clear Named Framebuffer Errors Test constructor.
6127*35238bceSAndroid Build Coastguard Worker *
6128*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
6129*35238bceSAndroid Build Coastguard Worker */
ClearNamedFramebufferErrorsTest(deqp::Context & context)6130*35238bceSAndroid Build Coastguard Worker ClearNamedFramebufferErrorsTest::ClearNamedFramebufferErrorsTest(deqp::Context &context)
6131*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "framebuffers_clear_errors", "Clear Named Framebuffer Errors Test")
6132*35238bceSAndroid Build Coastguard Worker , m_fbo_valid(0)
6133*35238bceSAndroid Build Coastguard Worker , m_rbo_color(0)
6134*35238bceSAndroid Build Coastguard Worker , m_rbo_depth_stencil(0)
6135*35238bceSAndroid Build Coastguard Worker , m_fbo_invalid(0)
6136*35238bceSAndroid Build Coastguard Worker {
6137*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
6138*35238bceSAndroid Build Coastguard Worker }
6139*35238bceSAndroid Build Coastguard Worker
6140*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Clear Named Framebuffer Errors Test cases.
6141*35238bceSAndroid Build Coastguard Worker *
6142*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
6143*35238bceSAndroid Build Coastguard Worker */
iterate()6144*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult ClearNamedFramebufferErrorsTest::iterate()
6145*35238bceSAndroid Build Coastguard Worker {
6146*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
6147*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
6148*35238bceSAndroid Build Coastguard Worker
6149*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
6150*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
6151*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
6152*35238bceSAndroid Build Coastguard Worker
6153*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
6154*35238bceSAndroid Build Coastguard Worker {
6155*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
6156*35238bceSAndroid Build Coastguard Worker
6157*35238bceSAndroid Build Coastguard Worker return STOP;
6158*35238bceSAndroid Build Coastguard Worker }
6159*35238bceSAndroid Build Coastguard Worker
6160*35238bceSAndroid Build Coastguard Worker /* Running tests. */
6161*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
6162*35238bceSAndroid Build Coastguard Worker bool is_error = false;
6163*35238bceSAndroid Build Coastguard Worker
6164*35238bceSAndroid Build Coastguard Worker try
6165*35238bceSAndroid Build Coastguard Worker {
6166*35238bceSAndroid Build Coastguard Worker /* Prepare objects. */
6167*35238bceSAndroid Build Coastguard Worker PrepareObjects();
6168*35238bceSAndroid Build Coastguard Worker
6169*35238bceSAndroid Build Coastguard Worker glw::GLint icolor[4] = {};
6170*35238bceSAndroid Build Coastguard Worker glw::GLuint ucolor[4] = {};
6171*35238bceSAndroid Build Coastguard Worker glw::GLfloat fcolor[4] = {};
6172*35238bceSAndroid Build Coastguard Worker
6173*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_OPERATION is generated by ClearNamedFramebuffer* if
6174*35238bceSAndroid Build Coastguard Worker framebuffer is not zero or the name of an existing framebuffer object. */
6175*35238bceSAndroid Build Coastguard Worker gl.clearNamedFramebufferiv(m_fbo_invalid, GL_COLOR, 0, icolor);
6176*35238bceSAndroid Build Coastguard Worker
6177*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "ClearNamedFramebufferiv",
6178*35238bceSAndroid Build Coastguard Worker "framebuffer is not zero or the name of an existing framebuffer object.");
6179*35238bceSAndroid Build Coastguard Worker
6180*35238bceSAndroid Build Coastguard Worker gl.clearNamedFramebufferuiv(m_fbo_invalid, GL_COLOR, 0, ucolor);
6181*35238bceSAndroid Build Coastguard Worker
6182*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "ClearNamedFramebufferuiv",
6183*35238bceSAndroid Build Coastguard Worker "framebuffer is not zero or the name of an existing framebuffer object.");
6184*35238bceSAndroid Build Coastguard Worker
6185*35238bceSAndroid Build Coastguard Worker gl.clearNamedFramebufferfv(m_fbo_invalid, GL_COLOR, 0, fcolor);
6186*35238bceSAndroid Build Coastguard Worker
6187*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "ClearNamedFramebufferfv",
6188*35238bceSAndroid Build Coastguard Worker "framebuffer is not zero or the name of an existing framebuffer object.");
6189*35238bceSAndroid Build Coastguard Worker
6190*35238bceSAndroid Build Coastguard Worker gl.clearNamedFramebufferfi(m_fbo_invalid, GL_DEPTH_STENCIL, 0, fcolor[0], icolor[0]);
6191*35238bceSAndroid Build Coastguard Worker
6192*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "ClearNamedFramebufferfi",
6193*35238bceSAndroid Build Coastguard Worker "framebuffer is not zero or the name of an existing framebuffer object.");
6194*35238bceSAndroid Build Coastguard Worker
6195*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_ENUM is generated by ClearNamedFramebufferiv if buffer
6196*35238bceSAndroid Build Coastguard Worker is not COLOR or STENCIL. */
6197*35238bceSAndroid Build Coastguard Worker gl.clearNamedFramebufferiv(m_fbo_valid, GL_DEPTH, 0, icolor);
6198*35238bceSAndroid Build Coastguard Worker
6199*35238bceSAndroid Build Coastguard Worker is_ok &=
6200*35238bceSAndroid Build Coastguard Worker ExpectError(GL_INVALID_ENUM, "ClearNamedFramebufferiv", "buffer is not COLOR or STENCIL (it is DEPTH).");
6201*35238bceSAndroid Build Coastguard Worker
6202*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_ENUM is generated by ClearNamedFramebufferuiv if buffer
6203*35238bceSAndroid Build Coastguard Worker is not COLOR. */
6204*35238bceSAndroid Build Coastguard Worker gl.clearNamedFramebufferuiv(m_fbo_valid, GL_DEPTH, 0, ucolor);
6205*35238bceSAndroid Build Coastguard Worker
6206*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, "ClearNamedFramebufferuiv", "buffer is not COLOR (it is DEPTH).");
6207*35238bceSAndroid Build Coastguard Worker
6208*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_ENUM is generated by ClearNamedFramebufferfv buffer
6209*35238bceSAndroid Build Coastguard Worker is not COLOR or DEPTH. */
6210*35238bceSAndroid Build Coastguard Worker gl.clearNamedFramebufferfv(m_fbo_valid, GL_STENCIL, 0, fcolor);
6211*35238bceSAndroid Build Coastguard Worker
6212*35238bceSAndroid Build Coastguard Worker is_ok &=
6213*35238bceSAndroid Build Coastguard Worker ExpectError(GL_INVALID_ENUM, "ClearNamedFramebufferfv", "buffer is not COLOR or DEPTH (it is STENCIL).");
6214*35238bceSAndroid Build Coastguard Worker
6215*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_ENUM is generated by ClearNamedFramebufferfi if buffer
6216*35238bceSAndroid Build Coastguard Worker is not DEPTH_STENCIL. */
6217*35238bceSAndroid Build Coastguard Worker gl.clearNamedFramebufferfi(m_fbo_valid, GL_COLOR, 0, fcolor[0], icolor[0]);
6218*35238bceSAndroid Build Coastguard Worker
6219*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, "ClearNamedFramebufferfi", "buffer is not DEPTH_STENCIL.");
6220*35238bceSAndroid Build Coastguard Worker
6221*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_VALUE is generated by ClearNamedFramebuffer* if buffer is COLOR drawbuffer is
6222*35238bceSAndroid Build Coastguard Worker negative, or greater than the value of MAX_DRAW_BUFFERS minus one. */
6223*35238bceSAndroid Build Coastguard Worker gl.clearNamedFramebufferiv(m_fbo_valid, GL_COLOR, -1, icolor);
6224*35238bceSAndroid Build Coastguard Worker
6225*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(
6226*35238bceSAndroid Build Coastguard Worker GL_INVALID_VALUE, "ClearNamedFramebufferiv",
6227*35238bceSAndroid Build Coastguard Worker "buffer is COLOR drawbuffer is negative, or greater than the value of MAX_DRAW_BUFFERS minus one.");
6228*35238bceSAndroid Build Coastguard Worker
6229*35238bceSAndroid Build Coastguard Worker gl.clearNamedFramebufferuiv(m_fbo_valid, GL_COLOR, -1, ucolor);
6230*35238bceSAndroid Build Coastguard Worker
6231*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(
6232*35238bceSAndroid Build Coastguard Worker GL_INVALID_VALUE, "ClearNamedFramebufferuiv",
6233*35238bceSAndroid Build Coastguard Worker "buffer is COLOR drawbuffer is negative, or greater than the value of MAX_DRAW_BUFFERS minus one.");
6234*35238bceSAndroid Build Coastguard Worker
6235*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_VALUE is generated by ClearNamedFramebuffer* if buffer is DEPTH, STENCIL or
6236*35238bceSAndroid Build Coastguard Worker DEPTH_STENCIL and drawbuffer is not zero. */
6237*35238bceSAndroid Build Coastguard Worker
6238*35238bceSAndroid Build Coastguard Worker gl.clearNamedFramebufferiv(m_fbo_valid, GL_STENCIL, 1, icolor);
6239*35238bceSAndroid Build Coastguard Worker
6240*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_VALUE, "ClearNamedFramebufferiv",
6241*35238bceSAndroid Build Coastguard Worker "buffer is DEPTH, STENCIL or DEPTH_STENCIL and drawbuffer is not zero.");
6242*35238bceSAndroid Build Coastguard Worker
6243*35238bceSAndroid Build Coastguard Worker gl.clearNamedFramebufferfv(m_fbo_valid, GL_DEPTH, 1, fcolor);
6244*35238bceSAndroid Build Coastguard Worker
6245*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_VALUE, "ClearNamedFramebufferfv",
6246*35238bceSAndroid Build Coastguard Worker "buffer is DEPTH, STENCIL or DEPTH_STENCIL and drawbuffer is not zero.");
6247*35238bceSAndroid Build Coastguard Worker
6248*35238bceSAndroid Build Coastguard Worker gl.clearNamedFramebufferfi(m_fbo_valid, GL_DEPTH_STENCIL, 1, fcolor[0], icolor[0]);
6249*35238bceSAndroid Build Coastguard Worker
6250*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_VALUE, "ClearNamedFramebufferfi",
6251*35238bceSAndroid Build Coastguard Worker "buffer is DEPTH, STENCIL or DEPTH_STENCIL and drawbuffer is not zero.");
6252*35238bceSAndroid Build Coastguard Worker }
6253*35238bceSAndroid Build Coastguard Worker catch (...)
6254*35238bceSAndroid Build Coastguard Worker {
6255*35238bceSAndroid Build Coastguard Worker is_ok = false;
6256*35238bceSAndroid Build Coastguard Worker is_error = true;
6257*35238bceSAndroid Build Coastguard Worker }
6258*35238bceSAndroid Build Coastguard Worker
6259*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
6260*35238bceSAndroid Build Coastguard Worker Clean();
6261*35238bceSAndroid Build Coastguard Worker
6262*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
6263*35238bceSAndroid Build Coastguard Worker if (is_ok)
6264*35238bceSAndroid Build Coastguard Worker {
6265*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
6266*35238bceSAndroid Build Coastguard Worker }
6267*35238bceSAndroid Build Coastguard Worker else
6268*35238bceSAndroid Build Coastguard Worker {
6269*35238bceSAndroid Build Coastguard Worker if (is_error)
6270*35238bceSAndroid Build Coastguard Worker {
6271*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
6272*35238bceSAndroid Build Coastguard Worker }
6273*35238bceSAndroid Build Coastguard Worker else
6274*35238bceSAndroid Build Coastguard Worker {
6275*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
6276*35238bceSAndroid Build Coastguard Worker }
6277*35238bceSAndroid Build Coastguard Worker }
6278*35238bceSAndroid Build Coastguard Worker
6279*35238bceSAndroid Build Coastguard Worker return STOP;
6280*35238bceSAndroid Build Coastguard Worker }
6281*35238bceSAndroid Build Coastguard Worker
6282*35238bceSAndroid Build Coastguard Worker /** Check Prepare test's GL objects.
6283*35238bceSAndroid Build Coastguard Worker */
PrepareObjects()6284*35238bceSAndroid Build Coastguard Worker void ClearNamedFramebufferErrorsTest::PrepareObjects()
6285*35238bceSAndroid Build Coastguard Worker {
6286*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
6287*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
6288*35238bceSAndroid Build Coastguard Worker
6289*35238bceSAndroid Build Coastguard Worker /* Valid objects. */
6290*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(1, &m_fbo_valid);
6291*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
6292*35238bceSAndroid Build Coastguard Worker
6293*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_valid);
6294*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
6295*35238bceSAndroid Build Coastguard Worker
6296*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(1, &m_rbo_color);
6297*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
6298*35238bceSAndroid Build Coastguard Worker
6299*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo_color);
6300*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
6301*35238bceSAndroid Build Coastguard Worker
6302*35238bceSAndroid Build Coastguard Worker gl.renderbufferStorage(GL_RENDERBUFFER, GL_R8, 1, 1);
6303*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
6304*35238bceSAndroid Build Coastguard Worker
6305*35238bceSAndroid Build Coastguard Worker gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo_color);
6306*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
6307*35238bceSAndroid Build Coastguard Worker
6308*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(1, &m_rbo_depth_stencil);
6309*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
6310*35238bceSAndroid Build Coastguard Worker
6311*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo_depth_stencil);
6312*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
6313*35238bceSAndroid Build Coastguard Worker
6314*35238bceSAndroid Build Coastguard Worker gl.renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 1, 1);
6315*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
6316*35238bceSAndroid Build Coastguard Worker
6317*35238bceSAndroid Build Coastguard Worker gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_rbo_depth_stencil);
6318*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
6319*35238bceSAndroid Build Coastguard Worker
6320*35238bceSAndroid Build Coastguard Worker /* Invalid objects. */
6321*35238bceSAndroid Build Coastguard Worker while (gl.isFramebuffer(++m_fbo_invalid))
6322*35238bceSAndroid Build Coastguard Worker ;
6323*35238bceSAndroid Build Coastguard Worker }
6324*35238bceSAndroid Build Coastguard Worker
6325*35238bceSAndroid Build Coastguard Worker /** Check if error is equal to the expected, log if not.
6326*35238bceSAndroid Build Coastguard Worker *
6327*35238bceSAndroid Build Coastguard Worker * @param [in] expected_error Error to be expected.
6328*35238bceSAndroid Build Coastguard Worker * @param [in] function Function name which is being tested (to be logged).
6329*35238bceSAndroid Build Coastguard Worker * @param [in] conditions Conditions when the expected error shall occure (to be logged).
6330*35238bceSAndroid Build Coastguard Worker *
6331*35238bceSAndroid Build Coastguard Worker * @return True if there is no error, false otherwise.
6332*35238bceSAndroid Build Coastguard Worker */
ExpectError(glw::GLenum expected_error,const glw::GLchar * function,const glw::GLchar * conditions)6333*35238bceSAndroid Build Coastguard Worker bool ClearNamedFramebufferErrorsTest::ExpectError(glw::GLenum expected_error, const glw::GLchar *function,
6334*35238bceSAndroid Build Coastguard Worker const glw::GLchar *conditions)
6335*35238bceSAndroid Build Coastguard Worker {
6336*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
6337*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
6338*35238bceSAndroid Build Coastguard Worker
6339*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
6340*35238bceSAndroid Build Coastguard Worker
6341*35238bceSAndroid Build Coastguard Worker glw::GLenum error = GL_NO_ERROR;
6342*35238bceSAndroid Build Coastguard Worker
6343*35238bceSAndroid Build Coastguard Worker if (expected_error != (error = gl.getError()))
6344*35238bceSAndroid Build Coastguard Worker {
6345*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog() << tcu::TestLog::Message << function << " was expected to generate "
6346*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(expected_error) << ", but " << glu::getErrorStr(error)
6347*35238bceSAndroid Build Coastguard Worker << " was observed instead when " << conditions << tcu::TestLog::EndMessage;
6348*35238bceSAndroid Build Coastguard Worker
6349*35238bceSAndroid Build Coastguard Worker is_ok = false;
6350*35238bceSAndroid Build Coastguard Worker }
6351*35238bceSAndroid Build Coastguard Worker
6352*35238bceSAndroid Build Coastguard Worker /* Clean additional possible errors. */
6353*35238bceSAndroid Build Coastguard Worker while (gl.getError())
6354*35238bceSAndroid Build Coastguard Worker ;
6355*35238bceSAndroid Build Coastguard Worker
6356*35238bceSAndroid Build Coastguard Worker return is_ok;
6357*35238bceSAndroid Build Coastguard Worker }
6358*35238bceSAndroid Build Coastguard Worker
6359*35238bceSAndroid Build Coastguard Worker /** @brief Clean up GL state.
6360*35238bceSAndroid Build Coastguard Worker */
Clean()6361*35238bceSAndroid Build Coastguard Worker void ClearNamedFramebufferErrorsTest::Clean()
6362*35238bceSAndroid Build Coastguard Worker {
6363*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
6364*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
6365*35238bceSAndroid Build Coastguard Worker
6366*35238bceSAndroid Build Coastguard Worker /* Release GL objects. */
6367*35238bceSAndroid Build Coastguard Worker if (m_fbo_valid)
6368*35238bceSAndroid Build Coastguard Worker {
6369*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &m_fbo_valid);
6370*35238bceSAndroid Build Coastguard Worker m_fbo_valid = 0;
6371*35238bceSAndroid Build Coastguard Worker }
6372*35238bceSAndroid Build Coastguard Worker
6373*35238bceSAndroid Build Coastguard Worker if (m_rbo_color)
6374*35238bceSAndroid Build Coastguard Worker {
6375*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &m_rbo_color);
6376*35238bceSAndroid Build Coastguard Worker m_rbo_color = 0;
6377*35238bceSAndroid Build Coastguard Worker }
6378*35238bceSAndroid Build Coastguard Worker
6379*35238bceSAndroid Build Coastguard Worker if (m_rbo_depth_stencil)
6380*35238bceSAndroid Build Coastguard Worker {
6381*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &m_rbo_depth_stencil);
6382*35238bceSAndroid Build Coastguard Worker m_rbo_depth_stencil = 0;
6383*35238bceSAndroid Build Coastguard Worker }
6384*35238bceSAndroid Build Coastguard Worker
6385*35238bceSAndroid Build Coastguard Worker /* Set initial values - all test shall have the same environment. */
6386*35238bceSAndroid Build Coastguard Worker m_fbo_invalid = 0;
6387*35238bceSAndroid Build Coastguard Worker
6388*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
6389*35238bceSAndroid Build Coastguard Worker while (gl.getError())
6390*35238bceSAndroid Build Coastguard Worker ;
6391*35238bceSAndroid Build Coastguard Worker }
6392*35238bceSAndroid Build Coastguard Worker
6393*35238bceSAndroid Build Coastguard Worker /******************************** Check Status Errors Test Implementation ********************************/
6394*35238bceSAndroid Build Coastguard Worker
6395*35238bceSAndroid Build Coastguard Worker /** @brief Clear Named Framebuffer Errors Test constructor.
6396*35238bceSAndroid Build Coastguard Worker *
6397*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
6398*35238bceSAndroid Build Coastguard Worker */
CheckStatusErrorsTest(deqp::Context & context)6399*35238bceSAndroid Build Coastguard Worker CheckStatusErrorsTest::CheckStatusErrorsTest(deqp::Context &context)
6400*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "framebuffers_check_status_errors", "Check Status Errors Test")
6401*35238bceSAndroid Build Coastguard Worker , m_fbo_valid(0)
6402*35238bceSAndroid Build Coastguard Worker , m_fbo_invalid(0)
6403*35238bceSAndroid Build Coastguard Worker , m_target_invalid(0)
6404*35238bceSAndroid Build Coastguard Worker {
6405*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
6406*35238bceSAndroid Build Coastguard Worker }
6407*35238bceSAndroid Build Coastguard Worker
6408*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Clear Named Framebuffer Errors Test cases.
6409*35238bceSAndroid Build Coastguard Worker *
6410*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
6411*35238bceSAndroid Build Coastguard Worker */
iterate()6412*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult CheckStatusErrorsTest::iterate()
6413*35238bceSAndroid Build Coastguard Worker {
6414*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
6415*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
6416*35238bceSAndroid Build Coastguard Worker
6417*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
6418*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
6419*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
6420*35238bceSAndroid Build Coastguard Worker
6421*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
6422*35238bceSAndroid Build Coastguard Worker {
6423*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
6424*35238bceSAndroid Build Coastguard Worker
6425*35238bceSAndroid Build Coastguard Worker return STOP;
6426*35238bceSAndroid Build Coastguard Worker }
6427*35238bceSAndroid Build Coastguard Worker
6428*35238bceSAndroid Build Coastguard Worker /* Running tests. */
6429*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
6430*35238bceSAndroid Build Coastguard Worker bool is_error = false;
6431*35238bceSAndroid Build Coastguard Worker
6432*35238bceSAndroid Build Coastguard Worker try
6433*35238bceSAndroid Build Coastguard Worker {
6434*35238bceSAndroid Build Coastguard Worker /* Prepare objects. */
6435*35238bceSAndroid Build Coastguard Worker PrepareObjects();
6436*35238bceSAndroid Build Coastguard Worker
6437*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_ENUM is generated by CheckNamedFramebufferStatus if
6438*35238bceSAndroid Build Coastguard Worker target is not DRAW_FRAMEBUFFER, READ_FRAMEBUFFER or FRAMEBUFFER. */
6439*35238bceSAndroid Build Coastguard Worker gl.checkNamedFramebufferStatus(m_fbo_valid, m_target_invalid);
6440*35238bceSAndroid Build Coastguard Worker
6441*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, "CheckNamedFramebufferStatus",
6442*35238bceSAndroid Build Coastguard Worker "target is not DRAW_FRAMEBUFFER, READ_FRAMEBUFFER or FRAMEBUFFER.");
6443*35238bceSAndroid Build Coastguard Worker
6444*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_OPERATION is generated by CheckNamedFramebufferStatus
6445*35238bceSAndroid Build Coastguard Worker if framebuffer is not zero or the name of an existing framebuffer
6446*35238bceSAndroid Build Coastguard Worker object. */
6447*35238bceSAndroid Build Coastguard Worker gl.checkNamedFramebufferStatus(m_fbo_invalid, GL_FRAMEBUFFER);
6448*35238bceSAndroid Build Coastguard Worker
6449*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "CheckNamedFramebufferStatus",
6450*35238bceSAndroid Build Coastguard Worker "framebuffer is not zero or the name of an existing framebuffer object.");
6451*35238bceSAndroid Build Coastguard Worker }
6452*35238bceSAndroid Build Coastguard Worker catch (...)
6453*35238bceSAndroid Build Coastguard Worker {
6454*35238bceSAndroid Build Coastguard Worker is_ok = false;
6455*35238bceSAndroid Build Coastguard Worker is_error = true;
6456*35238bceSAndroid Build Coastguard Worker }
6457*35238bceSAndroid Build Coastguard Worker
6458*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
6459*35238bceSAndroid Build Coastguard Worker Clean();
6460*35238bceSAndroid Build Coastguard Worker
6461*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
6462*35238bceSAndroid Build Coastguard Worker if (is_ok)
6463*35238bceSAndroid Build Coastguard Worker {
6464*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
6465*35238bceSAndroid Build Coastguard Worker }
6466*35238bceSAndroid Build Coastguard Worker else
6467*35238bceSAndroid Build Coastguard Worker {
6468*35238bceSAndroid Build Coastguard Worker if (is_error)
6469*35238bceSAndroid Build Coastguard Worker {
6470*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
6471*35238bceSAndroid Build Coastguard Worker }
6472*35238bceSAndroid Build Coastguard Worker else
6473*35238bceSAndroid Build Coastguard Worker {
6474*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
6475*35238bceSAndroid Build Coastguard Worker }
6476*35238bceSAndroid Build Coastguard Worker }
6477*35238bceSAndroid Build Coastguard Worker
6478*35238bceSAndroid Build Coastguard Worker return STOP;
6479*35238bceSAndroid Build Coastguard Worker }
6480*35238bceSAndroid Build Coastguard Worker
6481*35238bceSAndroid Build Coastguard Worker /** Check Prepare test's GL objects.
6482*35238bceSAndroid Build Coastguard Worker */
PrepareObjects()6483*35238bceSAndroid Build Coastguard Worker void CheckStatusErrorsTest::PrepareObjects()
6484*35238bceSAndroid Build Coastguard Worker {
6485*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
6486*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
6487*35238bceSAndroid Build Coastguard Worker
6488*35238bceSAndroid Build Coastguard Worker /* Valid objects. */
6489*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(1, &m_fbo_valid);
6490*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
6491*35238bceSAndroid Build Coastguard Worker
6492*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_valid);
6493*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
6494*35238bceSAndroid Build Coastguard Worker
6495*35238bceSAndroid Build Coastguard Worker /* Invalid target. */
6496*35238bceSAndroid Build Coastguard Worker bool is_target = true;
6497*35238bceSAndroid Build Coastguard Worker
6498*35238bceSAndroid Build Coastguard Worker while (is_target)
6499*35238bceSAndroid Build Coastguard Worker {
6500*35238bceSAndroid Build Coastguard Worker is_target = false;
6501*35238bceSAndroid Build Coastguard Worker
6502*35238bceSAndroid Build Coastguard Worker ++m_target_invalid;
6503*35238bceSAndroid Build Coastguard Worker
6504*35238bceSAndroid Build Coastguard Worker if (GL_FRAMEBUFFER == m_target_invalid)
6505*35238bceSAndroid Build Coastguard Worker {
6506*35238bceSAndroid Build Coastguard Worker is_target = true;
6507*35238bceSAndroid Build Coastguard Worker }
6508*35238bceSAndroid Build Coastguard Worker
6509*35238bceSAndroid Build Coastguard Worker if (GL_READ_FRAMEBUFFER == m_target_invalid)
6510*35238bceSAndroid Build Coastguard Worker {
6511*35238bceSAndroid Build Coastguard Worker is_target = true;
6512*35238bceSAndroid Build Coastguard Worker }
6513*35238bceSAndroid Build Coastguard Worker
6514*35238bceSAndroid Build Coastguard Worker if (GL_DRAW_FRAMEBUFFER == m_target_invalid)
6515*35238bceSAndroid Build Coastguard Worker {
6516*35238bceSAndroid Build Coastguard Worker is_target = true;
6517*35238bceSAndroid Build Coastguard Worker }
6518*35238bceSAndroid Build Coastguard Worker }
6519*35238bceSAndroid Build Coastguard Worker /* Invalid objects. */
6520*35238bceSAndroid Build Coastguard Worker while (gl.isFramebuffer(++m_fbo_invalid))
6521*35238bceSAndroid Build Coastguard Worker ;
6522*35238bceSAndroid Build Coastguard Worker }
6523*35238bceSAndroid Build Coastguard Worker
6524*35238bceSAndroid Build Coastguard Worker /** Check if error is equal to the expected, log if not.
6525*35238bceSAndroid Build Coastguard Worker *
6526*35238bceSAndroid Build Coastguard Worker * @param [in] expected_error Error to be expected.
6527*35238bceSAndroid Build Coastguard Worker * @param [in] function Function name which is being tested (to be logged).
6528*35238bceSAndroid Build Coastguard Worker * @param [in] conditions Conditions when the expected error shall occure (to be logged).
6529*35238bceSAndroid Build Coastguard Worker *
6530*35238bceSAndroid Build Coastguard Worker * @return True if there is no error, false otherwise.
6531*35238bceSAndroid Build Coastguard Worker */
ExpectError(glw::GLenum expected_error,const glw::GLchar * function,const glw::GLchar * conditions)6532*35238bceSAndroid Build Coastguard Worker bool CheckStatusErrorsTest::ExpectError(glw::GLenum expected_error, const glw::GLchar *function,
6533*35238bceSAndroid Build Coastguard Worker const glw::GLchar *conditions)
6534*35238bceSAndroid Build Coastguard Worker {
6535*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
6536*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
6537*35238bceSAndroid Build Coastguard Worker
6538*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
6539*35238bceSAndroid Build Coastguard Worker
6540*35238bceSAndroid Build Coastguard Worker glw::GLenum error = GL_NO_ERROR;
6541*35238bceSAndroid Build Coastguard Worker
6542*35238bceSAndroid Build Coastguard Worker if (expected_error != (error = gl.getError()))
6543*35238bceSAndroid Build Coastguard Worker {
6544*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog() << tcu::TestLog::Message << function << " was expected to generate "
6545*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(expected_error) << ", but " << glu::getErrorStr(error)
6546*35238bceSAndroid Build Coastguard Worker << " was observed instead when " << conditions << tcu::TestLog::EndMessage;
6547*35238bceSAndroid Build Coastguard Worker
6548*35238bceSAndroid Build Coastguard Worker is_ok = false;
6549*35238bceSAndroid Build Coastguard Worker }
6550*35238bceSAndroid Build Coastguard Worker
6551*35238bceSAndroid Build Coastguard Worker /* Clean additional possible errors. */
6552*35238bceSAndroid Build Coastguard Worker while (gl.getError())
6553*35238bceSAndroid Build Coastguard Worker ;
6554*35238bceSAndroid Build Coastguard Worker
6555*35238bceSAndroid Build Coastguard Worker return is_ok;
6556*35238bceSAndroid Build Coastguard Worker }
6557*35238bceSAndroid Build Coastguard Worker
6558*35238bceSAndroid Build Coastguard Worker /** @brief Clean up GL state.
6559*35238bceSAndroid Build Coastguard Worker */
Clean()6560*35238bceSAndroid Build Coastguard Worker void CheckStatusErrorsTest::Clean()
6561*35238bceSAndroid Build Coastguard Worker {
6562*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
6563*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
6564*35238bceSAndroid Build Coastguard Worker
6565*35238bceSAndroid Build Coastguard Worker /* Release GL objects. */
6566*35238bceSAndroid Build Coastguard Worker if (m_fbo_valid)
6567*35238bceSAndroid Build Coastguard Worker {
6568*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &m_fbo_valid);
6569*35238bceSAndroid Build Coastguard Worker m_fbo_valid = 0;
6570*35238bceSAndroid Build Coastguard Worker }
6571*35238bceSAndroid Build Coastguard Worker
6572*35238bceSAndroid Build Coastguard Worker /* Set initial values - all test shall have the same environment. */
6573*35238bceSAndroid Build Coastguard Worker m_fbo_invalid = 0;
6574*35238bceSAndroid Build Coastguard Worker m_target_invalid = 0;
6575*35238bceSAndroid Build Coastguard Worker
6576*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
6577*35238bceSAndroid Build Coastguard Worker while (gl.getError())
6578*35238bceSAndroid Build Coastguard Worker ;
6579*35238bceSAndroid Build Coastguard Worker }
6580*35238bceSAndroid Build Coastguard Worker
6581*35238bceSAndroid Build Coastguard Worker /******************************** Get Parameter Errors Test Implementation ********************************/
6582*35238bceSAndroid Build Coastguard Worker
6583*35238bceSAndroid Build Coastguard Worker /** @brief Get Parameter Errors Test constructor.
6584*35238bceSAndroid Build Coastguard Worker *
6585*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
6586*35238bceSAndroid Build Coastguard Worker */
GetParameterErrorsTest(deqp::Context & context)6587*35238bceSAndroid Build Coastguard Worker GetParameterErrorsTest::GetParameterErrorsTest(deqp::Context &context)
6588*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "framebuffers_get_parameter_errors", "Get Parameter Errors Test")
6589*35238bceSAndroid Build Coastguard Worker , m_fbo_valid(0)
6590*35238bceSAndroid Build Coastguard Worker , m_fbo_invalid(0)
6591*35238bceSAndroid Build Coastguard Worker , m_parameter_invalid(0)
6592*35238bceSAndroid Build Coastguard Worker {
6593*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
6594*35238bceSAndroid Build Coastguard Worker }
6595*35238bceSAndroid Build Coastguard Worker
6596*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Get Parameter Errors Test cases.
6597*35238bceSAndroid Build Coastguard Worker *
6598*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
6599*35238bceSAndroid Build Coastguard Worker */
iterate()6600*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult GetParameterErrorsTest::iterate()
6601*35238bceSAndroid Build Coastguard Worker {
6602*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
6603*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
6604*35238bceSAndroid Build Coastguard Worker
6605*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
6606*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
6607*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
6608*35238bceSAndroid Build Coastguard Worker
6609*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
6610*35238bceSAndroid Build Coastguard Worker {
6611*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
6612*35238bceSAndroid Build Coastguard Worker
6613*35238bceSAndroid Build Coastguard Worker return STOP;
6614*35238bceSAndroid Build Coastguard Worker }
6615*35238bceSAndroid Build Coastguard Worker
6616*35238bceSAndroid Build Coastguard Worker /* Running tests. */
6617*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
6618*35238bceSAndroid Build Coastguard Worker bool is_error = false;
6619*35238bceSAndroid Build Coastguard Worker
6620*35238bceSAndroid Build Coastguard Worker try
6621*35238bceSAndroid Build Coastguard Worker {
6622*35238bceSAndroid Build Coastguard Worker /* Prepare objects. */
6623*35238bceSAndroid Build Coastguard Worker PrepareObjects();
6624*35238bceSAndroid Build Coastguard Worker
6625*35238bceSAndroid Build Coastguard Worker glw::GLint return_values_unused_storage[4];
6626*35238bceSAndroid Build Coastguard Worker
6627*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_OPERATION is generated by
6628*35238bceSAndroid Build Coastguard Worker GetNamedFramebufferParameteriv if framebuffer is not zero or the name of
6629*35238bceSAndroid Build Coastguard Worker an existing framebuffer object. */
6630*35238bceSAndroid Build Coastguard Worker gl.getNamedFramebufferParameteriv(m_fbo_invalid, GL_SAMPLES, return_values_unused_storage);
6631*35238bceSAndroid Build Coastguard Worker
6632*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "GetNamedFramebufferParameteriv",
6633*35238bceSAndroid Build Coastguard Worker "framebuffer is not zero or the name of an existing framebuffer object.");
6634*35238bceSAndroid Build Coastguard Worker
6635*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_ENUM is generated by GetNamedFramebufferParameteriv
6636*35238bceSAndroid Build Coastguard Worker if pname is not one of the accepted parameter names. */
6637*35238bceSAndroid Build Coastguard Worker gl.getNamedFramebufferParameteriv(m_fbo_valid, m_parameter_invalid, return_values_unused_storage);
6638*35238bceSAndroid Build Coastguard Worker
6639*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, "GetNamedFramebufferParameteriv",
6640*35238bceSAndroid Build Coastguard Worker "pname is not one of the accepted parameter names.");
6641*35238bceSAndroid Build Coastguard Worker
6642*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_OPERATION is generated if a default framebuffer is
6643*35238bceSAndroid Build Coastguard Worker queried, and pname is not one of DOUBLEBUFFER,
6644*35238bceSAndroid Build Coastguard Worker IMPLEMENTATION_COLOR_READ_FORMAT, IMPLEMENTATION_COLOR_READ_TYPE,
6645*35238bceSAndroid Build Coastguard Worker SAMPLES, SAMPLE_BUFFERS or STEREO. */
6646*35238bceSAndroid Build Coastguard Worker gl.getNamedFramebufferParameteriv(0, GL_FRAMEBUFFER_DEFAULT_WIDTH, return_values_unused_storage);
6647*35238bceSAndroid Build Coastguard Worker
6648*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "GetNamedFramebufferParameteriv",
6649*35238bceSAndroid Build Coastguard Worker "a default framebuffer is queried, and pname is not one of DOUBLEBUFFER, "
6650*35238bceSAndroid Build Coastguard Worker "IMPLEMENTATION_COLOR_READ_FORMAT, IMPLEMENTATION_COLOR_READ_TYPE, SAMPLES, "
6651*35238bceSAndroid Build Coastguard Worker "SAMPLE_BUFFERS or STEREO.");
6652*35238bceSAndroid Build Coastguard Worker }
6653*35238bceSAndroid Build Coastguard Worker catch (...)
6654*35238bceSAndroid Build Coastguard Worker {
6655*35238bceSAndroid Build Coastguard Worker is_ok = false;
6656*35238bceSAndroid Build Coastguard Worker is_error = true;
6657*35238bceSAndroid Build Coastguard Worker }
6658*35238bceSAndroid Build Coastguard Worker
6659*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
6660*35238bceSAndroid Build Coastguard Worker Clean();
6661*35238bceSAndroid Build Coastguard Worker
6662*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
6663*35238bceSAndroid Build Coastguard Worker if (is_ok)
6664*35238bceSAndroid Build Coastguard Worker {
6665*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
6666*35238bceSAndroid Build Coastguard Worker }
6667*35238bceSAndroid Build Coastguard Worker else
6668*35238bceSAndroid Build Coastguard Worker {
6669*35238bceSAndroid Build Coastguard Worker if (is_error)
6670*35238bceSAndroid Build Coastguard Worker {
6671*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
6672*35238bceSAndroid Build Coastguard Worker }
6673*35238bceSAndroid Build Coastguard Worker else
6674*35238bceSAndroid Build Coastguard Worker {
6675*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
6676*35238bceSAndroid Build Coastguard Worker }
6677*35238bceSAndroid Build Coastguard Worker }
6678*35238bceSAndroid Build Coastguard Worker
6679*35238bceSAndroid Build Coastguard Worker return STOP;
6680*35238bceSAndroid Build Coastguard Worker }
6681*35238bceSAndroid Build Coastguard Worker
6682*35238bceSAndroid Build Coastguard Worker /** Check Prepare test's GL objects.
6683*35238bceSAndroid Build Coastguard Worker */
PrepareObjects()6684*35238bceSAndroid Build Coastguard Worker void GetParameterErrorsTest::PrepareObjects()
6685*35238bceSAndroid Build Coastguard Worker {
6686*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
6687*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
6688*35238bceSAndroid Build Coastguard Worker
6689*35238bceSAndroid Build Coastguard Worker /* Valid objects. */
6690*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(1, &m_fbo_valid);
6691*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
6692*35238bceSAndroid Build Coastguard Worker
6693*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_valid);
6694*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
6695*35238bceSAndroid Build Coastguard Worker
6696*35238bceSAndroid Build Coastguard Worker /* Invalid target. */
6697*35238bceSAndroid Build Coastguard Worker bool is_parameter = true;
6698*35238bceSAndroid Build Coastguard Worker
6699*35238bceSAndroid Build Coastguard Worker while (is_parameter)
6700*35238bceSAndroid Build Coastguard Worker {
6701*35238bceSAndroid Build Coastguard Worker is_parameter = false;
6702*35238bceSAndroid Build Coastguard Worker
6703*35238bceSAndroid Build Coastguard Worker ++m_parameter_invalid;
6704*35238bceSAndroid Build Coastguard Worker
6705*35238bceSAndroid Build Coastguard Worker static const glw::GLenum valid_parameters[] = {GL_FRAMEBUFFER_DEFAULT_WIDTH,
6706*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_DEFAULT_HEIGHT,
6707*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_DEFAULT_LAYERS,
6708*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_DEFAULT_SAMPLES,
6709*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS,
6710*35238bceSAndroid Build Coastguard Worker GL_DOUBLEBUFFER,
6711*35238bceSAndroid Build Coastguard Worker GL_IMPLEMENTATION_COLOR_READ_FORMAT,
6712*35238bceSAndroid Build Coastguard Worker GL_IMPLEMENTATION_COLOR_READ_TYPE,
6713*35238bceSAndroid Build Coastguard Worker GL_SAMPLES,
6714*35238bceSAndroid Build Coastguard Worker GL_SAMPLE_BUFFERS,
6715*35238bceSAndroid Build Coastguard Worker GL_STEREO};
6716*35238bceSAndroid Build Coastguard Worker
6717*35238bceSAndroid Build Coastguard Worker static const glw::GLuint valid_parameters_count = sizeof(valid_parameters) / sizeof(valid_parameters[0]);
6718*35238bceSAndroid Build Coastguard Worker
6719*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < valid_parameters_count; ++i)
6720*35238bceSAndroid Build Coastguard Worker {
6721*35238bceSAndroid Build Coastguard Worker if (valid_parameters[i] == m_parameter_invalid)
6722*35238bceSAndroid Build Coastguard Worker {
6723*35238bceSAndroid Build Coastguard Worker is_parameter = true;
6724*35238bceSAndroid Build Coastguard Worker }
6725*35238bceSAndroid Build Coastguard Worker }
6726*35238bceSAndroid Build Coastguard Worker }
6727*35238bceSAndroid Build Coastguard Worker
6728*35238bceSAndroid Build Coastguard Worker /* Invalid objects. */
6729*35238bceSAndroid Build Coastguard Worker while (gl.isFramebuffer(++m_fbo_invalid))
6730*35238bceSAndroid Build Coastguard Worker ;
6731*35238bceSAndroid Build Coastguard Worker }
6732*35238bceSAndroid Build Coastguard Worker
6733*35238bceSAndroid Build Coastguard Worker /** Check if error is equal to the expected, log if not.
6734*35238bceSAndroid Build Coastguard Worker *
6735*35238bceSAndroid Build Coastguard Worker * @param [in] expected_error Error to be expected.
6736*35238bceSAndroid Build Coastguard Worker * @param [in] function Function name which is being tested (to be logged).
6737*35238bceSAndroid Build Coastguard Worker * @param [in] conditions Conditions when the expected error shall occure (to be logged).
6738*35238bceSAndroid Build Coastguard Worker *
6739*35238bceSAndroid Build Coastguard Worker * @return True if there is no error, false otherwise.
6740*35238bceSAndroid Build Coastguard Worker */
ExpectError(glw::GLenum expected_error,const glw::GLchar * function,const glw::GLchar * conditions)6741*35238bceSAndroid Build Coastguard Worker bool GetParameterErrorsTest::ExpectError(glw::GLenum expected_error, const glw::GLchar *function,
6742*35238bceSAndroid Build Coastguard Worker const glw::GLchar *conditions)
6743*35238bceSAndroid Build Coastguard Worker {
6744*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
6745*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
6746*35238bceSAndroid Build Coastguard Worker
6747*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
6748*35238bceSAndroid Build Coastguard Worker
6749*35238bceSAndroid Build Coastguard Worker glw::GLenum error = GL_NO_ERROR;
6750*35238bceSAndroid Build Coastguard Worker
6751*35238bceSAndroid Build Coastguard Worker if (expected_error != (error = gl.getError()))
6752*35238bceSAndroid Build Coastguard Worker {
6753*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog() << tcu::TestLog::Message << function << " was expected to generate "
6754*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(expected_error) << ", but " << glu::getErrorStr(error)
6755*35238bceSAndroid Build Coastguard Worker << " was observed instead when " << conditions << tcu::TestLog::EndMessage;
6756*35238bceSAndroid Build Coastguard Worker
6757*35238bceSAndroid Build Coastguard Worker is_ok = false;
6758*35238bceSAndroid Build Coastguard Worker }
6759*35238bceSAndroid Build Coastguard Worker
6760*35238bceSAndroid Build Coastguard Worker /* Clean additional possible errors. */
6761*35238bceSAndroid Build Coastguard Worker while (gl.getError())
6762*35238bceSAndroid Build Coastguard Worker ;
6763*35238bceSAndroid Build Coastguard Worker
6764*35238bceSAndroid Build Coastguard Worker return is_ok;
6765*35238bceSAndroid Build Coastguard Worker }
6766*35238bceSAndroid Build Coastguard Worker
6767*35238bceSAndroid Build Coastguard Worker /** @brief Clean up GL state.
6768*35238bceSAndroid Build Coastguard Worker */
Clean()6769*35238bceSAndroid Build Coastguard Worker void GetParameterErrorsTest::Clean()
6770*35238bceSAndroid Build Coastguard Worker {
6771*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
6772*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
6773*35238bceSAndroid Build Coastguard Worker
6774*35238bceSAndroid Build Coastguard Worker /* Release GL objects. */
6775*35238bceSAndroid Build Coastguard Worker if (m_fbo_valid)
6776*35238bceSAndroid Build Coastguard Worker {
6777*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &m_fbo_valid);
6778*35238bceSAndroid Build Coastguard Worker m_fbo_valid = 0;
6779*35238bceSAndroid Build Coastguard Worker }
6780*35238bceSAndroid Build Coastguard Worker
6781*35238bceSAndroid Build Coastguard Worker /* Set initial values - all test shall have the same environment. */
6782*35238bceSAndroid Build Coastguard Worker m_fbo_invalid = 0;
6783*35238bceSAndroid Build Coastguard Worker m_parameter_invalid = 0;
6784*35238bceSAndroid Build Coastguard Worker
6785*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
6786*35238bceSAndroid Build Coastguard Worker while (gl.getError())
6787*35238bceSAndroid Build Coastguard Worker ;
6788*35238bceSAndroid Build Coastguard Worker }
6789*35238bceSAndroid Build Coastguard Worker
6790*35238bceSAndroid Build Coastguard Worker /******************************** Get Attachment Parameter Errors Test Implementation ********************************/
6791*35238bceSAndroid Build Coastguard Worker
6792*35238bceSAndroid Build Coastguard Worker /** @brief Get Attachment Parameter Errors Test constructor.
6793*35238bceSAndroid Build Coastguard Worker *
6794*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
6795*35238bceSAndroid Build Coastguard Worker */
GetAttachmentParameterErrorsTest(deqp::Context & context)6796*35238bceSAndroid Build Coastguard Worker GetAttachmentParameterErrorsTest::GetAttachmentParameterErrorsTest(deqp::Context &context)
6797*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "framebuffers_get_attachment_parameter_errors", "Get Attachment Parameter Errors Test")
6798*35238bceSAndroid Build Coastguard Worker , m_fbo_valid(0)
6799*35238bceSAndroid Build Coastguard Worker , m_rbo_color(0)
6800*35238bceSAndroid Build Coastguard Worker , m_rbo_depth_stencil(0)
6801*35238bceSAndroid Build Coastguard Worker , m_fbo_invalid(0)
6802*35238bceSAndroid Build Coastguard Worker , m_parameter_invalid(0)
6803*35238bceSAndroid Build Coastguard Worker , m_attachment_invalid(0)
6804*35238bceSAndroid Build Coastguard Worker , m_default_attachment_invalid(0)
6805*35238bceSAndroid Build Coastguard Worker , m_max_color_attachments(8) /* Spec default. */
6806*35238bceSAndroid Build Coastguard Worker {
6807*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
6808*35238bceSAndroid Build Coastguard Worker }
6809*35238bceSAndroid Build Coastguard Worker
6810*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Get Attachment Parameter Errors Test cases.
6811*35238bceSAndroid Build Coastguard Worker *
6812*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
6813*35238bceSAndroid Build Coastguard Worker */
iterate()6814*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult GetAttachmentParameterErrorsTest::iterate()
6815*35238bceSAndroid Build Coastguard Worker {
6816*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
6817*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
6818*35238bceSAndroid Build Coastguard Worker
6819*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
6820*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
6821*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
6822*35238bceSAndroid Build Coastguard Worker
6823*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
6824*35238bceSAndroid Build Coastguard Worker {
6825*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
6826*35238bceSAndroid Build Coastguard Worker
6827*35238bceSAndroid Build Coastguard Worker return STOP;
6828*35238bceSAndroid Build Coastguard Worker }
6829*35238bceSAndroid Build Coastguard Worker
6830*35238bceSAndroid Build Coastguard Worker /* Running tests. */
6831*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
6832*35238bceSAndroid Build Coastguard Worker bool is_error = false;
6833*35238bceSAndroid Build Coastguard Worker
6834*35238bceSAndroid Build Coastguard Worker try
6835*35238bceSAndroid Build Coastguard Worker {
6836*35238bceSAndroid Build Coastguard Worker /* Prepare objects. */
6837*35238bceSAndroid Build Coastguard Worker PrepareObjects();
6838*35238bceSAndroid Build Coastguard Worker
6839*35238bceSAndroid Build Coastguard Worker glw::GLint return_values_unused_storage[4];
6840*35238bceSAndroid Build Coastguard Worker
6841*35238bceSAndroid Build Coastguard Worker /* Check that GL_INVALID_OPERATION is generated by
6842*35238bceSAndroid Build Coastguard Worker GetNamedFramebufferAttachmentParameteriv if framebuffer is not zero or
6843*35238bceSAndroid Build Coastguard Worker the name of an existing framebuffer object. */
6844*35238bceSAndroid Build Coastguard Worker gl.getNamedFramebufferAttachmentParameteriv(m_fbo_invalid, GL_COLOR_ATTACHMENT0,
6845*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE,
6846*35238bceSAndroid Build Coastguard Worker return_values_unused_storage);
6847*35238bceSAndroid Build Coastguard Worker
6848*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "GetNamedFramebufferAttachmentParameteriv",
6849*35238bceSAndroid Build Coastguard Worker "framebuffer is not zero or the name of an existing framebuffer object.");
6850*35238bceSAndroid Build Coastguard Worker
6851*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_ENUM is generated by
6852*35238bceSAndroid Build Coastguard Worker GetNamedFramebufferAttachmentParameteriv if pname is not valid for the
6853*35238bceSAndroid Build Coastguard Worker value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, as described above. */
6854*35238bceSAndroid Build Coastguard Worker gl.getNamedFramebufferAttachmentParameteriv(
6855*35238bceSAndroid Build Coastguard Worker m_fbo_valid, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, return_values_unused_storage);
6856*35238bceSAndroid Build Coastguard Worker
6857*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(
6858*35238bceSAndroid Build Coastguard Worker GL_INVALID_ENUM, "GetNamedFramebufferAttachmentParameteriv",
6859*35238bceSAndroid Build Coastguard Worker "pname is not valid for the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, as described above.");
6860*35238bceSAndroid Build Coastguard Worker
6861*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_ENUM error is generated if a framebuffer object is queried, attachment
6862*35238bceSAndroid Build Coastguard Worker is not one of the attachments in table 9.2 (COLOR_ATTACHMENTi, DEPTH_ATTACHMENT, STENCIL_ATTACHMENT, DEPTH_STENCIL_ATTACHMENT), and attachment is not
6863*35238bceSAndroid Build Coastguard Worker COLOR_ATTACHMENTm where m is greater than or equal to the value of MAX_COLOR_ATTACHMENTS. */
6864*35238bceSAndroid Build Coastguard Worker gl.getNamedFramebufferAttachmentParameteriv(
6865*35238bceSAndroid Build Coastguard Worker m_fbo_valid, m_attachment_invalid, GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, return_values_unused_storage);
6866*35238bceSAndroid Build Coastguard Worker
6867*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(
6868*35238bceSAndroid Build Coastguard Worker GL_INVALID_ENUM, "GetNamedFramebufferAttachmentParameteriv",
6869*35238bceSAndroid Build Coastguard Worker "attachment is not one of the accepted framebuffer attachment points, as described in specification.");
6870*35238bceSAndroid Build Coastguard Worker
6871*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_OPERATION is generated by
6872*35238bceSAndroid Build Coastguard Worker GetNamedFramebufferAttachmentParameteriv if the value of
6873*35238bceSAndroid Build Coastguard Worker FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is GL_NONE and pname is not
6874*35238bceSAndroid Build Coastguard Worker FRAMEBUFFER_ATTACHMENT_OBJECT_NAME or
6875*35238bceSAndroid Build Coastguard Worker FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE. */
6876*35238bceSAndroid Build Coastguard Worker gl.getNamedFramebufferAttachmentParameteriv(
6877*35238bceSAndroid Build Coastguard Worker m_fbo_valid, GL_COLOR_ATTACHMENT1, GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, return_values_unused_storage);
6878*35238bceSAndroid Build Coastguard Worker
6879*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "GetNamedFramebufferAttachmentParameteriv",
6880*35238bceSAndroid Build Coastguard Worker "the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is GL_NONE and pname is not "
6881*35238bceSAndroid Build Coastguard Worker "FRAMEBUFFER_ATTACHMENT_OBJECT_NAME or FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE.");
6882*35238bceSAndroid Build Coastguard Worker
6883*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_OPERATION is generated by
6884*35238bceSAndroid Build Coastguard Worker GetNamedFramebufferAttachmentParameteriv if attachment is
6885*35238bceSAndroid Build Coastguard Worker DEPTH_STENCIL_ATTACHMENT and pname is FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE. */
6886*35238bceSAndroid Build Coastguard Worker gl.getNamedFramebufferAttachmentParameteriv(m_fbo_valid, GL_DEPTH_STENCIL_ATTACHMENT,
6887*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE,
6888*35238bceSAndroid Build Coastguard Worker return_values_unused_storage);
6889*35238bceSAndroid Build Coastguard Worker
6890*35238bceSAndroid Build Coastguard Worker is_ok &=
6891*35238bceSAndroid Build Coastguard Worker ExpectError(GL_INVALID_OPERATION, "GetNamedFramebufferAttachmentParameteriv",
6892*35238bceSAndroid Build Coastguard Worker "attachment is DEPTH_STENCIL_ATTACHMENT and pname is FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE.");
6893*35238bceSAndroid Build Coastguard Worker
6894*35238bceSAndroid Build Coastguard Worker /* Check that an INVALID_ENUM error is generated if the default framebuffer is
6895*35238bceSAndroid Build Coastguard Worker queried and attachment is not one the values FRONT, FRONT_LEFT, FRONT_RIGHT,
6896*35238bceSAndroid Build Coastguard Worker BACK, BACK_LEFT, BACK_RIGHT, DEPTH, STENCIL. */
6897*35238bceSAndroid Build Coastguard Worker gl.getNamedFramebufferAttachmentParameteriv(
6898*35238bceSAndroid Build Coastguard Worker 0, m_default_attachment_invalid, GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, return_values_unused_storage);
6899*35238bceSAndroid Build Coastguard Worker
6900*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, "GetNamedFramebufferAttachmentParameteriv",
6901*35238bceSAndroid Build Coastguard Worker "the default framebuffer is queried and attachment is not one the values FRONT, "
6902*35238bceSAndroid Build Coastguard Worker "FRONT_LEFT, FRONT_RIGHT, BACK, BACK_LEFT, BACK_RIGHT, DEPTH, STENCIL.");
6903*35238bceSAndroid Build Coastguard Worker
6904*35238bceSAndroid Build Coastguard Worker /* Check that an INVALID_OPERATION error is generated if a framebuffer object is
6905*35238bceSAndroid Build Coastguard Worker bound to target and attachment is COLOR_ATTACHMENTm where m is greater than or
6906*35238bceSAndroid Build Coastguard Worker equal to the value of MAX_COLOR_ATTACHMENTS. */
6907*35238bceSAndroid Build Coastguard Worker gl.getNamedFramebufferAttachmentParameteriv(m_fbo_valid, GL_COLOR_ATTACHMENT0 + m_max_color_attachments,
6908*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE,
6909*35238bceSAndroid Build Coastguard Worker return_values_unused_storage);
6910*35238bceSAndroid Build Coastguard Worker
6911*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "GetNamedFramebufferAttachmentParameteriv",
6912*35238bceSAndroid Build Coastguard Worker "a framebuffer object is bound to target and attachment is COLOR_ATTACHMENTm where m is "
6913*35238bceSAndroid Build Coastguard Worker "equal to the value of MAX_COLOR_ATTACHMENTS.");
6914*35238bceSAndroid Build Coastguard Worker
6915*35238bceSAndroid Build Coastguard Worker gl.getNamedFramebufferAttachmentParameteriv(m_fbo_valid, GL_COLOR_ATTACHMENT0 + m_max_color_attachments + 1,
6916*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE,
6917*35238bceSAndroid Build Coastguard Worker return_values_unused_storage);
6918*35238bceSAndroid Build Coastguard Worker
6919*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "GetNamedFramebufferAttachmentParameteriv",
6920*35238bceSAndroid Build Coastguard Worker "a framebuffer object is bound to target and attachment is COLOR_ATTACHMENTm where m is "
6921*35238bceSAndroid Build Coastguard Worker "greater than the value of MAX_COLOR_ATTACHMENTS.");
6922*35238bceSAndroid Build Coastguard Worker }
6923*35238bceSAndroid Build Coastguard Worker catch (...)
6924*35238bceSAndroid Build Coastguard Worker {
6925*35238bceSAndroid Build Coastguard Worker is_ok = false;
6926*35238bceSAndroid Build Coastguard Worker is_error = true;
6927*35238bceSAndroid Build Coastguard Worker }
6928*35238bceSAndroid Build Coastguard Worker
6929*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
6930*35238bceSAndroid Build Coastguard Worker Clean();
6931*35238bceSAndroid Build Coastguard Worker
6932*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
6933*35238bceSAndroid Build Coastguard Worker if (is_ok)
6934*35238bceSAndroid Build Coastguard Worker {
6935*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
6936*35238bceSAndroid Build Coastguard Worker }
6937*35238bceSAndroid Build Coastguard Worker else
6938*35238bceSAndroid Build Coastguard Worker {
6939*35238bceSAndroid Build Coastguard Worker if (is_error)
6940*35238bceSAndroid Build Coastguard Worker {
6941*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
6942*35238bceSAndroid Build Coastguard Worker }
6943*35238bceSAndroid Build Coastguard Worker else
6944*35238bceSAndroid Build Coastguard Worker {
6945*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
6946*35238bceSAndroid Build Coastguard Worker }
6947*35238bceSAndroid Build Coastguard Worker }
6948*35238bceSAndroid Build Coastguard Worker
6949*35238bceSAndroid Build Coastguard Worker return STOP;
6950*35238bceSAndroid Build Coastguard Worker }
6951*35238bceSAndroid Build Coastguard Worker
6952*35238bceSAndroid Build Coastguard Worker /** Check Prepare test's GL objects.
6953*35238bceSAndroid Build Coastguard Worker */
PrepareObjects()6954*35238bceSAndroid Build Coastguard Worker void GetAttachmentParameterErrorsTest::PrepareObjects()
6955*35238bceSAndroid Build Coastguard Worker {
6956*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
6957*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
6958*35238bceSAndroid Build Coastguard Worker
6959*35238bceSAndroid Build Coastguard Worker /* Valid objects. */
6960*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(1, &m_fbo_valid);
6961*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
6962*35238bceSAndroid Build Coastguard Worker
6963*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_valid);
6964*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
6965*35238bceSAndroid Build Coastguard Worker
6966*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(1, &m_rbo_color);
6967*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
6968*35238bceSAndroid Build Coastguard Worker
6969*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo_color);
6970*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
6971*35238bceSAndroid Build Coastguard Worker
6972*35238bceSAndroid Build Coastguard Worker gl.renderbufferStorage(GL_RENDERBUFFER, GL_R8, 1, 1);
6973*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
6974*35238bceSAndroid Build Coastguard Worker
6975*35238bceSAndroid Build Coastguard Worker gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo_color);
6976*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
6977*35238bceSAndroid Build Coastguard Worker
6978*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(1, &m_rbo_depth_stencil);
6979*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
6980*35238bceSAndroid Build Coastguard Worker
6981*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo_depth_stencil);
6982*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
6983*35238bceSAndroid Build Coastguard Worker
6984*35238bceSAndroid Build Coastguard Worker gl.renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 1, 1);
6985*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
6986*35238bceSAndroid Build Coastguard Worker
6987*35238bceSAndroid Build Coastguard Worker gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_rbo_depth_stencil);
6988*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
6989*35238bceSAndroid Build Coastguard Worker
6990*35238bceSAndroid Build Coastguard Worker /* Max color attachments. */
6991*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &m_max_color_attachments);
6992*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
6993*35238bceSAndroid Build Coastguard Worker
6994*35238bceSAndroid Build Coastguard Worker /* Invalid attachment. */
6995*35238bceSAndroid Build Coastguard Worker bool is_attachment = true;
6996*35238bceSAndroid Build Coastguard Worker
6997*35238bceSAndroid Build Coastguard Worker while (is_attachment)
6998*35238bceSAndroid Build Coastguard Worker {
6999*35238bceSAndroid Build Coastguard Worker is_attachment = false;
7000*35238bceSAndroid Build Coastguard Worker
7001*35238bceSAndroid Build Coastguard Worker if ((GL_DEPTH_ATTACHMENT == m_attachment_invalid) || (GL_STENCIL_ATTACHMENT == m_attachment_invalid) ||
7002*35238bceSAndroid Build Coastguard Worker (GL_DEPTH_STENCIL_ATTACHMENT == m_attachment_invalid))
7003*35238bceSAndroid Build Coastguard Worker {
7004*35238bceSAndroid Build Coastguard Worker ++m_attachment_invalid;
7005*35238bceSAndroid Build Coastguard Worker is_attachment = true;
7006*35238bceSAndroid Build Coastguard Worker }
7007*35238bceSAndroid Build Coastguard Worker
7008*35238bceSAndroid Build Coastguard Worker if (GL_COLOR_ATTACHMENT0 < m_attachment_invalid)
7009*35238bceSAndroid Build Coastguard Worker {
7010*35238bceSAndroid Build Coastguard Worker /* If this unlikely happen this mean that we cannot create invalid attachment which is not DEPTH_ATTACHMENT, STENCIL_ATTACHMENT, DEPTH_STENCIL_ATTACHMENT and
7011*35238bceSAndroid Build Coastguard Worker GL_COLOR_ATTACHMENTm where m IS any number (for m < MAX_COLOR_ATTACHMENTS attachments are valid, and for m >= MAX_COLOR_ATTACHMENTS is invalid, but
7012*35238bceSAndroid Build Coastguard Worker INVALID_OPERATION shall be generated instead of INVALID_ENUM. Such a situation may need change in the test or in the specification. */
7013*35238bceSAndroid Build Coastguard Worker throw 0;
7014*35238bceSAndroid Build Coastguard Worker }
7015*35238bceSAndroid Build Coastguard Worker }
7016*35238bceSAndroid Build Coastguard Worker
7017*35238bceSAndroid Build Coastguard Worker /* Invalid default framebuffer attachment. */
7018*35238bceSAndroid Build Coastguard Worker bool is_default_attachment = true;
7019*35238bceSAndroid Build Coastguard Worker
7020*35238bceSAndroid Build Coastguard Worker while (is_default_attachment)
7021*35238bceSAndroid Build Coastguard Worker {
7022*35238bceSAndroid Build Coastguard Worker is_default_attachment = false;
7023*35238bceSAndroid Build Coastguard Worker
7024*35238bceSAndroid Build Coastguard Worker static const glw::GLenum valid_values[] = {GL_FRONT, GL_FRONT_LEFT, GL_FRONT_RIGHT, GL_BACK,
7025*35238bceSAndroid Build Coastguard Worker GL_BACK_LEFT, GL_BACK_RIGHT, GL_DEPTH, GL_STENCIL};
7026*35238bceSAndroid Build Coastguard Worker
7027*35238bceSAndroid Build Coastguard Worker static const glw::GLuint valid_values_count = sizeof(valid_values) / sizeof(valid_values[0]);
7028*35238bceSAndroid Build Coastguard Worker
7029*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < valid_values_count; ++i)
7030*35238bceSAndroid Build Coastguard Worker {
7031*35238bceSAndroid Build Coastguard Worker if (valid_values[i] == m_default_attachment_invalid)
7032*35238bceSAndroid Build Coastguard Worker {
7033*35238bceSAndroid Build Coastguard Worker m_default_attachment_invalid++;
7034*35238bceSAndroid Build Coastguard Worker is_default_attachment = true;
7035*35238bceSAndroid Build Coastguard Worker break;
7036*35238bceSAndroid Build Coastguard Worker }
7037*35238bceSAndroid Build Coastguard Worker }
7038*35238bceSAndroid Build Coastguard Worker }
7039*35238bceSAndroid Build Coastguard Worker
7040*35238bceSAndroid Build Coastguard Worker /* Invalid parameter. */
7041*35238bceSAndroid Build Coastguard Worker bool is_parameter = true;
7042*35238bceSAndroid Build Coastguard Worker
7043*35238bceSAndroid Build Coastguard Worker while (is_parameter)
7044*35238bceSAndroid Build Coastguard Worker {
7045*35238bceSAndroid Build Coastguard Worker is_parameter = false;
7046*35238bceSAndroid Build Coastguard Worker
7047*35238bceSAndroid Build Coastguard Worker ++m_parameter_invalid;
7048*35238bceSAndroid Build Coastguard Worker
7049*35238bceSAndroid Build Coastguard Worker static const glw::GLenum valid_parameters[] = {GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE,
7050*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE,
7051*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE,
7052*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE,
7053*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE,
7054*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE,
7055*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE,
7056*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING,
7057*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME,
7058*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL,
7059*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE,
7060*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_LAYERED,
7061*35238bceSAndroid Build Coastguard Worker GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER};
7062*35238bceSAndroid Build Coastguard Worker
7063*35238bceSAndroid Build Coastguard Worker static const glw::GLuint valid_parameters_count = sizeof(valid_parameters) / sizeof(valid_parameters[0]);
7064*35238bceSAndroid Build Coastguard Worker
7065*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < valid_parameters_count; ++i)
7066*35238bceSAndroid Build Coastguard Worker {
7067*35238bceSAndroid Build Coastguard Worker if (valid_parameters[i] == m_parameter_invalid)
7068*35238bceSAndroid Build Coastguard Worker {
7069*35238bceSAndroid Build Coastguard Worker is_parameter = true;
7070*35238bceSAndroid Build Coastguard Worker }
7071*35238bceSAndroid Build Coastguard Worker }
7072*35238bceSAndroid Build Coastguard Worker }
7073*35238bceSAndroid Build Coastguard Worker
7074*35238bceSAndroid Build Coastguard Worker /* Invalid objects. */
7075*35238bceSAndroid Build Coastguard Worker while (gl.isFramebuffer(++m_fbo_invalid))
7076*35238bceSAndroid Build Coastguard Worker ;
7077*35238bceSAndroid Build Coastguard Worker }
7078*35238bceSAndroid Build Coastguard Worker
7079*35238bceSAndroid Build Coastguard Worker /** Check if error is equal to the expected, log if not.
7080*35238bceSAndroid Build Coastguard Worker *
7081*35238bceSAndroid Build Coastguard Worker * @param [in] expected_error Error to be expected.
7082*35238bceSAndroid Build Coastguard Worker * @param [in] function Function name which is being tested (to be logged).
7083*35238bceSAndroid Build Coastguard Worker * @param [in] conditions Conditions when the expected error shall occure (to be logged).
7084*35238bceSAndroid Build Coastguard Worker *
7085*35238bceSAndroid Build Coastguard Worker * @return True if there is no error, false otherwise.
7086*35238bceSAndroid Build Coastguard Worker */
ExpectError(glw::GLenum expected_error,const glw::GLchar * function,const glw::GLchar * conditions)7087*35238bceSAndroid Build Coastguard Worker bool GetAttachmentParameterErrorsTest::ExpectError(glw::GLenum expected_error, const glw::GLchar *function,
7088*35238bceSAndroid Build Coastguard Worker const glw::GLchar *conditions)
7089*35238bceSAndroid Build Coastguard Worker {
7090*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
7091*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
7092*35238bceSAndroid Build Coastguard Worker
7093*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
7094*35238bceSAndroid Build Coastguard Worker
7095*35238bceSAndroid Build Coastguard Worker glw::GLenum error = GL_NO_ERROR;
7096*35238bceSAndroid Build Coastguard Worker
7097*35238bceSAndroid Build Coastguard Worker if (expected_error != (error = gl.getError()))
7098*35238bceSAndroid Build Coastguard Worker {
7099*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog() << tcu::TestLog::Message << function << " was expected to generate "
7100*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(expected_error) << ", but " << glu::getErrorStr(error)
7101*35238bceSAndroid Build Coastguard Worker << " was observed instead when " << conditions << tcu::TestLog::EndMessage;
7102*35238bceSAndroid Build Coastguard Worker
7103*35238bceSAndroid Build Coastguard Worker is_ok = false;
7104*35238bceSAndroid Build Coastguard Worker }
7105*35238bceSAndroid Build Coastguard Worker
7106*35238bceSAndroid Build Coastguard Worker /* Clean additional possible errors. */
7107*35238bceSAndroid Build Coastguard Worker while (gl.getError())
7108*35238bceSAndroid Build Coastguard Worker ;
7109*35238bceSAndroid Build Coastguard Worker
7110*35238bceSAndroid Build Coastguard Worker return is_ok;
7111*35238bceSAndroid Build Coastguard Worker }
7112*35238bceSAndroid Build Coastguard Worker
7113*35238bceSAndroid Build Coastguard Worker /** @brief Clean up GL state.
7114*35238bceSAndroid Build Coastguard Worker */
Clean()7115*35238bceSAndroid Build Coastguard Worker void GetAttachmentParameterErrorsTest::Clean()
7116*35238bceSAndroid Build Coastguard Worker {
7117*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
7118*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
7119*35238bceSAndroid Build Coastguard Worker
7120*35238bceSAndroid Build Coastguard Worker /* Release GL objects. */
7121*35238bceSAndroid Build Coastguard Worker if (m_fbo_valid)
7122*35238bceSAndroid Build Coastguard Worker {
7123*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &m_fbo_valid);
7124*35238bceSAndroid Build Coastguard Worker m_fbo_valid = 0;
7125*35238bceSAndroid Build Coastguard Worker }
7126*35238bceSAndroid Build Coastguard Worker
7127*35238bceSAndroid Build Coastguard Worker if (m_rbo_color)
7128*35238bceSAndroid Build Coastguard Worker {
7129*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &m_rbo_color);
7130*35238bceSAndroid Build Coastguard Worker m_rbo_color = 0;
7131*35238bceSAndroid Build Coastguard Worker }
7132*35238bceSAndroid Build Coastguard Worker
7133*35238bceSAndroid Build Coastguard Worker if (m_rbo_depth_stencil)
7134*35238bceSAndroid Build Coastguard Worker {
7135*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &m_rbo_depth_stencil);
7136*35238bceSAndroid Build Coastguard Worker m_rbo_depth_stencil = 0;
7137*35238bceSAndroid Build Coastguard Worker }
7138*35238bceSAndroid Build Coastguard Worker
7139*35238bceSAndroid Build Coastguard Worker /* Set initial values - all test shall have the same environment. */
7140*35238bceSAndroid Build Coastguard Worker m_fbo_invalid = 0;
7141*35238bceSAndroid Build Coastguard Worker m_parameter_invalid = 0;
7142*35238bceSAndroid Build Coastguard Worker m_attachment_invalid = 0;
7143*35238bceSAndroid Build Coastguard Worker m_default_attachment_invalid = 0;
7144*35238bceSAndroid Build Coastguard Worker m_max_color_attachments = 8;
7145*35238bceSAndroid Build Coastguard Worker
7146*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
7147*35238bceSAndroid Build Coastguard Worker while (gl.getError())
7148*35238bceSAndroid Build Coastguard Worker ;
7149*35238bceSAndroid Build Coastguard Worker }
7150*35238bceSAndroid Build Coastguard Worker
7151*35238bceSAndroid Build Coastguard Worker /******************************** Functional Test Implementation ********************************/
7152*35238bceSAndroid Build Coastguard Worker
7153*35238bceSAndroid Build Coastguard Worker /** @brief Get Attachment Parameter Errors Test constructor.
7154*35238bceSAndroid Build Coastguard Worker *
7155*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
7156*35238bceSAndroid Build Coastguard Worker */
FunctionalTest(deqp::Context & context)7157*35238bceSAndroid Build Coastguard Worker FunctionalTest::FunctionalTest(deqp::Context &context)
7158*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "framebuffers_renderbuffers_functional", "Functional Test")
7159*35238bceSAndroid Build Coastguard Worker , m_fbo_1st(0)
7160*35238bceSAndroid Build Coastguard Worker , m_fbo_2nd(0)
7161*35238bceSAndroid Build Coastguard Worker , m_rbo_color(0)
7162*35238bceSAndroid Build Coastguard Worker , m_rbo_depth_stencil(0)
7163*35238bceSAndroid Build Coastguard Worker , m_to_color(0)
7164*35238bceSAndroid Build Coastguard Worker , m_po(0)
7165*35238bceSAndroid Build Coastguard Worker , m_vao_stencil_pass_quad(0)
7166*35238bceSAndroid Build Coastguard Worker , m_vao_depth_pass_quad(0)
7167*35238bceSAndroid Build Coastguard Worker , m_vao_color_pass_quad(0)
7168*35238bceSAndroid Build Coastguard Worker , m_bo_stencil_pass_quad(0)
7169*35238bceSAndroid Build Coastguard Worker , m_bo_depth_pass_quad(0)
7170*35238bceSAndroid Build Coastguard Worker , m_bo_color_pass_quad(0)
7171*35238bceSAndroid Build Coastguard Worker {
7172*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
7173*35238bceSAndroid Build Coastguard Worker }
7174*35238bceSAndroid Build Coastguard Worker
7175*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Get Attachment Parameter Errors Test cases.
7176*35238bceSAndroid Build Coastguard Worker *
7177*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
7178*35238bceSAndroid Build Coastguard Worker */
iterate()7179*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult FunctionalTest::iterate()
7180*35238bceSAndroid Build Coastguard Worker {
7181*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
7182*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
7183*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
7184*35238bceSAndroid Build Coastguard Worker
7185*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
7186*35238bceSAndroid Build Coastguard Worker {
7187*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
7188*35238bceSAndroid Build Coastguard Worker
7189*35238bceSAndroid Build Coastguard Worker return STOP;
7190*35238bceSAndroid Build Coastguard Worker }
7191*35238bceSAndroid Build Coastguard Worker
7192*35238bceSAndroid Build Coastguard Worker /* Running tests. */
7193*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
7194*35238bceSAndroid Build Coastguard Worker bool is_error = false;
7195*35238bceSAndroid Build Coastguard Worker
7196*35238bceSAndroid Build Coastguard Worker try
7197*35238bceSAndroid Build Coastguard Worker {
7198*35238bceSAndroid Build Coastguard Worker /* Test. */
7199*35238bceSAndroid Build Coastguard Worker is_ok &= PrepareFirstFramebuffer();
7200*35238bceSAndroid Build Coastguard Worker is_ok &= PrepareSecondFramebuffer();
7201*35238bceSAndroid Build Coastguard Worker is_ok &= ClearFramebuffers();
7202*35238bceSAndroid Build Coastguard Worker PrepareProgram();
7203*35238bceSAndroid Build Coastguard Worker PrepareBuffersAndVertexArrays();
7204*35238bceSAndroid Build Coastguard Worker is_ok &= DrawAndBlit();
7205*35238bceSAndroid Build Coastguard Worker is_ok &= CheckSecondFramebufferContent();
7206*35238bceSAndroid Build Coastguard Worker }
7207*35238bceSAndroid Build Coastguard Worker catch (...)
7208*35238bceSAndroid Build Coastguard Worker {
7209*35238bceSAndroid Build Coastguard Worker is_ok = false;
7210*35238bceSAndroid Build Coastguard Worker is_error = true;
7211*35238bceSAndroid Build Coastguard Worker }
7212*35238bceSAndroid Build Coastguard Worker
7213*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
7214*35238bceSAndroid Build Coastguard Worker Clean();
7215*35238bceSAndroid Build Coastguard Worker
7216*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
7217*35238bceSAndroid Build Coastguard Worker if (is_ok)
7218*35238bceSAndroid Build Coastguard Worker {
7219*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
7220*35238bceSAndroid Build Coastguard Worker }
7221*35238bceSAndroid Build Coastguard Worker else
7222*35238bceSAndroid Build Coastguard Worker {
7223*35238bceSAndroid Build Coastguard Worker if (is_error)
7224*35238bceSAndroid Build Coastguard Worker {
7225*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
7226*35238bceSAndroid Build Coastguard Worker }
7227*35238bceSAndroid Build Coastguard Worker else
7228*35238bceSAndroid Build Coastguard Worker {
7229*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
7230*35238bceSAndroid Build Coastguard Worker }
7231*35238bceSAndroid Build Coastguard Worker }
7232*35238bceSAndroid Build Coastguard Worker
7233*35238bceSAndroid Build Coastguard Worker return STOP;
7234*35238bceSAndroid Build Coastguard Worker }
7235*35238bceSAndroid Build Coastguard Worker
7236*35238bceSAndroid Build Coastguard Worker /** Prepare first framebuffer.
7237*35238bceSAndroid Build Coastguard Worker *
7238*35238bceSAndroid Build Coastguard Worker * @return True if there is no error, false otherwise.
7239*35238bceSAndroid Build Coastguard Worker */
PrepareFirstFramebuffer()7240*35238bceSAndroid Build Coastguard Worker bool FunctionalTest::PrepareFirstFramebuffer()
7241*35238bceSAndroid Build Coastguard Worker {
7242*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
7243*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
7244*35238bceSAndroid Build Coastguard Worker
7245*35238bceSAndroid Build Coastguard Worker /* Failure of this part shall result in test failure (it is DSA functionality failure). */
7246*35238bceSAndroid Build Coastguard Worker try
7247*35238bceSAndroid Build Coastguard Worker {
7248*35238bceSAndroid Build Coastguard Worker gl.createFramebuffers(1, &m_fbo_1st);
7249*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateFramebuffers has failed");
7250*35238bceSAndroid Build Coastguard Worker
7251*35238bceSAndroid Build Coastguard Worker gl.createRenderbuffers(1, &m_rbo_color);
7252*35238bceSAndroid Build Coastguard Worker gl.createRenderbuffers(1, &m_rbo_depth_stencil);
7253*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateRenderbuffers has failed");
7254*35238bceSAndroid Build Coastguard Worker
7255*35238bceSAndroid Build Coastguard Worker gl.namedRenderbufferStorage(m_rbo_color, GL_R8, 8, 8);
7256*35238bceSAndroid Build Coastguard Worker gl.namedRenderbufferStorage(m_rbo_depth_stencil, GL_DEPTH24_STENCIL8, 8, 8);
7257*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glNamedRenderbufferStorage has failed");
7258*35238bceSAndroid Build Coastguard Worker
7259*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferRenderbuffer(m_fbo_1st, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo_color);
7260*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferRenderbuffer(m_fbo_1st, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_rbo_depth_stencil);
7261*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glNamedFramebufferRenderbuffer has failed");
7262*35238bceSAndroid Build Coastguard Worker
7263*35238bceSAndroid Build Coastguard Worker if (GL_FRAMEBUFFER_COMPLETE != gl.checkNamedFramebufferStatus(m_fbo_1st, GL_FRAMEBUFFER))
7264*35238bceSAndroid Build Coastguard Worker {
7265*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
7266*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "CheckNamedFramebufferStatus is incomplete." << tcu::TestLog::EndMessage;
7267*35238bceSAndroid Build Coastguard Worker
7268*35238bceSAndroid Build Coastguard Worker throw 0;
7269*35238bceSAndroid Build Coastguard Worker }
7270*35238bceSAndroid Build Coastguard Worker }
7271*35238bceSAndroid Build Coastguard Worker catch (...)
7272*35238bceSAndroid Build Coastguard Worker {
7273*35238bceSAndroid Build Coastguard Worker return false;
7274*35238bceSAndroid Build Coastguard Worker }
7275*35238bceSAndroid Build Coastguard Worker
7276*35238bceSAndroid Build Coastguard Worker return true;
7277*35238bceSAndroid Build Coastguard Worker }
7278*35238bceSAndroid Build Coastguard Worker
7279*35238bceSAndroid Build Coastguard Worker /** Prepare second framebuffer.
7280*35238bceSAndroid Build Coastguard Worker *
7281*35238bceSAndroid Build Coastguard Worker * @return True if there is no error, false otherwise.
7282*35238bceSAndroid Build Coastguard Worker */
PrepareSecondFramebuffer()7283*35238bceSAndroid Build Coastguard Worker bool FunctionalTest::PrepareSecondFramebuffer()
7284*35238bceSAndroid Build Coastguard Worker {
7285*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
7286*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
7287*35238bceSAndroid Build Coastguard Worker
7288*35238bceSAndroid Build Coastguard Worker /* Failure of this part shall result in test internal error (it does not test the DSA functionality). */
7289*35238bceSAndroid Build Coastguard Worker gl.genTextures(1, &m_to_color);
7290*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
7291*35238bceSAndroid Build Coastguard Worker
7292*35238bceSAndroid Build Coastguard Worker gl.bindTexture(GL_TEXTURE_2D, m_to_color);
7293*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
7294*35238bceSAndroid Build Coastguard Worker
7295*35238bceSAndroid Build Coastguard Worker gl.texStorage2D(GL_TEXTURE_2D, 1, GL_R8, 4, 3);
7296*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2D has failed");
7297*35238bceSAndroid Build Coastguard Worker
7298*35238bceSAndroid Build Coastguard Worker /* Failure of this part shall result in test failure (it is DSA functionality failure). */
7299*35238bceSAndroid Build Coastguard Worker try
7300*35238bceSAndroid Build Coastguard Worker {
7301*35238bceSAndroid Build Coastguard Worker gl.createFramebuffers(1, &m_fbo_2nd);
7302*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateFramebuffers has failed");
7303*35238bceSAndroid Build Coastguard Worker
7304*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferTexture(m_fbo_2nd, GL_COLOR_ATTACHMENT0, m_to_color, 0);
7305*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glNamedFramebufferTexture has failed");
7306*35238bceSAndroid Build Coastguard Worker
7307*35238bceSAndroid Build Coastguard Worker if (GL_FRAMEBUFFER_COMPLETE != gl.checkNamedFramebufferStatus(m_fbo_2nd, GL_FRAMEBUFFER))
7308*35238bceSAndroid Build Coastguard Worker {
7309*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
7310*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "CheckNamedFramebufferStatus is incomplete." << tcu::TestLog::EndMessage;
7311*35238bceSAndroid Build Coastguard Worker
7312*35238bceSAndroid Build Coastguard Worker throw 0;
7313*35238bceSAndroid Build Coastguard Worker }
7314*35238bceSAndroid Build Coastguard Worker }
7315*35238bceSAndroid Build Coastguard Worker catch (...)
7316*35238bceSAndroid Build Coastguard Worker {
7317*35238bceSAndroid Build Coastguard Worker return false;
7318*35238bceSAndroid Build Coastguard Worker }
7319*35238bceSAndroid Build Coastguard Worker
7320*35238bceSAndroid Build Coastguard Worker return true;
7321*35238bceSAndroid Build Coastguard Worker }
7322*35238bceSAndroid Build Coastguard Worker
7323*35238bceSAndroid Build Coastguard Worker /** Clear framebuffers.
7324*35238bceSAndroid Build Coastguard Worker *
7325*35238bceSAndroid Build Coastguard Worker * @return True if there is no error, false otherwise.
7326*35238bceSAndroid Build Coastguard Worker */
ClearFramebuffers()7327*35238bceSAndroid Build Coastguard Worker bool FunctionalTest::ClearFramebuffers()
7328*35238bceSAndroid Build Coastguard Worker {
7329*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
7330*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
7331*35238bceSAndroid Build Coastguard Worker
7332*35238bceSAndroid Build Coastguard Worker /* Failure of this part shall result in test failure (it is DSA functionality failure). */
7333*35238bceSAndroid Build Coastguard Worker try
7334*35238bceSAndroid Build Coastguard Worker {
7335*35238bceSAndroid Build Coastguard Worker glw::GLfloat color_value[] = {0.f, 0.f, 0.f, 0.f};
7336*35238bceSAndroid Build Coastguard Worker glw::GLfloat depth_value = 0.f;
7337*35238bceSAndroid Build Coastguard Worker glw::GLint stencil_value = 0;
7338*35238bceSAndroid Build Coastguard Worker
7339*35238bceSAndroid Build Coastguard Worker /* 1st framebuffer. */
7340*35238bceSAndroid Build Coastguard Worker gl.clearNamedFramebufferfv(m_fbo_1st, GL_COLOR, 0, color_value);
7341*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glClearNamedFramebufferfv has failed");
7342*35238bceSAndroid Build Coastguard Worker
7343*35238bceSAndroid Build Coastguard Worker gl.clearNamedFramebufferfi(m_fbo_1st, GL_DEPTH_STENCIL, 0, depth_value, stencil_value);
7344*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glClearNamedFramebufferfi has failed");
7345*35238bceSAndroid Build Coastguard Worker
7346*35238bceSAndroid Build Coastguard Worker /* 2nd framebuffer. */
7347*35238bceSAndroid Build Coastguard Worker gl.clearNamedFramebufferfv(m_fbo_1st, GL_COLOR, 0, color_value);
7348*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glClearNamedFramebufferfv has failed");
7349*35238bceSAndroid Build Coastguard Worker }
7350*35238bceSAndroid Build Coastguard Worker catch (...)
7351*35238bceSAndroid Build Coastguard Worker {
7352*35238bceSAndroid Build Coastguard Worker return false;
7353*35238bceSAndroid Build Coastguard Worker }
7354*35238bceSAndroid Build Coastguard Worker
7355*35238bceSAndroid Build Coastguard Worker return true;
7356*35238bceSAndroid Build Coastguard Worker }
7357*35238bceSAndroid Build Coastguard Worker
7358*35238bceSAndroid Build Coastguard Worker /** Prepare test's GLSL program.
7359*35238bceSAndroid Build Coastguard Worker */
PrepareProgram()7360*35238bceSAndroid Build Coastguard Worker void FunctionalTest::PrepareProgram()
7361*35238bceSAndroid Build Coastguard Worker {
7362*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality */
7363*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
7364*35238bceSAndroid Build Coastguard Worker
7365*35238bceSAndroid Build Coastguard Worker struct Shader
7366*35238bceSAndroid Build Coastguard Worker {
7367*35238bceSAndroid Build Coastguard Worker glw::GLchar const *const source;
7368*35238bceSAndroid Build Coastguard Worker glw::GLenum const type;
7369*35238bceSAndroid Build Coastguard Worker glw::GLuint id;
7370*35238bceSAndroid Build Coastguard Worker } shader[] = {{s_vertex_shader, GL_VERTEX_SHADER, 0}, {s_fragment_shader, GL_FRAGMENT_SHADER, 0}};
7371*35238bceSAndroid Build Coastguard Worker
7372*35238bceSAndroid Build Coastguard Worker glw::GLuint const shader_count = sizeof(shader) / sizeof(shader[0]);
7373*35238bceSAndroid Build Coastguard Worker
7374*35238bceSAndroid Build Coastguard Worker try
7375*35238bceSAndroid Build Coastguard Worker {
7376*35238bceSAndroid Build Coastguard Worker /* Create program. */
7377*35238bceSAndroid Build Coastguard Worker m_po = gl.createProgram();
7378*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateProgram call failed.");
7379*35238bceSAndroid Build Coastguard Worker
7380*35238bceSAndroid Build Coastguard Worker /* Shader compilation. */
7381*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < shader_count; ++i)
7382*35238bceSAndroid Build Coastguard Worker {
7383*35238bceSAndroid Build Coastguard Worker if (DE_NULL != shader[i].source)
7384*35238bceSAndroid Build Coastguard Worker {
7385*35238bceSAndroid Build Coastguard Worker shader[i].id = gl.createShader(shader[i].type);
7386*35238bceSAndroid Build Coastguard Worker
7387*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateShader call failed.");
7388*35238bceSAndroid Build Coastguard Worker
7389*35238bceSAndroid Build Coastguard Worker gl.attachShader(m_po, shader[i].id);
7390*35238bceSAndroid Build Coastguard Worker
7391*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glAttachShader call failed.");
7392*35238bceSAndroid Build Coastguard Worker
7393*35238bceSAndroid Build Coastguard Worker gl.shaderSource(shader[i].id, 1, &(shader[i].source), NULL);
7394*35238bceSAndroid Build Coastguard Worker
7395*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource call failed.");
7396*35238bceSAndroid Build Coastguard Worker
7397*35238bceSAndroid Build Coastguard Worker gl.compileShader(shader[i].id);
7398*35238bceSAndroid Build Coastguard Worker
7399*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glCompileShader call failed.");
7400*35238bceSAndroid Build Coastguard Worker
7401*35238bceSAndroid Build Coastguard Worker glw::GLint status = GL_FALSE;
7402*35238bceSAndroid Build Coastguard Worker
7403*35238bceSAndroid Build Coastguard Worker gl.getShaderiv(shader[i].id, GL_COMPILE_STATUS, &status);
7404*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
7405*35238bceSAndroid Build Coastguard Worker
7406*35238bceSAndroid Build Coastguard Worker if (GL_FALSE == status)
7407*35238bceSAndroid Build Coastguard Worker {
7408*35238bceSAndroid Build Coastguard Worker glw::GLint log_size = 0;
7409*35238bceSAndroid Build Coastguard Worker gl.getShaderiv(shader[i].id, GL_INFO_LOG_LENGTH, &log_size);
7410*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
7411*35238bceSAndroid Build Coastguard Worker
7412*35238bceSAndroid Build Coastguard Worker glw::GLchar *log_text = new glw::GLchar[log_size];
7413*35238bceSAndroid Build Coastguard Worker
7414*35238bceSAndroid Build Coastguard Worker gl.getShaderInfoLog(shader[i].id, log_size, NULL, &log_text[0]);
7415*35238bceSAndroid Build Coastguard Worker
7416*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
7417*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Shader compilation has failed.\n"
7418*35238bceSAndroid Build Coastguard Worker << "Shader type: " << glu::getShaderTypeStr(shader[i].type) << "\n"
7419*35238bceSAndroid Build Coastguard Worker << "Shader compilation error log:\n"
7420*35238bceSAndroid Build Coastguard Worker << log_text << "\n"
7421*35238bceSAndroid Build Coastguard Worker << "Shader source code:\n"
7422*35238bceSAndroid Build Coastguard Worker << shader[i].source << "\n"
7423*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
7424*35238bceSAndroid Build Coastguard Worker
7425*35238bceSAndroid Build Coastguard Worker delete[] log_text;
7426*35238bceSAndroid Build Coastguard Worker
7427*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderInfoLog call failed.");
7428*35238bceSAndroid Build Coastguard Worker
7429*35238bceSAndroid Build Coastguard Worker throw 0;
7430*35238bceSAndroid Build Coastguard Worker }
7431*35238bceSAndroid Build Coastguard Worker }
7432*35238bceSAndroid Build Coastguard Worker }
7433*35238bceSAndroid Build Coastguard Worker
7434*35238bceSAndroid Build Coastguard Worker /* Link. */
7435*35238bceSAndroid Build Coastguard Worker gl.linkProgram(m_po);
7436*35238bceSAndroid Build Coastguard Worker
7437*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glTransformFeedbackVaryings call failed.");
7438*35238bceSAndroid Build Coastguard Worker
7439*35238bceSAndroid Build Coastguard Worker glw::GLint status = GL_FALSE;
7440*35238bceSAndroid Build Coastguard Worker
7441*35238bceSAndroid Build Coastguard Worker gl.getProgramiv(m_po, GL_LINK_STATUS, &status);
7442*35238bceSAndroid Build Coastguard Worker
7443*35238bceSAndroid Build Coastguard Worker if (GL_TRUE == status)
7444*35238bceSAndroid Build Coastguard Worker {
7445*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < shader_count; ++i)
7446*35238bceSAndroid Build Coastguard Worker {
7447*35238bceSAndroid Build Coastguard Worker if (shader[i].id)
7448*35238bceSAndroid Build Coastguard Worker {
7449*35238bceSAndroid Build Coastguard Worker gl.detachShader(m_po, shader[i].id);
7450*35238bceSAndroid Build Coastguard Worker
7451*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glDetachShader call failed.");
7452*35238bceSAndroid Build Coastguard Worker }
7453*35238bceSAndroid Build Coastguard Worker }
7454*35238bceSAndroid Build Coastguard Worker }
7455*35238bceSAndroid Build Coastguard Worker else
7456*35238bceSAndroid Build Coastguard Worker {
7457*35238bceSAndroid Build Coastguard Worker glw::GLint log_size = 0;
7458*35238bceSAndroid Build Coastguard Worker
7459*35238bceSAndroid Build Coastguard Worker gl.getProgramiv(m_po, GL_INFO_LOG_LENGTH, &log_size);
7460*35238bceSAndroid Build Coastguard Worker
7461*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramiv call failed.");
7462*35238bceSAndroid Build Coastguard Worker
7463*35238bceSAndroid Build Coastguard Worker glw::GLchar *log_text = new glw::GLchar[log_size];
7464*35238bceSAndroid Build Coastguard Worker
7465*35238bceSAndroid Build Coastguard Worker gl.getProgramInfoLog(m_po, log_size, NULL, &log_text[0]);
7466*35238bceSAndroid Build Coastguard Worker
7467*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog() << tcu::TestLog::Message << "Program linkage has failed due to:\n"
7468*35238bceSAndroid Build Coastguard Worker << log_text << "\n"
7469*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
7470*35238bceSAndroid Build Coastguard Worker
7471*35238bceSAndroid Build Coastguard Worker delete[] log_text;
7472*35238bceSAndroid Build Coastguard Worker
7473*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramInfoLog call failed.");
7474*35238bceSAndroid Build Coastguard Worker
7475*35238bceSAndroid Build Coastguard Worker throw 0;
7476*35238bceSAndroid Build Coastguard Worker }
7477*35238bceSAndroid Build Coastguard Worker }
7478*35238bceSAndroid Build Coastguard Worker catch (...)
7479*35238bceSAndroid Build Coastguard Worker {
7480*35238bceSAndroid Build Coastguard Worker if (m_po)
7481*35238bceSAndroid Build Coastguard Worker {
7482*35238bceSAndroid Build Coastguard Worker gl.deleteProgram(m_po);
7483*35238bceSAndroid Build Coastguard Worker
7484*35238bceSAndroid Build Coastguard Worker m_po = 0;
7485*35238bceSAndroid Build Coastguard Worker }
7486*35238bceSAndroid Build Coastguard Worker }
7487*35238bceSAndroid Build Coastguard Worker
7488*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < shader_count; ++i)
7489*35238bceSAndroid Build Coastguard Worker {
7490*35238bceSAndroid Build Coastguard Worker if (0 != shader[i].id)
7491*35238bceSAndroid Build Coastguard Worker {
7492*35238bceSAndroid Build Coastguard Worker gl.deleteShader(shader[i].id);
7493*35238bceSAndroid Build Coastguard Worker
7494*35238bceSAndroid Build Coastguard Worker shader[i].id = 0;
7495*35238bceSAndroid Build Coastguard Worker }
7496*35238bceSAndroid Build Coastguard Worker }
7497*35238bceSAndroid Build Coastguard Worker
7498*35238bceSAndroid Build Coastguard Worker if (0 == m_po)
7499*35238bceSAndroid Build Coastguard Worker {
7500*35238bceSAndroid Build Coastguard Worker throw 0;
7501*35238bceSAndroid Build Coastguard Worker }
7502*35238bceSAndroid Build Coastguard Worker }
7503*35238bceSAndroid Build Coastguard Worker
7504*35238bceSAndroid Build Coastguard Worker /** Prepare Vertex Array Objects (one for each draw pass).
7505*35238bceSAndroid Build Coastguard Worker */
PrepareBuffersAndVertexArrays()7506*35238bceSAndroid Build Coastguard Worker void FunctionalTest::PrepareBuffersAndVertexArrays()
7507*35238bceSAndroid Build Coastguard Worker {
7508*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
7509*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
7510*35238bceSAndroid Build Coastguard Worker
7511*35238bceSAndroid Build Coastguard Worker /* Query program attribute. */
7512*35238bceSAndroid Build Coastguard Worker glw::GLuint program_attribute = gl.getAttribLocation(m_po, s_attribute);
7513*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation call failed.");
7514*35238bceSAndroid Build Coastguard Worker
7515*35238bceSAndroid Build Coastguard Worker /* Create stencil pass buffer. */
7516*35238bceSAndroid Build Coastguard Worker gl.genVertexArrays(1, &m_vao_stencil_pass_quad);
7517*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays call failed.");
7518*35238bceSAndroid Build Coastguard Worker
7519*35238bceSAndroid Build Coastguard Worker gl.bindVertexArray(m_vao_stencil_pass_quad);
7520*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray call failed.");
7521*35238bceSAndroid Build Coastguard Worker
7522*35238bceSAndroid Build Coastguard Worker gl.genBuffers(1, &m_bo_stencil_pass_quad);
7523*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenBuffers call failed.");
7524*35238bceSAndroid Build Coastguard Worker
7525*35238bceSAndroid Build Coastguard Worker gl.bindBuffer(GL_ARRAY_BUFFER, m_bo_stencil_pass_quad);
7526*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffers call failed.");
7527*35238bceSAndroid Build Coastguard Worker
7528*35238bceSAndroid Build Coastguard Worker gl.bufferData(GL_ARRAY_BUFFER, s_stencil_pass_quad_size, s_stencil_pass_quad, GL_STATIC_DRAW);
7529*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData call failed.");
7530*35238bceSAndroid Build Coastguard Worker
7531*35238bceSAndroid Build Coastguard Worker gl.vertexAttribPointer(program_attribute, 3, GL_FLOAT, GL_FALSE, 0, NULL);
7532*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer call failed.");
7533*35238bceSAndroid Build Coastguard Worker
7534*35238bceSAndroid Build Coastguard Worker gl.enableVertexAttribArray(program_attribute);
7535*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray call failed.");
7536*35238bceSAndroid Build Coastguard Worker
7537*35238bceSAndroid Build Coastguard Worker /* Create depth pass buffer. */
7538*35238bceSAndroid Build Coastguard Worker gl.genVertexArrays(1, &m_vao_depth_pass_quad);
7539*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays call failed.");
7540*35238bceSAndroid Build Coastguard Worker
7541*35238bceSAndroid Build Coastguard Worker gl.bindVertexArray(m_vao_depth_pass_quad);
7542*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray call failed.");
7543*35238bceSAndroid Build Coastguard Worker
7544*35238bceSAndroid Build Coastguard Worker gl.genBuffers(1, &m_bo_depth_pass_quad);
7545*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenBuffers call failed.");
7546*35238bceSAndroid Build Coastguard Worker
7547*35238bceSAndroid Build Coastguard Worker gl.bindBuffer(GL_ARRAY_BUFFER, m_bo_depth_pass_quad);
7548*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffers call failed.");
7549*35238bceSAndroid Build Coastguard Worker
7550*35238bceSAndroid Build Coastguard Worker gl.bufferData(GL_ARRAY_BUFFER, s_depth_pass_quad_size, s_depth_pass_quad, GL_STATIC_DRAW);
7551*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData call failed.");
7552*35238bceSAndroid Build Coastguard Worker
7553*35238bceSAndroid Build Coastguard Worker gl.vertexAttribPointer(program_attribute, 3, GL_FLOAT, GL_FALSE, 0, NULL);
7554*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer call failed.");
7555*35238bceSAndroid Build Coastguard Worker
7556*35238bceSAndroid Build Coastguard Worker gl.enableVertexAttribArray(program_attribute);
7557*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray call failed.");
7558*35238bceSAndroid Build Coastguard Worker
7559*35238bceSAndroid Build Coastguard Worker /* Create color pass buffer. */
7560*35238bceSAndroid Build Coastguard Worker gl.genVertexArrays(1, &m_vao_color_pass_quad);
7561*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays call failed.");
7562*35238bceSAndroid Build Coastguard Worker
7563*35238bceSAndroid Build Coastguard Worker gl.bindVertexArray(m_vao_color_pass_quad);
7564*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray call failed.");
7565*35238bceSAndroid Build Coastguard Worker
7566*35238bceSAndroid Build Coastguard Worker gl.genBuffers(1, &m_bo_color_pass_quad);
7567*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenBuffers call failed.");
7568*35238bceSAndroid Build Coastguard Worker
7569*35238bceSAndroid Build Coastguard Worker gl.bindBuffer(GL_ARRAY_BUFFER, m_bo_color_pass_quad);
7570*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffers call failed.");
7571*35238bceSAndroid Build Coastguard Worker
7572*35238bceSAndroid Build Coastguard Worker gl.bufferData(GL_ARRAY_BUFFER, s_color_pass_quad_size, s_color_pass_quad, GL_STATIC_DRAW);
7573*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData call failed.");
7574*35238bceSAndroid Build Coastguard Worker
7575*35238bceSAndroid Build Coastguard Worker gl.vertexAttribPointer(program_attribute, 3, GL_FLOAT, GL_FALSE, 0, NULL);
7576*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer call failed.");
7577*35238bceSAndroid Build Coastguard Worker
7578*35238bceSAndroid Build Coastguard Worker gl.enableVertexAttribArray(program_attribute);
7579*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray call failed.");
7580*35238bceSAndroid Build Coastguard Worker }
7581*35238bceSAndroid Build Coastguard Worker
7582*35238bceSAndroid Build Coastguard Worker /** Do the test draww/blit calls.
7583*35238bceSAndroid Build Coastguard Worker *
7584*35238bceSAndroid Build Coastguard Worker * @return True if there is no error in DSA functionality, false otherwise.
7585*35238bceSAndroid Build Coastguard Worker */
DrawAndBlit()7586*35238bceSAndroid Build Coastguard Worker bool FunctionalTest::DrawAndBlit()
7587*35238bceSAndroid Build Coastguard Worker {
7588*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
7589*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
7590*35238bceSAndroid Build Coastguard Worker
7591*35238bceSAndroid Build Coastguard Worker gl.useProgram(m_po);
7592*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram call failed.");
7593*35238bceSAndroid Build Coastguard Worker
7594*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_1st);
7595*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
7596*35238bceSAndroid Build Coastguard Worker
7597*35238bceSAndroid Build Coastguard Worker gl.viewport(0, 0, 8, 8);
7598*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
7599*35238bceSAndroid Build Coastguard Worker
7600*35238bceSAndroid Build Coastguard Worker /* Draw to stencil buffer. */
7601*35238bceSAndroid Build Coastguard Worker gl.bindVertexArray(m_vao_stencil_pass_quad);
7602*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray call failed.");
7603*35238bceSAndroid Build Coastguard Worker
7604*35238bceSAndroid Build Coastguard Worker gl.stencilFunc(GL_NEVER, 0, 0xff);
7605*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilFunc call failed.");
7606*35238bceSAndroid Build Coastguard Worker
7607*35238bceSAndroid Build Coastguard Worker gl.stencilOp(GL_INCR, GL_KEEP, GL_KEEP);
7608*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilOp call failed.");
7609*35238bceSAndroid Build Coastguard Worker
7610*35238bceSAndroid Build Coastguard Worker gl.stencilMask(0xff);
7611*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilMask call failed.");
7612*35238bceSAndroid Build Coastguard Worker
7613*35238bceSAndroid Build Coastguard Worker gl.colorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
7614*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glColorMask call failed.");
7615*35238bceSAndroid Build Coastguard Worker
7616*35238bceSAndroid Build Coastguard Worker gl.depthMask(GL_FALSE);
7617*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glDepthMask call failed.");
7618*35238bceSAndroid Build Coastguard Worker
7619*35238bceSAndroid Build Coastguard Worker gl.enable(GL_STENCIL_TEST);
7620*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable call failed.");
7621*35238bceSAndroid Build Coastguard Worker
7622*35238bceSAndroid Build Coastguard Worker gl.disable(GL_DEPTH_TEST);
7623*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable call failed.");
7624*35238bceSAndroid Build Coastguard Worker
7625*35238bceSAndroid Build Coastguard Worker gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
7626*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays call failed.");
7627*35238bceSAndroid Build Coastguard Worker
7628*35238bceSAndroid Build Coastguard Worker /* Draw to depth buffer. */
7629*35238bceSAndroid Build Coastguard Worker gl.bindVertexArray(m_vao_depth_pass_quad);
7630*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray call failed.");
7631*35238bceSAndroid Build Coastguard Worker
7632*35238bceSAndroid Build Coastguard Worker gl.stencilFunc(GL_ALWAYS, 0, 0xff);
7633*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilFunc call failed.");
7634*35238bceSAndroid Build Coastguard Worker
7635*35238bceSAndroid Build Coastguard Worker gl.stencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
7636*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilOp call failed.");
7637*35238bceSAndroid Build Coastguard Worker
7638*35238bceSAndroid Build Coastguard Worker gl.stencilMask(0xff);
7639*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilMask call failed.");
7640*35238bceSAndroid Build Coastguard Worker
7641*35238bceSAndroid Build Coastguard Worker gl.depthFunc(GL_ALWAYS);
7642*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glDepthFunc call failed.");
7643*35238bceSAndroid Build Coastguard Worker
7644*35238bceSAndroid Build Coastguard Worker gl.disable(GL_STENCIL_TEST);
7645*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glDisable call failed.");
7646*35238bceSAndroid Build Coastguard Worker
7647*35238bceSAndroid Build Coastguard Worker gl.enable(GL_DEPTH_TEST);
7648*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable call failed.");
7649*35238bceSAndroid Build Coastguard Worker
7650*35238bceSAndroid Build Coastguard Worker gl.depthMask(GL_TRUE);
7651*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glDepthMask call failed.");
7652*35238bceSAndroid Build Coastguard Worker
7653*35238bceSAndroid Build Coastguard Worker gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
7654*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays call failed.");
7655*35238bceSAndroid Build Coastguard Worker
7656*35238bceSAndroid Build Coastguard Worker /* Draw to color buffer. */
7657*35238bceSAndroid Build Coastguard Worker gl.bindVertexArray(m_vao_color_pass_quad);
7658*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray call failed.");
7659*35238bceSAndroid Build Coastguard Worker
7660*35238bceSAndroid Build Coastguard Worker gl.colorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
7661*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glColorMask call failed.");
7662*35238bceSAndroid Build Coastguard Worker
7663*35238bceSAndroid Build Coastguard Worker gl.stencilFunc(GL_EQUAL, 1, 0xff);
7664*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilFunc call failed.");
7665*35238bceSAndroid Build Coastguard Worker
7666*35238bceSAndroid Build Coastguard Worker gl.enable(GL_STENCIL_TEST);
7667*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable call failed.");
7668*35238bceSAndroid Build Coastguard Worker
7669*35238bceSAndroid Build Coastguard Worker gl.enable(GL_DEPTH_TEST);
7670*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable call failed.");
7671*35238bceSAndroid Build Coastguard Worker
7672*35238bceSAndroid Build Coastguard Worker gl.depthFunc(GL_GREATER);
7673*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glDepthFunc call failed.");
7674*35238bceSAndroid Build Coastguard Worker
7675*35238bceSAndroid Build Coastguard Worker gl.depthMask(GL_FALSE);
7676*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glDepthMask call failed.");
7677*35238bceSAndroid Build Coastguard Worker
7678*35238bceSAndroid Build Coastguard Worker gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
7679*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays call failed.");
7680*35238bceSAndroid Build Coastguard Worker
7681*35238bceSAndroid Build Coastguard Worker /* Blit framebuffer content. */
7682*35238bceSAndroid Build Coastguard Worker gl.blitNamedFramebuffer(m_fbo_1st, m_fbo_2nd, 0, 0, 8, 8, 0, 0, 4, 3, GL_COLOR_BUFFER_BIT, GL_NEAREST);
7683*35238bceSAndroid Build Coastguard Worker
7684*35238bceSAndroid Build Coastguard Worker if (gl.getError())
7685*35238bceSAndroid Build Coastguard Worker {
7686*35238bceSAndroid Build Coastguard Worker return false;
7687*35238bceSAndroid Build Coastguard Worker }
7688*35238bceSAndroid Build Coastguard Worker
7689*35238bceSAndroid Build Coastguard Worker return true;
7690*35238bceSAndroid Build Coastguard Worker }
7691*35238bceSAndroid Build Coastguard Worker
7692*35238bceSAndroid Build Coastguard Worker /** Check resulting framebuffer content.
7693*35238bceSAndroid Build Coastguard Worker *
7694*35238bceSAndroid Build Coastguard Worker * @return True if content matches the reference false otherwise.
7695*35238bceSAndroid Build Coastguard Worker */
CheckSecondFramebufferContent()7696*35238bceSAndroid Build Coastguard Worker bool FunctionalTest::CheckSecondFramebufferContent()
7697*35238bceSAndroid Build Coastguard Worker {
7698*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
7699*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
7700*35238bceSAndroid Build Coastguard Worker
7701*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_2nd);
7702*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
7703*35238bceSAndroid Build Coastguard Worker
7704*35238bceSAndroid Build Coastguard Worker glw::GLubyte framebuffer_values[3][4] = {
7705*35238bceSAndroid Build Coastguard Worker {0} /* , ... */
7706*35238bceSAndroid Build Coastguard Worker };
7707*35238bceSAndroid Build Coastguard Worker
7708*35238bceSAndroid Build Coastguard Worker static const glw::GLubyte reference_values[3][4] = {{0, 0, 0, 0}, {0, 0, 255, 0}, {0, 0, 0, 0}};
7709*35238bceSAndroid Build Coastguard Worker
7710*35238bceSAndroid Build Coastguard Worker gl.readPixels(0, 0, 4, 3, GL_RED, GL_UNSIGNED_BYTE, framebuffer_values);
7711*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels call failed.");
7712*35238bceSAndroid Build Coastguard Worker
7713*35238bceSAndroid Build Coastguard Worker for (glw::GLuint j = 0; j < 3; ++j)
7714*35238bceSAndroid Build Coastguard Worker {
7715*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < 4; ++i)
7716*35238bceSAndroid Build Coastguard Worker {
7717*35238bceSAndroid Build Coastguard Worker if (reference_values[j][i] != framebuffer_values[j][i])
7718*35238bceSAndroid Build Coastguard Worker {
7719*35238bceSAndroid Build Coastguard Worker return false;
7720*35238bceSAndroid Build Coastguard Worker }
7721*35238bceSAndroid Build Coastguard Worker }
7722*35238bceSAndroid Build Coastguard Worker }
7723*35238bceSAndroid Build Coastguard Worker
7724*35238bceSAndroid Build Coastguard Worker return true;
7725*35238bceSAndroid Build Coastguard Worker }
7726*35238bceSAndroid Build Coastguard Worker
7727*35238bceSAndroid Build Coastguard Worker /** @brief Clean up GL state.
7728*35238bceSAndroid Build Coastguard Worker */
Clean()7729*35238bceSAndroid Build Coastguard Worker void FunctionalTest::Clean()
7730*35238bceSAndroid Build Coastguard Worker {
7731*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
7732*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
7733*35238bceSAndroid Build Coastguard Worker
7734*35238bceSAndroid Build Coastguard Worker /* Releas GL objects. */
7735*35238bceSAndroid Build Coastguard Worker if (m_fbo_1st)
7736*35238bceSAndroid Build Coastguard Worker {
7737*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &m_fbo_1st);
7738*35238bceSAndroid Build Coastguard Worker
7739*35238bceSAndroid Build Coastguard Worker m_fbo_1st = 0;
7740*35238bceSAndroid Build Coastguard Worker }
7741*35238bceSAndroid Build Coastguard Worker
7742*35238bceSAndroid Build Coastguard Worker if (m_fbo_2nd)
7743*35238bceSAndroid Build Coastguard Worker {
7744*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &m_fbo_2nd);
7745*35238bceSAndroid Build Coastguard Worker
7746*35238bceSAndroid Build Coastguard Worker m_fbo_2nd = 0;
7747*35238bceSAndroid Build Coastguard Worker }
7748*35238bceSAndroid Build Coastguard Worker
7749*35238bceSAndroid Build Coastguard Worker if (m_rbo_color)
7750*35238bceSAndroid Build Coastguard Worker {
7751*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &m_rbo_color);
7752*35238bceSAndroid Build Coastguard Worker
7753*35238bceSAndroid Build Coastguard Worker m_rbo_color = 0;
7754*35238bceSAndroid Build Coastguard Worker }
7755*35238bceSAndroid Build Coastguard Worker
7756*35238bceSAndroid Build Coastguard Worker if (m_rbo_depth_stencil)
7757*35238bceSAndroid Build Coastguard Worker {
7758*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &m_rbo_depth_stencil);
7759*35238bceSAndroid Build Coastguard Worker
7760*35238bceSAndroid Build Coastguard Worker m_rbo_depth_stencil = 0;
7761*35238bceSAndroid Build Coastguard Worker }
7762*35238bceSAndroid Build Coastguard Worker
7763*35238bceSAndroid Build Coastguard Worker if (m_to_color)
7764*35238bceSAndroid Build Coastguard Worker {
7765*35238bceSAndroid Build Coastguard Worker gl.deleteTextures(1, &m_to_color);
7766*35238bceSAndroid Build Coastguard Worker
7767*35238bceSAndroid Build Coastguard Worker m_to_color = 0;
7768*35238bceSAndroid Build Coastguard Worker }
7769*35238bceSAndroid Build Coastguard Worker
7770*35238bceSAndroid Build Coastguard Worker if (m_po)
7771*35238bceSAndroid Build Coastguard Worker {
7772*35238bceSAndroid Build Coastguard Worker gl.useProgram(0);
7773*35238bceSAndroid Build Coastguard Worker
7774*35238bceSAndroid Build Coastguard Worker gl.deleteProgram(m_po);
7775*35238bceSAndroid Build Coastguard Worker
7776*35238bceSAndroid Build Coastguard Worker m_po = 0;
7777*35238bceSAndroid Build Coastguard Worker }
7778*35238bceSAndroid Build Coastguard Worker
7779*35238bceSAndroid Build Coastguard Worker if (m_vao_stencil_pass_quad)
7780*35238bceSAndroid Build Coastguard Worker {
7781*35238bceSAndroid Build Coastguard Worker gl.deleteBuffers(1, &m_vao_stencil_pass_quad);
7782*35238bceSAndroid Build Coastguard Worker
7783*35238bceSAndroid Build Coastguard Worker m_vao_stencil_pass_quad = 0;
7784*35238bceSAndroid Build Coastguard Worker }
7785*35238bceSAndroid Build Coastguard Worker
7786*35238bceSAndroid Build Coastguard Worker if (m_vao_depth_pass_quad)
7787*35238bceSAndroid Build Coastguard Worker {
7788*35238bceSAndroid Build Coastguard Worker gl.deleteBuffers(1, &m_vao_depth_pass_quad);
7789*35238bceSAndroid Build Coastguard Worker
7790*35238bceSAndroid Build Coastguard Worker m_vao_depth_pass_quad = 0;
7791*35238bceSAndroid Build Coastguard Worker }
7792*35238bceSAndroid Build Coastguard Worker
7793*35238bceSAndroid Build Coastguard Worker if (m_vao_color_pass_quad)
7794*35238bceSAndroid Build Coastguard Worker {
7795*35238bceSAndroid Build Coastguard Worker gl.deleteBuffers(1, &m_vao_color_pass_quad);
7796*35238bceSAndroid Build Coastguard Worker
7797*35238bceSAndroid Build Coastguard Worker m_vao_color_pass_quad = 0;
7798*35238bceSAndroid Build Coastguard Worker }
7799*35238bceSAndroid Build Coastguard Worker
7800*35238bceSAndroid Build Coastguard Worker if (m_bo_stencil_pass_quad)
7801*35238bceSAndroid Build Coastguard Worker {
7802*35238bceSAndroid Build Coastguard Worker gl.deleteBuffers(1, &m_bo_stencil_pass_quad);
7803*35238bceSAndroid Build Coastguard Worker
7804*35238bceSAndroid Build Coastguard Worker m_bo_stencil_pass_quad = 0;
7805*35238bceSAndroid Build Coastguard Worker }
7806*35238bceSAndroid Build Coastguard Worker
7807*35238bceSAndroid Build Coastguard Worker if (m_bo_depth_pass_quad)
7808*35238bceSAndroid Build Coastguard Worker {
7809*35238bceSAndroid Build Coastguard Worker gl.deleteBuffers(1, &m_bo_depth_pass_quad);
7810*35238bceSAndroid Build Coastguard Worker
7811*35238bceSAndroid Build Coastguard Worker m_bo_depth_pass_quad = 0;
7812*35238bceSAndroid Build Coastguard Worker }
7813*35238bceSAndroid Build Coastguard Worker
7814*35238bceSAndroid Build Coastguard Worker if (m_bo_color_pass_quad)
7815*35238bceSAndroid Build Coastguard Worker {
7816*35238bceSAndroid Build Coastguard Worker gl.deleteBuffers(1, &m_bo_color_pass_quad);
7817*35238bceSAndroid Build Coastguard Worker
7818*35238bceSAndroid Build Coastguard Worker m_bo_color_pass_quad = 0;
7819*35238bceSAndroid Build Coastguard Worker }
7820*35238bceSAndroid Build Coastguard Worker
7821*35238bceSAndroid Build Coastguard Worker /* Reseting state. */
7822*35238bceSAndroid Build Coastguard Worker gl.stencilFunc(GL_ALWAYS, 0, 0xff);
7823*35238bceSAndroid Build Coastguard Worker gl.stencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
7824*35238bceSAndroid Build Coastguard Worker gl.stencilMask(0xff);
7825*35238bceSAndroid Build Coastguard Worker gl.colorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
7826*35238bceSAndroid Build Coastguard Worker gl.depthFunc(GL_LESS);
7827*35238bceSAndroid Build Coastguard Worker gl.depthMask(GL_TRUE);
7828*35238bceSAndroid Build Coastguard Worker gl.disable(GL_STENCIL_TEST);
7829*35238bceSAndroid Build Coastguard Worker gl.disable(GL_DEPTH_TEST);
7830*35238bceSAndroid Build Coastguard Worker
7831*35238bceSAndroid Build Coastguard Worker /* Clean errors. */
7832*35238bceSAndroid Build Coastguard Worker while (gl.getError())
7833*35238bceSAndroid Build Coastguard Worker ;
7834*35238bceSAndroid Build Coastguard Worker }
7835*35238bceSAndroid Build Coastguard Worker
7836*35238bceSAndroid Build Coastguard Worker /** Vertex shader source code. */
7837*35238bceSAndroid Build Coastguard Worker const glw::GLchar FunctionalTest::s_vertex_shader[] = "#version 330\n"
7838*35238bceSAndroid Build Coastguard Worker "\n"
7839*35238bceSAndroid Build Coastguard Worker "in vec3 position;\n"
7840*35238bceSAndroid Build Coastguard Worker "\n"
7841*35238bceSAndroid Build Coastguard Worker "void main()\n"
7842*35238bceSAndroid Build Coastguard Worker "{\n"
7843*35238bceSAndroid Build Coastguard Worker " gl_Position = vec4(position, 1.0);\n"
7844*35238bceSAndroid Build Coastguard Worker "}\n";
7845*35238bceSAndroid Build Coastguard Worker
7846*35238bceSAndroid Build Coastguard Worker /** Fragment shader source code. */
7847*35238bceSAndroid Build Coastguard Worker const glw::GLchar FunctionalTest::s_fragment_shader[] = "#version 330\n"
7848*35238bceSAndroid Build Coastguard Worker "\n"
7849*35238bceSAndroid Build Coastguard Worker "out vec4 color;\n"
7850*35238bceSAndroid Build Coastguard Worker "\n"
7851*35238bceSAndroid Build Coastguard Worker "void main()\n"
7852*35238bceSAndroid Build Coastguard Worker "{\n"
7853*35238bceSAndroid Build Coastguard Worker " color = vec4(1.0);\n"
7854*35238bceSAndroid Build Coastguard Worker "}\n";
7855*35238bceSAndroid Build Coastguard Worker
7856*35238bceSAndroid Build Coastguard Worker /** Vertex shader source code attribute name. */
7857*35238bceSAndroid Build Coastguard Worker const glw::GLchar FunctionalTest::s_attribute[] = "position";
7858*35238bceSAndroid Build Coastguard Worker
7859*35238bceSAndroid Build Coastguard Worker /** Stencil pass' geometry to be passed to vertex shader attribute. */
7860*35238bceSAndroid Build Coastguard Worker const glw::GLfloat FunctionalTest::s_stencil_pass_quad[] = {-0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f,
7861*35238bceSAndroid Build Coastguard Worker 0.5f, -0.5f, 0.5f, 0.5f, 0.5f, 0.5f};
7862*35238bceSAndroid Build Coastguard Worker
7863*35238bceSAndroid Build Coastguard Worker /** Depth pass' geometry to be passed to vertex shader attribute. */
7864*35238bceSAndroid Build Coastguard Worker const glw::GLfloat FunctionalTest::s_depth_pass_quad[] = {-1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f,
7865*35238bceSAndroid Build Coastguard Worker 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f};
7866*35238bceSAndroid Build Coastguard Worker
7867*35238bceSAndroid Build Coastguard Worker /** Color pass' geometry to be passed to vertex shader attribute. */
7868*35238bceSAndroid Build Coastguard Worker const glw::GLfloat FunctionalTest::s_color_pass_quad[] = {-1.0f, -1.0f, 0.0f, -1.0f, 1.0f, 0.0f,
7869*35238bceSAndroid Build Coastguard Worker 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 0.0f};
7870*35238bceSAndroid Build Coastguard Worker
7871*35238bceSAndroid Build Coastguard Worker const glw::GLuint FunctionalTest::s_stencil_pass_quad_size =
7872*35238bceSAndroid Build Coastguard Worker sizeof(s_stencil_pass_quad); //!< Size of stencil pass' geometry.
7873*35238bceSAndroid Build Coastguard Worker const glw::GLuint FunctionalTest::s_depth_pass_quad_size =
7874*35238bceSAndroid Build Coastguard Worker sizeof(s_depth_pass_quad); //!< Size of depth pass' geometry.
7875*35238bceSAndroid Build Coastguard Worker const glw::GLuint FunctionalTest::s_color_pass_quad_size =
7876*35238bceSAndroid Build Coastguard Worker sizeof(s_color_pass_quad); //!< Size of color pass' geometry.
7877*35238bceSAndroid Build Coastguard Worker
7878*35238bceSAndroid Build Coastguard Worker } // namespace Framebuffers
7879*35238bceSAndroid Build Coastguard Worker
7880*35238bceSAndroid Build Coastguard Worker namespace Renderbuffers
7881*35238bceSAndroid Build Coastguard Worker {
7882*35238bceSAndroid Build Coastguard Worker /******************************** Renderbuffer Creation Test Implementation ********************************/
7883*35238bceSAndroid Build Coastguard Worker
7884*35238bceSAndroid Build Coastguard Worker /** @brief Creation Test constructor.
7885*35238bceSAndroid Build Coastguard Worker *
7886*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
7887*35238bceSAndroid Build Coastguard Worker */
CreationTest(deqp::Context & context)7888*35238bceSAndroid Build Coastguard Worker CreationTest::CreationTest(deqp::Context &context)
7889*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "renderbuffers_creation", "Renderbuffer Objects Creation Test")
7890*35238bceSAndroid Build Coastguard Worker {
7891*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
7892*35238bceSAndroid Build Coastguard Worker }
7893*35238bceSAndroid Build Coastguard Worker
7894*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Creation Test cases.
7895*35238bceSAndroid Build Coastguard Worker *
7896*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
7897*35238bceSAndroid Build Coastguard Worker */
iterate()7898*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult CreationTest::iterate()
7899*35238bceSAndroid Build Coastguard Worker {
7900*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
7901*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
7902*35238bceSAndroid Build Coastguard Worker
7903*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
7904*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
7905*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
7906*35238bceSAndroid Build Coastguard Worker
7907*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
7908*35238bceSAndroid Build Coastguard Worker {
7909*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
7910*35238bceSAndroid Build Coastguard Worker
7911*35238bceSAndroid Build Coastguard Worker return STOP;
7912*35238bceSAndroid Build Coastguard Worker }
7913*35238bceSAndroid Build Coastguard Worker
7914*35238bceSAndroid Build Coastguard Worker /* Running tests. */
7915*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
7916*35238bceSAndroid Build Coastguard Worker bool is_error = false;
7917*35238bceSAndroid Build Coastguard Worker
7918*35238bceSAndroid Build Coastguard Worker /* Renderbuffers' objects */
7919*35238bceSAndroid Build Coastguard Worker static const glw::GLuint renderbuffers_count = 2;
7920*35238bceSAndroid Build Coastguard Worker
7921*35238bceSAndroid Build Coastguard Worker glw::GLuint renderbuffers_legacy[renderbuffers_count] = {};
7922*35238bceSAndroid Build Coastguard Worker glw::GLuint renderbuffers_dsa[renderbuffers_count] = {};
7923*35238bceSAndroid Build Coastguard Worker
7924*35238bceSAndroid Build Coastguard Worker try
7925*35238bceSAndroid Build Coastguard Worker {
7926*35238bceSAndroid Build Coastguard Worker /* Check legacy state creation. */
7927*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(renderbuffers_count, renderbuffers_legacy);
7928*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
7929*35238bceSAndroid Build Coastguard Worker
7930*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < renderbuffers_count; ++i)
7931*35238bceSAndroid Build Coastguard Worker {
7932*35238bceSAndroid Build Coastguard Worker if (gl.isRenderbuffer(renderbuffers_legacy[i]))
7933*35238bceSAndroid Build Coastguard Worker {
7934*35238bceSAndroid Build Coastguard Worker is_ok = false;
7935*35238bceSAndroid Build Coastguard Worker
7936*35238bceSAndroid Build Coastguard Worker /* Log. */
7937*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
7938*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message
7939*35238bceSAndroid Build Coastguard Worker << "GenRenderbuffers has created default objects, but it should create only a names."
7940*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
7941*35238bceSAndroid Build Coastguard Worker }
7942*35238bceSAndroid Build Coastguard Worker }
7943*35238bceSAndroid Build Coastguard Worker
7944*35238bceSAndroid Build Coastguard Worker /* Check direct state creation. */
7945*35238bceSAndroid Build Coastguard Worker gl.createRenderbuffers(renderbuffers_count, renderbuffers_dsa);
7946*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateRenderbuffers has failed");
7947*35238bceSAndroid Build Coastguard Worker
7948*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < renderbuffers_count; ++i)
7949*35238bceSAndroid Build Coastguard Worker {
7950*35238bceSAndroid Build Coastguard Worker if (!gl.isRenderbuffer(renderbuffers_dsa[i]))
7951*35238bceSAndroid Build Coastguard Worker {
7952*35238bceSAndroid Build Coastguard Worker is_ok = false;
7953*35238bceSAndroid Build Coastguard Worker
7954*35238bceSAndroid Build Coastguard Worker /* Log. */
7955*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
7956*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "CreateRenderbuffers has not created default objects."
7957*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
7958*35238bceSAndroid Build Coastguard Worker }
7959*35238bceSAndroid Build Coastguard Worker }
7960*35238bceSAndroid Build Coastguard Worker }
7961*35238bceSAndroid Build Coastguard Worker catch (...)
7962*35238bceSAndroid Build Coastguard Worker {
7963*35238bceSAndroid Build Coastguard Worker is_ok = false;
7964*35238bceSAndroid Build Coastguard Worker is_error = true;
7965*35238bceSAndroid Build Coastguard Worker }
7966*35238bceSAndroid Build Coastguard Worker
7967*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
7968*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < renderbuffers_count; ++i)
7969*35238bceSAndroid Build Coastguard Worker {
7970*35238bceSAndroid Build Coastguard Worker if (renderbuffers_legacy[i])
7971*35238bceSAndroid Build Coastguard Worker {
7972*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &renderbuffers_legacy[i]);
7973*35238bceSAndroid Build Coastguard Worker
7974*35238bceSAndroid Build Coastguard Worker renderbuffers_legacy[i] = 0;
7975*35238bceSAndroid Build Coastguard Worker }
7976*35238bceSAndroid Build Coastguard Worker
7977*35238bceSAndroid Build Coastguard Worker if (renderbuffers_dsa[i])
7978*35238bceSAndroid Build Coastguard Worker {
7979*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &renderbuffers_dsa[i]);
7980*35238bceSAndroid Build Coastguard Worker
7981*35238bceSAndroid Build Coastguard Worker renderbuffers_dsa[i] = 0;
7982*35238bceSAndroid Build Coastguard Worker }
7983*35238bceSAndroid Build Coastguard Worker }
7984*35238bceSAndroid Build Coastguard Worker
7985*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
7986*35238bceSAndroid Build Coastguard Worker while (gl.getError())
7987*35238bceSAndroid Build Coastguard Worker ;
7988*35238bceSAndroid Build Coastguard Worker
7989*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
7990*35238bceSAndroid Build Coastguard Worker if (is_ok)
7991*35238bceSAndroid Build Coastguard Worker {
7992*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
7993*35238bceSAndroid Build Coastguard Worker }
7994*35238bceSAndroid Build Coastguard Worker else
7995*35238bceSAndroid Build Coastguard Worker {
7996*35238bceSAndroid Build Coastguard Worker if (is_error)
7997*35238bceSAndroid Build Coastguard Worker {
7998*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
7999*35238bceSAndroid Build Coastguard Worker }
8000*35238bceSAndroid Build Coastguard Worker else
8001*35238bceSAndroid Build Coastguard Worker {
8002*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
8003*35238bceSAndroid Build Coastguard Worker }
8004*35238bceSAndroid Build Coastguard Worker }
8005*35238bceSAndroid Build Coastguard Worker
8006*35238bceSAndroid Build Coastguard Worker return STOP;
8007*35238bceSAndroid Build Coastguard Worker }
8008*35238bceSAndroid Build Coastguard Worker
8009*35238bceSAndroid Build Coastguard Worker /******************************** Renderbuffer Storage Test Implementation ********************************/
8010*35238bceSAndroid Build Coastguard Worker
8011*35238bceSAndroid Build Coastguard Worker /** @brief Renderbuffer Storage Test constructor.
8012*35238bceSAndroid Build Coastguard Worker *
8013*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
8014*35238bceSAndroid Build Coastguard Worker */
StorageTest(deqp::Context & context)8015*35238bceSAndroid Build Coastguard Worker StorageTest::StorageTest(deqp::Context &context)
8016*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "renderbuffers_storage", "Renderbuffer Objects Storage Test")
8017*35238bceSAndroid Build Coastguard Worker , m_fbo(0)
8018*35238bceSAndroid Build Coastguard Worker , m_rbo(0)
8019*35238bceSAndroid Build Coastguard Worker {
8020*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
8021*35238bceSAndroid Build Coastguard Worker }
8022*35238bceSAndroid Build Coastguard Worker
8023*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Creation Test cases.
8024*35238bceSAndroid Build Coastguard Worker *
8025*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
8026*35238bceSAndroid Build Coastguard Worker */
iterate()8027*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult StorageTest::iterate()
8028*35238bceSAndroid Build Coastguard Worker {
8029*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
8030*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
8031*35238bceSAndroid Build Coastguard Worker
8032*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
8033*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
8034*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
8035*35238bceSAndroid Build Coastguard Worker
8036*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
8037*35238bceSAndroid Build Coastguard Worker {
8038*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
8039*35238bceSAndroid Build Coastguard Worker
8040*35238bceSAndroid Build Coastguard Worker return STOP;
8041*35238bceSAndroid Build Coastguard Worker }
8042*35238bceSAndroid Build Coastguard Worker
8043*35238bceSAndroid Build Coastguard Worker /* Running tests. */
8044*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
8045*35238bceSAndroid Build Coastguard Worker bool is_error = false;
8046*35238bceSAndroid Build Coastguard Worker
8047*35238bceSAndroid Build Coastguard Worker try
8048*35238bceSAndroid Build Coastguard Worker {
8049*35238bceSAndroid Build Coastguard Worker glw::GLint max_renderbuffer_size = 16384 /* Specification minimum. */;
8050*35238bceSAndroid Build Coastguard Worker
8051*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_RENDERBUFFER_SIZE, &max_renderbuffer_size);
8052*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv call failed.");
8053*35238bceSAndroid Build Coastguard Worker
8054*35238bceSAndroid Build Coastguard Worker const struct
8055*35238bceSAndroid Build Coastguard Worker {
8056*35238bceSAndroid Build Coastguard Worker glw::GLuint width;
8057*35238bceSAndroid Build Coastguard Worker glw::GLuint height;
8058*35238bceSAndroid Build Coastguard Worker } test_cases[] = {{1, 1},
8059*35238bceSAndroid Build Coastguard Worker {256, 512},
8060*35238bceSAndroid Build Coastguard Worker {1280, 720},
8061*35238bceSAndroid Build Coastguard Worker {(glw::GLuint)max_renderbuffer_size, 1},
8062*35238bceSAndroid Build Coastguard Worker {1, (glw::GLuint)max_renderbuffer_size}};
8063*35238bceSAndroid Build Coastguard Worker
8064*35238bceSAndroid Build Coastguard Worker const glw::GLuint test_cases_count = sizeof(test_cases) / sizeof(test_cases[0]);
8065*35238bceSAndroid Build Coastguard Worker
8066*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < test_cases_count; ++i)
8067*35238bceSAndroid Build Coastguard Worker {
8068*35238bceSAndroid Build Coastguard Worker for (glw::GLuint j = 0; j < s_renderbuffer_internalformat_configuration_count; ++j)
8069*35238bceSAndroid Build Coastguard Worker {
8070*35238bceSAndroid Build Coastguard Worker if (PrepareRenderbuffer(s_renderbuffer_internalformat_configuration[j], test_cases[i].width,
8071*35238bceSAndroid Build Coastguard Worker test_cases[i].height))
8072*35238bceSAndroid Build Coastguard Worker {
8073*35238bceSAndroid Build Coastguard Worker Clear(s_renderbuffer_internalformat_configuration[j].isColorIntegralFormat);
8074*35238bceSAndroid Build Coastguard Worker is_ok &= Check(s_renderbuffer_internalformat_configuration[j], test_cases[i].width,
8075*35238bceSAndroid Build Coastguard Worker test_cases[i].height);
8076*35238bceSAndroid Build Coastguard Worker }
8077*35238bceSAndroid Build Coastguard Worker else
8078*35238bceSAndroid Build Coastguard Worker {
8079*35238bceSAndroid Build Coastguard Worker is_ok = false;
8080*35238bceSAndroid Build Coastguard Worker }
8081*35238bceSAndroid Build Coastguard Worker
8082*35238bceSAndroid Build Coastguard Worker Clean();
8083*35238bceSAndroid Build Coastguard Worker }
8084*35238bceSAndroid Build Coastguard Worker }
8085*35238bceSAndroid Build Coastguard Worker }
8086*35238bceSAndroid Build Coastguard Worker catch (...)
8087*35238bceSAndroid Build Coastguard Worker {
8088*35238bceSAndroid Build Coastguard Worker is_ok = false;
8089*35238bceSAndroid Build Coastguard Worker is_error = true;
8090*35238bceSAndroid Build Coastguard Worker
8091*35238bceSAndroid Build Coastguard Worker Clean();
8092*35238bceSAndroid Build Coastguard Worker }
8093*35238bceSAndroid Build Coastguard Worker
8094*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
8095*35238bceSAndroid Build Coastguard Worker if (is_ok)
8096*35238bceSAndroid Build Coastguard Worker {
8097*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
8098*35238bceSAndroid Build Coastguard Worker }
8099*35238bceSAndroid Build Coastguard Worker else
8100*35238bceSAndroid Build Coastguard Worker {
8101*35238bceSAndroid Build Coastguard Worker if (is_error)
8102*35238bceSAndroid Build Coastguard Worker {
8103*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
8104*35238bceSAndroid Build Coastguard Worker }
8105*35238bceSAndroid Build Coastguard Worker else
8106*35238bceSAndroid Build Coastguard Worker {
8107*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
8108*35238bceSAndroid Build Coastguard Worker }
8109*35238bceSAndroid Build Coastguard Worker }
8110*35238bceSAndroid Build Coastguard Worker
8111*35238bceSAndroid Build Coastguard Worker return STOP;
8112*35238bceSAndroid Build Coastguard Worker }
8113*35238bceSAndroid Build Coastguard Worker
8114*35238bceSAndroid Build Coastguard Worker /** Prepare renderbuffer.
8115*35238bceSAndroid Build Coastguard Worker *
8116*35238bceSAndroid Build Coastguard Worker * @param [in] format Internal format to be prepared.
8117*35238bceSAndroid Build Coastguard Worker * @param [in] width Width of the framebuffer.
8118*35238bceSAndroid Build Coastguard Worker * @param [in] height Height of the framebuffer.
8119*35238bceSAndroid Build Coastguard Worker *
8120*35238bceSAndroid Build Coastguard Worker * @return True if there is no error, false otherwise.
8121*35238bceSAndroid Build Coastguard Worker */
PrepareRenderbuffer(StorageTest::RenderbufferInternalFormatConfiguration format,glw::GLuint width,glw::GLuint height)8122*35238bceSAndroid Build Coastguard Worker bool StorageTest::PrepareRenderbuffer(StorageTest::RenderbufferInternalFormatConfiguration format, glw::GLuint width,
8123*35238bceSAndroid Build Coastguard Worker glw::GLuint height)
8124*35238bceSAndroid Build Coastguard Worker {
8125*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
8126*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
8127*35238bceSAndroid Build Coastguard Worker
8128*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(1, &m_fbo);
8129*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
8130*35238bceSAndroid Build Coastguard Worker
8131*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
8132*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
8133*35238bceSAndroid Build Coastguard Worker
8134*35238bceSAndroid Build Coastguard Worker gl.createRenderbuffers(1, &m_rbo);
8135*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateRenderbuffers call failed.");
8136*35238bceSAndroid Build Coastguard Worker
8137*35238bceSAndroid Build Coastguard Worker gl.namedRenderbufferStorage(m_rbo, format.internalformat, width, height);
8138*35238bceSAndroid Build Coastguard Worker
8139*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
8140*35238bceSAndroid Build Coastguard Worker {
8141*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
8142*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Renderbuffer storage test failed because NamedRenderbufferStorage generated "
8143*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(error) << " error value. Renderbuffers format was "
8144*35238bceSAndroid Build Coastguard Worker << glu::getInternalFormatParameterStr(format.internalformat) << ", width was " << width << ", height was "
8145*35238bceSAndroid Build Coastguard Worker << height << "." << tcu::TestLog::EndMessage;
8146*35238bceSAndroid Build Coastguard Worker return false;
8147*35238bceSAndroid Build Coastguard Worker }
8148*35238bceSAndroid Build Coastguard Worker
8149*35238bceSAndroid Build Coastguard Worker if (format.hasRedComponent || format.hasGreenComponent || format.hasBlueComponent || format.hasAlphaComponent)
8150*35238bceSAndroid Build Coastguard Worker {
8151*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferRenderbuffer(m_fbo, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo);
8152*35238bceSAndroid Build Coastguard Worker }
8153*35238bceSAndroid Build Coastguard Worker
8154*35238bceSAndroid Build Coastguard Worker if (format.hasDepthComponent)
8155*35238bceSAndroid Build Coastguard Worker {
8156*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferRenderbuffer(m_fbo, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_rbo);
8157*35238bceSAndroid Build Coastguard Worker }
8158*35238bceSAndroid Build Coastguard Worker
8159*35238bceSAndroid Build Coastguard Worker if (format.hasStencilComponent)
8160*35238bceSAndroid Build Coastguard Worker {
8161*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferRenderbuffer(m_fbo, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_rbo);
8162*35238bceSAndroid Build Coastguard Worker }
8163*35238bceSAndroid Build Coastguard Worker
8164*35238bceSAndroid Build Coastguard Worker if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
8165*35238bceSAndroid Build Coastguard Worker {
8166*35238bceSAndroid Build Coastguard Worker /* Log. */
8167*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
8168*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message
8169*35238bceSAndroid Build Coastguard Worker << "Renderbuffer storage test failed due to incomplete framebuffer status. Renderbuffers format was "
8170*35238bceSAndroid Build Coastguard Worker << glu::getInternalFormatParameterStr(format.internalformat) << ", width was " << width << ", height was "
8171*35238bceSAndroid Build Coastguard Worker << height << "." << tcu::TestLog::EndMessage;
8172*35238bceSAndroid Build Coastguard Worker
8173*35238bceSAndroid Build Coastguard Worker return false;
8174*35238bceSAndroid Build Coastguard Worker }
8175*35238bceSAndroid Build Coastguard Worker
8176*35238bceSAndroid Build Coastguard Worker return true;
8177*35238bceSAndroid Build Coastguard Worker }
8178*35238bceSAndroid Build Coastguard Worker
8179*35238bceSAndroid Build Coastguard Worker /** Clear renderbuffer.
8180*35238bceSAndroid Build Coastguard Worker *
8181*35238bceSAndroid Build Coastguard Worker * @param [in] isColorIntegralFormat Is this color integral format.
8182*35238bceSAndroid Build Coastguard Worker */
Clear(bool isColorIntegralFormat)8183*35238bceSAndroid Build Coastguard Worker void StorageTest::Clear(bool isColorIntegralFormat)
8184*35238bceSAndroid Build Coastguard Worker {
8185*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
8186*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
8187*35238bceSAndroid Build Coastguard Worker if (isColorIntegralFormat)
8188*35238bceSAndroid Build Coastguard Worker {
8189*35238bceSAndroid Build Coastguard Worker gl.clearBufferiv(GL_COLOR, 0, s_reference_color_integer);
8190*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glClearBufferiv has failed");
8191*35238bceSAndroid Build Coastguard Worker }
8192*35238bceSAndroid Build Coastguard Worker else
8193*35238bceSAndroid Build Coastguard Worker {
8194*35238bceSAndroid Build Coastguard Worker /* Setup clear values. */
8195*35238bceSAndroid Build Coastguard Worker gl.clearColor(s_reference_color[0], s_reference_color[1], s_reference_color[2], s_reference_color[3]);
8196*35238bceSAndroid Build Coastguard Worker gl.clearDepth(s_reference_depth);
8197*35238bceSAndroid Build Coastguard Worker gl.clearStencil(s_reference_stencil);
8198*35238bceSAndroid Build Coastguard Worker
8199*35238bceSAndroid Build Coastguard Worker /* Clear rbo/fbo. */
8200*35238bceSAndroid Build Coastguard Worker gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
8201*35238bceSAndroid Build Coastguard Worker }
8202*35238bceSAndroid Build Coastguard Worker }
8203*35238bceSAndroid Build Coastguard Worker
8204*35238bceSAndroid Build Coastguard Worker /** Check renderbuffer's content.
8205*35238bceSAndroid Build Coastguard Worker *
8206*35238bceSAndroid Build Coastguard Worker * @param [in] format Internal format to be prepared.
8207*35238bceSAndroid Build Coastguard Worker * @param [in] width Width of the framebuffer.
8208*35238bceSAndroid Build Coastguard Worker * @param [in] height Height of the framebuffer.
8209*35238bceSAndroid Build Coastguard Worker *
8210*35238bceSAndroid Build Coastguard Worker * @return True if content matches the reference, false otherwise.
8211*35238bceSAndroid Build Coastguard Worker */
Check(StorageTest::RenderbufferInternalFormatConfiguration format,glw::GLuint width,glw::GLuint height)8212*35238bceSAndroid Build Coastguard Worker bool StorageTest::Check(StorageTest::RenderbufferInternalFormatConfiguration format, glw::GLuint width,
8213*35238bceSAndroid Build Coastguard Worker glw::GLuint height)
8214*35238bceSAndroid Build Coastguard Worker {
8215*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
8216*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
8217*35238bceSAndroid Build Coastguard Worker
8218*35238bceSAndroid Build Coastguard Worker glw::GLuint size = width * height;
8219*35238bceSAndroid Build Coastguard Worker
8220*35238bceSAndroid Build Coastguard Worker if (format.hasRedComponent || format.hasGreenComponent || format.hasBlueComponent || format.hasAlphaComponent)
8221*35238bceSAndroid Build Coastguard Worker {
8222*35238bceSAndroid Build Coastguard Worker if (format.isColorIntegralFormat)
8223*35238bceSAndroid Build Coastguard Worker {
8224*35238bceSAndroid Build Coastguard Worker std::vector<glw::GLint> color(size * 4);
8225*35238bceSAndroid Build Coastguard Worker
8226*35238bceSAndroid Build Coastguard Worker gl.readPixels(0, 0, width, height, GL_RGBA_INTEGER, GL_INT, &color[0]);
8227*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels call failed.");
8228*35238bceSAndroid Build Coastguard Worker
8229*35238bceSAndroid Build Coastguard Worker const bool hasComponent[] = {format.hasRedComponent, format.hasGreenComponent, format.hasBlueComponent,
8230*35238bceSAndroid Build Coastguard Worker format.hasAlphaComponent};
8231*35238bceSAndroid Build Coastguard Worker
8232*35238bceSAndroid Build Coastguard Worker static const char *componentName[] = {"red", "green", "blue", "alpha"};
8233*35238bceSAndroid Build Coastguard Worker
8234*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < size; ++i)
8235*35238bceSAndroid Build Coastguard Worker {
8236*35238bceSAndroid Build Coastguard Worker if (hasComponent[i % 4 /* color components count*/])
8237*35238bceSAndroid Build Coastguard Worker {
8238*35238bceSAndroid Build Coastguard Worker if (de::abs(s_reference_color_integer[i % 4 /* color components count*/] - color[i]) >
8239*35238bceSAndroid Build Coastguard Worker 2 /* Precision */)
8240*35238bceSAndroid Build Coastguard Worker {
8241*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
8242*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Renderbuffer storage was cleared with color "
8243*35238bceSAndroid Build Coastguard Worker << componentName[i % 4 /* color components count*/] << " component equal to "
8244*35238bceSAndroid Build Coastguard Worker << s_reference_color_integer[i % 4 /* color components count*/] << ", but fetched value "
8245*35238bceSAndroid Build Coastguard Worker << color[i] << " is not the same. Renderbuffers format was " << format.internalformat_name
8246*35238bceSAndroid Build Coastguard Worker << ", width was " << width << ", height was " << height << "." << tcu::TestLog::EndMessage;
8247*35238bceSAndroid Build Coastguard Worker
8248*35238bceSAndroid Build Coastguard Worker return false;
8249*35238bceSAndroid Build Coastguard Worker }
8250*35238bceSAndroid Build Coastguard Worker }
8251*35238bceSAndroid Build Coastguard Worker }
8252*35238bceSAndroid Build Coastguard Worker }
8253*35238bceSAndroid Build Coastguard Worker else
8254*35238bceSAndroid Build Coastguard Worker {
8255*35238bceSAndroid Build Coastguard Worker std::vector<glw::GLfloat> color(size * 4);
8256*35238bceSAndroid Build Coastguard Worker
8257*35238bceSAndroid Build Coastguard Worker gl.readPixels(0, 0, width, height, GL_RGBA, GL_FLOAT, &color[0]);
8258*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels call failed.");
8259*35238bceSAndroid Build Coastguard Worker
8260*35238bceSAndroid Build Coastguard Worker const bool hasComponent[] = {format.hasRedComponent, format.hasGreenComponent, format.hasBlueComponent,
8261*35238bceSAndroid Build Coastguard Worker format.hasAlphaComponent};
8262*35238bceSAndroid Build Coastguard Worker
8263*35238bceSAndroid Build Coastguard Worker static const char *componentName[] = {"red", "green", "blue", "alpha"};
8264*35238bceSAndroid Build Coastguard Worker
8265*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < size; ++i)
8266*35238bceSAndroid Build Coastguard Worker {
8267*35238bceSAndroid Build Coastguard Worker if (hasComponent[i % 4 /* color components count*/])
8268*35238bceSAndroid Build Coastguard Worker {
8269*35238bceSAndroid Build Coastguard Worker if (de::abs(s_reference_color[i % 4 /* color components count*/] - color[i]) >
8270*35238bceSAndroid Build Coastguard Worker 0.0625 /* precision */)
8271*35238bceSAndroid Build Coastguard Worker {
8272*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
8273*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Renderbuffer storage was cleared with color "
8274*35238bceSAndroid Build Coastguard Worker << componentName[i % 4 /* color components count*/] << " component equal to "
8275*35238bceSAndroid Build Coastguard Worker << s_reference_color[i % 4 /* color components count*/] << ", but fetched value "
8276*35238bceSAndroid Build Coastguard Worker << color[i] << " is not the same. Renderbuffers format was " << format.internalformat_name
8277*35238bceSAndroid Build Coastguard Worker << ", width was " << width << ", height was " << height << "." << tcu::TestLog::EndMessage;
8278*35238bceSAndroid Build Coastguard Worker
8279*35238bceSAndroid Build Coastguard Worker return false;
8280*35238bceSAndroid Build Coastguard Worker }
8281*35238bceSAndroid Build Coastguard Worker }
8282*35238bceSAndroid Build Coastguard Worker }
8283*35238bceSAndroid Build Coastguard Worker }
8284*35238bceSAndroid Build Coastguard Worker }
8285*35238bceSAndroid Build Coastguard Worker
8286*35238bceSAndroid Build Coastguard Worker if (format.hasDepthComponent)
8287*35238bceSAndroid Build Coastguard Worker {
8288*35238bceSAndroid Build Coastguard Worker std::vector<glw::GLfloat> depth(size);
8289*35238bceSAndroid Build Coastguard Worker
8290*35238bceSAndroid Build Coastguard Worker gl.readPixels(0, 0, width, height, GL_DEPTH_COMPONENT, GL_FLOAT, &depth[0]);
8291*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels call failed.");
8292*35238bceSAndroid Build Coastguard Worker
8293*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < size; ++i)
8294*35238bceSAndroid Build Coastguard Worker {
8295*35238bceSAndroid Build Coastguard Worker if (de::abs(s_reference_depth - depth[i]) > 0.0625 /* 1/16 precision */)
8296*35238bceSAndroid Build Coastguard Worker {
8297*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
8298*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Renderbuffer storage was cleared with depth component equal to "
8299*35238bceSAndroid Build Coastguard Worker << s_reference_depth << ", but fetched value " << depth[i]
8300*35238bceSAndroid Build Coastguard Worker << " is not the same. Renderbuffers format was " << format.internalformat_name << ", width was "
8301*35238bceSAndroid Build Coastguard Worker << width << ", height was " << height << "." << tcu::TestLog::EndMessage;
8302*35238bceSAndroid Build Coastguard Worker
8303*35238bceSAndroid Build Coastguard Worker return false;
8304*35238bceSAndroid Build Coastguard Worker }
8305*35238bceSAndroid Build Coastguard Worker }
8306*35238bceSAndroid Build Coastguard Worker }
8307*35238bceSAndroid Build Coastguard Worker
8308*35238bceSAndroid Build Coastguard Worker if (format.hasStencilComponent)
8309*35238bceSAndroid Build Coastguard Worker {
8310*35238bceSAndroid Build Coastguard Worker std::vector<glw::GLint> stencil(size);
8311*35238bceSAndroid Build Coastguard Worker
8312*35238bceSAndroid Build Coastguard Worker gl.readPixels(0, 0, width, height, GL_STENCIL_INDEX, GL_INT, &stencil[0]);
8313*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels call failed.");
8314*35238bceSAndroid Build Coastguard Worker
8315*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < size; ++i)
8316*35238bceSAndroid Build Coastguard Worker {
8317*35238bceSAndroid Build Coastguard Worker if (s_reference_stencil != stencil[i])
8318*35238bceSAndroid Build Coastguard Worker {
8319*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
8320*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Renderbuffer storage was cleared with alpha component equal to "
8321*35238bceSAndroid Build Coastguard Worker << s_reference_stencil << ", but fetched value " << stencil[i]
8322*35238bceSAndroid Build Coastguard Worker << " is not the same. Renderbuffers format was " << format.internalformat_name << ", width was "
8323*35238bceSAndroid Build Coastguard Worker << width << ", height was " << height << "." << tcu::TestLog::EndMessage;
8324*35238bceSAndroid Build Coastguard Worker
8325*35238bceSAndroid Build Coastguard Worker return false;
8326*35238bceSAndroid Build Coastguard Worker }
8327*35238bceSAndroid Build Coastguard Worker }
8328*35238bceSAndroid Build Coastguard Worker }
8329*35238bceSAndroid Build Coastguard Worker
8330*35238bceSAndroid Build Coastguard Worker return true;
8331*35238bceSAndroid Build Coastguard Worker }
8332*35238bceSAndroid Build Coastguard Worker
8333*35238bceSAndroid Build Coastguard Worker /** @brief Clean up GL state.
8334*35238bceSAndroid Build Coastguard Worker */
Clean()8335*35238bceSAndroid Build Coastguard Worker void StorageTest::Clean()
8336*35238bceSAndroid Build Coastguard Worker {
8337*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
8338*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
8339*35238bceSAndroid Build Coastguard Worker
8340*35238bceSAndroid Build Coastguard Worker /* Release objects. */
8341*35238bceSAndroid Build Coastguard Worker if (m_rbo)
8342*35238bceSAndroid Build Coastguard Worker {
8343*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &m_rbo);
8344*35238bceSAndroid Build Coastguard Worker
8345*35238bceSAndroid Build Coastguard Worker m_rbo = 0;
8346*35238bceSAndroid Build Coastguard Worker }
8347*35238bceSAndroid Build Coastguard Worker
8348*35238bceSAndroid Build Coastguard Worker if (m_fbo)
8349*35238bceSAndroid Build Coastguard Worker {
8350*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &m_fbo);
8351*35238bceSAndroid Build Coastguard Worker
8352*35238bceSAndroid Build Coastguard Worker m_fbo = 0;
8353*35238bceSAndroid Build Coastguard Worker }
8354*35238bceSAndroid Build Coastguard Worker
8355*35238bceSAndroid Build Coastguard Worker /* Returning to default clear values. */
8356*35238bceSAndroid Build Coastguard Worker gl.clearColor(0.f, 0.f, 0.f, 0.f);
8357*35238bceSAndroid Build Coastguard Worker gl.clearDepth(1.f);
8358*35238bceSAndroid Build Coastguard Worker gl.clearStencil(0);
8359*35238bceSAndroid Build Coastguard Worker
8360*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
8361*35238bceSAndroid Build Coastguard Worker while (gl.getError())
8362*35238bceSAndroid Build Coastguard Worker ;
8363*35238bceSAndroid Build Coastguard Worker }
8364*35238bceSAndroid Build Coastguard Worker
8365*35238bceSAndroid Build Coastguard Worker /** Internal formats to be tested*/
8366*35238bceSAndroid Build Coastguard Worker const struct StorageTest::RenderbufferInternalFormatConfiguration
8367*35238bceSAndroid Build Coastguard Worker StorageTest::s_renderbuffer_internalformat_configuration[] = {
8368*35238bceSAndroid Build Coastguard Worker {GL_R8, "GL_R8", true, false, false, false, false, false, false},
8369*35238bceSAndroid Build Coastguard Worker {GL_R16, "GL_R16", true, false, false, false, false, false, false},
8370*35238bceSAndroid Build Coastguard Worker {GL_RG8, "GL_RG8", true, true, false, false, false, false, false},
8371*35238bceSAndroid Build Coastguard Worker {GL_RG16, "GL_RG16", true, true, false, false, false, false, false},
8372*35238bceSAndroid Build Coastguard Worker {GL_RGB565, "GL_RGB56", true, true, true, false, false, false, false},
8373*35238bceSAndroid Build Coastguard Worker {GL_RGBA4, "GL_RGBA4", true, true, true, true, false, false, false},
8374*35238bceSAndroid Build Coastguard Worker {GL_RGB5_A1, "GL_RGB5_A1", true, true, true, true, false, false, false},
8375*35238bceSAndroid Build Coastguard Worker {GL_RGBA8, "GL_RGBA8", true, true, true, true, false, false, false},
8376*35238bceSAndroid Build Coastguard Worker {GL_RGB10_A2, "GL_RGB10_A2", true, true, true, true, false, false, false},
8377*35238bceSAndroid Build Coastguard Worker {GL_RGB10_A2UI, "GL_RGB10_A2UI", true, true, true, true, false, false, true},
8378*35238bceSAndroid Build Coastguard Worker {GL_RGBA16, "GL_RGBA16", true, true, true, true, false, false, false},
8379*35238bceSAndroid Build Coastguard Worker {GL_SRGB8_ALPHA8, "GL_SRGB8_ALPHA8", true, true, true, true, false, false, false},
8380*35238bceSAndroid Build Coastguard Worker {GL_R16F, "GL_R16F", true, false, false, false, false, false, false},
8381*35238bceSAndroid Build Coastguard Worker {GL_RG16F, "GL_RG16F", true, true, false, false, false, false, false},
8382*35238bceSAndroid Build Coastguard Worker {GL_RGBA16F, "GL_RGBA16F", true, true, true, true, false, false, false},
8383*35238bceSAndroid Build Coastguard Worker {GL_R32F, "GL_R32F", true, false, false, false, false, false, false},
8384*35238bceSAndroid Build Coastguard Worker {GL_RG32F, "GL_RG32F", true, true, false, false, false, false, false},
8385*35238bceSAndroid Build Coastguard Worker {GL_RGBA32F, "GL_RGBA32F", true, true, true, true, false, false, false},
8386*35238bceSAndroid Build Coastguard Worker {GL_R11F_G11F_B10F, "GL_R11F_G11F_B10F", true, true, true, false, false, false, false},
8387*35238bceSAndroid Build Coastguard Worker {GL_R8I, "GL_R8I", true, false, false, false, false, false, true},
8388*35238bceSAndroid Build Coastguard Worker {GL_R8UI, "GL_R8UI", true, false, false, false, false, false, true},
8389*35238bceSAndroid Build Coastguard Worker {GL_R16I, "GL_R16I", true, false, false, false, false, false, true},
8390*35238bceSAndroid Build Coastguard Worker {GL_R16UI, "GL_R16UI", true, false, false, false, false, false, true},
8391*35238bceSAndroid Build Coastguard Worker {GL_R32I, "GL_R32I", true, false, false, false, false, false, true},
8392*35238bceSAndroid Build Coastguard Worker {GL_R32UI, "GL_R32UI", true, false, false, false, false, false, true},
8393*35238bceSAndroid Build Coastguard Worker {GL_RG8I, "GL_RG8I", true, true, false, false, false, false, true},
8394*35238bceSAndroid Build Coastguard Worker {GL_RG8UI, "GL_RG8UI", true, true, false, false, false, false, true},
8395*35238bceSAndroid Build Coastguard Worker {GL_RG16I, "GL_RG16I", true, true, false, false, false, false, true},
8396*35238bceSAndroid Build Coastguard Worker {GL_RG16UI, "GL_RG16UI", true, true, false, false, false, false, true},
8397*35238bceSAndroid Build Coastguard Worker {GL_RG32I, "GL_RG32I", true, true, false, false, false, false, true},
8398*35238bceSAndroid Build Coastguard Worker {GL_RG32UI, "GL_RG32UI", true, true, false, false, false, false, true},
8399*35238bceSAndroid Build Coastguard Worker {GL_RGBA8I, "GL_RGBA8I", true, true, true, true, false, false, true},
8400*35238bceSAndroid Build Coastguard Worker {GL_RGBA8UI, "GL_RGBA8UI", true, true, true, true, false, false, true},
8401*35238bceSAndroid Build Coastguard Worker {GL_RGBA16I, "GL_RGBA16I", true, true, true, true, false, false, true},
8402*35238bceSAndroid Build Coastguard Worker {GL_RGBA16UI, "GL_RGBA16UI", true, true, true, true, false, false, true},
8403*35238bceSAndroid Build Coastguard Worker {GL_RGBA32I, "GL_RGBA32I", true, true, true, true, false, false, true},
8404*35238bceSAndroid Build Coastguard Worker {GL_RGBA32UI, "GL_RGBA32UI", true, true, true, true, false, false, true},
8405*35238bceSAndroid Build Coastguard Worker {GL_DEPTH_COMPONENT16, "GL_DEPTH_COMPONENT16", false, false, false, false, true, false, false},
8406*35238bceSAndroid Build Coastguard Worker {GL_DEPTH_COMPONENT24, "GL_DEPTH_COMPONENT24", false, false, false, false, true, false, false},
8407*35238bceSAndroid Build Coastguard Worker {GL_DEPTH_COMPONENT32F, "GL_DEPTH_COMPONENT32F", false, false, false, false, true, false, false},
8408*35238bceSAndroid Build Coastguard Worker {GL_DEPTH24_STENCIL8, "GL_DEPTH24_STENCIL8", false, false, false, false, true, true, false},
8409*35238bceSAndroid Build Coastguard Worker {GL_DEPTH32F_STENCIL8, "GL_DEPTH32F_STENCIL8", false, false, false, false, true, true, false},
8410*35238bceSAndroid Build Coastguard Worker {GL_STENCIL_INDEX8, "GL_STENCIL_INDEX8", false, false, false, false, false, true, false}};
8411*35238bceSAndroid Build Coastguard Worker
8412*35238bceSAndroid Build Coastguard Worker /** Internal formats count */
8413*35238bceSAndroid Build Coastguard Worker const glw::GLuint StorageTest::s_renderbuffer_internalformat_configuration_count =
8414*35238bceSAndroid Build Coastguard Worker sizeof(s_renderbuffer_internalformat_configuration) / sizeof(s_renderbuffer_internalformat_configuration[0]);
8415*35238bceSAndroid Build Coastguard Worker
8416*35238bceSAndroid Build Coastguard Worker const glw::GLfloat StorageTest::s_reference_color[4] = {0.25, 0.5, 0.75, 1.0}; //!< Reference color.
8417*35238bceSAndroid Build Coastguard Worker const glw::GLint StorageTest::s_reference_color_integer[4] = {1, 2, 3, 4}; //!< Reference integral color.
8418*35238bceSAndroid Build Coastguard Worker const glw::GLfloat StorageTest::s_reference_depth = 0.5; //!< Reference depth.
8419*35238bceSAndroid Build Coastguard Worker const glw::GLint StorageTest::s_reference_stencil = 7; //!< Reference stencil.
8420*35238bceSAndroid Build Coastguard Worker
8421*35238bceSAndroid Build Coastguard Worker /***************************** Renderbuffer Storage Multisample Test Implementation ***************************/
8422*35238bceSAndroid Build Coastguard Worker
8423*35238bceSAndroid Build Coastguard Worker /** @brief Renderbuffer Storage Multisample Test constructor.
8424*35238bceSAndroid Build Coastguard Worker *
8425*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
8426*35238bceSAndroid Build Coastguard Worker */
StorageMultisampleTest(deqp::Context & context)8427*35238bceSAndroid Build Coastguard Worker StorageMultisampleTest::StorageMultisampleTest(deqp::Context &context)
8428*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "renderbuffers_storage_multisample", "Renderbuffer Objects Storage Multisample Test")
8429*35238bceSAndroid Build Coastguard Worker {
8430*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < 2; ++i)
8431*35238bceSAndroid Build Coastguard Worker {
8432*35238bceSAndroid Build Coastguard Worker m_fbo[i] = 0;
8433*35238bceSAndroid Build Coastguard Worker m_rbo[i] = 0;
8434*35238bceSAndroid Build Coastguard Worker }
8435*35238bceSAndroid Build Coastguard Worker }
8436*35238bceSAndroid Build Coastguard Worker
8437*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Creation Test cases.
8438*35238bceSAndroid Build Coastguard Worker *
8439*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
8440*35238bceSAndroid Build Coastguard Worker */
iterate()8441*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult StorageMultisampleTest::iterate()
8442*35238bceSAndroid Build Coastguard Worker {
8443*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
8444*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
8445*35238bceSAndroid Build Coastguard Worker
8446*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
8447*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
8448*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
8449*35238bceSAndroid Build Coastguard Worker
8450*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
8451*35238bceSAndroid Build Coastguard Worker {
8452*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
8453*35238bceSAndroid Build Coastguard Worker
8454*35238bceSAndroid Build Coastguard Worker return STOP;
8455*35238bceSAndroid Build Coastguard Worker }
8456*35238bceSAndroid Build Coastguard Worker
8457*35238bceSAndroid Build Coastguard Worker /* Running tests. */
8458*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
8459*35238bceSAndroid Build Coastguard Worker bool is_error = false;
8460*35238bceSAndroid Build Coastguard Worker
8461*35238bceSAndroid Build Coastguard Worker try
8462*35238bceSAndroid Build Coastguard Worker {
8463*35238bceSAndroid Build Coastguard Worker glw::GLint max_renderbuffer_size = 16384 /* Specification minimum. */;
8464*35238bceSAndroid Build Coastguard Worker
8465*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_RENDERBUFFER_SIZE, &max_renderbuffer_size);
8466*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv call failed.");
8467*35238bceSAndroid Build Coastguard Worker
8468*35238bceSAndroid Build Coastguard Worker const struct
8469*35238bceSAndroid Build Coastguard Worker {
8470*35238bceSAndroid Build Coastguard Worker glw::GLuint width;
8471*35238bceSAndroid Build Coastguard Worker glw::GLuint height;
8472*35238bceSAndroid Build Coastguard Worker } test_cases[] = {
8473*35238bceSAndroid Build Coastguard Worker {1, 1}, {(glw::GLuint)max_renderbuffer_size / 2, 1}, {1, (glw::GLuint)max_renderbuffer_size / 2}};
8474*35238bceSAndroid Build Coastguard Worker
8475*35238bceSAndroid Build Coastguard Worker const glw::GLuint test_cases_count = sizeof(test_cases) / sizeof(test_cases[0]);
8476*35238bceSAndroid Build Coastguard Worker
8477*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < test_cases_count; ++i)
8478*35238bceSAndroid Build Coastguard Worker {
8479*35238bceSAndroid Build Coastguard Worker for (glw::GLuint j = 0; j < s_renderbuffer_internalformat_configuration_count; ++j)
8480*35238bceSAndroid Build Coastguard Worker {
8481*35238bceSAndroid Build Coastguard Worker glw::GLint max_integer_samples = GetMaxConformantSampleCount(
8482*35238bceSAndroid Build Coastguard Worker GL_RENDERBUFFER, s_renderbuffer_internalformat_configuration[j].internalformat);
8483*35238bceSAndroid Build Coastguard Worker for (glw::GLint k = 0; k <= max_integer_samples; ++k)
8484*35238bceSAndroid Build Coastguard Worker {
8485*35238bceSAndroid Build Coastguard Worker if (PrepareRenderbuffer(s_renderbuffer_internalformat_configuration[j], test_cases[i].width,
8486*35238bceSAndroid Build Coastguard Worker test_cases[i].height, k))
8487*35238bceSAndroid Build Coastguard Worker {
8488*35238bceSAndroid Build Coastguard Worker Bind(GL_DRAW_FRAMEBUFFER, 0);
8489*35238bceSAndroid Build Coastguard Worker Clear(s_renderbuffer_internalformat_configuration[j].isColorIntegralFormat);
8490*35238bceSAndroid Build Coastguard Worker Bind(GL_READ_FRAMEBUFFER, 0);
8491*35238bceSAndroid Build Coastguard Worker Bind(GL_DRAW_FRAMEBUFFER, 1);
8492*35238bceSAndroid Build Coastguard Worker Blit(test_cases[i].width, test_cases[i].height);
8493*35238bceSAndroid Build Coastguard Worker Bind(GL_READ_FRAMEBUFFER, 1);
8494*35238bceSAndroid Build Coastguard Worker is_ok &= Check(s_renderbuffer_internalformat_configuration[j], test_cases[i].width,
8495*35238bceSAndroid Build Coastguard Worker test_cases[i].height);
8496*35238bceSAndroid Build Coastguard Worker }
8497*35238bceSAndroid Build Coastguard Worker else
8498*35238bceSAndroid Build Coastguard Worker {
8499*35238bceSAndroid Build Coastguard Worker is_ok = false;
8500*35238bceSAndroid Build Coastguard Worker }
8501*35238bceSAndroid Build Coastguard Worker
8502*35238bceSAndroid Build Coastguard Worker Clean();
8503*35238bceSAndroid Build Coastguard Worker }
8504*35238bceSAndroid Build Coastguard Worker }
8505*35238bceSAndroid Build Coastguard Worker }
8506*35238bceSAndroid Build Coastguard Worker }
8507*35238bceSAndroid Build Coastguard Worker catch (...)
8508*35238bceSAndroid Build Coastguard Worker {
8509*35238bceSAndroid Build Coastguard Worker is_ok = false;
8510*35238bceSAndroid Build Coastguard Worker is_error = true;
8511*35238bceSAndroid Build Coastguard Worker
8512*35238bceSAndroid Build Coastguard Worker Clean();
8513*35238bceSAndroid Build Coastguard Worker }
8514*35238bceSAndroid Build Coastguard Worker
8515*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
8516*35238bceSAndroid Build Coastguard Worker if (is_ok)
8517*35238bceSAndroid Build Coastguard Worker {
8518*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
8519*35238bceSAndroid Build Coastguard Worker }
8520*35238bceSAndroid Build Coastguard Worker else
8521*35238bceSAndroid Build Coastguard Worker {
8522*35238bceSAndroid Build Coastguard Worker if (is_error)
8523*35238bceSAndroid Build Coastguard Worker {
8524*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
8525*35238bceSAndroid Build Coastguard Worker }
8526*35238bceSAndroid Build Coastguard Worker else
8527*35238bceSAndroid Build Coastguard Worker {
8528*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
8529*35238bceSAndroid Build Coastguard Worker }
8530*35238bceSAndroid Build Coastguard Worker }
8531*35238bceSAndroid Build Coastguard Worker
8532*35238bceSAndroid Build Coastguard Worker return STOP;
8533*35238bceSAndroid Build Coastguard Worker }
8534*35238bceSAndroid Build Coastguard Worker
8535*35238bceSAndroid Build Coastguard Worker /** Prepare renderbuffer.
8536*35238bceSAndroid Build Coastguard Worker *
8537*35238bceSAndroid Build Coastguard Worker * @param [in] format Internal format to be prepared.
8538*35238bceSAndroid Build Coastguard Worker * @param [in] width Width of the framebuffer.
8539*35238bceSAndroid Build Coastguard Worker * @param [in] height Height of the framebuffer.
8540*35238bceSAndroid Build Coastguard Worker *
8541*35238bceSAndroid Build Coastguard Worker * @return True if there is no error, false otherwise.
8542*35238bceSAndroid Build Coastguard Worker */
PrepareRenderbuffer(StorageMultisampleTest::RenderbufferInternalFormatConfiguration format,glw::GLuint width,glw::GLuint height,glw::GLsizei samples)8543*35238bceSAndroid Build Coastguard Worker bool StorageMultisampleTest::PrepareRenderbuffer(StorageMultisampleTest::RenderbufferInternalFormatConfiguration format,
8544*35238bceSAndroid Build Coastguard Worker glw::GLuint width, glw::GLuint height, glw::GLsizei samples)
8545*35238bceSAndroid Build Coastguard Worker {
8546*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
8547*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
8548*35238bceSAndroid Build Coastguard Worker
8549*35238bceSAndroid Build Coastguard Worker gl.genFramebuffers(2, m_fbo);
8550*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
8551*35238bceSAndroid Build Coastguard Worker
8552*35238bceSAndroid Build Coastguard Worker gl.createRenderbuffers(2, m_rbo);
8553*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateRenderbuffers call failed.");
8554*35238bceSAndroid Build Coastguard Worker
8555*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < 2; ++i)
8556*35238bceSAndroid Build Coastguard Worker {
8557*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo[i]);
8558*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
8559*35238bceSAndroid Build Coastguard Worker
8560*35238bceSAndroid Build Coastguard Worker if (i)
8561*35238bceSAndroid Build Coastguard Worker {
8562*35238bceSAndroid Build Coastguard Worker /* 2nd is not multisampled. */
8563*35238bceSAndroid Build Coastguard Worker gl.namedRenderbufferStorageMultisample(m_rbo[i], 0, format.internalformat, width, height);
8564*35238bceSAndroid Build Coastguard Worker
8565*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
8566*35238bceSAndroid Build Coastguard Worker {
8567*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
8568*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message
8569*35238bceSAndroid Build Coastguard Worker << "Renderbuffer storage multisample test failed because "
8570*35238bceSAndroid Build Coastguard Worker "NamedRenderbufferStorageMultisample generated "
8571*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(error) << " error value. Renderbuffers format was "
8572*35238bceSAndroid Build Coastguard Worker << format.internalformat_name << ", samples was " << 0 << ", width was " << width << ", height was "
8573*35238bceSAndroid Build Coastguard Worker << height << "." << tcu::TestLog::EndMessage;
8574*35238bceSAndroid Build Coastguard Worker return false;
8575*35238bceSAndroid Build Coastguard Worker }
8576*35238bceSAndroid Build Coastguard Worker }
8577*35238bceSAndroid Build Coastguard Worker else
8578*35238bceSAndroid Build Coastguard Worker {
8579*35238bceSAndroid Build Coastguard Worker /* 1st is multisampled. */
8580*35238bceSAndroid Build Coastguard Worker gl.namedRenderbufferStorageMultisample(m_rbo[i], samples, format.internalformat, width, height);
8581*35238bceSAndroid Build Coastguard Worker
8582*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
8583*35238bceSAndroid Build Coastguard Worker {
8584*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
8585*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message
8586*35238bceSAndroid Build Coastguard Worker << "Renderbuffer storage multisample test failed because "
8587*35238bceSAndroid Build Coastguard Worker "NamedRenderbufferStorageMultisample generated "
8588*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(error) << " error value. Renderbuffers format was "
8589*35238bceSAndroid Build Coastguard Worker << format.internalformat_name << ", samples was " << samples << ", width was " << width
8590*35238bceSAndroid Build Coastguard Worker << ", height was " << height << "." << tcu::TestLog::EndMessage;
8591*35238bceSAndroid Build Coastguard Worker return false;
8592*35238bceSAndroid Build Coastguard Worker }
8593*35238bceSAndroid Build Coastguard Worker }
8594*35238bceSAndroid Build Coastguard Worker
8595*35238bceSAndroid Build Coastguard Worker if (format.hasRedComponent || format.hasGreenComponent || format.hasBlueComponent || format.hasAlphaComponent)
8596*35238bceSAndroid Build Coastguard Worker {
8597*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferRenderbuffer(m_fbo[i], GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo[i]);
8598*35238bceSAndroid Build Coastguard Worker }
8599*35238bceSAndroid Build Coastguard Worker
8600*35238bceSAndroid Build Coastguard Worker if (format.hasDepthComponent)
8601*35238bceSAndroid Build Coastguard Worker {
8602*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferRenderbuffer(m_fbo[i], GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_rbo[i]);
8603*35238bceSAndroid Build Coastguard Worker }
8604*35238bceSAndroid Build Coastguard Worker
8605*35238bceSAndroid Build Coastguard Worker if (format.hasStencilComponent)
8606*35238bceSAndroid Build Coastguard Worker {
8607*35238bceSAndroid Build Coastguard Worker gl.namedFramebufferRenderbuffer(m_fbo[i], GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_rbo[i]);
8608*35238bceSAndroid Build Coastguard Worker }
8609*35238bceSAndroid Build Coastguard Worker
8610*35238bceSAndroid Build Coastguard Worker glw::GLenum status = gl.checkFramebufferStatus(GL_FRAMEBUFFER);
8611*35238bceSAndroid Build Coastguard Worker if (status != GL_FRAMEBUFFER_COMPLETE)
8612*35238bceSAndroid Build Coastguard Worker {
8613*35238bceSAndroid Build Coastguard Worker /* Log. */
8614*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
8615*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Renderbuffer storage multisample test failed due to "
8616*35238bceSAndroid Build Coastguard Worker << glu::getFramebufferStatusStr(status) << " framebuffer status. Renderbuffers format was "
8617*35238bceSAndroid Build Coastguard Worker << format.internalformat_name << ", samples was " << (i ? 0 : samples) << ", width was " << width
8618*35238bceSAndroid Build Coastguard Worker << ", height was " << height << "." << tcu::TestLog::EndMessage;
8619*35238bceSAndroid Build Coastguard Worker
8620*35238bceSAndroid Build Coastguard Worker return false;
8621*35238bceSAndroid Build Coastguard Worker }
8622*35238bceSAndroid Build Coastguard Worker }
8623*35238bceSAndroid Build Coastguard Worker
8624*35238bceSAndroid Build Coastguard Worker return true;
8625*35238bceSAndroid Build Coastguard Worker }
8626*35238bceSAndroid Build Coastguard Worker
8627*35238bceSAndroid Build Coastguard Worker /** Bind framebuffer to the target.
8628*35238bceSAndroid Build Coastguard Worker *
8629*35238bceSAndroid Build Coastguard Worker * @param [in] target Bind to target.
8630*35238bceSAndroid Build Coastguard Worker * @param [in] selector Index of the framebuffer in framebuffers' arrays.
8631*35238bceSAndroid Build Coastguard Worker */
Bind(glw::GLenum target,glw::GLuint selector)8632*35238bceSAndroid Build Coastguard Worker void StorageMultisampleTest::Bind(glw::GLenum target, glw::GLuint selector)
8633*35238bceSAndroid Build Coastguard Worker {
8634*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
8635*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
8636*35238bceSAndroid Build Coastguard Worker
8637*35238bceSAndroid Build Coastguard Worker /* Binding framebuffer. */
8638*35238bceSAndroid Build Coastguard Worker gl.bindFramebuffer(target, m_fbo[selector]);
8639*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
8640*35238bceSAndroid Build Coastguard Worker }
8641*35238bceSAndroid Build Coastguard Worker
8642*35238bceSAndroid Build Coastguard Worker /** Blit one framebuffer to the second.
8643*35238bceSAndroid Build Coastguard Worker *
8644*35238bceSAndroid Build Coastguard Worker * @param [in] width Width of the framebuffer.
8645*35238bceSAndroid Build Coastguard Worker * @param [in] height Height of the framebuffer.
8646*35238bceSAndroid Build Coastguard Worker *
8647*35238bceSAndroid Build Coastguard Worker * @return True if there is no error, false otherwise.
8648*35238bceSAndroid Build Coastguard Worker */
Blit(glw::GLuint width,glw::GLuint height)8649*35238bceSAndroid Build Coastguard Worker void StorageMultisampleTest::Blit(glw::GLuint width, glw::GLuint height)
8650*35238bceSAndroid Build Coastguard Worker {
8651*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
8652*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
8653*35238bceSAndroid Build Coastguard Worker
8654*35238bceSAndroid Build Coastguard Worker /* Binding framebuffer. */
8655*35238bceSAndroid Build Coastguard Worker gl.blitFramebuffer(0, 0, width, height, 0, 0, width, height,
8656*35238bceSAndroid Build Coastguard Worker GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST);
8657*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
8658*35238bceSAndroid Build Coastguard Worker }
8659*35238bceSAndroid Build Coastguard Worker
8660*35238bceSAndroid Build Coastguard Worker /** Clear framebuffer.
8661*35238bceSAndroid Build Coastguard Worker *
8662*35238bceSAndroid Build Coastguard Worker * @param [in] isColorIntegralFormat Is framebuffer a color integral type.
8663*35238bceSAndroid Build Coastguard Worker */
Clear(bool isColorIntegralFormat)8664*35238bceSAndroid Build Coastguard Worker void StorageMultisampleTest::Clear(bool isColorIntegralFormat)
8665*35238bceSAndroid Build Coastguard Worker {
8666*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
8667*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
8668*35238bceSAndroid Build Coastguard Worker
8669*35238bceSAndroid Build Coastguard Worker if (isColorIntegralFormat)
8670*35238bceSAndroid Build Coastguard Worker {
8671*35238bceSAndroid Build Coastguard Worker gl.clearBufferiv(GL_COLOR, 0, s_reference_color_integer);
8672*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glClearBufferiv has failed");
8673*35238bceSAndroid Build Coastguard Worker }
8674*35238bceSAndroid Build Coastguard Worker else
8675*35238bceSAndroid Build Coastguard Worker {
8676*35238bceSAndroid Build Coastguard Worker /* Setup clear values. */
8677*35238bceSAndroid Build Coastguard Worker gl.clearColor(s_reference_color[0], s_reference_color[1], s_reference_color[2], s_reference_color[3]);
8678*35238bceSAndroid Build Coastguard Worker gl.clearDepth(s_reference_depth);
8679*35238bceSAndroid Build Coastguard Worker gl.clearStencil(s_reference_stencil);
8680*35238bceSAndroid Build Coastguard Worker
8681*35238bceSAndroid Build Coastguard Worker /* Clear rbo/fbo. */
8682*35238bceSAndroid Build Coastguard Worker gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
8683*35238bceSAndroid Build Coastguard Worker }
8684*35238bceSAndroid Build Coastguard Worker }
8685*35238bceSAndroid Build Coastguard Worker
8686*35238bceSAndroid Build Coastguard Worker /** Check renderbuffer's content.
8687*35238bceSAndroid Build Coastguard Worker *
8688*35238bceSAndroid Build Coastguard Worker * @param [in] format Internal format to be prepared.
8689*35238bceSAndroid Build Coastguard Worker * @param [in] width Width of the framebuffer.
8690*35238bceSAndroid Build Coastguard Worker * @param [in] height Height of the framebuffer.
8691*35238bceSAndroid Build Coastguard Worker *
8692*35238bceSAndroid Build Coastguard Worker * @return True if content matches the reference, false otherwise.
8693*35238bceSAndroid Build Coastguard Worker */
Check(StorageMultisampleTest::RenderbufferInternalFormatConfiguration format,glw::GLuint width,glw::GLuint height)8694*35238bceSAndroid Build Coastguard Worker bool StorageMultisampleTest::Check(StorageMultisampleTest::RenderbufferInternalFormatConfiguration format,
8695*35238bceSAndroid Build Coastguard Worker glw::GLuint width, glw::GLuint height)
8696*35238bceSAndroid Build Coastguard Worker {
8697*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
8698*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
8699*35238bceSAndroid Build Coastguard Worker
8700*35238bceSAndroid Build Coastguard Worker glw::GLuint size = width * height;
8701*35238bceSAndroid Build Coastguard Worker
8702*35238bceSAndroid Build Coastguard Worker if (format.hasRedComponent || format.hasGreenComponent || format.hasBlueComponent || format.hasAlphaComponent)
8703*35238bceSAndroid Build Coastguard Worker {
8704*35238bceSAndroid Build Coastguard Worker if (format.isColorIntegralFormat)
8705*35238bceSAndroid Build Coastguard Worker {
8706*35238bceSAndroid Build Coastguard Worker std::vector<glw::GLint> color(size * 4);
8707*35238bceSAndroid Build Coastguard Worker
8708*35238bceSAndroid Build Coastguard Worker gl.readPixels(0, 0, width, height, GL_RGBA_INTEGER, GL_INT, &color[0]);
8709*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels call failed.");
8710*35238bceSAndroid Build Coastguard Worker
8711*35238bceSAndroid Build Coastguard Worker const bool hasComponent[] = {format.hasRedComponent, format.hasGreenComponent, format.hasBlueComponent,
8712*35238bceSAndroid Build Coastguard Worker format.hasAlphaComponent};
8713*35238bceSAndroid Build Coastguard Worker
8714*35238bceSAndroid Build Coastguard Worker static const char *componentName[] = {"red", "green", "blue", "alpha"};
8715*35238bceSAndroid Build Coastguard Worker
8716*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < size; ++i)
8717*35238bceSAndroid Build Coastguard Worker {
8718*35238bceSAndroid Build Coastguard Worker if (hasComponent[i % 4 /* color components count*/])
8719*35238bceSAndroid Build Coastguard Worker {
8720*35238bceSAndroid Build Coastguard Worker if (de::abs(s_reference_color_integer[i % 4 /* color components count*/] - color[i]) >
8721*35238bceSAndroid Build Coastguard Worker 2 /* Precision */)
8722*35238bceSAndroid Build Coastguard Worker {
8723*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
8724*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Renderbuffer storage multisample was cleared with color "
8725*35238bceSAndroid Build Coastguard Worker << componentName[i % 4 /* color components count*/] << " component equal to "
8726*35238bceSAndroid Build Coastguard Worker << s_reference_color_integer[i % 4 /* color components count*/] << ", but fetched value "
8727*35238bceSAndroid Build Coastguard Worker << color[i] << " is not the same. Renderbuffers format was " << format.internalformat_name
8728*35238bceSAndroid Build Coastguard Worker << ", width was " << width << ", height was " << height << "." << tcu::TestLog::EndMessage;
8729*35238bceSAndroid Build Coastguard Worker
8730*35238bceSAndroid Build Coastguard Worker return false;
8731*35238bceSAndroid Build Coastguard Worker }
8732*35238bceSAndroid Build Coastguard Worker }
8733*35238bceSAndroid Build Coastguard Worker }
8734*35238bceSAndroid Build Coastguard Worker }
8735*35238bceSAndroid Build Coastguard Worker else
8736*35238bceSAndroid Build Coastguard Worker {
8737*35238bceSAndroid Build Coastguard Worker std::vector<glw::GLfloat> color(size * 4);
8738*35238bceSAndroid Build Coastguard Worker
8739*35238bceSAndroid Build Coastguard Worker gl.readPixels(0, 0, width, height, GL_RGBA, GL_FLOAT, &color[0]);
8740*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels call failed.");
8741*35238bceSAndroid Build Coastguard Worker
8742*35238bceSAndroid Build Coastguard Worker const bool hasComponent[] = {format.hasRedComponent, format.hasGreenComponent, format.hasBlueComponent,
8743*35238bceSAndroid Build Coastguard Worker format.hasAlphaComponent};
8744*35238bceSAndroid Build Coastguard Worker
8745*35238bceSAndroid Build Coastguard Worker static const char *componentName[] = {"red", "green", "blue", "alpha"};
8746*35238bceSAndroid Build Coastguard Worker
8747*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < size; ++i)
8748*35238bceSAndroid Build Coastguard Worker {
8749*35238bceSAndroid Build Coastguard Worker if (hasComponent[i % 4 /* color components count*/])
8750*35238bceSAndroid Build Coastguard Worker {
8751*35238bceSAndroid Build Coastguard Worker if (de::abs(s_reference_color[i % 4 /* color components count*/] - color[i]) >
8752*35238bceSAndroid Build Coastguard Worker 0.0625 /* precision */)
8753*35238bceSAndroid Build Coastguard Worker {
8754*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
8755*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "Renderbuffer storage multisample was cleared with color "
8756*35238bceSAndroid Build Coastguard Worker << componentName[i % 4 /* color components count*/] << " component equal to "
8757*35238bceSAndroid Build Coastguard Worker << s_reference_color[i % 4 /* color components count*/] << ", but fetched value "
8758*35238bceSAndroid Build Coastguard Worker << color[i] << " is not the same. Renderbuffers format was " << format.internalformat_name
8759*35238bceSAndroid Build Coastguard Worker << ", width was " << width << ", height was " << height << "." << tcu::TestLog::EndMessage;
8760*35238bceSAndroid Build Coastguard Worker
8761*35238bceSAndroid Build Coastguard Worker return false;
8762*35238bceSAndroid Build Coastguard Worker }
8763*35238bceSAndroid Build Coastguard Worker }
8764*35238bceSAndroid Build Coastguard Worker }
8765*35238bceSAndroid Build Coastguard Worker }
8766*35238bceSAndroid Build Coastguard Worker }
8767*35238bceSAndroid Build Coastguard Worker
8768*35238bceSAndroid Build Coastguard Worker if (format.hasDepthComponent)
8769*35238bceSAndroid Build Coastguard Worker {
8770*35238bceSAndroid Build Coastguard Worker std::vector<glw::GLfloat> depth(size);
8771*35238bceSAndroid Build Coastguard Worker
8772*35238bceSAndroid Build Coastguard Worker gl.readPixels(0, 0, width, height, GL_DEPTH_COMPONENT, GL_FLOAT, &depth[0]);
8773*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels call failed.");
8774*35238bceSAndroid Build Coastguard Worker
8775*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < size; ++i)
8776*35238bceSAndroid Build Coastguard Worker {
8777*35238bceSAndroid Build Coastguard Worker if (de::abs(s_reference_depth - depth[i]) > 0.0625 /* 1/16 precision */)
8778*35238bceSAndroid Build Coastguard Worker {
8779*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
8780*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message
8781*35238bceSAndroid Build Coastguard Worker << "Renderbuffer storage multisample was cleared with depth component equal to "
8782*35238bceSAndroid Build Coastguard Worker << s_reference_depth << ", but fetched value " << depth[i]
8783*35238bceSAndroid Build Coastguard Worker << " is not the same. Renderbuffers format was " << format.internalformat_name << ", width was "
8784*35238bceSAndroid Build Coastguard Worker << width << ", height was " << height << "." << tcu::TestLog::EndMessage;
8785*35238bceSAndroid Build Coastguard Worker
8786*35238bceSAndroid Build Coastguard Worker return false;
8787*35238bceSAndroid Build Coastguard Worker }
8788*35238bceSAndroid Build Coastguard Worker }
8789*35238bceSAndroid Build Coastguard Worker }
8790*35238bceSAndroid Build Coastguard Worker
8791*35238bceSAndroid Build Coastguard Worker if (format.hasStencilComponent)
8792*35238bceSAndroid Build Coastguard Worker {
8793*35238bceSAndroid Build Coastguard Worker std::vector<glw::GLint> stencil(size);
8794*35238bceSAndroid Build Coastguard Worker
8795*35238bceSAndroid Build Coastguard Worker gl.readPixels(0, 0, width, height, GL_STENCIL_INDEX, GL_INT, &stencil[0]);
8796*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels call failed.");
8797*35238bceSAndroid Build Coastguard Worker
8798*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < size; ++i)
8799*35238bceSAndroid Build Coastguard Worker {
8800*35238bceSAndroid Build Coastguard Worker if (s_reference_stencil != stencil[i])
8801*35238bceSAndroid Build Coastguard Worker {
8802*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
8803*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message
8804*35238bceSAndroid Build Coastguard Worker << "Renderbuffer storage multisample was cleared with alpha component equal to "
8805*35238bceSAndroid Build Coastguard Worker << s_reference_stencil << ", but fetched value " << stencil[i]
8806*35238bceSAndroid Build Coastguard Worker << " is not the same. Renderbuffers format was " << format.internalformat_name << ", width was "
8807*35238bceSAndroid Build Coastguard Worker << width << ", height was " << height << "." << tcu::TestLog::EndMessage;
8808*35238bceSAndroid Build Coastguard Worker
8809*35238bceSAndroid Build Coastguard Worker return false;
8810*35238bceSAndroid Build Coastguard Worker }
8811*35238bceSAndroid Build Coastguard Worker }
8812*35238bceSAndroid Build Coastguard Worker }
8813*35238bceSAndroid Build Coastguard Worker
8814*35238bceSAndroid Build Coastguard Worker return true;
8815*35238bceSAndroid Build Coastguard Worker }
8816*35238bceSAndroid Build Coastguard Worker
8817*35238bceSAndroid Build Coastguard Worker /** @brief Clean up GL state.
8818*35238bceSAndroid Build Coastguard Worker */
Clean()8819*35238bceSAndroid Build Coastguard Worker void StorageMultisampleTest::Clean()
8820*35238bceSAndroid Build Coastguard Worker {
8821*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
8822*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
8823*35238bceSAndroid Build Coastguard Worker
8824*35238bceSAndroid Build Coastguard Worker /* Release objects. */
8825*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < 2; ++i)
8826*35238bceSAndroid Build Coastguard Worker {
8827*35238bceSAndroid Build Coastguard Worker if (m_rbo[i])
8828*35238bceSAndroid Build Coastguard Worker {
8829*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &m_rbo[i]);
8830*35238bceSAndroid Build Coastguard Worker
8831*35238bceSAndroid Build Coastguard Worker m_rbo[i] = 0;
8832*35238bceSAndroid Build Coastguard Worker }
8833*35238bceSAndroid Build Coastguard Worker
8834*35238bceSAndroid Build Coastguard Worker if (m_fbo[i])
8835*35238bceSAndroid Build Coastguard Worker {
8836*35238bceSAndroid Build Coastguard Worker gl.deleteFramebuffers(1, &m_fbo[i]);
8837*35238bceSAndroid Build Coastguard Worker
8838*35238bceSAndroid Build Coastguard Worker m_fbo[i] = 0;
8839*35238bceSAndroid Build Coastguard Worker }
8840*35238bceSAndroid Build Coastguard Worker }
8841*35238bceSAndroid Build Coastguard Worker
8842*35238bceSAndroid Build Coastguard Worker /* Returning to default clear values. */
8843*35238bceSAndroid Build Coastguard Worker gl.clearColor(0.f, 0.f, 0.f, 0.f);
8844*35238bceSAndroid Build Coastguard Worker gl.clearDepth(1.f);
8845*35238bceSAndroid Build Coastguard Worker gl.clearStencil(0);
8846*35238bceSAndroid Build Coastguard Worker
8847*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
8848*35238bceSAndroid Build Coastguard Worker while (gl.getError())
8849*35238bceSAndroid Build Coastguard Worker ;
8850*35238bceSAndroid Build Coastguard Worker }
8851*35238bceSAndroid Build Coastguard Worker
8852*35238bceSAndroid Build Coastguard Worker /** @brief Retrieve max conformant sample count when GL_NV_internalformat_sample_query is supported
8853*35238bceSAndroid Build Coastguard Worker *
8854*35238bceSAndroid Build Coastguard Worker * @param [in] target Target indicating usage of internal format
8855*35238bceSAndroid Build Coastguard Worker * @param [in] internalFormat Internal format about which to retrieve information
8856*35238bceSAndroid Build Coastguard Worker *
8857*35238bceSAndroid Build Coastguard Worker * @return Max conformant sample count
8858*35238bceSAndroid Build Coastguard Worker */
GetMaxConformantSampleCount(glw::GLenum target,glw::GLenum internalFormat)8859*35238bceSAndroid Build Coastguard Worker glw::GLint StorageMultisampleTest::GetMaxConformantSampleCount(glw::GLenum target, glw::GLenum internalFormat)
8860*35238bceSAndroid Build Coastguard Worker {
8861*35238bceSAndroid Build Coastguard Worker glw::GLint max_conformant_samples = 0;
8862*35238bceSAndroid Build Coastguard Worker
8863*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
8864*35238bceSAndroid Build Coastguard Worker
8865*35238bceSAndroid Build Coastguard Worker /* Return the max conformant sample count if extension is supported */
8866*35238bceSAndroid Build Coastguard Worker if (m_context.getContextInfo().isExtensionSupported("GL_NV_internalformat_sample_query"))
8867*35238bceSAndroid Build Coastguard Worker {
8868*35238bceSAndroid Build Coastguard Worker glw::GLint gl_sample_counts = 0;
8869*35238bceSAndroid Build Coastguard Worker gl.getInternalformativ(target, internalFormat, GL_NUM_SAMPLE_COUNTS, 1, &gl_sample_counts);
8870*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetInternalformativ() failed for GL_NUM_SAMPLE_COUNTS pname");
8871*35238bceSAndroid Build Coastguard Worker
8872*35238bceSAndroid Build Coastguard Worker /* Check and return the max conformant sample count */
8873*35238bceSAndroid Build Coastguard Worker glw::GLint *gl_supported_samples = new glw::GLint[gl_sample_counts];
8874*35238bceSAndroid Build Coastguard Worker if (gl_supported_samples)
8875*35238bceSAndroid Build Coastguard Worker {
8876*35238bceSAndroid Build Coastguard Worker gl.getInternalformativ(target, internalFormat, GL_SAMPLES, gl_sample_counts, gl_supported_samples);
8877*35238bceSAndroid Build Coastguard Worker
8878*35238bceSAndroid Build Coastguard Worker for (glw::GLint i = 0; i < gl_sample_counts; i++)
8879*35238bceSAndroid Build Coastguard Worker {
8880*35238bceSAndroid Build Coastguard Worker glw::GLint isConformant = 0;
8881*35238bceSAndroid Build Coastguard Worker gl.getInternalformatSampleivNV(target, internalFormat, gl_supported_samples[i], GL_CONFORMANT_NV, 1,
8882*35238bceSAndroid Build Coastguard Worker &isConformant);
8883*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetInternalformatSampleivNV() call(s) failed");
8884*35238bceSAndroid Build Coastguard Worker
8885*35238bceSAndroid Build Coastguard Worker if (isConformant && gl_supported_samples[i] > max_conformant_samples)
8886*35238bceSAndroid Build Coastguard Worker {
8887*35238bceSAndroid Build Coastguard Worker max_conformant_samples = gl_supported_samples[i];
8888*35238bceSAndroid Build Coastguard Worker }
8889*35238bceSAndroid Build Coastguard Worker }
8890*35238bceSAndroid Build Coastguard Worker delete[] gl_supported_samples;
8891*35238bceSAndroid Build Coastguard Worker }
8892*35238bceSAndroid Build Coastguard Worker }
8893*35238bceSAndroid Build Coastguard Worker else
8894*35238bceSAndroid Build Coastguard Worker {
8895*35238bceSAndroid Build Coastguard Worker /* Otherwise return GL_MAX_INTEGER_SAMPLES */
8896*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_MAX_INTEGER_SAMPLES, &max_conformant_samples);
8897*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv() call failed for GL_MAX_INTEGER_SAMPLES pname.");
8898*35238bceSAndroid Build Coastguard Worker }
8899*35238bceSAndroid Build Coastguard Worker
8900*35238bceSAndroid Build Coastguard Worker return max_conformant_samples;
8901*35238bceSAndroid Build Coastguard Worker }
8902*35238bceSAndroid Build Coastguard Worker
8903*35238bceSAndroid Build Coastguard Worker /** Tested internal format */
8904*35238bceSAndroid Build Coastguard Worker const struct StorageMultisampleTest::RenderbufferInternalFormatConfiguration
8905*35238bceSAndroid Build Coastguard Worker StorageMultisampleTest::s_renderbuffer_internalformat_configuration[] = {
8906*35238bceSAndroid Build Coastguard Worker {GL_R8, "GL_R8", true, false, false, false, false, false, false},
8907*35238bceSAndroid Build Coastguard Worker {GL_R16, "GL_R16", true, false, false, false, false, false, false},
8908*35238bceSAndroid Build Coastguard Worker {GL_RG8, "GL_RG8", true, true, false, false, false, false, false},
8909*35238bceSAndroid Build Coastguard Worker {GL_RG16, "GL_RG16", true, true, false, false, false, false, false},
8910*35238bceSAndroid Build Coastguard Worker {GL_RGB565, "GL_RGB56", true, true, true, false, false, false, false},
8911*35238bceSAndroid Build Coastguard Worker {GL_RGBA4, "GL_RGBA4", true, true, true, true, false, false, false},
8912*35238bceSAndroid Build Coastguard Worker {GL_RGB5_A1, "GL_RGB5_A1", true, true, true, true, false, false, false},
8913*35238bceSAndroid Build Coastguard Worker {GL_RGBA8, "GL_RGBA8", true, true, true, true, false, false, false},
8914*35238bceSAndroid Build Coastguard Worker {GL_RGB10_A2, "GL_RGB10_A2", true, true, true, true, false, false, false},
8915*35238bceSAndroid Build Coastguard Worker {GL_RGB10_A2UI, "GL_RGB10_A2UI", true, true, true, true, false, false, true},
8916*35238bceSAndroid Build Coastguard Worker {GL_RGBA16, "GL_RGBA16", true, true, true, true, false, false, false},
8917*35238bceSAndroid Build Coastguard Worker {GL_SRGB8_ALPHA8, "GL_SRGB8_ALPHA8", true, true, true, true, false, false, false},
8918*35238bceSAndroid Build Coastguard Worker {GL_R16F, "GL_R16F", true, false, false, false, false, false, false},
8919*35238bceSAndroid Build Coastguard Worker {GL_RG16F, "GL_RG16F", true, true, false, false, false, false, false},
8920*35238bceSAndroid Build Coastguard Worker {GL_RGBA16F, "GL_RGBA16F", true, true, true, true, false, false, false},
8921*35238bceSAndroid Build Coastguard Worker {GL_R32F, "GL_R32F", true, false, false, false, false, false, false},
8922*35238bceSAndroid Build Coastguard Worker {GL_RG32F, "GL_RG32F", true, true, false, false, false, false, false},
8923*35238bceSAndroid Build Coastguard Worker {GL_RGBA32F, "GL_RGBA32F", true, true, true, true, false, false, false},
8924*35238bceSAndroid Build Coastguard Worker {GL_R11F_G11F_B10F, "GL_R11F_G11F_B10F", true, true, true, false, false, false, false},
8925*35238bceSAndroid Build Coastguard Worker {GL_R8I, "GL_R8I", true, false, false, false, false, false, true},
8926*35238bceSAndroid Build Coastguard Worker {GL_R8UI, "GL_R8UI", true, false, false, false, false, false, true},
8927*35238bceSAndroid Build Coastguard Worker {GL_R16I, "GL_R16I", true, false, false, false, false, false, true},
8928*35238bceSAndroid Build Coastguard Worker {GL_R16UI, "GL_R16UI", true, false, false, false, false, false, true},
8929*35238bceSAndroid Build Coastguard Worker {GL_R32I, "GL_R32I", true, false, false, false, false, false, true},
8930*35238bceSAndroid Build Coastguard Worker {GL_R32UI, "GL_R32UI", true, false, false, false, false, false, true},
8931*35238bceSAndroid Build Coastguard Worker {GL_RG8I, "GL_RG8I", true, true, false, false, false, false, true},
8932*35238bceSAndroid Build Coastguard Worker {GL_RG8UI, "GL_RG8UI", true, true, false, false, false, false, true},
8933*35238bceSAndroid Build Coastguard Worker {GL_RG16I, "GL_RG16I", true, true, false, false, false, false, true},
8934*35238bceSAndroid Build Coastguard Worker {GL_RG16UI, "GL_RG16UI", true, true, false, false, false, false, true},
8935*35238bceSAndroid Build Coastguard Worker {GL_RG32I, "GL_RG32I", true, true, false, false, false, false, true},
8936*35238bceSAndroid Build Coastguard Worker {GL_RG32UI, "GL_RG32UI", true, true, false, false, false, false, true},
8937*35238bceSAndroid Build Coastguard Worker {GL_RGBA8I, "GL_RGBA8I", true, true, true, true, false, false, true},
8938*35238bceSAndroid Build Coastguard Worker {GL_RGBA8UI, "GL_RGBA8UI", true, true, true, true, false, false, true},
8939*35238bceSAndroid Build Coastguard Worker {GL_RGBA16I, "GL_RGBA16I", true, true, true, true, false, false, true},
8940*35238bceSAndroid Build Coastguard Worker {GL_RGBA16UI, "GL_RGBA16UI", true, true, true, true, false, false, true},
8941*35238bceSAndroid Build Coastguard Worker {GL_RGBA32I, "GL_RGBA32I", true, true, true, true, false, false, true},
8942*35238bceSAndroid Build Coastguard Worker {GL_RGBA32UI, "GL_RGBA32UI", true, true, true, true, false, false, true},
8943*35238bceSAndroid Build Coastguard Worker {GL_DEPTH_COMPONENT16, "GL_DEPTH_COMPONENT16", false, false, false, false, true, false, false},
8944*35238bceSAndroid Build Coastguard Worker {GL_DEPTH_COMPONENT24, "GL_DEPTH_COMPONENT24", false, false, false, false, true, false, false},
8945*35238bceSAndroid Build Coastguard Worker {GL_DEPTH_COMPONENT32F, "GL_DEPTH_COMPONENT32F", false, false, false, false, true, false, false},
8946*35238bceSAndroid Build Coastguard Worker {GL_DEPTH24_STENCIL8, "GL_DEPTH24_STENCIL8", false, false, false, false, true, true, false},
8947*35238bceSAndroid Build Coastguard Worker {GL_DEPTH32F_STENCIL8, "GL_DEPTH32F_STENCIL8", false, false, false, false, true, true, false},
8948*35238bceSAndroid Build Coastguard Worker {GL_STENCIL_INDEX8, "GL_STENCIL_INDEX8", false, false, false, false, false, true, false}};
8949*35238bceSAndroid Build Coastguard Worker
8950*35238bceSAndroid Build Coastguard Worker /** Tesetd internal format count */
8951*35238bceSAndroid Build Coastguard Worker const glw::GLuint StorageMultisampleTest::s_renderbuffer_internalformat_configuration_count =
8952*35238bceSAndroid Build Coastguard Worker sizeof(s_renderbuffer_internalformat_configuration) / sizeof(s_renderbuffer_internalformat_configuration[0]);
8953*35238bceSAndroid Build Coastguard Worker
8954*35238bceSAndroid Build Coastguard Worker const glw::GLfloat StorageMultisampleTest::s_reference_color[4] = {0.25, 0.5, 0.75, 1.0}; //!< Reference color value.
8955*35238bceSAndroid Build Coastguard Worker const glw::GLint StorageMultisampleTest::s_reference_color_integer[4] = {
8956*35238bceSAndroid Build Coastguard Worker 1, 2, 3, 4}; //!< Reference color value for integral color internal formats.
8957*35238bceSAndroid Build Coastguard Worker const glw::GLfloat StorageMultisampleTest::s_reference_depth = 0.5; //!< Reference depth value.
8958*35238bceSAndroid Build Coastguard Worker const glw::GLint StorageMultisampleTest::s_reference_stencil = 7; //!< Reference stencil value.
8959*35238bceSAndroid Build Coastguard Worker
8960*35238bceSAndroid Build Coastguard Worker /******************************** Get Named Renderbuffer Parameters Test Implementation ********************************/
8961*35238bceSAndroid Build Coastguard Worker
8962*35238bceSAndroid Build Coastguard Worker /** @brief Get Named Renderbuffer Parameters Test constructor.
8963*35238bceSAndroid Build Coastguard Worker *
8964*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
8965*35238bceSAndroid Build Coastguard Worker */
GetParametersTest(deqp::Context & context)8966*35238bceSAndroid Build Coastguard Worker GetParametersTest::GetParametersTest(deqp::Context &context)
8967*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "renderbuffers_get_parameters", "Get Named Renderbuffer Parameters Test")
8968*35238bceSAndroid Build Coastguard Worker , m_fbo(0)
8969*35238bceSAndroid Build Coastguard Worker , m_rbo(0)
8970*35238bceSAndroid Build Coastguard Worker {
8971*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
8972*35238bceSAndroid Build Coastguard Worker }
8973*35238bceSAndroid Build Coastguard Worker
8974*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Check Status Test cases.
8975*35238bceSAndroid Build Coastguard Worker *
8976*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
8977*35238bceSAndroid Build Coastguard Worker */
iterate()8978*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult GetParametersTest::iterate()
8979*35238bceSAndroid Build Coastguard Worker {
8980*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
8981*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
8982*35238bceSAndroid Build Coastguard Worker
8983*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
8984*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
8985*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
8986*35238bceSAndroid Build Coastguard Worker
8987*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
8988*35238bceSAndroid Build Coastguard Worker {
8989*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
8990*35238bceSAndroid Build Coastguard Worker
8991*35238bceSAndroid Build Coastguard Worker return STOP;
8992*35238bceSAndroid Build Coastguard Worker }
8993*35238bceSAndroid Build Coastguard Worker
8994*35238bceSAndroid Build Coastguard Worker /* Running tests. */
8995*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
8996*35238bceSAndroid Build Coastguard Worker bool is_error = false;
8997*35238bceSAndroid Build Coastguard Worker
8998*35238bceSAndroid Build Coastguard Worker /* Test renderbuffer. */
8999*35238bceSAndroid Build Coastguard Worker glw::GLuint renderbuffer = 0;
9000*35238bceSAndroid Build Coastguard Worker
9001*35238bceSAndroid Build Coastguard Worker /* Test. */
9002*35238bceSAndroid Build Coastguard Worker try
9003*35238bceSAndroid Build Coastguard Worker {
9004*35238bceSAndroid Build Coastguard Worker static const glw::GLenum internalformats[] = {GL_RGBA8, GL_DEPTH_COMPONENT24, GL_STENCIL_INDEX8,
9005*35238bceSAndroid Build Coastguard Worker GL_DEPTH24_STENCIL8};
9006*35238bceSAndroid Build Coastguard Worker
9007*35238bceSAndroid Build Coastguard Worker static const glw::GLuint internalformats_count = sizeof(internalformats) / sizeof(internalformats[0]);
9008*35238bceSAndroid Build Coastguard Worker
9009*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < internalformats_count; ++i)
9010*35238bceSAndroid Build Coastguard Worker {
9011*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(1, &renderbuffer);
9012*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
9013*35238bceSAndroid Build Coastguard Worker
9014*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
9015*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer has failed");
9016*35238bceSAndroid Build Coastguard Worker
9017*35238bceSAndroid Build Coastguard Worker gl.renderbufferStorage(GL_RENDERBUFFER, internalformats[i], 1, 2);
9018*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
9019*35238bceSAndroid Build Coastguard Worker
9020*35238bceSAndroid Build Coastguard Worker static const glw::GLenum pnames[] = {GL_RENDERBUFFER_WIDTH, GL_RENDERBUFFER_HEIGHT,
9021*35238bceSAndroid Build Coastguard Worker GL_RENDERBUFFER_INTERNAL_FORMAT, GL_RENDERBUFFER_SAMPLES,
9022*35238bceSAndroid Build Coastguard Worker GL_RENDERBUFFER_RED_SIZE, GL_RENDERBUFFER_GREEN_SIZE,
9023*35238bceSAndroid Build Coastguard Worker GL_RENDERBUFFER_BLUE_SIZE, GL_RENDERBUFFER_ALPHA_SIZE,
9024*35238bceSAndroid Build Coastguard Worker GL_RENDERBUFFER_DEPTH_SIZE, GL_RENDERBUFFER_STENCIL_SIZE};
9025*35238bceSAndroid Build Coastguard Worker
9026*35238bceSAndroid Build Coastguard Worker static const glw::GLchar *pnames_strings[] = {
9027*35238bceSAndroid Build Coastguard Worker "GL_RENDERBUFFER_WIDTH", "GL_RENDERBUFFER_HEIGHT", "GL_RENDERBUFFER_INTERNAL_FORMAT",
9028*35238bceSAndroid Build Coastguard Worker "GL_RENDERBUFFER_SAMPLES", "GL_RENDERBUFFER_RED_SIZE", "GL_RENDERBUFFER_GREEN_SIZE",
9029*35238bceSAndroid Build Coastguard Worker "GL_RENDERBUFFER_BLUE_SIZE", "GL_RENDERBUFFER_ALPHA_SIZE", "GL_RENDERBUFFER_DEPTH_SIZE",
9030*35238bceSAndroid Build Coastguard Worker "GL_RENDERBUFFER_STENCIL_SIZE"};
9031*35238bceSAndroid Build Coastguard Worker
9032*35238bceSAndroid Build Coastguard Worker for (glw::GLuint j = 0; j < internalformats_count; ++j)
9033*35238bceSAndroid Build Coastguard Worker {
9034*35238bceSAndroid Build Coastguard Worker glw::GLint parameter_legacy = 0;
9035*35238bceSAndroid Build Coastguard Worker glw::GLint parameter_dsa = 0;
9036*35238bceSAndroid Build Coastguard Worker
9037*35238bceSAndroid Build Coastguard Worker gl.getRenderbufferParameteriv(GL_RENDERBUFFER, pnames[j], ¶meter_legacy);
9038*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetRenderbufferParameteriv has failed");
9039*35238bceSAndroid Build Coastguard Worker
9040*35238bceSAndroid Build Coastguard Worker gl.getNamedRenderbufferParameteriv(renderbuffer, pnames[j], ¶meter_dsa);
9041*35238bceSAndroid Build Coastguard Worker
9042*35238bceSAndroid Build Coastguard Worker if (glw::GLenum error = gl.getError())
9043*35238bceSAndroid Build Coastguard Worker {
9044*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
9045*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "GetNamedRenderbufferParameteriv unexpectedly generated "
9046*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(error) << " error when called with " << pnames_strings[i]
9047*35238bceSAndroid Build Coastguard Worker << " parameter name of renderbuffer with internalformat = "
9048*35238bceSAndroid Build Coastguard Worker << glu::getInternalFormatParameterStr(internalformats[i]) << ", width = 1, height = 2."
9049*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
9050*35238bceSAndroid Build Coastguard Worker
9051*35238bceSAndroid Build Coastguard Worker is_ok = false;
9052*35238bceSAndroid Build Coastguard Worker
9053*35238bceSAndroid Build Coastguard Worker continue;
9054*35238bceSAndroid Build Coastguard Worker }
9055*35238bceSAndroid Build Coastguard Worker
9056*35238bceSAndroid Build Coastguard Worker if (parameter_legacy != parameter_dsa)
9057*35238bceSAndroid Build Coastguard Worker {
9058*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
9059*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "GetNamedRenderbufferParameteriv returned " << parameter_dsa
9060*35238bceSAndroid Build Coastguard Worker << ", but " << parameter_legacy << " was expected for " << pnames_strings[i]
9061*35238bceSAndroid Build Coastguard Worker << " parameter name of renderbuffer with internalformat = "
9062*35238bceSAndroid Build Coastguard Worker << glu::getInternalFormatParameterStr(internalformats[i]) << ", width = 1, height = 2."
9063*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
9064*35238bceSAndroid Build Coastguard Worker
9065*35238bceSAndroid Build Coastguard Worker is_ok = false;
9066*35238bceSAndroid Build Coastguard Worker }
9067*35238bceSAndroid Build Coastguard Worker }
9068*35238bceSAndroid Build Coastguard Worker
9069*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &renderbuffer);
9070*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glDeleteRenderbuffers has failed");
9071*35238bceSAndroid Build Coastguard Worker
9072*35238bceSAndroid Build Coastguard Worker renderbuffer = 0;
9073*35238bceSAndroid Build Coastguard Worker }
9074*35238bceSAndroid Build Coastguard Worker }
9075*35238bceSAndroid Build Coastguard Worker catch (...)
9076*35238bceSAndroid Build Coastguard Worker {
9077*35238bceSAndroid Build Coastguard Worker is_ok = false;
9078*35238bceSAndroid Build Coastguard Worker is_error = true;
9079*35238bceSAndroid Build Coastguard Worker }
9080*35238bceSAndroid Build Coastguard Worker
9081*35238bceSAndroid Build Coastguard Worker /* Clean up. */
9082*35238bceSAndroid Build Coastguard Worker if (renderbuffer)
9083*35238bceSAndroid Build Coastguard Worker {
9084*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &renderbuffer);
9085*35238bceSAndroid Build Coastguard Worker }
9086*35238bceSAndroid Build Coastguard Worker
9087*35238bceSAndroid Build Coastguard Worker while (gl.getError())
9088*35238bceSAndroid Build Coastguard Worker ;
9089*35238bceSAndroid Build Coastguard Worker
9090*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
9091*35238bceSAndroid Build Coastguard Worker if (is_ok)
9092*35238bceSAndroid Build Coastguard Worker {
9093*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
9094*35238bceSAndroid Build Coastguard Worker }
9095*35238bceSAndroid Build Coastguard Worker else
9096*35238bceSAndroid Build Coastguard Worker {
9097*35238bceSAndroid Build Coastguard Worker if (is_error)
9098*35238bceSAndroid Build Coastguard Worker {
9099*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
9100*35238bceSAndroid Build Coastguard Worker }
9101*35238bceSAndroid Build Coastguard Worker else
9102*35238bceSAndroid Build Coastguard Worker {
9103*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
9104*35238bceSAndroid Build Coastguard Worker }
9105*35238bceSAndroid Build Coastguard Worker }
9106*35238bceSAndroid Build Coastguard Worker
9107*35238bceSAndroid Build Coastguard Worker return STOP;
9108*35238bceSAndroid Build Coastguard Worker }
9109*35238bceSAndroid Build Coastguard Worker
9110*35238bceSAndroid Build Coastguard Worker /******************************** Renderbuffer Creation Errors Test Implementation ********************************/
9111*35238bceSAndroid Build Coastguard Worker
9112*35238bceSAndroid Build Coastguard Worker /** @brief Creation Errors Test constructor.
9113*35238bceSAndroid Build Coastguard Worker *
9114*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
9115*35238bceSAndroid Build Coastguard Worker */
CreationErrorsTest(deqp::Context & context)9116*35238bceSAndroid Build Coastguard Worker CreationErrorsTest::CreationErrorsTest(deqp::Context &context)
9117*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "renderbuffers_creation_errors", "Renderbuffer Objects Creation Errors Test")
9118*35238bceSAndroid Build Coastguard Worker {
9119*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
9120*35238bceSAndroid Build Coastguard Worker }
9121*35238bceSAndroid Build Coastguard Worker
9122*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Creation Test cases.
9123*35238bceSAndroid Build Coastguard Worker *
9124*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
9125*35238bceSAndroid Build Coastguard Worker */
iterate()9126*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult CreationErrorsTest::iterate()
9127*35238bceSAndroid Build Coastguard Worker {
9128*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
9129*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
9130*35238bceSAndroid Build Coastguard Worker
9131*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
9132*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
9133*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
9134*35238bceSAndroid Build Coastguard Worker
9135*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
9136*35238bceSAndroid Build Coastguard Worker {
9137*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
9138*35238bceSAndroid Build Coastguard Worker
9139*35238bceSAndroid Build Coastguard Worker return STOP;
9140*35238bceSAndroid Build Coastguard Worker }
9141*35238bceSAndroid Build Coastguard Worker
9142*35238bceSAndroid Build Coastguard Worker /* Running tests. */
9143*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
9144*35238bceSAndroid Build Coastguard Worker
9145*35238bceSAndroid Build Coastguard Worker /* Framebuffer object */
9146*35238bceSAndroid Build Coastguard Worker glw::GLuint renderbuffer = 0;
9147*35238bceSAndroid Build Coastguard Worker
9148*35238bceSAndroid Build Coastguard Worker /* Check direct state creation of negative numbers of framebuffers. */
9149*35238bceSAndroid Build Coastguard Worker gl.createRenderbuffers(-1, &renderbuffer);
9150*35238bceSAndroid Build Coastguard Worker
9151*35238bceSAndroid Build Coastguard Worker glw::GLenum error = GL_NO_ERROR;
9152*35238bceSAndroid Build Coastguard Worker
9153*35238bceSAndroid Build Coastguard Worker if (GL_INVALID_VALUE != (error = gl.getError()))
9154*35238bceSAndroid Build Coastguard Worker {
9155*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog()
9156*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::Message << "CreateRenderbuffers generated " << glu::getErrorStr(error)
9157*35238bceSAndroid Build Coastguard Worker << " error when called with negative number of renderbuffers, but GL_INVALID_VALUE was expected."
9158*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
9159*35238bceSAndroid Build Coastguard Worker
9160*35238bceSAndroid Build Coastguard Worker is_ok = false;
9161*35238bceSAndroid Build Coastguard Worker }
9162*35238bceSAndroid Build Coastguard Worker
9163*35238bceSAndroid Build Coastguard Worker /* Cleanup (sanity). */
9164*35238bceSAndroid Build Coastguard Worker if (renderbuffer)
9165*35238bceSAndroid Build Coastguard Worker {
9166*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &renderbuffer);
9167*35238bceSAndroid Build Coastguard Worker }
9168*35238bceSAndroid Build Coastguard Worker
9169*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
9170*35238bceSAndroid Build Coastguard Worker while (gl.getError())
9171*35238bceSAndroid Build Coastguard Worker ;
9172*35238bceSAndroid Build Coastguard Worker
9173*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
9174*35238bceSAndroid Build Coastguard Worker if (is_ok)
9175*35238bceSAndroid Build Coastguard Worker {
9176*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
9177*35238bceSAndroid Build Coastguard Worker }
9178*35238bceSAndroid Build Coastguard Worker else
9179*35238bceSAndroid Build Coastguard Worker {
9180*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
9181*35238bceSAndroid Build Coastguard Worker }
9182*35238bceSAndroid Build Coastguard Worker
9183*35238bceSAndroid Build Coastguard Worker return STOP;
9184*35238bceSAndroid Build Coastguard Worker }
9185*35238bceSAndroid Build Coastguard Worker
9186*35238bceSAndroid Build Coastguard Worker /******************************** Storage Errors Test Implementation ********************************/
9187*35238bceSAndroid Build Coastguard Worker
9188*35238bceSAndroid Build Coastguard Worker /** @brief Storage Errors Test constructor.
9189*35238bceSAndroid Build Coastguard Worker *
9190*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
9191*35238bceSAndroid Build Coastguard Worker */
StorageErrorsTest(deqp::Context & context)9192*35238bceSAndroid Build Coastguard Worker StorageErrorsTest::StorageErrorsTest(deqp::Context &context)
9193*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "renderbuffers_storage_errors", "Storage Errors Test")
9194*35238bceSAndroid Build Coastguard Worker , m_rbo_valid(0)
9195*35238bceSAndroid Build Coastguard Worker , m_rbo_invalid(0)
9196*35238bceSAndroid Build Coastguard Worker , m_internalformat_invalid(0)
9197*35238bceSAndroid Build Coastguard Worker {
9198*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
9199*35238bceSAndroid Build Coastguard Worker }
9200*35238bceSAndroid Build Coastguard Worker
9201*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Creation Test cases.
9202*35238bceSAndroid Build Coastguard Worker *
9203*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
9204*35238bceSAndroid Build Coastguard Worker */
iterate()9205*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult StorageErrorsTest::iterate()
9206*35238bceSAndroid Build Coastguard Worker {
9207*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
9208*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
9209*35238bceSAndroid Build Coastguard Worker
9210*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
9211*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
9212*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
9213*35238bceSAndroid Build Coastguard Worker
9214*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
9215*35238bceSAndroid Build Coastguard Worker {
9216*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
9217*35238bceSAndroid Build Coastguard Worker
9218*35238bceSAndroid Build Coastguard Worker return STOP;
9219*35238bceSAndroid Build Coastguard Worker }
9220*35238bceSAndroid Build Coastguard Worker
9221*35238bceSAndroid Build Coastguard Worker /* Running tests. */
9222*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
9223*35238bceSAndroid Build Coastguard Worker bool is_error = false;
9224*35238bceSAndroid Build Coastguard Worker
9225*35238bceSAndroid Build Coastguard Worker try
9226*35238bceSAndroid Build Coastguard Worker {
9227*35238bceSAndroid Build Coastguard Worker /* Prepare objects. */
9228*35238bceSAndroid Build Coastguard Worker PrepareObjects();
9229*35238bceSAndroid Build Coastguard Worker
9230*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_OPERATION is generated by NamedRenderbufferStorage if
9231*35238bceSAndroid Build Coastguard Worker renderbuffer is not the name of an existing renderbuffer object. */
9232*35238bceSAndroid Build Coastguard Worker gl.namedRenderbufferStorage(m_rbo_invalid, GL_RGBA8, 1, 1);
9233*35238bceSAndroid Build Coastguard Worker
9234*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedRenderbufferStorage",
9235*35238bceSAndroid Build Coastguard Worker "renderbuffer is not the name of an existing renderbuffer object.");
9236*35238bceSAndroid Build Coastguard Worker
9237*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_VALUE is generated by NamedRenderbufferStorage if
9238*35238bceSAndroid Build Coastguard Worker either of width or height is negative, or greater than the value of
9239*35238bceSAndroid Build Coastguard Worker MAX_RENDERBUFFER_SIZE. */
9240*35238bceSAndroid Build Coastguard Worker gl.namedRenderbufferStorage(m_rbo_valid, GL_RGBA8, -1, 1);
9241*35238bceSAndroid Build Coastguard Worker
9242*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_VALUE, "NamedRenderbufferStorage", "either of width is negative.");
9243*35238bceSAndroid Build Coastguard Worker
9244*35238bceSAndroid Build Coastguard Worker gl.namedRenderbufferStorage(m_rbo_valid, GL_RGBA8, 1, -1);
9245*35238bceSAndroid Build Coastguard Worker
9246*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_VALUE, "NamedRenderbufferStorage", "either of height is negative.");
9247*35238bceSAndroid Build Coastguard Worker
9248*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_ENUM is generated by NamedRenderbufferStorage if
9249*35238bceSAndroid Build Coastguard Worker internalformat is not a color-renderable, depth-renderable, or
9250*35238bceSAndroid Build Coastguard Worker stencil-renderable format. */
9251*35238bceSAndroid Build Coastguard Worker gl.namedRenderbufferStorage(m_rbo_valid, m_internalformat_invalid, 1, 1);
9252*35238bceSAndroid Build Coastguard Worker
9253*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, "NamedRenderbufferStorage",
9254*35238bceSAndroid Build Coastguard Worker "internalformat is not a color-renderable, "
9255*35238bceSAndroid Build Coastguard Worker "depth-renderable, or stencil-renderable "
9256*35238bceSAndroid Build Coastguard Worker "format (it is COMPRESSED_RED).");
9257*35238bceSAndroid Build Coastguard Worker }
9258*35238bceSAndroid Build Coastguard Worker catch (...)
9259*35238bceSAndroid Build Coastguard Worker {
9260*35238bceSAndroid Build Coastguard Worker is_ok = false;
9261*35238bceSAndroid Build Coastguard Worker is_error = true;
9262*35238bceSAndroid Build Coastguard Worker }
9263*35238bceSAndroid Build Coastguard Worker
9264*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
9265*35238bceSAndroid Build Coastguard Worker Clean();
9266*35238bceSAndroid Build Coastguard Worker
9267*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
9268*35238bceSAndroid Build Coastguard Worker if (is_ok)
9269*35238bceSAndroid Build Coastguard Worker {
9270*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
9271*35238bceSAndroid Build Coastguard Worker }
9272*35238bceSAndroid Build Coastguard Worker else
9273*35238bceSAndroid Build Coastguard Worker {
9274*35238bceSAndroid Build Coastguard Worker if (is_error)
9275*35238bceSAndroid Build Coastguard Worker {
9276*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
9277*35238bceSAndroid Build Coastguard Worker }
9278*35238bceSAndroid Build Coastguard Worker else
9279*35238bceSAndroid Build Coastguard Worker {
9280*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
9281*35238bceSAndroid Build Coastguard Worker }
9282*35238bceSAndroid Build Coastguard Worker }
9283*35238bceSAndroid Build Coastguard Worker
9284*35238bceSAndroid Build Coastguard Worker return STOP;
9285*35238bceSAndroid Build Coastguard Worker }
9286*35238bceSAndroid Build Coastguard Worker
9287*35238bceSAndroid Build Coastguard Worker /** Check Prepare test's GL objects.
9288*35238bceSAndroid Build Coastguard Worker */
PrepareObjects()9289*35238bceSAndroid Build Coastguard Worker void StorageErrorsTest::PrepareObjects()
9290*35238bceSAndroid Build Coastguard Worker {
9291*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
9292*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
9293*35238bceSAndroid Build Coastguard Worker
9294*35238bceSAndroid Build Coastguard Worker /* Valid objects. */
9295*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(1, &m_rbo_valid);
9296*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
9297*35238bceSAndroid Build Coastguard Worker
9298*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo_valid);
9299*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
9300*35238bceSAndroid Build Coastguard Worker
9301*35238bceSAndroid Build Coastguard Worker /* Invalid objects. */
9302*35238bceSAndroid Build Coastguard Worker while (gl.isRenderbuffer(++m_rbo_invalid))
9303*35238bceSAndroid Build Coastguard Worker ;
9304*35238bceSAndroid Build Coastguard Worker }
9305*35238bceSAndroid Build Coastguard Worker
9306*35238bceSAndroid Build Coastguard Worker /** Check if error is equal to the expected, log if not.
9307*35238bceSAndroid Build Coastguard Worker *
9308*35238bceSAndroid Build Coastguard Worker * @param [in] expected_error Error to be expected.
9309*35238bceSAndroid Build Coastguard Worker * @param [in] function Function name which is being tested (to be logged).
9310*35238bceSAndroid Build Coastguard Worker * @param [in] conditions Conditions when the expected error shall occure (to be logged).
9311*35238bceSAndroid Build Coastguard Worker *
9312*35238bceSAndroid Build Coastguard Worker * @return True if there is no error, false otherwise.
9313*35238bceSAndroid Build Coastguard Worker */
ExpectError(glw::GLenum expected_error,const glw::GLchar * function,const glw::GLchar * conditions)9314*35238bceSAndroid Build Coastguard Worker bool StorageErrorsTest::ExpectError(glw::GLenum expected_error, const glw::GLchar *function,
9315*35238bceSAndroid Build Coastguard Worker const glw::GLchar *conditions)
9316*35238bceSAndroid Build Coastguard Worker {
9317*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
9318*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
9319*35238bceSAndroid Build Coastguard Worker
9320*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
9321*35238bceSAndroid Build Coastguard Worker
9322*35238bceSAndroid Build Coastguard Worker glw::GLenum error = GL_NO_ERROR;
9323*35238bceSAndroid Build Coastguard Worker
9324*35238bceSAndroid Build Coastguard Worker if (expected_error != (error = gl.getError()))
9325*35238bceSAndroid Build Coastguard Worker {
9326*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog() << tcu::TestLog::Message << function << " was expected to generate "
9327*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(expected_error) << ", but " << glu::getErrorStr(error)
9328*35238bceSAndroid Build Coastguard Worker << " was observed instead when " << conditions << tcu::TestLog::EndMessage;
9329*35238bceSAndroid Build Coastguard Worker
9330*35238bceSAndroid Build Coastguard Worker is_ok = false;
9331*35238bceSAndroid Build Coastguard Worker }
9332*35238bceSAndroid Build Coastguard Worker
9333*35238bceSAndroid Build Coastguard Worker /* Clean additional possible errors. */
9334*35238bceSAndroid Build Coastguard Worker while (gl.getError())
9335*35238bceSAndroid Build Coastguard Worker ;
9336*35238bceSAndroid Build Coastguard Worker
9337*35238bceSAndroid Build Coastguard Worker return is_ok;
9338*35238bceSAndroid Build Coastguard Worker }
9339*35238bceSAndroid Build Coastguard Worker
9340*35238bceSAndroid Build Coastguard Worker /** @brief Clean up GL state.
9341*35238bceSAndroid Build Coastguard Worker */
Clean()9342*35238bceSAndroid Build Coastguard Worker void StorageErrorsTest::Clean()
9343*35238bceSAndroid Build Coastguard Worker {
9344*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
9345*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
9346*35238bceSAndroid Build Coastguard Worker
9347*35238bceSAndroid Build Coastguard Worker /* Release GL objects. */
9348*35238bceSAndroid Build Coastguard Worker if (m_rbo_valid)
9349*35238bceSAndroid Build Coastguard Worker {
9350*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &m_rbo_valid);
9351*35238bceSAndroid Build Coastguard Worker m_rbo_valid = 0;
9352*35238bceSAndroid Build Coastguard Worker }
9353*35238bceSAndroid Build Coastguard Worker
9354*35238bceSAndroid Build Coastguard Worker /* COmpressed internal formats are not color renderable (OpenGL 4.5 Core PRofile SPecification Chapter 9.4 )*/
9355*35238bceSAndroid Build Coastguard Worker m_internalformat_invalid = GL_COMPRESSED_RED;
9356*35238bceSAndroid Build Coastguard Worker
9357*35238bceSAndroid Build Coastguard Worker /* Set initial values - all test shall have the same environment. */
9358*35238bceSAndroid Build Coastguard Worker m_rbo_valid = 0;
9359*35238bceSAndroid Build Coastguard Worker m_rbo_invalid = 0;
9360*35238bceSAndroid Build Coastguard Worker
9361*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
9362*35238bceSAndroid Build Coastguard Worker while (gl.getError())
9363*35238bceSAndroid Build Coastguard Worker ;
9364*35238bceSAndroid Build Coastguard Worker }
9365*35238bceSAndroid Build Coastguard Worker
9366*35238bceSAndroid Build Coastguard Worker /******************************** Storage Multisample Errors Test Implementation ********************************/
9367*35238bceSAndroid Build Coastguard Worker
9368*35238bceSAndroid Build Coastguard Worker /** @brief Storage Errors Test constructor.
9369*35238bceSAndroid Build Coastguard Worker *
9370*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
9371*35238bceSAndroid Build Coastguard Worker */
StorageMultisampleErrorsTest(deqp::Context & context)9372*35238bceSAndroid Build Coastguard Worker StorageMultisampleErrorsTest::StorageMultisampleErrorsTest(deqp::Context &context)
9373*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "renderbuffers_storage_multisample_errors", "Storage Multisample Errors Test")
9374*35238bceSAndroid Build Coastguard Worker , m_rbo_valid(0)
9375*35238bceSAndroid Build Coastguard Worker , m_rbo_invalid(0)
9376*35238bceSAndroid Build Coastguard Worker , m_internalformat_invalid(0)
9377*35238bceSAndroid Build Coastguard Worker , m_max_samples(0)
9378*35238bceSAndroid Build Coastguard Worker , m_max_integer_samples(0)
9379*35238bceSAndroid Build Coastguard Worker {
9380*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
9381*35238bceSAndroid Build Coastguard Worker }
9382*35238bceSAndroid Build Coastguard Worker
9383*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Creation Test cases.
9384*35238bceSAndroid Build Coastguard Worker *
9385*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
9386*35238bceSAndroid Build Coastguard Worker */
iterate()9387*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult StorageMultisampleErrorsTest::iterate()
9388*35238bceSAndroid Build Coastguard Worker {
9389*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
9390*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
9391*35238bceSAndroid Build Coastguard Worker
9392*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
9393*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
9394*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
9395*35238bceSAndroid Build Coastguard Worker
9396*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
9397*35238bceSAndroid Build Coastguard Worker {
9398*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
9399*35238bceSAndroid Build Coastguard Worker
9400*35238bceSAndroid Build Coastguard Worker return STOP;
9401*35238bceSAndroid Build Coastguard Worker }
9402*35238bceSAndroid Build Coastguard Worker
9403*35238bceSAndroid Build Coastguard Worker /* Running tests. */
9404*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
9405*35238bceSAndroid Build Coastguard Worker bool is_error = false;
9406*35238bceSAndroid Build Coastguard Worker
9407*35238bceSAndroid Build Coastguard Worker try
9408*35238bceSAndroid Build Coastguard Worker {
9409*35238bceSAndroid Build Coastguard Worker /* Prepare objects. */
9410*35238bceSAndroid Build Coastguard Worker PrepareObjects();
9411*35238bceSAndroid Build Coastguard Worker
9412*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_OPERATION is generated by NamedRenderbufferStorage if
9413*35238bceSAndroid Build Coastguard Worker renderbuffer is not the name of an existing renderbuffer object. */
9414*35238bceSAndroid Build Coastguard Worker gl.namedRenderbufferStorageMultisample(m_rbo_invalid, 1, GL_RGBA8, 1, 1);
9415*35238bceSAndroid Build Coastguard Worker
9416*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedRenderbufferStorageMultisample",
9417*35238bceSAndroid Build Coastguard Worker "renderbuffer is not the name of an existing renderbuffer object.");
9418*35238bceSAndroid Build Coastguard Worker
9419*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_VALUE is generated by
9420*35238bceSAndroid Build Coastguard Worker NamedRenderbufferStorageMultisample if samples is greater than
9421*35238bceSAndroid Build Coastguard Worker the maximum number of SAMPLES reported for GL_RGBA8. */
9422*35238bceSAndroid Build Coastguard Worker gl.namedRenderbufferStorageMultisample(m_rbo_valid, m_max_samples + 1, GL_RGBA8, 1, 1);
9423*35238bceSAndroid Build Coastguard Worker
9424*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedRenderbufferStorageMultisample",
9425*35238bceSAndroid Build Coastguard Worker "samples is greater than MAX_SAMPLES.");
9426*35238bceSAndroid Build Coastguard Worker
9427*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_VALUE is generated by NamedRenderbufferStorage if
9428*35238bceSAndroid Build Coastguard Worker either of width or height is negative, or greater than the value of
9429*35238bceSAndroid Build Coastguard Worker MAX_RENDERBUFFER_SIZE. */
9430*35238bceSAndroid Build Coastguard Worker gl.namedRenderbufferStorageMultisample(m_rbo_valid, 1, GL_RGBA8, -1, 1);
9431*35238bceSAndroid Build Coastguard Worker
9432*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_VALUE, "NamedRenderbufferStorageMultisample", "either of width is negative.");
9433*35238bceSAndroid Build Coastguard Worker
9434*35238bceSAndroid Build Coastguard Worker gl.namedRenderbufferStorageMultisample(m_rbo_valid, 1, GL_RGBA8, 1, -1);
9435*35238bceSAndroid Build Coastguard Worker
9436*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_VALUE, "NamedRenderbufferStorageMultisample", "either of height is negative.");
9437*35238bceSAndroid Build Coastguard Worker
9438*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_OPERATION is generated by
9439*35238bceSAndroid Build Coastguard Worker NamedRenderbufferStorageMultisample if internalformat is a signed or
9440*35238bceSAndroid Build Coastguard Worker unsigned integer format and samples is greater than the maximum number
9441*35238bceSAndroid Build Coastguard Worker of samples reported for GL_RGB10_A2UI */
9442*35238bceSAndroid Build Coastguard Worker gl.namedRenderbufferStorageMultisample(m_rbo_valid, m_max_integer_samples + 1, GL_RGB10_A2UI, 1, 1);
9443*35238bceSAndroid Build Coastguard Worker
9444*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedRenderbufferStorageMultisample",
9445*35238bceSAndroid Build Coastguard Worker "internalformat is a signed or unsigned integer format and samples is greater than the "
9446*35238bceSAndroid Build Coastguard Worker "value of MAX_INTEGER_SAMPLES.");
9447*35238bceSAndroid Build Coastguard Worker
9448*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_ENUM is generated by NamedRenderbufferStorage if
9449*35238bceSAndroid Build Coastguard Worker internalformat is not a color-renderable, depth-renderable, or
9450*35238bceSAndroid Build Coastguard Worker stencil-renderable format. */
9451*35238bceSAndroid Build Coastguard Worker gl.namedRenderbufferStorageMultisample(m_rbo_valid, 1, m_internalformat_invalid, 1, 1);
9452*35238bceSAndroid Build Coastguard Worker
9453*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, "NamedRenderbufferStorageMultisample",
9454*35238bceSAndroid Build Coastguard Worker "internalformat is not a color-renderable, depth-renderable, or stencil-renderable format "
9455*35238bceSAndroid Build Coastguard Worker "(it is COMPRESSED_RED).");
9456*35238bceSAndroid Build Coastguard Worker }
9457*35238bceSAndroid Build Coastguard Worker catch (...)
9458*35238bceSAndroid Build Coastguard Worker {
9459*35238bceSAndroid Build Coastguard Worker is_ok = false;
9460*35238bceSAndroid Build Coastguard Worker is_error = true;
9461*35238bceSAndroid Build Coastguard Worker }
9462*35238bceSAndroid Build Coastguard Worker
9463*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
9464*35238bceSAndroid Build Coastguard Worker Clean();
9465*35238bceSAndroid Build Coastguard Worker
9466*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
9467*35238bceSAndroid Build Coastguard Worker if (is_ok)
9468*35238bceSAndroid Build Coastguard Worker {
9469*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
9470*35238bceSAndroid Build Coastguard Worker }
9471*35238bceSAndroid Build Coastguard Worker else
9472*35238bceSAndroid Build Coastguard Worker {
9473*35238bceSAndroid Build Coastguard Worker if (is_error)
9474*35238bceSAndroid Build Coastguard Worker {
9475*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
9476*35238bceSAndroid Build Coastguard Worker }
9477*35238bceSAndroid Build Coastguard Worker else
9478*35238bceSAndroid Build Coastguard Worker {
9479*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
9480*35238bceSAndroid Build Coastguard Worker }
9481*35238bceSAndroid Build Coastguard Worker }
9482*35238bceSAndroid Build Coastguard Worker
9483*35238bceSAndroid Build Coastguard Worker return STOP;
9484*35238bceSAndroid Build Coastguard Worker }
9485*35238bceSAndroid Build Coastguard Worker
9486*35238bceSAndroid Build Coastguard Worker /** Check Prepare test's GL objects.
9487*35238bceSAndroid Build Coastguard Worker */
PrepareObjects()9488*35238bceSAndroid Build Coastguard Worker void StorageMultisampleErrorsTest::PrepareObjects()
9489*35238bceSAndroid Build Coastguard Worker {
9490*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
9491*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
9492*35238bceSAndroid Build Coastguard Worker
9493*35238bceSAndroid Build Coastguard Worker /* Valid objects. */
9494*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(1, &m_rbo_valid);
9495*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
9496*35238bceSAndroid Build Coastguard Worker
9497*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo_valid);
9498*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
9499*35238bceSAndroid Build Coastguard Worker
9500*35238bceSAndroid Build Coastguard Worker /* Limits. */
9501*35238bceSAndroid Build Coastguard Worker gl.getInternalformativ(GL_RENDERBUFFER, GL_RGBA8, GL_SAMPLES, 1, &m_max_samples);
9502*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetInternalformativ has failed");
9503*35238bceSAndroid Build Coastguard Worker
9504*35238bceSAndroid Build Coastguard Worker gl.getInternalformativ(GL_RENDERBUFFER, GL_RGB10_A2UI, GL_SAMPLES, 1, &m_max_integer_samples);
9505*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetInternalformativ has failed");
9506*35238bceSAndroid Build Coastguard Worker
9507*35238bceSAndroid Build Coastguard Worker /* Invalid objects. */
9508*35238bceSAndroid Build Coastguard Worker while (gl.isRenderbuffer(++m_rbo_invalid))
9509*35238bceSAndroid Build Coastguard Worker ;
9510*35238bceSAndroid Build Coastguard Worker }
9511*35238bceSAndroid Build Coastguard Worker
9512*35238bceSAndroid Build Coastguard Worker /** Check if error is equal to the expected, log if not.
9513*35238bceSAndroid Build Coastguard Worker *
9514*35238bceSAndroid Build Coastguard Worker * @param [in] expected_error Error to be expected.
9515*35238bceSAndroid Build Coastguard Worker * @param [in] function Function name which is being tested (to be logged).
9516*35238bceSAndroid Build Coastguard Worker * @param [in] conditions Conditions when the expected error shall occure (to be logged).
9517*35238bceSAndroid Build Coastguard Worker *
9518*35238bceSAndroid Build Coastguard Worker * @return True if there is no error, false otherwise.
9519*35238bceSAndroid Build Coastguard Worker */
ExpectError(glw::GLenum expected_error,const glw::GLchar * function,const glw::GLchar * conditions)9520*35238bceSAndroid Build Coastguard Worker bool StorageMultisampleErrorsTest::ExpectError(glw::GLenum expected_error, const glw::GLchar *function,
9521*35238bceSAndroid Build Coastguard Worker const glw::GLchar *conditions)
9522*35238bceSAndroid Build Coastguard Worker {
9523*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
9524*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
9525*35238bceSAndroid Build Coastguard Worker
9526*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
9527*35238bceSAndroid Build Coastguard Worker
9528*35238bceSAndroid Build Coastguard Worker glw::GLenum error = GL_NO_ERROR;
9529*35238bceSAndroid Build Coastguard Worker
9530*35238bceSAndroid Build Coastguard Worker if (expected_error != (error = gl.getError()))
9531*35238bceSAndroid Build Coastguard Worker {
9532*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog() << tcu::TestLog::Message << function << " was expected to generate "
9533*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(expected_error) << ", but " << glu::getErrorStr(error)
9534*35238bceSAndroid Build Coastguard Worker << " was observed instead when " << conditions << tcu::TestLog::EndMessage;
9535*35238bceSAndroid Build Coastguard Worker
9536*35238bceSAndroid Build Coastguard Worker is_ok = false;
9537*35238bceSAndroid Build Coastguard Worker }
9538*35238bceSAndroid Build Coastguard Worker
9539*35238bceSAndroid Build Coastguard Worker /* Clean additional possible errors. */
9540*35238bceSAndroid Build Coastguard Worker while (gl.getError())
9541*35238bceSAndroid Build Coastguard Worker ;
9542*35238bceSAndroid Build Coastguard Worker
9543*35238bceSAndroid Build Coastguard Worker return is_ok;
9544*35238bceSAndroid Build Coastguard Worker }
9545*35238bceSAndroid Build Coastguard Worker
9546*35238bceSAndroid Build Coastguard Worker /** @brief Clean up GL state.
9547*35238bceSAndroid Build Coastguard Worker */
Clean()9548*35238bceSAndroid Build Coastguard Worker void StorageMultisampleErrorsTest::Clean()
9549*35238bceSAndroid Build Coastguard Worker {
9550*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
9551*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
9552*35238bceSAndroid Build Coastguard Worker
9553*35238bceSAndroid Build Coastguard Worker /* Release GL objects. */
9554*35238bceSAndroid Build Coastguard Worker if (m_rbo_valid)
9555*35238bceSAndroid Build Coastguard Worker {
9556*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &m_rbo_valid);
9557*35238bceSAndroid Build Coastguard Worker m_rbo_valid = 0;
9558*35238bceSAndroid Build Coastguard Worker }
9559*35238bceSAndroid Build Coastguard Worker
9560*35238bceSAndroid Build Coastguard Worker /* COmpressed internal formats are not color renderable (OpenGL 4.5 Core PRofile SPecification Chapter 9.4 )*/
9561*35238bceSAndroid Build Coastguard Worker m_internalformat_invalid = GL_COMPRESSED_RED;
9562*35238bceSAndroid Build Coastguard Worker
9563*35238bceSAndroid Build Coastguard Worker /* Set initial values - all test shall have the same environment. */
9564*35238bceSAndroid Build Coastguard Worker m_rbo_valid = 0;
9565*35238bceSAndroid Build Coastguard Worker m_rbo_invalid = 0;
9566*35238bceSAndroid Build Coastguard Worker m_max_samples = 0;
9567*35238bceSAndroid Build Coastguard Worker m_max_integer_samples = 0;
9568*35238bceSAndroid Build Coastguard Worker
9569*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
9570*35238bceSAndroid Build Coastguard Worker while (gl.getError())
9571*35238bceSAndroid Build Coastguard Worker ;
9572*35238bceSAndroid Build Coastguard Worker }
9573*35238bceSAndroid Build Coastguard Worker
9574*35238bceSAndroid Build Coastguard Worker /******************************** Get Parameter Errors Test Implementation ********************************/
9575*35238bceSAndroid Build Coastguard Worker
9576*35238bceSAndroid Build Coastguard Worker /** @brief Parameter Errors Test constructor.
9577*35238bceSAndroid Build Coastguard Worker *
9578*35238bceSAndroid Build Coastguard Worker * @param [in] context OpenGL context.
9579*35238bceSAndroid Build Coastguard Worker */
GetParameterErrorsTest(deqp::Context & context)9580*35238bceSAndroid Build Coastguard Worker GetParameterErrorsTest::GetParameterErrorsTest(deqp::Context &context)
9581*35238bceSAndroid Build Coastguard Worker : deqp::TestCase(context, "renderbuffers_get_parameters_errors", "Get Parameter Errors Test")
9582*35238bceSAndroid Build Coastguard Worker , m_rbo_valid(0)
9583*35238bceSAndroid Build Coastguard Worker , m_rbo_invalid(0)
9584*35238bceSAndroid Build Coastguard Worker , m_parameter_invalid(0)
9585*35238bceSAndroid Build Coastguard Worker {
9586*35238bceSAndroid Build Coastguard Worker /* Intentionally left blank. */
9587*35238bceSAndroid Build Coastguard Worker }
9588*35238bceSAndroid Build Coastguard Worker
9589*35238bceSAndroid Build Coastguard Worker /** @brief Iterate Parameter Errors Test cases.
9590*35238bceSAndroid Build Coastguard Worker *
9591*35238bceSAndroid Build Coastguard Worker * @return Iteration result.
9592*35238bceSAndroid Build Coastguard Worker */
iterate()9593*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult GetParameterErrorsTest::iterate()
9594*35238bceSAndroid Build Coastguard Worker {
9595*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
9596*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
9597*35238bceSAndroid Build Coastguard Worker
9598*35238bceSAndroid Build Coastguard Worker /* Get context setup. */
9599*35238bceSAndroid Build Coastguard Worker bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
9600*35238bceSAndroid Build Coastguard Worker bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
9601*35238bceSAndroid Build Coastguard Worker
9602*35238bceSAndroid Build Coastguard Worker if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
9603*35238bceSAndroid Build Coastguard Worker {
9604*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
9605*35238bceSAndroid Build Coastguard Worker
9606*35238bceSAndroid Build Coastguard Worker return STOP;
9607*35238bceSAndroid Build Coastguard Worker }
9608*35238bceSAndroid Build Coastguard Worker
9609*35238bceSAndroid Build Coastguard Worker /* Running tests. */
9610*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
9611*35238bceSAndroid Build Coastguard Worker bool is_error = false;
9612*35238bceSAndroid Build Coastguard Worker
9613*35238bceSAndroid Build Coastguard Worker try
9614*35238bceSAndroid Build Coastguard Worker {
9615*35238bceSAndroid Build Coastguard Worker /* Prepare objects. */
9616*35238bceSAndroid Build Coastguard Worker PrepareObjects();
9617*35238bceSAndroid Build Coastguard Worker
9618*35238bceSAndroid Build Coastguard Worker glw::GLint return_value_unused_storage;
9619*35238bceSAndroid Build Coastguard Worker
9620*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_OPERATION is generated by
9621*35238bceSAndroid Build Coastguard Worker GetNamedRenderbufferParameteriv if renderbuffer is not the name of an
9622*35238bceSAndroid Build Coastguard Worker existing renderbuffer object. */
9623*35238bceSAndroid Build Coastguard Worker gl.getNamedRenderbufferParameteriv(m_rbo_invalid, GL_RENDERBUFFER_WIDTH, &return_value_unused_storage);
9624*35238bceSAndroid Build Coastguard Worker
9625*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_OPERATION, "GetNamedRenderbufferParameteriv",
9626*35238bceSAndroid Build Coastguard Worker "renderbuffer is not the name of an existing renderbuffer object.");
9627*35238bceSAndroid Build Coastguard Worker
9628*35238bceSAndroid Build Coastguard Worker /* Check that INVALID_ENUM is generated by GetNamedRenderbufferParameteriv
9629*35238bceSAndroid Build Coastguard Worker if parameter name is not one of the accepted parameter names described
9630*35238bceSAndroid Build Coastguard Worker in specification. */
9631*35238bceSAndroid Build Coastguard Worker gl.getNamedRenderbufferParameteriv(m_rbo_valid, m_parameter_invalid, &return_value_unused_storage);
9632*35238bceSAndroid Build Coastguard Worker
9633*35238bceSAndroid Build Coastguard Worker is_ok &= ExpectError(GL_INVALID_ENUM, "GetNamedRenderbufferParameteriv",
9634*35238bceSAndroid Build Coastguard Worker "parameter name is not one of the accepted parameter names described in specification.");
9635*35238bceSAndroid Build Coastguard Worker }
9636*35238bceSAndroid Build Coastguard Worker catch (...)
9637*35238bceSAndroid Build Coastguard Worker {
9638*35238bceSAndroid Build Coastguard Worker is_ok = false;
9639*35238bceSAndroid Build Coastguard Worker is_error = true;
9640*35238bceSAndroid Build Coastguard Worker }
9641*35238bceSAndroid Build Coastguard Worker
9642*35238bceSAndroid Build Coastguard Worker /* Cleanup. */
9643*35238bceSAndroid Build Coastguard Worker Clean();
9644*35238bceSAndroid Build Coastguard Worker
9645*35238bceSAndroid Build Coastguard Worker /* Result's setup. */
9646*35238bceSAndroid Build Coastguard Worker if (is_ok)
9647*35238bceSAndroid Build Coastguard Worker {
9648*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
9649*35238bceSAndroid Build Coastguard Worker }
9650*35238bceSAndroid Build Coastguard Worker else
9651*35238bceSAndroid Build Coastguard Worker {
9652*35238bceSAndroid Build Coastguard Worker if (is_error)
9653*35238bceSAndroid Build Coastguard Worker {
9654*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
9655*35238bceSAndroid Build Coastguard Worker }
9656*35238bceSAndroid Build Coastguard Worker else
9657*35238bceSAndroid Build Coastguard Worker {
9658*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
9659*35238bceSAndroid Build Coastguard Worker }
9660*35238bceSAndroid Build Coastguard Worker }
9661*35238bceSAndroid Build Coastguard Worker
9662*35238bceSAndroid Build Coastguard Worker return STOP;
9663*35238bceSAndroid Build Coastguard Worker }
9664*35238bceSAndroid Build Coastguard Worker
9665*35238bceSAndroid Build Coastguard Worker /** Check Prepare test's GL objects.
9666*35238bceSAndroid Build Coastguard Worker */
PrepareObjects()9667*35238bceSAndroid Build Coastguard Worker void GetParameterErrorsTest::PrepareObjects()
9668*35238bceSAndroid Build Coastguard Worker {
9669*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
9670*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
9671*35238bceSAndroid Build Coastguard Worker
9672*35238bceSAndroid Build Coastguard Worker /* Valid objects. */
9673*35238bceSAndroid Build Coastguard Worker gl.genRenderbuffers(1, &m_rbo_valid);
9674*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
9675*35238bceSAndroid Build Coastguard Worker
9676*35238bceSAndroid Build Coastguard Worker gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo_valid);
9677*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
9678*35238bceSAndroid Build Coastguard Worker
9679*35238bceSAndroid Build Coastguard Worker /* Invalid parameter. */
9680*35238bceSAndroid Build Coastguard Worker bool is_parameter = true;
9681*35238bceSAndroid Build Coastguard Worker
9682*35238bceSAndroid Build Coastguard Worker while (is_parameter)
9683*35238bceSAndroid Build Coastguard Worker {
9684*35238bceSAndroid Build Coastguard Worker is_parameter = false;
9685*35238bceSAndroid Build Coastguard Worker
9686*35238bceSAndroid Build Coastguard Worker ++m_parameter_invalid;
9687*35238bceSAndroid Build Coastguard Worker
9688*35238bceSAndroid Build Coastguard Worker static const glw::GLenum valid_parameters[] = {GL_RENDERBUFFER_WIDTH, GL_RENDERBUFFER_HEIGHT,
9689*35238bceSAndroid Build Coastguard Worker GL_RENDERBUFFER_INTERNAL_FORMAT, GL_RENDERBUFFER_SAMPLES,
9690*35238bceSAndroid Build Coastguard Worker GL_RENDERBUFFER_RED_SIZE, GL_RENDERBUFFER_GREEN_SIZE,
9691*35238bceSAndroid Build Coastguard Worker GL_RENDERBUFFER_BLUE_SIZE, GL_RENDERBUFFER_ALPHA_SIZE,
9692*35238bceSAndroid Build Coastguard Worker GL_RENDERBUFFER_DEPTH_SIZE, GL_RENDERBUFFER_STENCIL_SIZE};
9693*35238bceSAndroid Build Coastguard Worker
9694*35238bceSAndroid Build Coastguard Worker static const glw::GLuint valid_parameters_count = sizeof(valid_parameters) / sizeof(valid_parameters[0]);
9695*35238bceSAndroid Build Coastguard Worker
9696*35238bceSAndroid Build Coastguard Worker for (glw::GLuint i = 0; i < valid_parameters_count; ++i)
9697*35238bceSAndroid Build Coastguard Worker {
9698*35238bceSAndroid Build Coastguard Worker if (valid_parameters[i] == m_parameter_invalid)
9699*35238bceSAndroid Build Coastguard Worker {
9700*35238bceSAndroid Build Coastguard Worker is_parameter = true;
9701*35238bceSAndroid Build Coastguard Worker }
9702*35238bceSAndroid Build Coastguard Worker }
9703*35238bceSAndroid Build Coastguard Worker }
9704*35238bceSAndroid Build Coastguard Worker
9705*35238bceSAndroid Build Coastguard Worker /* Invalid objects. */
9706*35238bceSAndroid Build Coastguard Worker while (gl.isRenderbuffer(++m_rbo_invalid))
9707*35238bceSAndroid Build Coastguard Worker ;
9708*35238bceSAndroid Build Coastguard Worker }
9709*35238bceSAndroid Build Coastguard Worker
9710*35238bceSAndroid Build Coastguard Worker /** Check if error is equal to the expected, log if not.
9711*35238bceSAndroid Build Coastguard Worker *
9712*35238bceSAndroid Build Coastguard Worker * @param [in] expected_error Error to be expected.
9713*35238bceSAndroid Build Coastguard Worker * @param [in] function Function name which is being tested (to be logged).
9714*35238bceSAndroid Build Coastguard Worker * @param [in] conditions Conditions when the expected error shall occure (to be logged).
9715*35238bceSAndroid Build Coastguard Worker *
9716*35238bceSAndroid Build Coastguard Worker * @return True if there is no error, false otherwise.
9717*35238bceSAndroid Build Coastguard Worker */
ExpectError(glw::GLenum expected_error,const glw::GLchar * function,const glw::GLchar * conditions)9718*35238bceSAndroid Build Coastguard Worker bool GetParameterErrorsTest::ExpectError(glw::GLenum expected_error, const glw::GLchar *function,
9719*35238bceSAndroid Build Coastguard Worker const glw::GLchar *conditions)
9720*35238bceSAndroid Build Coastguard Worker {
9721*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
9722*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
9723*35238bceSAndroid Build Coastguard Worker
9724*35238bceSAndroid Build Coastguard Worker bool is_ok = true;
9725*35238bceSAndroid Build Coastguard Worker
9726*35238bceSAndroid Build Coastguard Worker glw::GLenum error = GL_NO_ERROR;
9727*35238bceSAndroid Build Coastguard Worker
9728*35238bceSAndroid Build Coastguard Worker if (expected_error != (error = gl.getError()))
9729*35238bceSAndroid Build Coastguard Worker {
9730*35238bceSAndroid Build Coastguard Worker m_context.getTestContext().getLog() << tcu::TestLog::Message << function << " was expected to generate "
9731*35238bceSAndroid Build Coastguard Worker << glu::getErrorStr(expected_error) << ", but " << glu::getErrorStr(error)
9732*35238bceSAndroid Build Coastguard Worker << " was observed instead when " << conditions << tcu::TestLog::EndMessage;
9733*35238bceSAndroid Build Coastguard Worker
9734*35238bceSAndroid Build Coastguard Worker is_ok = false;
9735*35238bceSAndroid Build Coastguard Worker }
9736*35238bceSAndroid Build Coastguard Worker
9737*35238bceSAndroid Build Coastguard Worker /* Clean additional possible errors. */
9738*35238bceSAndroid Build Coastguard Worker while (gl.getError())
9739*35238bceSAndroid Build Coastguard Worker ;
9740*35238bceSAndroid Build Coastguard Worker
9741*35238bceSAndroid Build Coastguard Worker return is_ok;
9742*35238bceSAndroid Build Coastguard Worker }
9743*35238bceSAndroid Build Coastguard Worker
9744*35238bceSAndroid Build Coastguard Worker /** @brief Clean up GL state.
9745*35238bceSAndroid Build Coastguard Worker */
Clean()9746*35238bceSAndroid Build Coastguard Worker void GetParameterErrorsTest::Clean()
9747*35238bceSAndroid Build Coastguard Worker {
9748*35238bceSAndroid Build Coastguard Worker /* Shortcut for GL functionality. */
9749*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
9750*35238bceSAndroid Build Coastguard Worker
9751*35238bceSAndroid Build Coastguard Worker /* Release GL objects. */
9752*35238bceSAndroid Build Coastguard Worker if (m_rbo_valid)
9753*35238bceSAndroid Build Coastguard Worker {
9754*35238bceSAndroid Build Coastguard Worker gl.deleteRenderbuffers(1, &m_rbo_valid);
9755*35238bceSAndroid Build Coastguard Worker m_rbo_valid = 0;
9756*35238bceSAndroid Build Coastguard Worker }
9757*35238bceSAndroid Build Coastguard Worker
9758*35238bceSAndroid Build Coastguard Worker /* Set initial values - all test shall have the same environment. */
9759*35238bceSAndroid Build Coastguard Worker m_rbo_valid = 0;
9760*35238bceSAndroid Build Coastguard Worker m_rbo_invalid = 0;
9761*35238bceSAndroid Build Coastguard Worker
9762*35238bceSAndroid Build Coastguard Worker /* Errors clean up. */
9763*35238bceSAndroid Build Coastguard Worker while (gl.getError())
9764*35238bceSAndroid Build Coastguard Worker ;
9765*35238bceSAndroid Build Coastguard Worker }
9766*35238bceSAndroid Build Coastguard Worker
9767*35238bceSAndroid Build Coastguard Worker } // namespace Renderbuffers
9768*35238bceSAndroid Build Coastguard Worker } // namespace DirectStateAccess
9769*35238bceSAndroid Build Coastguard Worker } // namespace gl4cts
9770