1 /*-------------------------------------------------------------------------
2 * OpenGL Conformance Test Suite
3 * -----------------------------
5 * Copyright (c) 2015-2016 The Khronos Group Inc.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 */ /*-------------------------------------------------------------------*/
26 * \file gl4cDirectStateAccessFramebuffersAndRenderbuffersTests.cpp
27 * \brief Conformance tests for the Direct State Access feature functionality (Framebuffers and Renderbuffer access part).
28 */ /*------------------------------------------------------------------------------------------------------------------------*/
31 #include "gl4cDirectStateAccessTests.hpp"
33 #include "deSharedPtr.hpp"
35 #include "gluContextInfo.hpp"
36 #include "gluDefs.hpp"
37 #include "gluPixelTransfer.hpp"
38 #include "gluStrUtil.hpp"
40 #include "tcuFuzzyImageCompare.hpp"
41 #include "tcuImageCompare.hpp"
42 #include "tcuRenderTarget.hpp"
43 #include "tcuSurface.hpp"
44 #include "tcuTestLog.hpp"
47 #include "glwFunctions.hpp"
60 namespace DirectStateAccess
62 namespace Framebuffers
64 /******************************** Framebuffer Creation Test Implementation ********************************/
66 /** @brief Creation Test constructor.
68 * @param [in] context OpenGL context.
70 CreationTest::CreationTest(deqp::Context& context)
71 : deqp::TestCase(context, "framebuffers_creation", "Framebuffer Objects Creation Test")
73 /* Intentionally left blank. */
76 /** @brief Iterate Creation Test cases.
78 * @return Iteration result.
80 tcu::TestNode::IterateResult CreationTest::iterate()
82 /* Shortcut for GL functionality. */
83 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
85 /* Get context setup. */
86 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
87 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
89 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
91 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
98 bool is_error = false;
100 /* Framebuffers' objects */
101 static const glw::GLuint framebuffers_count = 2;
103 glw::GLuint framebuffers_legacy[framebuffers_count] = {};
104 glw::GLuint framebuffers_dsa[framebuffers_count] = {};
108 /* Check legacy state creation. */
109 gl.genFramebuffers(framebuffers_count, framebuffers_legacy);
110 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
112 for (glw::GLuint i = 0; i < framebuffers_count; ++i)
114 if (gl.isFramebuffer(framebuffers_legacy[i]))
119 m_context.getTestContext().getLog()
120 << tcu::TestLog::Message
121 << "GenFramebuffers has created default objects, but it should create only a names."
122 << tcu::TestLog::EndMessage;
126 /* Check direct state creation. */
127 gl.createFramebuffers(framebuffers_count, framebuffers_dsa);
128 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateFramebuffers has failed");
130 for (glw::GLuint i = 0; i < framebuffers_count; ++i)
132 if (!gl.isFramebuffer(framebuffers_dsa[i]))
137 m_context.getTestContext().getLog() << tcu::TestLog::Message
138 << "CreateFramebuffers has not created default objects."
139 << tcu::TestLog::EndMessage;
150 for (glw::GLuint i = 0; i < framebuffers_count; ++i)
152 if (framebuffers_legacy[i])
154 gl.deleteFramebuffers(1, &framebuffers_legacy[i]);
156 framebuffers_legacy[i] = 0;
159 if (framebuffers_dsa[i])
161 gl.deleteFramebuffers(1, &framebuffers_dsa[i]);
163 framebuffers_dsa[i] = 0;
167 /* Errors clean up. */
168 while (gl.getError())
171 /* Result's setup. */
174 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
180 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
184 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
191 /******************************** Framebuffer Renderbuffer Attachment Test Implementation ********************************/
193 /** @brief Framebuffer Renderbuffer Attachment Test constructor.
195 * @param [in] context OpenGL context.
197 RenderbufferAttachmentTest::RenderbufferAttachmentTest(deqp::Context& context)
198 : deqp::TestCase(context, "framebuffers_renderbuffer_attachment", "Framebuffer Renderbuffer Attachment Test")
202 /* Intentionally left blank. */
205 /** @brief Iterate Framebuffer Renderbuffer Attachment Test cases.
207 * @return Iteration result.
209 tcu::TestNode::IterateResult RenderbufferAttachmentTest::iterate()
211 /* Shortcut for GL functionality. */
212 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
214 /* Get context setup. */
215 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
216 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
218 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
220 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
227 bool is_error = false;
231 glw::GLint max_color_attachments = 8 /* Specification minimum OpenGL 4.5 Core Profile p. 627 */;
233 gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
234 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
236 for (glw::GLint i = 0; i < max_color_attachments; ++i)
238 is_ok &= Test(GL_COLOR_ATTACHMENT0 + i, GL_RGBA8);
242 is_ok &= Test(GL_DEPTH_ATTACHMENT, GL_DEPTH_COMPONENT24);
245 is_ok &= Test(GL_STENCIL_ATTACHMENT, GL_STENCIL_INDEX8);
248 is_ok &= Test(GL_DEPTH_STENCIL_ATTACHMENT, GL_DEPTH24_STENCIL8);
260 /* Result's setup. */
263 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
269 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
273 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
280 /** @brief Test functionality.
282 * @param [in] attachment Framebuffer attachment.
283 * @param [in] internalformat Internal format.
285 * @return True if test succeeded, false otherwise.
287 bool RenderbufferAttachmentTest::Test(glw::GLenum attachment, glw::GLenum internalformat)
289 /* Shortcut for GL functionality. */
290 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
293 gl.genRenderbuffers(1, &m_rbo);
294 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
296 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo);
297 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer has failed");
299 gl.renderbufferStorage(GL_RENDERBUFFER, internalformat, 1, 1);
300 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
302 gl.bindRenderbuffer(GL_RENDERBUFFER, 0);
303 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer has failed");
306 gl.createFramebuffers(1, &m_fbo);
307 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateFramebuffers has failed");
309 gl.namedFramebufferRenderbuffer(m_fbo, attachment, GL_RENDERBUFFER, m_rbo);
311 if (glw::GLenum error = gl.getError())
313 m_context.getTestContext().getLog() << tcu::TestLog::Message << "NamedFramebufferRenderbuffer for "
314 << glu::getFramebufferAttachmentStr(attachment)
315 << " attachment failed with error value " << glu::getErrorStr(error) << "."
316 << tcu::TestLog::EndMessage;
321 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
322 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
324 glw::GLenum status = gl.checkFramebufferStatus(GL_FRAMEBUFFER);
326 if (GL_FRAMEBUFFER_COMPLETE != status)
328 m_context.getTestContext().getLog()
329 << tcu::TestLog::Message << "Named Framebuffer Renderbuffer Attachment test failed because of framebuffer "
330 << glu::getFramebufferStatusStr(status) << " with renderbuffer set up as "
331 << glu::getFramebufferAttachmentStr(attachment) << " attachment." << tcu::TestLog::EndMessage;
339 /** @brief Clean up GL state.
341 void RenderbufferAttachmentTest::Clean()
343 /* Shortcut for GL functionality. */
344 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
349 gl.deleteFramebuffers(1, &m_fbo);
356 gl.deleteRenderbuffers(1, &m_rbo);
361 /* Errors clean up. */
362 while (gl.getError())
366 /******************************** Framebuffer Texture Attachment Test Implementation ********************************/
368 /** @brief Creation Test constructor.
370 * @param [in] context OpenGL context.
372 TextureAttachmentTest::TextureAttachmentTest(deqp::Context& context)
373 : deqp::TestCase(context, "framebuffers_texture_attachment", "Framebuffer Texture Attachment Test")
377 /* Intentionally left blank. */
380 /** @brief Iterate Creation Test cases.
382 * @return Iteration result.
384 tcu::TestNode::IterateResult TextureAttachmentTest::iterate()
386 /* Shortcut for GL functionality. */
387 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
389 /* Get context setup. */
390 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
391 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
393 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
395 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
402 bool is_error = false;
406 glw::GLint max_color_attachments = 8 /* Specification minimum OpenGL 4.5 Core Profile p. 627 */;
408 gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
409 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
411 for (glw::GLuint i = 0; i < s_targets_count; ++i)
413 for (glw::GLuint j = 1; j <= MaxTextureLevels(s_targets[i]); ++j)
415 for (glw::GLint k = 0; k < max_color_attachments; ++k)
417 is_ok &= Test(GL_COLOR_ATTACHMENT0 + k, true, s_targets[i], GL_RGBA8, j);
421 is_ok &= Test(GL_DEPTH_ATTACHMENT, false, s_targets[i], GL_DEPTH_COMPONENT24, j);
424 is_ok &= Test(GL_STENCIL_ATTACHMENT, false, s_targets[i], GL_STENCIL_INDEX8, j);
427 is_ok &= Test(GL_DEPTH_STENCIL_ATTACHMENT, false, s_targets[i], GL_DEPTH24_STENCIL8, j);
441 /* Result's setup. */
444 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
450 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
454 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
461 /** @brief Test functionality.
463 * @param [in] attachment Framebuffer attachment.
464 * @param [in] is_color_attachment Is color attachment tested.
465 * @param [in] texture_target Texture target.
466 * @param [in] internalformat Internal format ot be tested.
467 * @param [in] levels Number of levels.
469 * @return True if test succeeded, false otherwise.
471 bool TextureAttachmentTest::Test(glw::GLenum attachment, bool is_color_attachment, glw::GLenum texture_target,
472 glw::GLenum internalformat, glw::GLuint levels)
474 /* Shortcut for GL functionality. */
475 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
478 gl.genTextures(1, &m_to);
479 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
481 gl.bindTexture(texture_target, m_to);
482 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
484 if (GL_TEXTURE_2D_MULTISAMPLE == texture_target)
486 gl.texStorage2DMultisample(texture_target, 1, internalformat, (glw::GLuint)std::pow((double)2, (double)levels),
487 (glw::GLuint)std::pow((double)2, (double)levels), GL_FALSE);
488 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
492 gl.texStorage2D(texture_target, levels, internalformat, (glw::GLuint)std::pow((double)2, (double)levels),
493 (glw::GLuint)std::pow((double)2, (double)levels));
494 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
497 gl.bindTexture(texture_target, 0);
498 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer has failed");
501 gl.createFramebuffers(1, &m_fbo);
502 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateFramebuffers has failed");
504 for (glw::GLuint i = 0; i < levels; ++i)
506 gl.namedFramebufferTexture(m_fbo, attachment, m_to, i);
508 SubTestAttachmentError(attachment, texture_target, i, levels);
510 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
511 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
513 if (is_color_attachment)
515 gl.drawBuffer(attachment);
516 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawBuffer has failed");
518 gl.readBuffer(attachment);
519 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadBuffer has failed");
522 SubTestStatus(attachment, texture_target, i, levels);
524 if (GL_TEXTURE_2D_MULTISAMPLE != texture_target)
528 if (!SubTestContent(attachment, texture_target, internalformat, i, levels))
534 gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
535 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
541 /** @brief Check error and log.
543 * @param [in] attachment Framebuffer attachment.
544 * @param [in] texture_target Texture target.
545 * @param [in] level Tested level.
546 * @param [in] levels Number of levels.
548 * @return True if no error, false otherwise.
550 bool TextureAttachmentTest::SubTestAttachmentError(glw::GLenum attachment, glw::GLenum texture_target,
551 glw::GLuint level, glw::GLuint levels)
553 /* Shortcut for GL functionality. */
554 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
556 if (glw::GLenum error = gl.getError())
558 m_context.getTestContext().getLog()
559 << tcu::TestLog::Message << "NamedFramebufferTexture for " << glu::getFramebufferAttachmentStr(attachment)
560 << " attachment of " << glu::getTextureTargetStr(texture_target) << " texture and texture level " << level
561 << " of texture with " << levels << " levels failed with error value " << glu::getErrorStr(error) << "."
562 << tcu::TestLog::EndMessage;
570 /** @brief Check status and log.
572 * @param [in] attachment Framebuffer attachment.
573 * @param [in] texture_target Texture target.
574 * @param [in] level Tested level.
575 * @param [in] levels Number of levels.
577 * @return True if FRAMEBUFFER_COMPLETE, false otherwise.
579 bool TextureAttachmentTest::SubTestStatus(glw::GLenum attachment, glw::GLenum texture_target, glw::GLuint level,
582 /* Shortcut for GL functionality. */
583 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
585 glw::GLenum status = gl.checkFramebufferStatus(GL_FRAMEBUFFER);
587 if (GL_FRAMEBUFFER_COMPLETE != status)
589 m_context.getTestContext().getLog()
590 << tcu::TestLog::Message << "Named Framebuffer Texture Attachment test failed because of framebuffer "
591 << glu::getFramebufferStatusStr(status) << " status with " << glu::getTextureTargetStr(texture_target)
592 << " texture set up as " << glu::getFramebufferAttachmentStr(attachment) << " attachment and texture level "
593 << level << " of texture with " << levels << " levels." << tcu::TestLog::EndMessage;
601 /** @brief Check framebuffer content and log.
603 * @param [in] attachment Framebuffer attachment.
604 * @param [in] texture_target Texture target.
605 * @param [in] internalformat Tested internal format.
606 * @param [in] level Tested level.
607 * @param [in] levels Number of levels.
609 * @return True if FRAMEBUFFER_COMPLETE, false otherwise.
611 bool TextureAttachmentTest::SubTestContent(glw::GLenum attachment, glw::GLenum texture_target,
612 glw::GLenum internalformat, glw::GLuint level, glw::GLuint levels)
614 /* Shortcut for GL functionality. */
615 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
617 /* Check framebuffer's color content. */
618 if (GL_RGBA8 == internalformat)
620 glw::GLfloat color[4] = { 0.f };
622 gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_FLOAT, color);
623 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
625 for (int i = 0; i < 4 /* color components */; ++i)
627 if (de::abs(s_reference_color[i] - color[i]) > 0.0625 /* precision */)
629 m_context.getTestContext().getLog()
630 << tcu::TestLog::Message << "Named Framebuffer Texture Layer Attachment test failed with "
631 << glu::getTextureTargetStr(texture_target) << " texture set up as "
632 << glu::getFramebufferAttachmentStr(attachment) << " attachment and texture level " << level
633 << " of texture with " << levels << " levels. The color content of the framebuffer was ["
634 << color[0] << ", " << color[1] << ", " << color[2] << ", " << color[3] << "], but ["
635 << s_reference_color[0] << ", " << s_reference_color[1] << ", " << s_reference_color[2] << ", "
636 << s_reference_color[3] << "] was expected." << tcu::TestLog::EndMessage;
643 /* Check framebuffer's depth content. */
644 if ((GL_DEPTH_COMPONENT24 == internalformat) || (GL_DEPTH24_STENCIL8 == internalformat))
646 glw::GLfloat depth = 0.f;
648 gl.readPixels(0, 0, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
649 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
651 if (de::abs(s_reference_depth - depth) > 0.0625 /* precision */)
653 m_context.getTestContext().getLog()
654 << tcu::TestLog::Message << "Named Framebuffer Texture Layer Attachment test failed "
655 << "with texture set up as " << glu::getFramebufferAttachmentStr(attachment)
656 << " attachment and texture level " << level << " of texture with " << levels
657 << " levels. The depth content of the framebuffer was [" << depth << "], but [" << s_reference_depth
658 << "] was expected." << tcu::TestLog::EndMessage;
664 /* Check framebuffer's stencil content. */
665 if ((GL_STENCIL_INDEX8 == internalformat) || (GL_DEPTH24_STENCIL8 == internalformat))
667 glw::GLint stencil = 0;
669 gl.readPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_INT, &stencil);
670 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
672 if (s_reference_stencil != stencil)
674 m_context.getTestContext().getLog()
675 << tcu::TestLog::Message << "Named Framebuffer Texture Layer Attachment test failed "
676 << "with texture set up as " << glu::getFramebufferAttachmentStr(attachment)
677 << " attachment and texture level " << level << " of texture with " << levels
678 << " levels. The stencil content of the framebuffer was [" << stencil << "], but ["
679 << s_reference_stencil << "] was expected." << tcu::TestLog::EndMessage;
688 /** @brief Query max texture levels.
690 * @param [in] texture_target Texture target.
692 * @return Max texture levels.
694 glw::GLuint TextureAttachmentTest::MaxTextureLevels(glw::GLenum texture_target)
696 /* Shortcut for GL functionality. */
697 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
699 glw::GLint max_texture_size = 1024 /* Specification default. */;
701 switch (texture_target)
703 case GL_TEXTURE_RECTANGLE:
704 case GL_TEXTURE_2D_MULTISAMPLE:
708 gl.getIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size);
709 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
711 return (glw::GLuint)std::log((double)max_texture_size);
713 case GL_TEXTURE_CUBE_MAP:
714 gl.getIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &max_texture_size);
715 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
717 return (glw::GLuint)std::log((double)max_texture_size);
723 /* For compiler warnings only. */
727 /** @brief Clear texture.
729 void TextureAttachmentTest::Clear()
731 /* Shortcut for GL functionality. */
732 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
734 /* Setup clear values. */
735 gl.clearColor(s_reference_color[0], s_reference_color[1], s_reference_color[2], s_reference_color[3]);
736 gl.clearDepth(s_reference_depth);
737 gl.clearStencil(s_reference_stencil);
740 gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
743 /** @brief Clean up GL state.
745 void TextureAttachmentTest::Clean()
747 /* Shortcut for GL functionality. */
748 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
753 gl.deleteFramebuffers(1, &m_fbo);
760 gl.deleteTextures(1, &m_to);
765 /* Returning to default clear values. */
766 gl.clearColor(0.f, 0.f, 0.f, 0.f);
770 /* Errors clean up. */
771 while (gl.getError())
775 /** Tested targets. */
776 const glw::GLenum TextureAttachmentTest::s_targets[] = { GL_TEXTURE_RECTANGLE, GL_TEXTURE_2D, GL_TEXTURE_2D_MULTISAMPLE,
777 GL_TEXTURE_CUBE_MAP };
779 /** Tested targets count. */
780 const glw::GLuint TextureAttachmentTest::s_targets_count = sizeof(s_targets) / sizeof(s_targets[0]);
782 const glw::GLfloat TextureAttachmentTest::s_reference_color[4] = { 0.25, 0.5, 0.75, 1.0 }; //!< Reference color.
783 const glw::GLint TextureAttachmentTest::s_reference_color_integer[4] = { 1, 2, 3,
784 4 }; //!< Reference color for integer format.
785 const glw::GLfloat TextureAttachmentTest::s_reference_depth = 0.5; //!< Reference depth value.
786 const glw::GLint TextureAttachmentTest::s_reference_stencil = 7; //!< Reference stencil value.
788 /******************************** Framebuffer Texture Layer Attachment Test Implementation ********************************/
790 /** @brief Framebuffer Texture Layer Attachment Test constructor.
792 * @param [in] context OpenGL context.
794 TextureLayerAttachmentTest::TextureLayerAttachmentTest(deqp::Context& context)
795 : deqp::TestCase(context, "framebuffers_texture_layer_attachment", "Framebuffer Texture Layer Attachment Test")
799 /* Intentionally left blank. */
802 /** @brief Iterate Framebuffer Texture Layer Attachment Test cases.
804 * @return Iteration result.
806 tcu::TestNode::IterateResult TextureLayerAttachmentTest::iterate()
808 /* Shortcut for GL functionality. */
809 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
811 /* Get context setup. */
812 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
813 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
815 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
817 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
824 bool is_error = false;
828 glw::GLint max_color_attachments = 8 /* Specification minimum OpenGL 4.5 Core Profile p. 627 */;
830 gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
831 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
833 for (glw::GLuint i = 0; i < s_targets_count; ++i)
835 glw::GLuint layers_counts[] = { (GL_TEXTURE_CUBE_MAP_ARRAY == (glw::GLuint)s_targets[i]) ? 6u : 1u,
836 (GL_TEXTURE_CUBE_MAP_ARRAY == (glw::GLuint)s_targets[i]) ? 192u : 192u,
837 MaxTextureLayers(s_targets[i]) };
839 glw::GLuint layers_counts_count = sizeof(layers_counts) / sizeof(layers_counts[0]);
841 for (glw::GLuint j = 1; j <= MaxTextureLevels(s_targets[i]); ++j)
843 for (glw::GLuint k = 0; k < layers_counts_count; ++k)
845 for (glw::GLint l = 0; l < max_color_attachments; ++l)
847 is_ok &= Test(GL_COLOR_ATTACHMENT0 + l, true, s_targets[i], GL_RGBA8, j, layers_counts[k]);
851 if (GL_TEXTURE_3D != s_targets[i])
854 Test(GL_DEPTH_ATTACHMENT, false, s_targets[i], GL_DEPTH_COMPONENT24, j, layers_counts[k]);
857 is_ok &= Test(GL_DEPTH_STENCIL_ATTACHMENT, false, s_targets[i], GL_DEPTH24_STENCIL8, j,
862 Test(GL_STENCIL_ATTACHMENT, false, s_targets[i], GL_STENCIL_INDEX8, j, layers_counts[k]);
878 /* Result's setup. */
881 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
887 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
891 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
898 /** @brief Test texture layer attachment.
900 * @param [in] attachment Framebuffer attachment.
901 * @param [in] is_color_attachment Is color attachment tested.
902 * @param [in] texture_target Texture target.
903 * @param [in] internalformat Tested internal format.
904 * @param [in] level Tested level.
905 * @param [in] levels Number of levels.
906 * @param [in] layers Number of layers.
908 * @return True if test succeeded, false otherwise.
910 bool TextureLayerAttachmentTest::Test(glw::GLenum attachment, bool is_color_attachment, glw::GLenum texture_target,
911 glw::GLenum internalformat, glw::GLuint levels, glw::GLint layers)
913 /* Shortcut for GL functionality. */
914 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
917 gl.genTextures(1, &m_to);
918 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
920 gl.bindTexture(texture_target, m_to);
921 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
923 // Lower the layers count when multiple levels are requested to limit the amount of memory required
924 layers = deMax32(1, (glw::GLint)((deUint64)layers / (1ull<<(deUint64)(2*(levels-1)))));
925 if (GL_TEXTURE_CUBE_MAP_ARRAY == texture_target)
927 layers = deMax32(6, (layers / 6) * 6);
930 if (GL_TEXTURE_2D_MULTISAMPLE_ARRAY == texture_target)
932 gl.texStorage3DMultisample(texture_target, 1, internalformat, (glw::GLuint)std::pow((double)2, (double)levels),
933 (glw::GLuint)std::pow((double)2, (double)levels), layers, GL_FALSE);
934 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
938 gl.texStorage3D(texture_target, levels, internalformat, (glw::GLuint)std::pow((double)2, (double)levels),
939 (glw::GLuint)std::pow((double)2, (double)levels), layers);
940 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
943 gl.bindTexture(texture_target, 0);
944 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer has failed");
947 gl.createFramebuffers(1, &m_fbo);
948 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateFramebuffers has failed");
950 for (glw::GLuint i = 0; i < levels; ++i)
955 /* 3D textures are mipmapped also in depth directio, so number of layers to be tested must be limited. */
956 glw::GLuint layers_at_level = (GL_TEXTURE_3D == texture_target) ?
957 (de::min(layers, layers / (glw::GLint)std::pow(2.0, (double)i))) :
960 while (j < layers_at_level) /* Only layers with Fibonacci number index are tested to reduce the test time. */
962 /* Attach texture layer. */
963 gl.namedFramebufferTextureLayer(m_fbo, attachment, m_to, i, j);
965 if (!SubTestAttachmentError(attachment, texture_target, i, j, levels, layers))
970 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
971 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
973 if (is_color_attachment)
975 gl.drawBuffer(attachment);
976 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawBuffer has failed");
978 gl.readBuffer(attachment);
979 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadBuffer has failed");
982 if (!SubTestStatus(attachment, texture_target, i, j, levels, layers))
987 if (GL_TEXTURE_2D_MULTISAMPLE_ARRAY != texture_target)
991 if (!SubTestContent(attachment, texture_target, internalformat, i, j, levels, layers))
997 gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
998 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
1000 /* Fibonacci number iteration. */
1010 /** @brief Check error and log.
1012 * @param [in] attachment Framebuffer attachment.
1013 * @param [in] texture_target Texture target.
1014 * @param [in] level Tested level.
1015 * @param [in] layer Tested layer.
1016 * @param [in] levels Number of levels.
1017 * @param [in] layers Number of layers.
1019 * @return True if no error, false otherwise.
1021 bool TextureLayerAttachmentTest::SubTestAttachmentError(glw::GLenum attachment, glw::GLenum texture_target,
1022 glw::GLuint level, glw::GLint layer, glw::GLuint levels,
1025 /* Shortcut for GL functionality. */
1026 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1028 /* Check and log. */
1029 if (glw::GLenum error = gl.getError())
1031 m_context.getTestContext().getLog()
1032 << tcu::TestLog::Message << "NamedFramebufferTexture for " << glu::getFramebufferAttachmentStr(attachment)
1033 << " attachment of " << glu::getTextureTargetStr(texture_target) << " texture at level " << level
1034 << " and at layer " << layer << " where texture has " << levels << " levels and " << layers
1035 << " layers failed with error value " << glu::getErrorStr(error) << "." << tcu::TestLog::EndMessage;
1043 /** @brief Check framebuffer completness.
1045 * @param [in] attachment Framebuffer attachment.
1046 * @param [in] texture_target Texture target.
1047 * @param [in] level Tested level.
1048 * @param [in] layer Tested layer.
1049 * @param [in] levels Number of levels.
1050 * @param [in] layers Number of layers.
1052 * @return True if framebuffer is complete, false otherwise.
1054 bool TextureLayerAttachmentTest::SubTestStatus(glw::GLenum attachment, glw::GLenum texture_target, glw::GLuint level,
1055 glw::GLint layer, glw::GLuint levels, glw::GLint layers)
1057 /* Shortcut for GL functionality. */
1058 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1060 /* Check framebuffer status. */
1061 glw::GLenum status = gl.checkFramebufferStatus(GL_FRAMEBUFFER);
1063 if (GL_FRAMEBUFFER_COMPLETE != status)
1065 m_context.getTestContext().getLog()
1066 << tcu::TestLog::Message << "Named Framebuffer Texture Layer Attachment test failed because of framebuffer "
1067 << glu::getFramebufferStatusStr(status) << " with " << glu::getTextureTargetStr(texture_target)
1068 << " texture set up as " << glu::getFramebufferAttachmentStr(attachment) << " attachment and texture level "
1069 << level << " and texture layer " << layer << " of texture with " << levels << " levels and " << layers
1070 << " layers." << tcu::TestLog::EndMessage;
1078 /** @brief Check framebuffer cntent.
1080 * @param [in] attachment Framebuffer attachment.
1081 * @param [in] texture_target Texture target.
1082 * @param [in] internalformat Tested internal format.
1083 * @param [in] level Tested level.
1084 * @param [in] layer Tested layer.
1085 * @param [in] levels Number of levels.
1086 * @param [in] layers Number of layers.
1088 * @return True if framebuffer content is equal to the reference, false otherwise.
1090 bool TextureLayerAttachmentTest::SubTestContent(glw::GLenum attachment, glw::GLenum texture_target,
1091 glw::GLenum internalformat, glw::GLuint level, glw::GLint layer,
1092 glw::GLuint levels, glw::GLint layers)
1094 /* Shortcut for GL functionality. */
1095 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1097 /* Check framebuffer's color content. */
1098 if (GL_RGBA8 == internalformat)
1100 glw::GLfloat color[4] = { 0.f };
1102 gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_FLOAT, color);
1103 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
1105 for (int i = 0; i < 4 /* color components */; ++i)
1107 if (de::abs(s_reference_color[i] - color[i]) > 0.0625 /* precision */)
1109 m_context.getTestContext().getLog()
1110 << tcu::TestLog::Message << "Named Framebuffer Texture Layer Attachment test failed with "
1111 << glu::getTextureTargetStr(texture_target) << " texture set up as "
1112 << glu::getFramebufferAttachmentStr(attachment) << " attachment and texture level " << level
1113 << " and texture layer " << layer << " of texture with " << levels << " levels and " << layers
1114 << " layers. The color content of the framebuffer was [" << color[0] << ", " << color[1] << ", "
1115 << color[2] << ", " << color[3] << "], but [" << s_reference_color[0] << ", "
1116 << s_reference_color[1] << ", " << s_reference_color[2] << ", " << s_reference_color[3]
1117 << "] was expected." << tcu::TestLog::EndMessage;
1123 /* Check framebuffer's depth content. */
1124 if ((GL_DEPTH_COMPONENT24 == internalformat) || (GL_DEPTH24_STENCIL8 == internalformat))
1126 glw::GLfloat depth = 0.f;
1128 gl.readPixels(0, 0, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
1129 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
1131 if (de::abs(s_reference_depth - depth) > 0.0625 /* precision */)
1133 m_context.getTestContext().getLog()
1134 << tcu::TestLog::Message << "Named Framebuffer Texture Layer Attachment test failed "
1135 << "with texture set up as " << glu::getFramebufferAttachmentStr(attachment)
1136 << " attachment and texture level " << level << " and texture layer " << layer << " of texture with "
1137 << levels << " levels and " << layers << " layers. The depth content of the framebuffer was [" << depth
1138 << "], but [" << s_reference_depth << "] was expected." << tcu::TestLog::EndMessage;
1144 /* Check framebuffer's stencil content. */
1145 if ((GL_STENCIL_INDEX8 == internalformat) || (GL_DEPTH24_STENCIL8 == internalformat))
1147 glw::GLint stencil = 0;
1149 gl.readPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_INT, &stencil);
1150 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
1152 if (s_reference_stencil != stencil)
1154 m_context.getTestContext().getLog()
1155 << tcu::TestLog::Message << "Named Framebuffer Texture Layer Attachment test failed "
1156 << "with texture set up as " << glu::getFramebufferAttachmentStr(attachment)
1157 << " attachment and texture level " << level << " and texture layer " << layer << " of texture with "
1158 << levels << " levels and " << layers << " layers. The stencil content of the framebuffer was ["
1159 << stencil << "], but [" << s_reference_stencil << "] was expected." << tcu::TestLog::EndMessage;
1168 /** @brief Clear framebuffer.
1170 void TextureLayerAttachmentTest::Clear()
1172 /* Shortcut for GL functionality. */
1173 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1175 /* Setup clear values. */
1176 gl.clearColor(s_reference_color[0], s_reference_color[1], s_reference_color[2], s_reference_color[3]);
1177 gl.clearDepth(s_reference_depth);
1178 gl.clearStencil(s_reference_stencil);
1180 /* Clear rbo/fbo. */
1181 gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
1184 /** @brief Query maximum number of texture levels.
1186 * @return True if max number of texture levels, false otherwise.
1188 glw::GLuint TextureLayerAttachmentTest::MaxTextureLevels(glw::GLenum texture_target)
1190 /* Shortcut for GL functionality. */
1191 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1193 glw::GLint max_texture_size = 1024 /* Specification default. */;
1195 switch (texture_target)
1197 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
1200 case GL_TEXTURE_2D_ARRAY:
1202 gl.getIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size);
1203 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
1205 return (glw::GLuint)std::log((double)max_texture_size);
1207 case GL_TEXTURE_CUBE_MAP_ARRAY:
1209 gl.getIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE , &max_texture_size);
1210 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
1212 return (glw::GLuint)std::log((double)max_texture_size);
1216 gl.getIntegerv(GL_MAX_3D_TEXTURE_SIZE, &max_texture_size);
1217 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
1219 return (glw::GLuint)std::log((double)max_texture_size);
1224 /* For compiler warnings only. */
1228 /** @brief Query maximum number of texture layers.
1230 * @return True if max number of texture layers, false otherwise.
1232 glw::GLuint TextureLayerAttachmentTest::MaxTextureLayers(glw::GLenum texture_target)
1234 /* Shortcut for GL functionality. */
1235 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1237 glw::GLint max_texture_size = 1024 /* Specification default. */;
1239 switch (texture_target)
1242 gl.getIntegerv(GL_MAX_3D_TEXTURE_SIZE, &max_texture_size);
1243 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
1245 return max_texture_size;
1247 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
1248 case GL_TEXTURE_2D_ARRAY:
1250 gl.getIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &max_texture_size);
1251 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
1253 return max_texture_size;
1255 case GL_TEXTURE_CUBE_MAP_ARRAY:
1256 gl.getIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &max_texture_size);
1257 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
1259 return (max_texture_size / 6) * 6; /* Make sure that max_texture_size is dividable by 6 */
1265 /* For compiler warnings only. */
1269 /** @brief Clean up GL state.
1271 void TextureLayerAttachmentTest::Clean()
1273 /* Shortcut for GL functionality. */
1274 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1279 gl.deleteFramebuffers(1, &m_fbo);
1286 gl.deleteTextures(1, &m_to);
1291 /* Returning to default clear values. */
1292 gl.clearColor(0.f, 0.f, 0.f, 0.f);
1296 /* Errors clean up. */
1297 while (gl.getError())
1301 const glw::GLenum TextureLayerAttachmentTest::s_targets[] = //!< Targets to be tested.
1302 { GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_2D_ARRAY, GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_3D };
1304 const glw::GLuint TextureLayerAttachmentTest::s_targets_count =
1305 sizeof(s_targets) / sizeof(s_targets[0]); //!< Number of tested targets.
1307 const glw::GLfloat TextureLayerAttachmentTest::s_reference_color[4] = { 0.25, 0.5, 0.75, 1.0 }; //!< Reference color.
1308 const glw::GLint TextureLayerAttachmentTest::s_reference_color_integer[4] = { 1, 2, 3,
1309 4 }; //!< Reference integer color.
1310 const glw::GLfloat TextureLayerAttachmentTest::s_reference_depth = 0.5; //!< Reference depth.
1311 const glw::GLint TextureLayerAttachmentTest::s_reference_stencil = 7; //!< Reference stencil index.
1313 /******************************** Named Framebuffer Read / Draw Buffer Test Implementation ********************************/
1315 /** @brief Named Framebuffer Read / Draw Buffer Test constructor.
1317 * @param [in] context OpenGL context.
1319 DrawReadBufferTest::DrawReadBufferTest(deqp::Context& context)
1320 : deqp::TestCase(context, "framebuffers_read_draw_buffer", "Framebuffer Read and Draw Buffer Test")
1322 /* Intentionally left blank. */
1325 /** @brief Iterate Named Framebuffer Read / Draw Buffer Test cases.
1327 * @return Iteration result.
1329 tcu::TestNode::IterateResult DrawReadBufferTest::iterate()
1331 /* Shortcut for GL functionality. */
1332 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1334 /* Get context setup. */
1335 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
1336 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
1338 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
1340 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
1345 /* Running tests. */
1347 bool is_error = false;
1349 /* Framebuffers' objects */
1350 glw::GLuint framebuffer = 0;
1352 /* Get number of color attachments. */
1353 glw::GLint max_color_attachments = 8 /* Specification minimum OpenGL 4.5 Core Profile p. 627 */;
1355 gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
1356 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
1358 std::vector<glw::GLuint> renderbuffers(max_color_attachments);
1360 for (glw::GLint i = 0; i < max_color_attachments; ++i)
1362 renderbuffers[i] = 0;
1367 /* Prepare framebuffer... */
1368 gl.genFramebuffers(1, &framebuffer);
1369 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
1371 gl.bindFramebuffer(GL_FRAMEBUFFER, framebuffer);
1372 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
1374 gl.genRenderbuffers(max_color_attachments, &(renderbuffers[0]));
1375 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
1377 /* .. with renderbuffer color attachments. */
1378 for (glw::GLint i = 0; i < max_color_attachments; ++i)
1380 gl.bindRenderbuffer(GL_RENDERBUFFER, renderbuffers[i]);
1381 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer has failed");
1383 gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA32F, 1, 1);
1384 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
1386 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_RENDERBUFFER, renderbuffers[i]);
1387 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
1390 /* Check that framebuffer is complete. */
1391 if (GL_FRAMEBUFFER_COMPLETE != gl.checkFramebufferStatus(GL_FRAMEBUFFER))
1393 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Framebuffer is unexpectedly incomplete."
1394 << tcu::TestLog::EndMessage;
1399 /* Clear each of the framebuffer's attachments with unique color using NamedFramebufferDrawBuffer for attachment selection. */
1400 for (glw::GLint i = 0; i < max_color_attachments; ++i)
1402 gl.clearColor((float)i / (float)max_color_attachments, (float)i / (float)max_color_attachments,
1403 (float)i / (float)max_color_attachments, (float)i / (float)max_color_attachments);
1404 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor has failed");
1406 gl.namedFramebufferDrawBuffer(framebuffer, GL_COLOR_ATTACHMENT0 + i);
1408 if (glw::GLenum error = gl.getError())
1410 m_context.getTestContext().getLog()
1411 << tcu::TestLog::Message << "NamedFramebufferDrawBuffer unexpectedly generated "
1412 << glu::getErrorStr(error) << " error with GL_COLOR_ATTACHMENT" << i << ". Test fails."
1413 << tcu::TestLog::EndMessage;
1417 gl.clear(GL_COLOR_BUFFER_BIT);
1418 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear has failed");
1421 /* Fetch framebuffer's content and compare it with reference using NamedFramebufferReadBuffer for attachment selection. */
1422 for (glw::GLint i = 0; i < max_color_attachments; ++i)
1424 gl.namedFramebufferReadBuffer(framebuffer, GL_COLOR_ATTACHMENT0 + i);
1426 if (glw::GLenum error = gl.getError())
1428 m_context.getTestContext().getLog()
1429 << tcu::TestLog::Message << "NamedFramebufferReadBuffer unexpectedly generated "
1430 << glu::getErrorStr(error) << " error with GL_COLOR_ATTACHMENT" << i << ". Test fails."
1431 << tcu::TestLog::EndMessage;
1435 glw::GLfloat rgba[4] = { -1.f, -1.f, -1.f, -1.f };
1437 gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_FLOAT, rgba);
1438 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
1440 float expected_value = (float)i / (float)max_color_attachments;
1442 for (glw::GLuint j = 0; j < 4 /* number of components */; ++j)
1444 if (de::abs(expected_value - rgba[j]) > 0.0001 /* Precision */)
1446 m_context.getTestContext().getLog()
1447 << tcu::TestLog::Message
1448 << "Named Framebuffer Draw And Read Buffer failed because resulting color value was ["
1449 << rgba[0] << ", " << rgba[1] << ", " << rgba[2] << ", " << rgba[3] << "] but ["
1450 << expected_value << ", " << expected_value << ", " << expected_value << ", " << expected_value
1451 << "] had been expected." << tcu::TestLog::EndMessage;
1460 /* Check that NamedFramebufferDrawBuffer accepts GL_NONE as mode. */
1461 gl.namedFramebufferDrawBuffer(framebuffer, GL_NONE);
1463 if (glw::GLenum error = gl.getError())
1465 m_context.getTestContext().getLog()
1466 << tcu::TestLog::Message << "NamedFramebufferDrawBuffer unexpectedly generated "
1467 << glu::getErrorStr(error) << " error with GL_NONE mode. Test fails." << tcu::TestLog::EndMessage;
1471 /* Check that NamedFramebufferReadBuffer accepts GL_NONE as mode. */
1472 gl.namedFramebufferReadBuffer(framebuffer, GL_NONE);
1474 if (glw::GLenum error = gl.getError())
1476 m_context.getTestContext().getLog()
1477 << tcu::TestLog::Message << "NamedFramebufferReadBuffer unexpectedly generated "
1478 << glu::getErrorStr(error) << " error with GL_NONE mode. Test fails." << tcu::TestLog::EndMessage;
1491 gl.deleteFramebuffers(1, &framebuffer);
1496 for (glw::GLint i = 0; i < max_color_attachments; ++i)
1498 if (renderbuffers[i])
1500 gl.deleteRenderbuffers(1, &(renderbuffers[i]));
1504 gl.clearColor(0.f, 0.f, 0.f, 0.f);
1506 /* Errors clean up. */
1507 while (gl.getError())
1510 /* Result's setup. */
1513 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1519 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
1523 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
1530 /******************************** Named Framebuffer Draw Buffers Test Implementation ********************************/
1532 /** @brief Named Framebuffer Draw Buffers Test constructor.
1534 * @param [in] context OpenGL context.
1536 DrawBuffersTest::DrawBuffersTest(deqp::Context& context)
1537 : deqp::TestCase(context, "framebuffers_draw_buffers", "Framebuffer Draw Buffers Test")
1539 /* Intentionally left blank. */
1542 /** @brief Iterate Named Framebuffer Read / Draw Buffer Test cases.
1544 * @return Iteration result.
1546 tcu::TestNode::IterateResult DrawBuffersTest::iterate()
1548 /* Shortcut for GL functionality. */
1549 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1551 /* Get context setup. */
1552 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
1553 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
1555 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
1557 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
1562 /* Running tests. */
1564 bool is_error = false;
1566 /* Framebuffers' objects */
1567 glw::GLuint framebuffer = 0;
1569 /* Get number of color attachments. */
1570 glw::GLint max_color_attachments = 8 /* Specification minimum OpenGL 4.5 Core Profile p. 627 */;
1572 gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
1573 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
1575 std::vector<glw::GLuint> renderbuffers(max_color_attachments);
1576 std::vector<glw::GLuint> color_attachments(max_color_attachments);
1578 for (glw::GLint i = 0; i < max_color_attachments; ++i)
1580 renderbuffers[i] = 0;
1581 color_attachments[i] = GL_COLOR_ATTACHMENT0 + i;
1586 /* Prepare framebuffer... */
1587 gl.genFramebuffers(1, &framebuffer);
1588 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
1590 gl.bindFramebuffer(GL_FRAMEBUFFER, framebuffer);
1591 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
1593 gl.genRenderbuffers(max_color_attachments, &(renderbuffers[0]));
1594 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
1596 /* .. with renderbuffer color attachments. */
1597 for (glw::GLint i = 0; i < max_color_attachments; ++i)
1599 gl.bindRenderbuffer(GL_RENDERBUFFER, renderbuffers[i]);
1600 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer has failed");
1602 gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA32F, 1, 1);
1603 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
1605 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_RENDERBUFFER, renderbuffers[i]);
1606 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
1609 /* Check that framebuffer is complete. */
1610 if (GL_FRAMEBUFFER_COMPLETE != gl.checkFramebufferStatus(GL_FRAMEBUFFER))
1612 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Framebuffer is unexpectedly incomplete."
1613 << tcu::TestLog::EndMessage;
1618 /* Set up all attachments as draw buffer. */
1619 gl.namedFramebufferDrawBuffers(framebuffer, max_color_attachments, &(color_attachments[0]));
1621 if (glw::GLenum error = gl.getError())
1623 m_context.getTestContext().getLog()
1624 << tcu::TestLog::Message << "NamedFramebufferDrawBuffers unexpectedly generated "
1625 << glu::getErrorStr(error) << " error. Test fails." << tcu::TestLog::EndMessage;
1629 /* Clear each of the framebuffer's attachments with unique color using NamedFramebufferDrawBuffer for attachment selection. */
1630 for (glw::GLint i = 0; i < max_color_attachments; ++i)
1632 gl.clearColor(s_rgba[0], s_rgba[1], s_rgba[2], s_rgba[3]);
1633 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor has failed");
1635 gl.clear(GL_COLOR_BUFFER_BIT);
1636 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear has failed");
1639 /* Fetch framebuffer's content and compare it with reference using NamedFramebufferReadBuffer for attachment selection. */
1640 for (glw::GLint i = 0; i < max_color_attachments; ++i)
1642 gl.readBuffer(GL_COLOR_ATTACHMENT0 + i);
1643 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadBuffer has failed");
1645 glw::GLfloat rgba[4] = { -1.f, -1.f, -1.f, -1.f };
1647 gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_FLOAT, rgba);
1648 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
1650 for (glw::GLuint j = 0; j < 4 /* number of components */; ++j)
1652 if (de::abs(s_rgba[j] - rgba[j]) > 0.0001 /* Precision */)
1654 m_context.getTestContext().getLog()
1655 << tcu::TestLog::Message
1656 << "Named Framebuffer Draw Buffers test have failed because resulting color value was ["
1657 << rgba[0] << ", " << rgba[1] << ", " << rgba[2] << ", " << rgba[3] << "] but [" << s_rgba[0]
1658 << ", " << s_rgba[1] << ", " << s_rgba[2] << ", " << s_rgba[3] << "] had been expected."
1659 << tcu::TestLog::EndMessage;
1668 /* Check that NamedFramebufferDrawBuffers accepts GL_NONE as mode. */
1669 glw::GLenum none_bufs = GL_NONE;
1670 gl.namedFramebufferDrawBuffers(framebuffer, 1, &none_bufs);
1672 if (glw::GLenum error = gl.getError())
1674 m_context.getTestContext().getLog()
1675 << tcu::TestLog::Message << "NamedFramebufferDrawBuffers unexpectedly generated "
1676 << glu::getErrorStr(error) << " error with GL_NONE mode. Test fails." << tcu::TestLog::EndMessage;
1689 gl.deleteFramebuffers(1, &framebuffer);
1694 for (glw::GLint i = 0; i < max_color_attachments; ++i)
1696 if (renderbuffers[i])
1698 gl.deleteRenderbuffers(1, &(renderbuffers[i]));
1702 gl.clearColor(0.f, 0.f, 0.f, 0.f);
1704 /* Errors clean up. */
1705 while (gl.getError())
1708 /* Result's setup. */
1711 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1717 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
1721 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
1728 const glw::GLfloat DrawBuffersTest::s_rgba[4] = { 0.f, 0.25f, 0.5f, 0.75f };
1730 /******************************** Named Framebuffer Invalidate Data Test Implementation ********************************/
1732 /** @brief Named Framebuffer Invalidate Data Test constructor.
1734 * @param [in] context OpenGL context.
1736 InvalidateDataTest::InvalidateDataTest(deqp::Context& context)
1737 : deqp::TestCase(context, "framebuffers_invalidate_data", "Framebuffer Invalidate Data Test")
1739 /* Intentionally left blank. */
1742 /** @brief Iterate Named Framebuffer Read / Draw Buffer Test cases.
1744 * @return Iteration result.
1746 tcu::TestNode::IterateResult InvalidateDataTest::iterate()
1748 /* Shortcut for GL functionality. */
1749 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1751 /* Get context setup. */
1752 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
1753 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
1755 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
1757 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
1762 /* Running tests. */
1764 bool is_error = false;
1766 /* Framebuffers' objects */
1767 glw::GLuint framebuffer = 0;
1769 /* Get number of color attachments. */
1770 glw::GLint max_color_attachments = 8 /* Specification minimum OpenGL 4.5 Core Profile p. 627 */;
1772 gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
1773 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
1775 std::vector<glw::GLuint> renderbuffers(max_color_attachments);
1776 std::vector<glw::GLuint> color_attachments(max_color_attachments);
1777 static const glw::GLenum default_attachments[] = { GL_COLOR, GL_DEPTH, GL_STENCIL };
1778 static const glw::GLuint default_attachments_count = sizeof(default_attachments) / sizeof(default_attachments[0]);
1780 for (glw::GLint i = 0; i < max_color_attachments; ++i)
1782 renderbuffers[i] = 0;
1783 color_attachments[i] = GL_COLOR_ATTACHMENT0 + i;
1788 /* Invalidate Default Framebuffer data */
1789 gl.invalidateNamedFramebufferData(0, default_attachments_count, &(default_attachments[0]));
1790 is_ok &= CheckErrorAndLog(default_attachments, default_attachments_count);
1792 for (glw::GLuint i = 0; i < default_attachments_count; ++i)
1794 gl.invalidateNamedFramebufferData(0, 1, &(default_attachments[i]));
1795 is_ok &= CheckErrorAndLog(default_attachments[i]);
1798 /* Prepare framebuffer... */
1799 gl.genFramebuffers(1, &framebuffer);
1800 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
1802 gl.bindFramebuffer(GL_FRAMEBUFFER, framebuffer);
1803 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
1805 gl.genRenderbuffers(max_color_attachments, &(renderbuffers[0]));
1806 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
1808 /* .. with renderbuffer color attachments. */
1809 for (glw::GLint i = 0; i < max_color_attachments; ++i)
1811 gl.bindRenderbuffer(GL_RENDERBUFFER, renderbuffers[i]);
1812 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer has failed");
1814 gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA32F, 1, 1);
1815 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
1817 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_RENDERBUFFER, renderbuffers[i]);
1818 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
1821 /* Check that framebuffer is complete. */
1822 if (GL_FRAMEBUFFER_COMPLETE != gl.checkFramebufferStatus(GL_FRAMEBUFFER))
1824 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Framebuffer is unexpectedly incomplete."
1825 << tcu::TestLog::EndMessage;
1830 gl.invalidateNamedFramebufferData(framebuffer, max_color_attachments, &(color_attachments[0]));
1831 is_ok &= CheckErrorAndLog(&(color_attachments[0]), max_color_attachments);
1833 for (glw::GLint i = 0; i < max_color_attachments; ++i)
1835 gl.invalidateNamedFramebufferData(framebuffer, 1, &(color_attachments[i]));
1836 is_ok &= CheckErrorAndLog(color_attachments[i]);
1848 gl.deleteFramebuffers(1, &framebuffer);
1853 for (glw::GLint i = 0; i < max_color_attachments; ++i)
1855 if (renderbuffers[i])
1857 gl.deleteRenderbuffers(1, &(renderbuffers[i]));
1861 /* Errors clean up. */
1862 while (gl.getError())
1865 /* Result's setup. */
1868 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1874 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
1878 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
1885 /** @brief Check error and log.
1887 * @param [in] attachment Framebuffer attachment.
1889 * @return True if no error, false otherwise.
1891 bool InvalidateDataTest::CheckErrorAndLog(const glw::GLenum attachment)
1893 /* Shortcut for GL functionality. */
1894 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1897 if (glw::GLenum error = gl.getError())
1899 /* There is an error. Log. */
1900 m_context.getTestContext().getLog() << tcu::TestLog::Message << "InvalidateDataTest unexpectedly generated "
1901 << glu::getErrorStr(error) << " error for attachment "
1902 << glu::getFramebufferAttachmentStr(attachment) << ". Test fails."
1903 << tcu::TestLog::EndMessage;
1911 /** @brief Check error and log.
1913 * @param [in] attachments Framebuffer attachments.
1914 * @param [in] attachments_count Framebuffer attachments count.
1916 * @return True if no error, false otherwise.
1918 bool InvalidateDataTest::CheckErrorAndLog(const glw::GLenum attachments[], glw::GLuint count)
1920 /* Shortcut for GL functionality. */
1921 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1924 if (glw::GLenum error = gl.getError())
1926 /* There is an error. Log. */
1927 std::string attachments_names = "";
1929 for (glw::GLuint i = 0; i < count; ++i)
1931 attachments_names.append(glu::getFramebufferAttachmentStr(attachments[i]).toString());
1933 if ((count - 1) != i)
1935 attachments_names.append(", ");
1939 m_context.getTestContext().getLog() << tcu::TestLog::Message << "InvalidateDataTest unexpectedly generated "
1940 << glu::getErrorStr(error) << " error for following attachments ["
1941 << attachments_names << "]. Test fails." << tcu::TestLog::EndMessage;
1949 /******************************** Named Framebuffer Invalidate Sub Data Test Implementation ********************************/
1951 /** @brief Named Framebuffer Invalidate Sub Data Test constructor.
1953 * @param [in] context OpenGL context.
1955 InvalidateSubDataTest::InvalidateSubDataTest(deqp::Context& context)
1956 : deqp::TestCase(context, "framebuffers_invalidate_subdata", "Framebuffer Invalidate Sub Data Test")
1958 /* Intentionally left blank. */
1961 /** @brief Iterate Named Framebuffer Read / Draw Buffer Test cases.
1963 * @return Iteration result.
1965 tcu::TestNode::IterateResult InvalidateSubDataTest::iterate()
1967 /* Shortcut for GL functionality. */
1968 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1970 /* Get context setup. */
1971 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
1972 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
1974 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
1976 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
1981 /* Running tests. */
1983 bool is_error = false;
1985 /* Framebuffers' objects */
1986 glw::GLuint framebuffer = 0;
1988 /* Get number of color attachments. */
1989 glw::GLint max_color_attachments = 8 /* Specification minimum OpenGL 4.5 Core Profile p. 627 */;
1991 gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
1992 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
1994 std::vector<glw::GLuint> renderbuffers(max_color_attachments);
1995 std::vector<glw::GLuint> color_attachments(max_color_attachments);
1996 static const glw::GLenum default_attachments[] = { GL_COLOR, GL_DEPTH, GL_STENCIL };
1997 static const glw::GLuint default_attachments_count = sizeof(default_attachments) / sizeof(default_attachments[0]);
1999 for (glw::GLint i = 0; i < max_color_attachments; ++i)
2001 renderbuffers[i] = 0;
2002 color_attachments[i] = GL_COLOR_ATTACHMENT0 + i;
2007 /* Invalidate Default Framebuffer data */
2008 gl.invalidateNamedFramebufferSubData(0, default_attachments_count, &(default_attachments[0]), 0, 0, 1, 1);
2009 is_ok &= CheckErrorAndLog(default_attachments, default_attachments_count);
2011 for (glw::GLuint i = 0; i < default_attachments_count; ++i)
2013 gl.invalidateNamedFramebufferSubData(0, 1, &(default_attachments[i]), 0, 0, 1, 1);
2014 is_ok &= CheckErrorAndLog(default_attachments[i]);
2017 /* Prepare framebuffer... */
2018 gl.genFramebuffers(1, &framebuffer);
2019 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
2021 gl.bindFramebuffer(GL_FRAMEBUFFER, framebuffer);
2022 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
2024 gl.genRenderbuffers(max_color_attachments, &(renderbuffers[0]));
2025 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
2027 /* .. with renderbuffer color attachments. */
2028 for (glw::GLint i = 0; i < max_color_attachments; ++i)
2030 gl.bindRenderbuffer(GL_RENDERBUFFER, renderbuffers[i]);
2031 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer has failed");
2033 gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA32F, 4, 4);
2034 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
2036 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_RENDERBUFFER, renderbuffers[i]);
2037 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
2040 /* Check that framebuffer is complete. */
2041 if (GL_FRAMEBUFFER_COMPLETE != gl.checkFramebufferStatus(GL_FRAMEBUFFER))
2043 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Framebuffer is unexpectedly incomplete."
2044 << tcu::TestLog::EndMessage;
2049 gl.invalidateNamedFramebufferSubData(framebuffer, max_color_attachments, &(color_attachments[0]), 1, 1, 2, 2);
2050 is_ok &= CheckErrorAndLog(&(color_attachments[0]), max_color_attachments);
2052 for (glw::GLint i = 0; i < max_color_attachments; ++i)
2054 gl.invalidateNamedFramebufferSubData(framebuffer, 1, &(color_attachments[i]), 1, 1, 2, 2);
2055 is_ok &= CheckErrorAndLog(color_attachments[i]);
2067 gl.deleteFramebuffers(1, &framebuffer);
2072 for (glw::GLint i = 0; i < max_color_attachments; ++i)
2074 if (renderbuffers[i])
2076 gl.deleteRenderbuffers(1, &(renderbuffers[i]));
2080 /* Errors clean up. */
2081 while (gl.getError())
2084 /* Result's setup. */
2087 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
2093 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
2097 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
2104 /** @brief Check error and log.
2106 * @param [in] attachment Framebuffer attachment.
2108 * @return True if no error, false otherwise.
2110 bool InvalidateSubDataTest::CheckErrorAndLog(const glw::GLenum attachment)
2112 /* Shortcut for GL functionality. */
2113 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2116 if (glw::GLenum error = gl.getError())
2118 /* There is an error. Log. */
2119 m_context.getTestContext().getLog() << tcu::TestLog::Message << "InvalidateSubDataTest unexpectedly generated "
2120 << glu::getErrorStr(error) << " error for attachment "
2121 << glu::getFramebufferAttachmentStr(attachment) << ". Test fails."
2122 << tcu::TestLog::EndMessage;
2130 /** @brief Check error and log.
2132 * @param [in] attachments Framebuffer attachments.
2133 * @param [in] attachments_count Framebuffer attachments count.
2135 * @return True if no error, false otherwise.
2137 bool InvalidateSubDataTest::CheckErrorAndLog(const glw::GLenum attachments[], glw::GLuint count)
2139 /* Shortcut for GL functionality. */
2140 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2143 if (glw::GLenum error = gl.getError())
2145 /* There is an error. Log. */
2146 std::string attachments_names = "";
2148 for (glw::GLuint i = 0; i < count; ++i)
2150 attachments_names.append(glu::getFramebufferAttachmentStr(attachments[i]).toString());
2152 if ((count - 1) != i)
2154 attachments_names.append(", ");
2158 m_context.getTestContext().getLog() << tcu::TestLog::Message << "InvalidateSubDataTest unexpectedly generated "
2159 << glu::getErrorStr(error) << " error for following attachments ["
2160 << attachments_names << "]. Test fails." << tcu::TestLog::EndMessage;
2168 /******************************** Clear Named Framebuffer Test Implementation ********************************/
2170 /** @brief Clear Named Framebuffer Test constructor.
2172 * @param [in] context OpenGL context.
2174 ClearTest::ClearTest(deqp::Context& context)
2175 : deqp::TestCase(context, "framebuffers_clear", "Clear Named Framebuffer Test")
2177 , m_renderbuffers(0)
2178 , m_renderbuffers_count(0)
2180 /* Intentionally left blank. */
2183 /** @brief Compare two floats (template specialization).
2185 * @param [in] first First float to be compared.
2186 * @param [in] second Second float to be compared.
2188 * @return True if floats are equal within +-(1.f/64.f) precision range, false otherwise.
2191 bool ClearTest::Compare<glw::GLfloat>(const glw::GLfloat first, const glw::GLfloat second)
2193 return (de::abs(first - second) < (1.f / 64.f) /* Precission. */);
2196 /** @brief Compare two objects (template general specialization).
2198 * @param [in] first First objetc to be compared.
2199 * @param [in] second Second object to be compared.
2201 * @return True if floats are equal, false otherwise.
2203 template <typename T>
2204 bool ClearTest::Compare(const T first, const T second)
2206 return (first == second);
2209 /** @brief Clear color buffer (float specialization), check errors and log.
2211 * @param [in] buffer Buffer to be cleared.
2212 * @param [in] drawbuffer Drawbuffer to be cleared.
2213 * @param [in] value Value to be cleared with.
2215 * @return True if succeeded without errors, false otherwise.
2218 bool ClearTest::ClearColor<glw::GLfloat>(glw::GLenum buffer, glw::GLint drawbuffer, glw::GLfloat value)
2220 /* Shortcut for GL functionality. */
2221 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2223 glw::GLfloat value_vector[4] = { value, 0, 0, 0 };
2225 gl.clearNamedFramebufferfv(m_fbo, buffer, drawbuffer, value_vector);
2227 if (glw::GLenum error = gl.getError())
2229 m_context.getTestContext().getLog()
2230 << tcu::TestLog::Message << "ClearNamedFramebufferfv unexpectedly generated " << glu::getErrorStr(error)
2231 << " error. Test fails." << tcu::TestLog::EndMessage;
2239 /** @brief Clear color buffer (int specialization), check errors and log.
2241 * @param [in] buffer Buffer to be cleared.
2242 * @param [in] drawbuffer Drawbuffer to be cleared.
2243 * @param [in] value Value to be cleared with.
2245 * @return True if succeeded without errors, false otherwise.
2248 bool ClearTest::ClearColor<glw::GLint>(glw::GLenum buffer, glw::GLint drawbuffer, glw::GLint value)
2250 /* Shortcut for GL functionality. */
2251 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2253 glw::GLint value_vector[4] = { value, 0, 0, 0 };
2255 gl.clearNamedFramebufferiv(m_fbo, buffer, drawbuffer, value_vector);
2257 if (glw::GLenum error = gl.getError())
2259 m_context.getTestContext().getLog()
2260 << tcu::TestLog::Message << "ClearNamedFramebufferiv unexpectedly generated " << glu::getErrorStr(error)
2261 << " error. Test fails." << tcu::TestLog::EndMessage;
2269 /** @brief Clear color buffer (uint specialization), check errors and log.
2271 * @param [in] buffer Buffer to be cleared.
2272 * @param [in] drawbuffer Drawbuffer to be cleared.
2273 * @param [in] value Value to be cleared with.
2275 * @return True if succeeded without errors, false otherwise.
2278 bool ClearTest::ClearColor<glw::GLuint>(glw::GLenum buffer, glw::GLint drawbuffer, glw::GLuint value)
2280 /* Shortcut for GL functionality. */
2281 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2283 glw::GLuint value_vector[4] = { value, 0, 0, 0 };
2285 gl.clearNamedFramebufferuiv(m_fbo, buffer, drawbuffer, value_vector);
2287 if (glw::GLenum error = gl.getError())
2289 m_context.getTestContext().getLog()
2290 << tcu::TestLog::Message << "ClearNamedFramebufferuiv unexpectedly generated " << glu::getErrorStr(error)
2291 << " error. Test fails." << tcu::TestLog::EndMessage;
2299 /** @brief Format of the buffer (float specialization).
2304 glw::GLenum ClearTest::Format<GLfloat>()
2309 /** @brief Format of the buffer (int and uint specialization).
2313 template <typename T>
2314 glw::GLenum ClearTest::Format()
2316 return GL_RED_INTEGER;
2319 /** @brief Type of the buffer (float specialization).
2324 glw::GLenum ClearTest::Type<glw::GLfloat>()
2329 /** @brief Type of the buffer (int specialization).
2334 glw::GLenum ClearTest::Type<glw::GLint>()
2339 /** @brief Type of the buffer (uint specialization).
2344 glw::GLenum ClearTest::Type<glw::GLuint>()
2346 return GL_UNSIGNED_INT;
2349 /** @brief Test DSA Clear function (color).
2351 * @param [in] buffer Buffer to be cleared.
2352 * @param [in] attachment Attachment to be tested.
2353 * @param [in] value Value to be cleared with.
2355 * @return True if test succeeded, false otherwise.
2357 template <typename T>
2358 bool ClearTest::TestClearColor(glw::GLenum buffer, glw::GLenum attachment, T value)
2360 /* Shortcut for GL functionality. */
2361 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2363 gl.drawBuffer(attachment);
2364 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawBuffer has failed");
2367 if (ClearColor<T>(buffer, 0, value))
2369 /* Fetching framebuffer content. */
2372 gl.readBuffer(attachment);
2373 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadBuffer has failed");
2375 gl.readPixels(0, 0, 1, 1, Format<T>(), Type<T>(), &pixel);
2376 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixel has failed");
2378 /* Comparison with reference value. */
2379 if (Compare(pixel, value))
2384 m_context.getTestContext().getLog()
2385 << tcu::TestLog::Message << "ClearNamedFramebuffer did not cleared color attachment "
2386 << glu::getFramebufferAttachmentStr(attachment) << " of the framebuffer." << tcu::TestLog::EndMessage;
2392 /** @brief Test DSA Clear function (depth/stencil).
2394 * @param [in] stencil Stencil value to be cleared with.
2395 * @param [in] depth Depth value to be cleared with.
2397 * @return True if test succeeded, false otherwise.
2399 bool ClearTest::TestClearDepthAndStencil(glw::GLfloat depth, glw::GLint stencil)
2401 /* Shortcut for GL functionality. */
2402 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2404 /* Clearing depth and stencil. */
2405 gl.clearNamedFramebufferfi(m_fbo, GL_DEPTH_STENCIL, 0, depth, stencil);
2407 if (glw::GLenum error = gl.getError())
2409 m_context.getTestContext().getLog()
2410 << tcu::TestLog::Message << "ClearNamedFramebufferufi unexpectedly generated " << glu::getErrorStr(error)
2411 << " error. Test fails." << tcu::TestLog::EndMessage;
2417 /* Fetching framebuffer content. */
2418 glw::GLfloat the_depth = 0.f;
2419 glw::GLint the_stencil = 0;
2421 gl.readPixels(0, 0, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &the_depth);
2422 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixel has failed");
2424 gl.readPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_INT, &the_stencil);
2425 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixel has failed");
2427 /* Comparison with reference value. */
2428 if (Compare(the_depth, depth) || Compare(the_stencil, stencil))
2433 m_context.getTestContext().getLog()
2434 << tcu::TestLog::Message
2435 << "ClearNamedFramebufferfi did not cleared depth/stencil attachment of the framebuffer."
2436 << tcu::TestLog::EndMessage;
2441 /** @brief Iterate Clear Named Framebuffer Test cases.
2443 * @return Iteration result.
2445 tcu::TestNode::IterateResult ClearTest::iterate()
2447 /* Get context setup. */
2448 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
2449 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
2451 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
2453 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
2458 /* Running tests. */
2460 bool is_error = false;
2464 /* Fixed point color test. */
2465 PrepareFramebuffer(GL_COLOR, GL_R8);
2467 for (glw::GLint i = 0; i < (glw::GLint)m_renderbuffers_count; ++i)
2469 is_ok &= TestClearColor<glw::GLfloat>(GL_COLOR, GL_COLOR_ATTACHMENT0 + i, 0.5);
2474 /* Floating point color test. */
2475 PrepareFramebuffer(GL_COLOR, GL_R32F);
2477 for (glw::GLint i = 0; i < (glw::GLint)m_renderbuffers_count; ++i)
2479 is_ok &= TestClearColor<glw::GLfloat>(GL_COLOR, GL_COLOR_ATTACHMENT0 + i, 0.5);
2484 /* Signed integer color test. */
2485 PrepareFramebuffer(GL_COLOR, GL_R8I);
2487 for (glw::GLint i = 0; i < (glw::GLint)m_renderbuffers_count; ++i)
2489 is_ok &= TestClearColor<glw::GLint>(GL_COLOR, GL_COLOR_ATTACHMENT0 + i, -16);
2494 /* Unsigned integer color test. */
2495 PrepareFramebuffer(GL_COLOR, GL_R8UI);
2497 for (glw::GLint i = 0; i < (glw::GLint)m_renderbuffers_count; ++i)
2499 is_ok &= TestClearColor<glw::GLuint>(GL_COLOR, GL_COLOR_ATTACHMENT0 + i, 16);
2504 /* Depth / stencil test. */
2505 PrepareFramebuffer(GL_DEPTH_STENCIL, GL_DEPTH24_STENCIL8);
2507 is_ok &= TestClearDepthAndStencil(1, 1);
2520 /* Result's setup. */
2523 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
2529 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
2533 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
2540 /** @brief Prepare framebuffer.
2542 * @param [in] buffer Buffer to be prepared.
2543 * @param [in] internalformat Internal format to be prepared
2545 void ClearTest::PrepareFramebuffer(glw::GLenum buffer, glw::GLenum internalformat)
2547 /* Shortcut for GL functionality. */
2548 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2550 /* Check that ther is no other fbo. */
2551 if ((0 != m_fbo) || (DE_NULL != m_renderbuffers))
2556 /* Prepare framebuffer... */
2557 gl.genFramebuffers(1, &m_fbo);
2558 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
2560 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
2561 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
2563 if (buffer == GL_COLOR)
2565 glw::GLint max_color_attachments =
2566 8; /* OpenGL 4.5 specification default (see Implementation Dependent Values tables). */
2568 gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
2569 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
2571 m_renderbuffers = new glw::GLuint[max_color_attachments];
2573 if (m_renderbuffers)
2575 /* ... with renderbuffer color attachments. */
2577 gl.genRenderbuffers(max_color_attachments, m_renderbuffers);
2578 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
2580 m_renderbuffers_count = max_color_attachments;
2582 for (glw::GLint i = 0; i < max_color_attachments; ++i)
2584 gl.bindRenderbuffer(GL_RENDERBUFFER, m_renderbuffers[i]);
2585 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer has failed");
2587 gl.renderbufferStorage(GL_RENDERBUFFER, internalformat, 1, 1);
2588 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
2590 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_RENDERBUFFER,
2591 m_renderbuffers[i]);
2592 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
2597 if (buffer == GL_DEPTH_STENCIL)
2599 /* ... with depth and stencil attachments. */
2601 m_renderbuffers = new glw::GLuint[1];
2603 if (m_renderbuffers)
2605 gl.genRenderbuffers(1, m_renderbuffers);
2606 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
2608 gl.bindRenderbuffer(GL_RENDERBUFFER, m_renderbuffers[0]);
2609 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer has failed");
2611 m_renderbuffers_count = 1;
2613 gl.renderbufferStorage(GL_RENDERBUFFER, internalformat, 1, 1);
2614 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
2616 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
2617 m_renderbuffers[0]);
2618 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
2622 /* Check that framebuffer is complete. */
2623 if (GL_FRAMEBUFFER_COMPLETE != gl.checkFramebufferStatus(GL_FRAMEBUFFER))
2625 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Framebuffer is unexpectedly incomplete."
2626 << tcu::TestLog::EndMessage;
2632 /** @brief Clean up GL state.
2634 void ClearTest::Clean()
2636 /* Shortcut for GL functionality. */
2637 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2639 /* Releasing objects. */
2642 gl.deleteFramebuffers(1, &m_fbo);
2647 if (DE_NULL != m_renderbuffers)
2649 if (m_renderbuffers_count)
2651 gl.deleteRenderbuffers(m_renderbuffers_count, m_renderbuffers);
2654 delete[] m_renderbuffers;
2656 m_renderbuffers = DE_NULL;
2657 m_renderbuffers_count = 0;
2660 /* Errors clean up. */
2661 while (gl.getError())
2665 /******************************** Blit Named Framebuffer Test Implementation ********************************/
2667 /** @brief Named Framebuffer blit Test constructor.
2669 * @param [in] context OpenGL context.
2671 BlitTest::BlitTest(deqp::Context& context)
2672 : deqp::TestCase(context, "framebuffers_blit", "Framebuffer Blit Test")
2674 , m_rbo_color_src(0)
2675 , m_rbo_depth_stencil_src(0)
2677 , m_rbo_color_dst(0)
2678 , m_rbo_depth_stencil_dst(0)
2680 /* Intentionally left blank. */
2683 /** @brief Iterate Named Framebuffer Blit Test cases.
2685 * @return Iteration result.
2687 tcu::TestNode::IterateResult BlitTest::iterate()
2689 /* Shortcut for GL functionality. */
2690 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2692 /* Get context setup. */
2693 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
2694 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
2696 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
2698 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
2703 /* Running tests. */
2705 bool is_error = false;
2709 PrepareFramebuffers();
2722 /* Errors clean up. */
2723 while (gl.getError())
2726 /* Result's setup. */
2729 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
2735 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
2739 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
2746 /** @brief Prepare framebuffer.
2748 void BlitTest::PrepareFramebuffers()
2750 /* Shortcut for GL functionality. */
2751 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2753 /* Prepare source framebuffer */
2754 gl.genFramebuffers(1, &m_fbo_src);
2755 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
2757 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_src);
2758 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
2760 gl.genRenderbuffers(1, &m_rbo_color_src);
2761 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
2763 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo_color_src);
2764 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
2766 gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 2, 2);
2767 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
2769 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo_color_src);
2770 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
2772 gl.genRenderbuffers(1, &m_rbo_depth_stencil_src);
2773 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
2775 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo_depth_stencil_src);
2776 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
2778 gl.renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 2, 2);
2779 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
2781 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_rbo_depth_stencil_src);
2782 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
2784 /* Check that framebuffer is complete. */
2785 if (GL_FRAMEBUFFER_COMPLETE != gl.checkFramebufferStatus(GL_FRAMEBUFFER))
2787 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Framebuffer is unexpectedly incomplete."
2788 << tcu::TestLog::EndMessage;
2793 /* Prepare destination framebuffer */
2794 gl.genFramebuffers(1, &m_fbo_dst);
2795 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
2797 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_dst);
2798 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
2800 gl.genRenderbuffers(1, &m_rbo_color_dst);
2801 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
2803 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo_color_dst);
2804 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
2806 gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 3, 2);
2807 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
2809 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo_color_dst);
2810 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
2812 gl.genRenderbuffers(1, &m_rbo_depth_stencil_dst);
2813 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
2815 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo_depth_stencil_dst);
2816 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
2818 gl.renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 3, 2);
2819 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
2821 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_rbo_depth_stencil_dst);
2822 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
2824 /* Check that framebuffer is complete. */
2825 if (GL_FRAMEBUFFER_COMPLETE != gl.checkFramebufferStatus(GL_FRAMEBUFFER))
2827 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Framebuffer is unexpectedly incomplete."
2828 << tcu::TestLog::EndMessage;
2834 /** @brief Do the blit test.
2836 bool BlitTest::Test()
2838 /* Shortcut for GL functionality. */
2839 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2841 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_src);
2842 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
2844 ClearFramebuffer(1.f, 0.f, 0.f, 0.5f, 1);
2846 gl.blitNamedFramebuffer(m_fbo_src, m_fbo_dst, 0, 0, 1, 1, 0, 0, 1, 1,
2847 GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST);
2849 if (CheckErrorAndLog())
2851 ClearFramebuffer(0.f, 1.f, 0.f, 0.25f, 2);
2853 gl.blitNamedFramebuffer(m_fbo_src, m_fbo_dst, 0, 0, 1, 1, 1, 0, 2, 1, GL_COLOR_BUFFER_BIT, GL_LINEAR);
2854 gl.blitNamedFramebuffer(m_fbo_src, m_fbo_dst, 0, 0, 1, 1, 1, 0, 2, 1,
2855 GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST);
2857 if (CheckErrorAndLog())
2859 ClearFramebuffer(0.f, 0.f, 1.f, 0.125f, 3);
2861 gl.blitNamedFramebuffer(m_fbo_src, m_fbo_dst, 0, 0, 2, 2, 2, 0, 3, 1,
2862 GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST);
2864 if (CheckErrorAndLog())
2866 ClearFramebuffer(1.f, 1.f, 0.f, 0.0625f, 4);
2868 gl.blitNamedFramebuffer(m_fbo_src, m_fbo_dst, 0, 0, 1, 1, 0, 1, 3, 2,
2869 GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST);
2871 if (CheckErrorAndLog())
2873 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_dst);
2874 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
2876 if (CheckColor() && CheckDepth() && CheckStencil())
2888 /** @brief Check error and log.
2890 * @return true if no error, false otherwise.
2892 bool BlitTest::CheckErrorAndLog()
2894 /* Shortcut for GL functionality. */
2895 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2898 if (glw::GLenum error = gl.getError())
2901 m_context.getTestContext().getLog() << tcu::TestLog::Message << "BlitNamedFramebuffer unexpectedly generated "
2902 << glu::getErrorStr(error) << " error." << tcu::TestLog::EndMessage;
2904 /* Returning result. */
2908 /* Returning result. */
2912 /** @brief Check color and log.
2914 * @return true if color matches reference, false otherwise.
2916 bool BlitTest::CheckColor()
2918 /* Shortcut for GL functionality. */
2919 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2921 /* Reference values. */
2922 static const glw::GLfloat reference[2][3][4] = {
2923 { { 1.f, 0.f, 0.f, 1.f }, { 0.f, 1.f, 0.f, 1.f }, { 0.f, 0.f, 1.f, 1.f } },
2924 { { 1.f, 1.f, 0.f, 1.f }, { 1.f, 1.f, 0.f, 1.f }, { 1.f, 1.f, 0.f, 1.f } }
2928 glw::GLfloat color[2][3][4] = { { { 0 } } };
2930 /* Reading from GL. */
2931 gl.readPixels(0, 0, 3, 2, GL_RGBA, GL_FLOAT, color);
2932 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
2934 /* Comparison against the reference. */
2935 for (glw::GLuint j = 0; j < 2; ++j)
2937 for (glw::GLuint i = 0; i < 3; ++i)
2939 for (glw::GLuint k = 0; k < 4; ++k)
2941 if (de::abs(reference[j][i][k] - color[j][i][k]) > (1.f / 64.f) /* Precision. */)
2944 m_context.getTestContext().getLog()
2945 << tcu::TestLog::Message << "Blitted framebuffer color buffer contains [[" << color[0][0][0]
2946 << ", " << color[0][0][1] << ", " << color[0][0][2] << ", " << color[0][0][3] << "], ["
2947 << color[0][1][0] << ", " << color[0][1][1] << ", " << color[0][1][2] << ", " << color[0][1][3]
2948 << "], [" << color[0][2][0] << ", " << color[0][2][1] << ", " << color[0][2][2] << ", "
2949 << color[0][2][3] << "],\n[" << color[1][0][0] << ", " << color[1][0][1] << ", "
2950 << color[1][0][2] << ", " << color[1][0][3] << "], [" << color[1][1][0] << ", "
2951 << color[1][1][1] << ", " << color[1][1][2] << ", " << color[1][1][3] << "], ["
2952 << color[1][2][0] << ", " << color[1][2][1] << ", " << color[1][2][2] << ", " << color[1][2][3]
2954 << reference[0][0][0] << ", " << reference[0][0][1] << ", " << reference[0][0][2] << ", "
2955 << reference[0][0][3] << "], [" << reference[0][1][0] << ", " << reference[0][1][1] << ", "
2956 << reference[0][1][2] << ", " << reference[0][1][3] << "], [" << reference[0][2][0] << ", "
2957 << reference[0][2][1] << ", " << reference[0][2][2] << ", " << reference[0][2][3] << "],\n["
2958 << reference[1][0][0] << ", " << reference[1][0][1] << ", " << reference[1][0][2] << ", "
2959 << reference[1][0][3] << "], [" << reference[1][1][0] << ", " << reference[1][1][1] << ", "
2960 << reference[1][1][2] << ", " << reference[1][1][3] << "], [" << reference[1][2][0] << ", "
2961 << reference[1][2][1] << ", " << reference[1][2][2] << ", " << reference[1][2][3]
2962 << "]] was expected.\n"
2963 << tcu::TestLog::EndMessage;
2974 /** @brief Check depth and log.
2976 * @return true if depth matches reference, false otherwise.
2978 bool BlitTest::CheckDepth()
2980 /* Shortcut for GL functionality. */
2981 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2983 /* Reference values. */
2984 static const glw::GLfloat reference[2][3] = { { 0.5, 0.25, 0.125 }, { 0.0625, 0.0625, 0.0625 } };
2987 glw::GLfloat depth[2][3] = { { 0 } };
2989 /* Reading from GL. */
2990 gl.readPixels(0, 0, 3, 2, GL_DEPTH_COMPONENT, GL_FLOAT, depth);
2991 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
2993 /* Comparison against the reference. */
2994 for (glw::GLuint j = 0; j < 2; ++j)
2996 for (glw::GLuint i = 0; i < 3; ++i)
2998 if (de::abs(reference[j][i] - depth[j][i]) > (1.f / 64.f) /* Precision. */)
3001 m_context.getTestContext().getLog()
3002 << tcu::TestLog::Message << "Blitted framebuffer depth buffer contains [" << depth[0][0] << ", "
3003 << depth[0][1] << ", " << depth[0][2] << ", \n"
3004 << depth[1][0] << ", " << depth[1][1] << ", " << depth[1][2] << "], but " << reference[0][0] << ", "
3005 << reference[0][1] << ", " << reference[0][2] << ", \n"
3006 << reference[1][0] << ", " << reference[1][1] << ", " << reference[1][2] << "] was expected."
3007 << tcu::TestLog::EndMessage;
3017 /** @brief Check stencil and log.
3019 * @return true if stencil matches reference, false otherwise.
3021 bool BlitTest::CheckStencil()
3023 /* Shortcut for GL functionality. */
3024 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3026 /* Reference values. */
3027 static const glw::GLint reference[2][3] = { { 1, 2, 3 }, { 4, 4, 4 } };
3030 glw::GLint stencil[2][3] = { { 0 } };
3032 /* Reading from GL. */
3033 gl.readPixels(0, 0, 3, 2, GL_STENCIL_INDEX, GL_INT, stencil);
3034 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels has failed");
3036 /* Comparison against the reference. */
3037 for (glw::GLuint j = 0; j < 2; ++j)
3039 for (glw::GLuint i = 0; i < 3; ++i)
3041 if (reference[j][i] != stencil[j][i])
3044 m_context.getTestContext().getLog()
3045 << tcu::TestLog::Message << "Blitted framebuffer stencil buffer contains [" << stencil[0][0] << ", "
3046 << stencil[0][1] << ", " << stencil[0][2] << ", \n"
3047 << stencil[1][0] << ", " << stencil[1][1] << ", " << stencil[1][2] << "], but " << reference[0][0]
3048 << ", " << reference[0][1] << ", " << reference[0][2] << ", \n"
3049 << reference[1][0] << ", " << reference[1][1] << ", " << reference[1][2] << "] was expected."
3050 << tcu::TestLog::EndMessage;
3060 /** @brief Clear framebuffer.
3062 * @param [in] red Color component.
3063 * @param [in] green Color component.
3064 * @param [in] blue Color component.
3065 * @param [in] alpha Color component.
3066 * @param [in] depth Depth component.
3067 * @param [in] stencil Stencil index.
3069 void BlitTest::ClearFramebuffer(glw::GLfloat red, glw::GLfloat green, glw::GLfloat blue, glw::GLfloat depth,
3072 /* Shortcut for GL functionality. */
3073 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3075 /* Setup clear values. */
3076 gl.clearColor(red, green, blue, 1.f);
3077 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor has failed");
3079 gl.clearDepth(depth);
3080 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor has failed");
3082 gl.clearStencil(stencil);
3083 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor has failed");
3086 gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
3087 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor has failed");
3090 /** @brief Clean up GL state.
3092 void BlitTest::Clean()
3094 /* Shortcut for GL functionality. */
3095 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3097 /* Releasing objects. */
3100 gl.deleteFramebuffers(1, &m_fbo_src);
3107 gl.deleteFramebuffers(1, &m_fbo_dst);
3112 if (m_rbo_color_src)
3114 gl.deleteRenderbuffers(1, &m_rbo_color_src);
3116 m_rbo_color_src = 0;
3119 if (m_rbo_color_dst)
3121 gl.deleteRenderbuffers(1, &m_rbo_color_dst);
3123 m_rbo_color_dst = 0;
3126 if (m_rbo_depth_stencil_src)
3128 gl.deleteRenderbuffers(1, &m_rbo_depth_stencil_src);
3130 m_rbo_depth_stencil_src = 0;
3133 if (m_rbo_depth_stencil_dst)
3135 gl.deleteRenderbuffers(1, &m_rbo_depth_stencil_dst);
3137 m_rbo_depth_stencil_dst = 0;
3140 /* Errors clean up. */
3141 while (gl.getError())
3145 /******************************** Framebuffer Check Status Test Implementation ********************************/
3147 /** @brief Check Status Test constructor.
3149 * @param [in] context OpenGL context.
3151 CheckStatusTest::CheckStatusTest(deqp::Context& context)
3152 : deqp::TestCase(context, "framebuffers_check_status", "Framebuffer Check Status Test")
3154 /* Intentionally left blank. */
3157 /** @brief Iterate Check Status Test cases.
3159 * @return Iteration result.
3161 tcu::TestNode::IterateResult CheckStatusTest::iterate()
3163 /* Shortcut for GL functionality. */
3164 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3166 /* Get context setup. */
3167 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
3168 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
3170 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
3172 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
3177 /* Running tests. */
3179 bool maybe_ok = true;
3180 bool is_error = false;
3184 /* The specification is not clear about framebuffer completness. OpenGL 4.5 core profile
3185 specification in chapter 9.4.2 says:
3186 "The framebuffer object bound to target is said to be framebuffer complete if all
3187 the following conditions are true [...]"
3188 It does not say that framebuffer is incomplete when any of the conditions are not met.
3189 Due to this wording, except for obvious cases (incomplete attachment and missing attachments)
3190 other tests ar optional and may result in QP_TEST_RESULT_COMPATIBILITY_WARNING when fail. */
3191 is_ok &= IncompleteAttachmentTestCase();
3192 is_ok &= MissingAttachmentTestCase();
3194 maybe_ok &= IncompleteMultisampleRenderbufferTestCase();
3195 maybe_ok &= IncompleteMultisampleTextureTestCase();
3196 maybe_ok &= IncompleteLayerTargetsTestCase();
3204 /* Errors clean up. */
3205 while (gl.getError())
3208 /* Result's setup. */
3213 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
3217 m_testCtx.setTestResult(QP_TEST_RESULT_COMPATIBILITY_WARNING, "Pass with Compatibility Warning");
3224 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
3228 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
3235 /** Incomplete Attachment Test Case
3237 * @return True if test case succeeded, false otherwise.
3239 bool CheckStatusTest::IncompleteAttachmentTestCase()
3241 /* Shortcut for GL functionality. */
3242 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3246 bool is_error = false;
3249 glw::GLuint fbo = 0;
3250 glw::GLuint rbo = 0;
3254 gl.genFramebuffers(1, &fbo);
3255 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
3257 gl.bindFramebuffer(GL_FRAMEBUFFER, fbo);
3258 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
3260 gl.genRenderbuffers(1, &rbo);
3261 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
3263 gl.bindRenderbuffer(GL_RENDERBUFFER, rbo);
3264 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
3266 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo);
3267 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
3269 gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
3270 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
3272 glw::GLenum status = 0;
3274 /* Check that framebuffer is complete. */
3275 if (GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT != (status = gl.checkNamedFramebufferStatus(fbo, GL_FRAMEBUFFER)))
3277 m_context.getTestContext().getLog()
3278 << tcu::TestLog::Message
3279 << "CheckNamedFramebufferStatus did not return FRAMEBUFFER_INCOMPLETE_ATTACHMENT value. "
3280 << glu::getFramebufferStatusStr(status) << " was observed instead." << tcu::TestLog::EndMessage;
3291 /* Releasing obnjects. */
3294 gl.deleteFramebuffers(1, &fbo);
3299 gl.deleteRenderbuffers(1, &rbo);
3307 /* Errors clean up. */
3308 while (gl.getError())
3314 /** Missing Attachment Test Case
3316 * @return True if test case succeeded, false otherwise.
3318 bool CheckStatusTest::MissingAttachmentTestCase()
3320 /* Shortcut for GL functionality. */
3321 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3325 bool is_error = false;
3328 glw::GLuint fbo = 0;
3332 gl.genFramebuffers(1, &fbo);
3333 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
3335 gl.bindFramebuffer(GL_FRAMEBUFFER, fbo);
3336 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
3338 gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
3339 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
3341 glw::GLenum status = 0;
3343 /* Check that framebuffer is complete. */
3344 if (GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT !=
3345 (status = gl.checkNamedFramebufferStatus(fbo, GL_FRAMEBUFFER)))
3347 m_context.getTestContext().getLog()
3348 << tcu::TestLog::Message
3349 << "CheckNamedFramebufferStatus did not return FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT value. "
3350 << glu::getFramebufferStatusStr(status) << " was observed instead." << tcu::TestLog::EndMessage;
3361 /* Releasing obnjects. */
3364 gl.deleteRenderbuffers(1, &fbo);
3372 /* Errors clean up. */
3373 while (gl.getError())
3379 /** Incomplete Multisample Renderbuffer Test Case
3381 * @return True if test case succeeded, false otherwise.
3383 bool CheckStatusTest::IncompleteMultisampleRenderbufferTestCase()
3385 /* Shortcut for GL functionality. */
3386 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3390 bool is_error = false;
3393 glw::GLuint fbo = 0;
3394 glw::GLuint rbo[2] = { 0 };
3398 gl.genFramebuffers(1, &fbo);
3399 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
3401 gl.bindFramebuffer(GL_FRAMEBUFFER, fbo);
3402 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
3404 gl.genRenderbuffers(2, rbo);
3405 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
3407 gl.bindRenderbuffer(GL_RENDERBUFFER, rbo[0]);
3408 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
3410 gl.renderbufferStorageMultisample(GL_RENDERBUFFER, 1, GL_R8, 1, 1);
3411 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
3413 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[0]);
3414 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
3416 gl.bindRenderbuffer(GL_RENDERBUFFER, rbo[1]);
3417 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
3419 gl.renderbufferStorageMultisample(GL_RENDERBUFFER, 2, GL_R8, 1, 1);
3420 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
3422 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_RENDERBUFFER, rbo[1]);
3423 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
3425 gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
3426 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
3428 glw::GLenum status = 0;
3430 /* Check that framebuffer is complete. */
3431 if (GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE != (status = gl.checkNamedFramebufferStatus(fbo, GL_FRAMEBUFFER)))
3433 m_context.getTestContext().getLog()
3434 << tcu::TestLog::Message
3435 << "CheckNamedFramebufferStatus did not return FRAMEBUFFER_INCOMPLETE_MULTISAMPLE value. "
3436 << glu::getFramebufferStatusStr(status) << " was observed instead." << tcu::TestLog::EndMessage;
3447 /* Releasing obnjects. */
3450 gl.deleteFramebuffers(1, &fbo);
3453 for (glw::GLuint i = 0; i < 2; ++i)
3457 gl.deleteRenderbuffers(1, &rbo[i]);
3466 /* Errors clean up. */
3467 while (gl.getError())
3473 /** Incomplete Multisample Texture Test Case
3475 * @return True if test case succeeded, false otherwise.
3477 bool CheckStatusTest::IncompleteMultisampleTextureTestCase()
3479 /* Shortcut for GL functionality. */
3480 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3484 bool is_error = false;
3487 glw::GLuint fbo = 0;
3488 glw::GLuint rbo = 0;
3489 glw::GLuint to[2] = { 0 };
3493 gl.genFramebuffers(1, &fbo);
3494 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
3496 gl.bindFramebuffer(GL_FRAMEBUFFER, fbo);
3497 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
3499 gl.genTextures(2, to);
3500 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
3502 gl.bindTexture(GL_TEXTURE_2D_MULTISAMPLE, to[0]);
3503 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
3505 gl.texStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 2, GL_R8, 1, 1, GL_FALSE);
3506 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2DMultisample has failed");
3508 gl.framebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, to[0], 0);
3509 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
3511 gl.bindTexture(GL_TEXTURE_2D_MULTISAMPLE, to[1]);
3512 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
3514 gl.texStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_R8, 1, 1, GL_TRUE);
3515 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2DMultisample has failed");
3517 gl.framebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, to[1], 0);
3518 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
3520 gl.genRenderbuffers(1, &rbo);
3521 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
3523 gl.bindRenderbuffer(GL_RENDERBUFFER, rbo);
3524 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
3526 gl.renderbufferStorageMultisample(GL_RENDERBUFFER, 1, GL_R8, 1, 1);
3527 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
3529 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_RENDERBUFFER, rbo);
3530 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
3532 gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
3533 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
3535 glw::GLenum status = 0;
3537 /* Check that framebuffer is complete. */
3538 if (GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE != (status = gl.checkNamedFramebufferStatus(fbo, GL_FRAMEBUFFER)))
3540 m_context.getTestContext().getLog()
3541 << tcu::TestLog::Message
3542 << "CheckNamedFramebufferStatus did not return FRAMEBUFFER_INCOMPLETE_MULTISAMPLE value. "
3543 << glu::getFramebufferStatusStr(status) << " was observed instead." << tcu::TestLog::EndMessage;
3554 /* Releasing obnjects. */
3557 gl.deleteFramebuffers(1, &fbo);
3560 for (glw::GLuint i = 0; i < 2; ++i)
3564 gl.deleteTextures(1, &to[i]);
3570 gl.deleteRenderbuffers(1, &rbo);
3578 /* Errors clean up. */
3579 while (gl.getError())
3585 /** Incomplete Layer Targets Test Case
3587 * @return True if test case succeeded, false otherwise.
3589 bool CheckStatusTest::IncompleteLayerTargetsTestCase()
3591 /* Shortcut for GL functionality. */
3592 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3596 bool is_error = false;
3599 glw::GLuint fbo = 0;
3600 glw::GLuint to[2] = { 0 };
3604 gl.genFramebuffers(1, &fbo);
3605 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
3607 gl.bindFramebuffer(GL_FRAMEBUFFER, fbo);
3608 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
3610 gl.genTextures(2, to);
3611 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
3613 gl.bindTexture(GL_TEXTURE_3D, to[0]);
3614 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
3616 gl.texStorage3D(GL_TEXTURE_3D, 1, GL_R8, 2, 2, 2);
3617 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2DMultisample has failed");
3619 gl.framebufferTexture3D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_3D, to[0], 0, 0);
3620 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
3622 gl.bindTexture(GL_TEXTURE_2D, to[1]);
3623 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
3625 gl.texStorage2D(GL_TEXTURE_2D, 1, GL_R8, 1, 1);
3626 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2DMultisample has failed");
3628 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, to[1], 0);
3629 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
3631 gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
3632 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
3634 glw::GLenum status = 0;
3636 /* Check that framebuffer is complete. */
3637 if (GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS != (status = gl.checkNamedFramebufferStatus(fbo, GL_FRAMEBUFFER)))
3639 m_context.getTestContext().getLog()
3640 << tcu::TestLog::Message
3641 << "CheckNamedFramebufferStatus did not return FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS value. "
3642 << glu::getFramebufferStatusStr(status) << " was observed instead." << tcu::TestLog::EndMessage;
3653 /* Releasing obnjects. */
3656 gl.deleteFramebuffers(1, &fbo);
3659 for (glw::GLuint i = 0; i < 2; ++i)
3663 gl.deleteTextures(1, &to[i]);
3672 /* Errors clean up. */
3673 while (gl.getError())
3679 /******************************** Get Named Framebuffer Parameters Test Implementation ********************************/
3681 /** @brief Get Named Framebuffer Parameters Test constructor.
3683 * @param [in] context OpenGL context.
3685 GetParametersTest::GetParametersTest(deqp::Context& context)
3686 : deqp::TestCase(context, "framebuffers_get_parameters", "Get Named Framebuffer Parameters Test")
3690 /* Intentionally left blank. */
3693 /** @brief Iterate Check Status Test cases.
3695 * @return Iteration result.
3697 tcu::TestNode::IterateResult GetParametersTest::iterate()
3699 /* Shortcut for GL functionality. */
3700 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3702 /* Get context setup. */
3703 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
3704 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
3706 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
3708 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
3713 /* Running tests. */
3715 bool is_error = false;
3719 gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
3720 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
3722 is_ok &= TestDefaultFramebuffer();
3724 PrepareFramebuffer();
3726 is_ok &= TestCustomFramebuffer();
3737 /* Result's setup. */
3740 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
3746 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
3750 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
3757 /** @brief Prepare framebuffer.
3759 void GetParametersTest::PrepareFramebuffer()
3761 /* Shortcut for GL functionality. */
3762 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3764 gl.genFramebuffers(1, &m_fbo);
3765 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
3767 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
3768 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
3770 gl.genRenderbuffers(1, &m_rbo);
3771 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
3773 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo);
3774 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
3776 gl.renderbufferStorage(GL_RENDERBUFFER, GL_R8, 1, 2);
3777 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
3779 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo);
3780 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
3782 /* Check that framebuffer is complete. */
3783 if (GL_FRAMEBUFFER_COMPLETE != glCheckFramebufferStatus(GL_FRAMEBUFFER))
3785 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Unexpectedly framebuffer was incomplete."
3786 << tcu::TestLog::EndMessage;
3792 /** Default framebuffer Test Case
3794 * @return True if test case succeeded, false otherwise.
3796 bool GetParametersTest::TestDefaultFramebuffer()
3798 /* Shortcut for GL functionality. */
3799 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3804 static const glw::GLenum pnames[] = { GL_DOUBLEBUFFER,
3805 GL_IMPLEMENTATION_COLOR_READ_FORMAT,
3806 GL_IMPLEMENTATION_COLOR_READ_TYPE,
3811 static const glw::GLchar* pnames_strings[] = { "GL_DOUBLEBUFFER",
3812 "GL_IMPLEMENTATION_COLOR_READ_FORMAT",
3813 "GL_IMPLEMENTATION_COLOR_READ_TYPE",
3815 "GL_SAMPLE_BUFFERS",
3818 glw::GLuint pnames_count = sizeof(pnames) / sizeof(pnames[0]);
3820 for (glw::GLuint i = 0; i < pnames_count; ++i)
3822 glw::GLint parameter_legacy = 0;
3823 glw::GLint parameter_dsa = 0;
3825 gl.getFramebufferParameteriv(GL_FRAMEBUFFER, pnames[i], ¶meter_legacy);
3826 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetFramebufferParameteriv has failed");
3828 gl.getNamedFramebufferParameteriv(0, pnames[i], ¶meter_dsa);
3830 if (glw::GLenum error = gl.getError())
3832 m_context.getTestContext().getLog()
3833 << tcu::TestLog::Message << "GetNamedFramebufferParameteriv unexpectedly generated "
3834 << glu::getErrorStr(error) << " error when called with " << pnames_strings[i]
3835 << " parameter name for default framebuffer." << tcu::TestLog::EndMessage;
3842 if (parameter_legacy != parameter_dsa)
3844 m_context.getTestContext().getLog() << tcu::TestLog::Message << "GetNamedFramebufferParameteriv returned "
3845 << parameter_dsa << ", but " << parameter_legacy << " was expected for "
3846 << pnames_strings[i] << " parameter name of default object."
3847 << tcu::TestLog::EndMessage;
3856 /** Framebuffer Object Test Case
3858 * @return True if test case succeeded, false otherwise.
3860 bool GetParametersTest::TestCustomFramebuffer()
3862 /* Shortcut for GL functionality. */
3863 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3868 static const glw::GLenum pnames[] = { GL_DOUBLEBUFFER,
3869 GL_IMPLEMENTATION_COLOR_READ_FORMAT,
3870 GL_IMPLEMENTATION_COLOR_READ_TYPE,
3874 GL_FRAMEBUFFER_DEFAULT_WIDTH,
3875 GL_FRAMEBUFFER_DEFAULT_HEIGHT,
3876 GL_FRAMEBUFFER_DEFAULT_LAYERS,
3877 GL_FRAMEBUFFER_DEFAULT_SAMPLES,
3878 GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS };
3880 static const glw::GLchar* pnames_strings[] = { "GL_DOUBLEBUFFER",
3881 "GL_IMPLEMENTATION_COLOR_READ_FORMAT",
3882 "GL_IMPLEMENTATION_COLOR_READ_TYPE",
3884 "GL_SAMPLE_BUFFERS",
3886 "FRAMEBUFFER_DEFAULT_WIDTH",
3887 "FRAMEBUFFER_DEFAULT_HEIGHT",
3888 "FRAMEBUFFER_DEFAULT_LAYERS",
3889 "FRAMEBUFFER_DEFAULT_SAMPLES",
3890 "FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS" };
3892 glw::GLuint pnames_count = sizeof(pnames) / sizeof(pnames[0]);
3894 for (glw::GLuint i = 0; i < pnames_count; ++i)
3896 glw::GLint parameter_legacy = 0;
3897 glw::GLint parameter_dsa = 0;
3899 gl.getFramebufferParameteriv(GL_FRAMEBUFFER, pnames[i], ¶meter_legacy);
3900 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetFramebufferParameteriv has failed");
3902 gl.getNamedFramebufferParameteriv(m_fbo, pnames[i], ¶meter_dsa);
3904 if (glw::GLenum error = gl.getError())
3906 m_context.getTestContext().getLog()
3907 << tcu::TestLog::Message << "GetNamedFramebufferParameteriv unexpectedly generated "
3908 << glu::getErrorStr(error) << " error when called with " << pnames_strings[i]
3909 << " parameter name for framebuffer object." << tcu::TestLog::EndMessage;
3916 if (parameter_legacy != parameter_dsa)
3918 m_context.getTestContext().getLog() << tcu::TestLog::Message << "GetNamedFramebufferParameteriv returned "
3919 << parameter_dsa << ", but " << parameter_legacy << " was expected for "
3920 << pnames_strings[i] << " parameter name of framebuffer object."
3921 << tcu::TestLog::EndMessage;
3930 /** @brief Clean up GL state.
3932 void GetParametersTest::Clean()
3934 /* Shortcut for GL functionality. */
3935 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3937 /* Releasing obnjects. */
3940 gl.deleteFramebuffers(1, &m_fbo);
3947 gl.deleteRenderbuffers(1, &m_rbo);
3952 /* Errors clean up. */
3953 while (gl.getError())
3957 /******************************** Get Named Framebuffer Attachment Parameters Test Implementation ********************************/
3959 /** @brief Get Named Framebuffer Parameters Test constructor.
3961 * @param [in] context OpenGL context.
3963 GetAttachmentParametersTest::GetAttachmentParametersTest(deqp::Context& context)
3964 : deqp::TestCase(context, "framebuffers_get_attachment_parameters",
3965 "Get Named Framebuffer Attachment Parameters Test")
3968 memset(m_rbo, 0, sizeof(m_rbo));
3969 memset(m_to, 0, sizeof(m_to));
3972 /** @brief Iterate Get Named Framebuffer Attachment Parameters Test cases.
3974 * @return Iteration result.
3976 tcu::TestNode::IterateResult GetAttachmentParametersTest::iterate()
3978 /* Shortcut for GL functionality. */
3979 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3981 /* Get context setup. */
3982 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
3983 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
3985 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
3987 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
3992 /* Running tests. */
3994 bool is_error = false;
3998 /* Default framebuffer. */
3999 gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
4000 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
4002 is_ok &= TestDefaultFramebuffer();
4004 /* Framebuffer object with renderbuffer attachments (depth only). */
4005 CreateRenderbufferFramebuffer(true, false);
4007 is_ok &= TestRenderbufferFramebuffer(false);
4011 /* Framebuffer object with renderbuffer attachments (stencil only). */
4012 CreateRenderbufferFramebuffer(false, true);
4014 is_ok &= TestRenderbufferFramebuffer(false);
4018 /* Framebuffer object with renderbuffer attachments (depth-stencil merged). */
4019 CreateRenderbufferFramebuffer(true, true);
4021 is_ok &= TestRenderbufferFramebuffer(true);
4025 /* Framebuffer object with texture attachments (depth only). */
4026 CreateTextureFramebuffer(true, false);
4028 is_ok &= TestTextureFramebuffer(false);
4032 /* Framebuffer object with texture attachments (stencil only). */
4033 CreateTextureFramebuffer(false, true);
4035 is_ok &= TestTextureFramebuffer(false);
4039 /* Framebuffer object with texture attachments (depth-stencil merged). */
4040 CreateTextureFramebuffer(true, true);
4042 is_ok &= TestTextureFramebuffer(true);
4055 /* Result's setup. */
4058 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
4064 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
4068 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
4075 /** Create framebuffer with renderbuffer
4077 * @param [in] depth Prepare framebuffer with depth buffer.
4078 * @param [in] stencil Prepare framebuffer with stencil buffer.
4080 * @note If both depth and stencil, the joined dept_stencil buffer will be created.
4082 void GetAttachmentParametersTest::CreateRenderbufferFramebuffer(bool depth, bool stencil)
4084 /* Shortcut for GL functionality. */
4085 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4087 gl.genFramebuffers(1, &m_fbo);
4088 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
4090 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
4091 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
4093 gl.genRenderbuffers(2, m_rbo);
4094 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
4096 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo[0]);
4097 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
4099 gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 1, 2);
4100 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
4102 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo[0]);
4103 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
4105 if (depth && (!stencil))
4107 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo[1]);
4108 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
4110 gl.renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, 1, 2);
4111 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
4113 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_rbo[1]);
4114 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
4117 if ((!depth) && stencil)
4119 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo[1]);
4120 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
4122 gl.renderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, 1, 2);
4123 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
4125 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_rbo[1]);
4126 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
4129 if (depth && stencil)
4131 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo[1]);
4132 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
4134 gl.renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 1, 2);
4135 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
4137 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_rbo[1]);
4138 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
4141 /* Check that framebuffer is complete. */
4142 if (GL_FRAMEBUFFER_COMPLETE != glCheckFramebufferStatus(GL_FRAMEBUFFER))
4144 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Unexpectedly framebuffer was incomplete."
4145 << tcu::TestLog::EndMessage;
4151 /** Create framebuffer with tetxure
4153 * @param [in] depth Prepare framebuffer with depth buffer.
4154 * @param [in] stencil Prepare framebuffer with stencil buffer.
4156 * @note If both depth and stencil, the joined dept_stencil buffer will be created.
4158 void GetAttachmentParametersTest::CreateTextureFramebuffer(bool depth, bool stencil)
4160 /* Shortcut for GL functionality. */
4161 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4163 gl.genFramebuffers(1, &m_fbo);
4164 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
4166 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
4167 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffers has failed");
4169 gl.genTextures(2, m_to);
4170 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
4172 gl.bindTexture(GL_TEXTURE_2D, m_to[0]);
4173 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
4175 gl.texStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 1, 2);
4176 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
4178 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_to[0], 0);
4179 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
4181 if (depth && (!stencil))
4183 gl.bindTexture(GL_TEXTURE_2D, m_to[1]);
4184 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
4186 gl.texStorage2D(GL_TEXTURE_2D, 1, GL_DEPTH_COMPONENT24, 1, 2);
4187 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
4189 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_to[1], 0);
4190 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
4193 if ((!depth) && stencil)
4195 gl.bindTexture(GL_TEXTURE_2D, m_to[1]);
4196 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
4198 gl.texStorage2D(GL_TEXTURE_2D, 1, GL_STENCIL_INDEX8, 1, 2);
4199 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
4201 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_to[1], 0);
4202 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
4205 if (depth && stencil)
4207 gl.bindTexture(GL_TEXTURE_2D, m_to[1]);
4208 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffers has failed");
4210 gl.texStorage2D(GL_TEXTURE_2D, 1, GL_DEPTH24_STENCIL8, 1, 2);
4211 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
4213 gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_to[1], 0);
4214 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
4217 /* Check that framebuffer is complete. */
4218 if (GL_FRAMEBUFFER_COMPLETE != glCheckFramebufferStatus(GL_FRAMEBUFFER))
4220 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Unexpectedly framebuffer was incomplete."
4221 << tcu::TestLog::EndMessage;
4227 /** Test default framebuffer.
4229 * @return True if test succeeded, false otherwise.
4231 bool GetAttachmentParametersTest::TestDefaultFramebuffer()
4233 /* Shortcut for GL functionality. */
4234 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4239 static const glw::GLenum attachments[] = { GL_FRONT_LEFT, GL_FRONT_RIGHT, GL_BACK_LEFT,
4240 GL_BACK_RIGHT, GL_DEPTH, GL_STENCIL };
4242 static const glw::GLchar* attachments_strings[] = { "GL_FRONT_LEFT", "GL_FRONT_RIGHT", "GL_BACK_LEFT",
4243 "GL_BACK_RIGHT", "GL_DEPTH", "GL_STENCIL" };
4245 static const glw::GLuint attachments_count = sizeof(attachments) / sizeof(attachments[0]);
4247 for (glw::GLuint j = 0; j < attachments_count; ++j)
4249 glw::GLint parameter_legacy = 0;
4250 glw::GLint parameter_dsa = 0;
4252 gl.getFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, attachments[j], GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
4254 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetFramebufferParameteriv has failed");
4256 gl.getNamedFramebufferAttachmentParameteriv(0, attachments[j], GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
4260 if (glw::GLenum error = gl.getError())
4262 m_context.getTestContext().getLog()
4263 << tcu::TestLog::Message << "GetNamedFramebufferAttachmentParameteriv unexpectedly generated "
4264 << glu::getErrorStr(error)
4265 << " error when called with GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE parameter name for "
4266 << attachments_strings[j] << " attachment of default framebuffer." << tcu::TestLog::EndMessage;
4273 if (parameter_legacy != parameter_dsa)
4275 m_context.getTestContext().getLog()
4276 << tcu::TestLog::Message << "GetNamedFramebufferAttachmentParameteriv returned " << parameter_dsa
4277 << ", but " << parameter_legacy
4278 << " was expected for GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE parameter name of default framebuffer."
4279 << tcu::TestLog::EndMessage;
4286 if (parameter_dsa != GL_NONE)
4288 static const glw::GLenum optional_pnames[] = {
4289 GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE, GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE,
4290 GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE, GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE,
4291 GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE,
4292 GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING
4295 static const glw::GLchar* optional_pnames_strings[] = {
4296 "GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE", "GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",
4297 "GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE", "GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",
4298 "GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE", "GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",
4299 "GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE", "GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING"
4302 static const glw::GLuint optional_pnames_count = sizeof(optional_pnames) / sizeof(optional_pnames[0]);
4304 for (glw::GLuint i = 0; i < optional_pnames_count; ++i)
4306 glw::GLint optional_parameter_legacy = 0;
4307 glw::GLint optional_parameter_dsa = 0;
4309 gl.getFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, attachments[j], optional_pnames[i],
4310 &optional_parameter_legacy);
4311 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetFramebufferParameteriv has failed");
4313 gl.getNamedFramebufferAttachmentParameteriv(0, attachments[j], optional_pnames[i],
4314 &optional_parameter_dsa);
4316 if (glw::GLenum error = gl.getError())
4318 m_context.getTestContext().getLog()
4319 << tcu::TestLog::Message << "GetNamedFramebufferAttachmentParameteriv unexpectedly generated "
4320 << glu::getErrorStr(error) << " error when called with " << optional_pnames_strings[i]
4321 << " parameter name for " << attachments_strings[j]
4322 << " attachment of default framebuffer. The GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE was "
4323 << parameter_legacy << "." << tcu::TestLog::EndMessage;
4330 if (optional_parameter_legacy != optional_parameter_dsa)
4332 m_context.getTestContext().getLog()
4333 << tcu::TestLog::Message << "GetNamedFramebufferAttachmentParameteriv returned "
4334 << optional_parameter_dsa << ", but " << optional_parameter_legacy << " was expected for "
4335 << optional_pnames_strings << " parameter name for " << attachments_strings[j]
4336 << " attachment of default framebuffer." << tcu::TestLog::EndMessage;
4349 /** Test framebuffer object (with renderbuffer).
4351 * @param [in] depth_stencil Has framebuffer depth_stencil attachment.
4353 * @return True if test succeeded, false otherwise.
4355 bool GetAttachmentParametersTest::TestRenderbufferFramebuffer(bool depth_stencil)
4357 /* Shortcut for GL functionality. */
4358 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4363 static const glw::GLenum attachments[] = { GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT, GL_DEPTH_STENCIL_ATTACHMENT,
4364 GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 };
4366 static const glw::GLchar* attachments_strings[] = { "GL_DEPTH_ATTACHMENT", "GL_STENCIL_ATTACHMENT",
4367 "GL_DEPTH_STENCIL_ATTACHMENT", "GL_COLOR_ATTACHMENT0",
4368 "GL_COLOR_ATTACHMENT1" };
4370 static const glw::GLuint attachments_count = sizeof(attachments) / sizeof(attachments[0]);
4372 for (glw::GLuint j = 0; j < attachments_count; ++j)
4374 glw::GLint parameter_legacy = 0;
4375 glw::GLint parameter_dsa = 0;
4377 /* Omit DEPTH_STENCIL_ATTACHMENT attachment if the renderbuffer is not depth-stencil. */
4378 if (attachments[j] == GL_DEPTH_STENCIL_ATTACHMENT)
4386 gl.getFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, attachments[j], GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
4388 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetFramebufferParameteriv has failed");
4390 gl.getNamedFramebufferAttachmentParameteriv(m_fbo, attachments[j], GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
4394 if (glw::GLenum error = gl.getError())
4396 m_context.getTestContext().getLog()
4397 << tcu::TestLog::Message << "GetNamedFramebufferAttachmentParameteriv unexpectedly generated "
4398 << glu::getErrorStr(error)
4399 << " error when called with GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE parameter name for "
4400 << attachments_strings[j] << " attachment of renderbuffer framebuffer object."
4401 << tcu::TestLog::EndMessage;
4408 if (parameter_legacy != parameter_dsa)
4410 m_context.getTestContext().getLog()
4411 << tcu::TestLog::Message << "GetNamedFramebufferAttachmentParameteriv returned " << parameter_dsa
4412 << ", but " << parameter_legacy << " was expected for GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE parameter "
4413 "name of renderbuffer framebuffer object."
4414 << tcu::TestLog::EndMessage;
4421 if (parameter_dsa != GL_NONE)
4423 static const glw::GLenum optional_pnames[] = {
4424 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE,
4425 GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE, GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE,
4426 GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE,
4427 GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE, GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE,
4428 GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING
4431 static const glw::GLchar* optional_pnames_strings[] = {
4432 "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME", "GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE",
4433 "GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE", "GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",
4434 "GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE", "GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",
4435 "GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE", "GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",
4436 "GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING"
4439 static const glw::GLuint optional_pnames_count = sizeof(optional_pnames) / sizeof(optional_pnames[0]);
4441 for (glw::GLuint i = 0; i < optional_pnames_count; ++i)
4443 /* Omit FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE pname when DEPTH_STENCIL_ATTACHMENT attachment is used. */
4444 if (attachments[j] == GL_DEPTH_STENCIL_ATTACHMENT)
4446 if (optional_pnames[i] == GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE)
4452 glw::GLint optional_parameter_legacy = 0;
4453 glw::GLint optional_parameter_dsa = 0;
4455 gl.getFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, attachments[j], optional_pnames[i],
4456 &optional_parameter_legacy);
4457 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetFramebufferParameteriv has failed");
4459 gl.getNamedFramebufferAttachmentParameteriv(m_fbo, attachments[j], optional_pnames[i],
4460 &optional_parameter_dsa);
4462 if (glw::GLenum error = gl.getError())
4464 m_context.getTestContext().getLog()
4465 << tcu::TestLog::Message << "GetNamedFramebufferAttachmentParameteriv unexpectedly generated "
4466 << glu::getErrorStr(error) << " error when called with " << optional_pnames_strings[i]
4467 << " parameter name for " << attachments_strings[j]
4468 << " attachment of renderbuffer framebuffer object. The GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE "
4470 << parameter_legacy << "." << tcu::TestLog::EndMessage;
4477 if (optional_parameter_legacy != optional_parameter_dsa)
4479 m_context.getTestContext().getLog()
4480 << tcu::TestLog::Message << "GetNamedFramebufferAttachmentParameteriv returned "
4481 << optional_parameter_dsa << ", but " << optional_parameter_legacy << " was expected for "
4482 << optional_pnames_strings << " parameter name for " << attachments_strings[j]
4483 << " attachment of renderbuffer framebuffer object." << tcu::TestLog::EndMessage;
4496 /** Test framebuffer object (with texture).
4498 * @param [in] depth_stencil Has framebuffer depth_stencil attachment.
4500 * @return True if test succeeded, false otherwise.
4502 bool GetAttachmentParametersTest::TestTextureFramebuffer(bool depth_stencil)
4504 /* Shortcut for GL functionality. */
4505 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4510 static const glw::GLenum attachments[] = { GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT, GL_DEPTH_STENCIL_ATTACHMENT,
4511 GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 };
4513 static const glw::GLchar* attachments_strings[] = { "GL_DEPTH_ATTACHMENT", "GL_STENCIL_ATTACHMENT",
4514 "GL_DEPTH_STENCIL_ATTACHMENT", "GL_COLOR_ATTACHMENT0",
4515 "GL_COLOR_ATTACHMENT1" };
4517 static const glw::GLuint attachments_count = sizeof(attachments) / sizeof(attachments[0]);
4519 for (glw::GLuint j = 0; j < attachments_count; ++j)
4521 /* Omit DEPTH_STENCIL_ATTACHMENT attachment if the renderbuffer is not depth-stencil. */
4522 if (attachments[j] == GL_DEPTH_STENCIL_ATTACHMENT)
4530 glw::GLint parameter_legacy = 0;
4531 glw::GLint parameter_dsa = 0;
4533 gl.getFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, attachments[j], GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
4535 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetFramebufferParameteriv has failed");
4537 gl.getNamedFramebufferAttachmentParameteriv(m_fbo, attachments[j], GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
4541 if (glw::GLenum error = gl.getError())
4543 m_context.getTestContext().getLog()
4544 << tcu::TestLog::Message << "GetNamedFramebufferAttachmentParameteriv unexpectedly generated "
4545 << glu::getErrorStr(error)
4546 << " error when called with GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE parameter name for "
4547 << attachments_strings[j] << " attachment of texture framebuffer object." << tcu::TestLog::EndMessage;
4554 if (parameter_legacy != parameter_dsa)
4556 m_context.getTestContext().getLog()
4557 << tcu::TestLog::Message << "GetNamedFramebufferAttachmentParameteriv returned " << parameter_dsa
4558 << ", but " << parameter_legacy << " was expected for GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE parameter "
4559 "name of texture framebuffer object."
4560 << tcu::TestLog::EndMessage;
4567 if (parameter_dsa != GL_NONE)
4569 static const glw::GLenum optional_pnames[] = { GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME,
4570 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL,
4571 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE,
4572 GL_FRAMEBUFFER_ATTACHMENT_LAYERED,
4573 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER,
4574 GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE,
4575 GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE,
4576 GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE,
4577 GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE,
4578 GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE,
4579 GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE,
4580 GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE,
4581 GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING };
4583 static const glw::GLchar* optional_pnames_strings[] = { "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",
4584 "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",
4585 "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",
4586 "GL_FRAMEBUFFER_ATTACHMENT_LAYERED",
4587 "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",
4588 "GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE",
4589 "GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",
4590 "GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",
4591 "GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",
4592 "GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",
4593 "GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",
4594 "GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",
4595 "GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING" };
4597 static const glw::GLuint optional_pnames_count = sizeof(optional_pnames) / sizeof(optional_pnames[0]);
4599 for (glw::GLuint i = 0; i < optional_pnames_count; ++i)
4601 /* Omit FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE pname when DEPTH_STENCIL_ATTACHMENT attachment is used. */
4602 if (attachments[j] == GL_DEPTH_STENCIL_ATTACHMENT)
4604 if (optional_pnames[i] == GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE)
4610 glw::GLint optional_parameter_legacy = 0;
4611 glw::GLint optional_parameter_dsa = 0;
4613 gl.getFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, attachments[j], optional_pnames[i],
4614 &optional_parameter_legacy);
4615 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetFramebufferParameteriv has failed");
4617 gl.getNamedFramebufferAttachmentParameteriv(m_fbo, attachments[j], optional_pnames[i],
4618 &optional_parameter_dsa);
4620 if (glw::GLenum error = gl.getError())
4622 m_context.getTestContext().getLog()
4623 << tcu::TestLog::Message << "GetNamedFramebufferAttachmentParameteriv unexpectedly generated "
4624 << glu::getErrorStr(error) << " error when called with " << optional_pnames_strings[i]
4625 << " parameter name for " << attachments_strings[j]
4626 << " attachment of texture framebuffer object. The GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE was "
4627 << parameter_legacy << "." << tcu::TestLog::EndMessage;
4634 if (optional_parameter_legacy != optional_parameter_dsa)
4636 m_context.getTestContext().getLog()
4637 << tcu::TestLog::Message << "GetNamedFramebufferAttachmentParameteriv returned "
4638 << optional_parameter_dsa << ", but " << optional_parameter_legacy << " was expected for "
4639 << optional_pnames_strings << " parameter name for " << attachments_strings[j]
4640 << " attachment of texture framebuffer object." << tcu::TestLog::EndMessage;
4653 /** @brief Clean up GL state.
4655 void GetAttachmentParametersTest::Clean()
4657 /* Shortcut for GL functionality. */
4658 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4660 /* Releasing obnjects. */
4663 gl.deleteFramebuffers(1, &m_fbo);
4668 /* Releasing renderbuffers. */
4669 for (glw::GLuint i = 0; i < 2; ++i)
4673 gl.deleteRenderbuffers(1, &m_rbo[i]);
4679 /* Releasing textures. */
4680 for (glw::GLuint i = 0; i < 2; ++i)
4684 gl.deleteTextures(1, &m_to[i]);
4690 /* Errors clean up. */
4691 while (gl.getError())
4695 /******************************** Framebuffer Creation Errors Test Implementation ********************************/
4697 /** @brief Creation Errors Test constructor.
4699 * @param [in] context OpenGL context.
4701 CreationErrorsTest::CreationErrorsTest(deqp::Context& context)
4702 : deqp::TestCase(context, "framebuffers_creation_errors", "Framebuffer Objects Creation Errors Test")
4704 /* Intentionally left blank. */
4707 /** @brief Iterate Creation Test cases.
4709 * @return Iteration result.
4711 tcu::TestNode::IterateResult CreationErrorsTest::iterate()
4713 /* Shortcut for GL functionality. */
4714 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4716 /* Get context setup. */
4717 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
4718 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
4720 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
4722 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
4727 /* Running tests. */
4730 /* Framebuffer object */
4731 glw::GLuint framebuffer = 0;
4733 /* Check direct state creation of negative numbers of framebuffers. */
4734 gl.createFramebuffers(-1, &framebuffer);
4736 glw::GLenum error = GL_NO_ERROR;
4738 if (GL_INVALID_VALUE != (error = gl.getError()))
4740 m_context.getTestContext().getLog()
4741 << tcu::TestLog::Message << "CreateFramebuffers generated " << glu::getErrorStr(error)
4742 << " error when called with negative number of framebuffers, but GL_INVALID_VALUE was expected."
4743 << tcu::TestLog::EndMessage;
4748 /* Cleanup (sanity). */
4751 gl.deleteFramebuffers(1, &framebuffer);
4754 /* Errors clean up. */
4755 while (gl.getError())
4758 /* Result's setup. */
4761 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
4765 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
4771 /******************************** Renderbuffer Attachment Errors Test Implementation ********************************/
4773 /** @brief Renderbuffer Attachment Errors Test constructor.
4775 * @param [in] context OpenGL context.
4777 RenderbufferAttachmentErrorsTest::RenderbufferAttachmentErrorsTest(deqp::Context& context)
4778 : deqp::TestCase(context, "framebuffers_renderbuffer_attachment_errors", "Renderbuffer Attachment Errors Test")
4783 , m_color_attachment_invalid(0)
4784 , m_attachment_invalid(0)
4785 , m_renderbuffer_target_invalid(0)
4787 /* Intentionally left blank. */
4790 /** @brief Iterate Renderbuffer Attachment Errors Test cases.
4792 * @return Iteration result.
4794 tcu::TestNode::IterateResult RenderbufferAttachmentErrorsTest::iterate()
4796 /* Shortcut for GL functionality. */
4797 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4799 /* Get context setup. */
4800 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
4801 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
4803 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
4805 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
4810 /* Running tests. */
4812 bool is_error = false;
4816 /* Prepare objects. */
4819 /* Invalid Framebuffer ID. */
4820 gl.namedFramebufferRenderbuffer(m_fbo_invalid, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo_valid);
4822 is_ok &= ExpectError(GL_INVALID_OPERATION, false, true, false, true, true);
4824 /* Invalid color attachment. */
4825 gl.namedFramebufferRenderbuffer(m_fbo_valid, m_color_attachment_invalid, GL_RENDERBUFFER, m_rbo_valid);
4827 is_ok &= ExpectError(GL_INVALID_OPERATION, true, false, true, true, true);
4829 /* Invalid attachment. */
4830 gl.namedFramebufferRenderbuffer(m_fbo_valid, m_attachment_invalid, GL_RENDERBUFFER, m_rbo_valid);
4832 is_ok &= ExpectError(GL_INVALID_ENUM, true, false, false, true, true);
4834 /* Invalid Renderbuffer Target. */
4835 gl.namedFramebufferRenderbuffer(m_fbo_valid, GL_COLOR_ATTACHMENT0, m_renderbuffer_target_invalid, m_rbo_valid);
4837 is_ok &= ExpectError(GL_INVALID_ENUM, true, true, false, false, true);
4839 /* Invalid Renderbuffer ID. */
4840 gl.namedFramebufferRenderbuffer(m_fbo_valid, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo_invalid);
4842 is_ok &= ExpectError(GL_INVALID_OPERATION, true, true, false, true, false);
4853 /* Result's setup. */
4856 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
4862 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
4866 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
4873 /** Prepare test objects.
4875 void RenderbufferAttachmentErrorsTest::PrepareObjects()
4877 /* Shortcut for GL functionality. */
4878 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4880 /* Valid objects. */
4881 gl.genFramebuffers(1, &m_fbo_valid);
4882 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
4884 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_valid);
4885 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
4887 gl.genRenderbuffers(1, &m_rbo_valid);
4888 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
4890 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo_valid);
4891 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
4893 /* Invalid objects. */
4894 while (gl.isFramebuffer(++m_fbo_invalid))
4896 while (gl.isRenderbuffer(++m_rbo_invalid))
4899 /* Max color attachments query. */
4900 glw::GLint max_color_attachments = 8; /* Spec default. */
4901 gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
4902 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
4904 /* Invalid color attachment */
4905 m_color_attachment_invalid = GL_COLOR_ATTACHMENT0 + max_color_attachments;
4907 /* Invalid attachment. */
4908 bool is_attachment = true;
4910 while (is_attachment)
4912 ++m_attachment_invalid;
4914 is_attachment = false;
4916 if ((GL_DEPTH_ATTACHMENT == m_attachment_invalid) || (GL_STENCIL_ATTACHMENT == m_attachment_invalid) ||
4917 (GL_DEPTH_STENCIL_ATTACHMENT == m_attachment_invalid))
4919 is_attachment = true;
4922 if (GL_COLOR_ATTACHMENT0 < m_attachment_invalid)
4924 /* If this unlikely happen this mean that we cannot create invalid attachment which is not DEPTH_ATTACHMENT, STENCIL_ATTACHMENT, DEPTH_STENCIL_ATTACHMENT and
4925 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
4926 INVALID_OPERATION shall be generated instead of INVALID_ENUM. Such a situation may need change in the test or in the specification. */
4931 /* Invalid renderbuffer target. */
4932 m_renderbuffer_target_invalid = GL_RENDERBUFFER + 1;
4935 /** Check if error is equal to the expected, log if not.
4937 * @param [in] expected_error Error to be expected.
4938 * @param [in] framebuffer Framebuffer name to be logged.
4939 * @param [in] attachment Attachment name to be logged.
4940 * @param [in] renderbuffertarget Renderbuffertarget name to be logged.
4941 * @param [in] renderbuffer Renderbuffer name to be logged.
4943 * @return True if test succeeded, false otherwise.
4945 bool RenderbufferAttachmentErrorsTest::ExpectError(glw::GLenum expected_error, bool framebuffer, bool attachment,
4946 bool color_attachment, bool renderbuffertarget, bool renderbuffer)
4948 /* Shortcut for GL functionality. */
4949 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4953 glw::GLenum error = GL_NO_ERROR;
4955 if (expected_error != (error = gl.getError()))
4957 m_context.getTestContext().getLog()
4958 << tcu::TestLog::Message << "NamedFramebufferRenderbuffer called with "
4959 << (framebuffer ? "valid" : "invalid") << " framebuffer, " << (attachment ? "valid" : "invalid")
4960 << (color_attachment ? " color" : "") << " attachment, " << (renderbuffertarget ? "valid" : "invalid")
4961 << " renderbuffer target, " << (renderbuffer ? "valid" : "invalid")
4962 << " renderbuffer was expected to generate " << glu::getErrorStr(expected_error) << ", but "
4963 << glu::getErrorStr(error) << " was observed instead." << tcu::TestLog::EndMessage;
4968 /* Clean additional possible errors. */
4969 while (gl.getError())
4975 /** @brief Clean up GL state.
4977 void RenderbufferAttachmentErrorsTest::Clean()
4979 /* Shortcut for GL functionality. */
4980 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4982 /* Release GL objects. */
4985 gl.deleteFramebuffers(1, &m_fbo_valid);
4991 gl.deleteRenderbuffers(1, &m_rbo_valid);
4995 /* Set initial values - all test shall have the same environment. */
4998 m_attachment_invalid = 0;
4999 m_color_attachment_invalid = 0;
5000 m_renderbuffer_target_invalid = 0;
5002 /* Errors clean up. */
5003 while (gl.getError())
5007 /******************************** Texture Attachment Errors Test Implementation ********************************/
5009 /** @brief Texture Attachment Errors Test constructor.
5011 * @param [in] context OpenGL context.
5013 TextureAttachmentErrorsTest::TextureAttachmentErrorsTest(deqp::Context& context)
5014 : deqp::TestCase(context, "framebuffers_texture_attachment_errors", "Texture Attachment Errors Test")
5018 , m_to_array_valid(0)
5019 , m_to_cubearray_valid(0)
5023 , m_to_layer_invalid(0)
5024 , m_color_attachment_invalid(0)
5025 , m_attachment_invalid(0)
5026 , m_level_invalid(0)
5027 , m_max_3d_texture_size(2048) /* OpenGL 4.5 Core Profile default values (Table 23.53). */
5028 , m_max_3d_texture_depth(2048) /* == m_max_3d_texture_size or value of GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV. */
5029 , m_max_array_texture_layers(2048) /* OpenGL 4.5 Core Profile default values (Table 23.53). */
5030 , m_max_cube_map_texture_size(16384) /* OpenGL 4.5 Core Profile default values (Table 23.53). */
5032 /* Intentionally left blank. */
5035 /** @brief Iterate Texture Attachment Errors Test cases.
5037 * @return Iteration result.
5039 tcu::TestNode::IterateResult TextureAttachmentErrorsTest::iterate()
5041 /* Shortcut for GL functionality. */
5042 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5044 /* Get context setup. */
5045 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
5046 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
5048 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
5050 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
5055 /* Running tests. */
5057 bool is_error = false;
5061 /* Prepare objects. */
5064 /********** NamedFramebufferTexture **************/
5066 /* Invalid Framebuffer ID. */
5067 gl.namedFramebufferTexture(m_fbo_invalid, GL_COLOR_ATTACHMENT0, m_to_valid, 0);
5069 is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferTexture", false, true, false, true, true, "", true);
5071 /* Invalid Color Attachment. */
5072 gl.namedFramebufferTexture(m_fbo_valid, m_color_attachment_invalid, m_to_valid, 0);
5074 is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferTexture", true, false, true, true, true, "", true);
5076 /* Invalid Attachment. */
5077 gl.namedFramebufferTexture(m_fbo_valid, m_attachment_invalid, m_to_valid, 0);
5079 is_ok &= ExpectError(GL_INVALID_ENUM, "NamedFramebufferTexture", true, false, false, true, true, "", true);
5081 /* Invalid Texture ID. */
5082 gl.namedFramebufferTexture(m_fbo_valid, GL_COLOR_ATTACHMENT0, m_to_invalid, 0);
5084 is_ok &= ExpectError(GL_INVALID_VALUE, "NamedFramebufferTexture", true, true, false, false, true, "", true);
5086 /* Invalid Level. */
5087 gl.namedFramebufferTexture(m_fbo_valid, GL_COLOR_ATTACHMENT0, m_to_valid, m_level_invalid);
5089 is_ok &= ExpectError(GL_INVALID_VALUE, "NamedFramebufferTexture", true, true, false, true, false, "", true);
5091 /* Buffer texture. */
5092 gl.namedFramebufferTexture(m_fbo_valid, GL_COLOR_ATTACHMENT0, m_tbo_valid, 0);
5095 ExpectError(GL_INVALID_OPERATION, "NamedFramebufferTexture", true, true, false, true, true, "buffer", true);
5097 /********** NamedFramebufferTextureLayer **************/
5099 /* Invalid Framebuffer ID. */
5100 gl.namedFramebufferTextureLayer(m_fbo_invalid, GL_COLOR_ATTACHMENT0, m_to_array_valid, 0, 0);
5103 ExpectError(GL_INVALID_OPERATION, "NamedFramebufferTextureLayer", false, true, false, true, true, "", true);
5105 /* Invalid Color Attachment. */
5106 gl.namedFramebufferTextureLayer(m_fbo_valid, m_color_attachment_invalid, m_to_array_valid, 0, 0);
5109 ExpectError(GL_INVALID_OPERATION, "NamedFramebufferTextureLayer", true, false, true, true, true, "", true);
5111 /* Invalid Attachment. */
5112 gl.namedFramebufferTextureLayer(m_fbo_valid, m_attachment_invalid, m_to_array_valid, 0, 0);
5114 is_ok &= ExpectError(GL_INVALID_ENUM, "NamedFramebufferTextureLayer", true, false, false, true, true, "", true);
5116 /* Invalid Texture ID. */
5117 gl.namedFramebufferTextureLayer(m_fbo_valid, GL_COLOR_ATTACHMENT0, m_to_invalid, 0, 0);
5120 ExpectError(GL_INVALID_OPERATION, "NamedFramebufferTextureLayer", true, true, false, false, true, "", true);
5122 /* Invalid Level. */
5123 gl.namedFramebufferTextureLayer(m_fbo_valid, GL_COLOR_ATTACHMENT0, m_to_array_valid, m_level_invalid, 0);
5126 ExpectError(GL_INVALID_VALUE, "NamedFramebufferTextureLayer", true, true, false, true, false, "", true);
5128 /* Buffer texture. */
5129 gl.namedFramebufferTextureLayer(m_fbo_valid, GL_COLOR_ATTACHMENT0, m_tbo_valid, 0, 0);
5131 is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferTextureLayer", true, true, false, true, true,
5134 /* Check that INVALID_VALUE error is generated by NamedFramebufferTextureLayer if texture is a three-dimensional
5135 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. */
5136 gl.namedFramebufferTextureLayer(m_fbo_valid, GL_COLOR_ATTACHMENT0, m_to_3d_valid, 0, m_max_3d_texture_depth);
5138 is_ok &= ExpectError(GL_INVALID_VALUE, "NamedFramebufferTextureLayer", true, true, false, true, true,
5139 "3D texture", false);
5141 /* Check that INVALID_VALUE error is generated by NamedFramebufferTextureLayer if texture is an array texture,
5142 and layer is larger than the value of MAX_ARRAY_TEXTURE_LAYERS minus one. */
5143 gl.namedFramebufferTextureLayer(m_fbo_valid, GL_COLOR_ATTACHMENT0, m_to_array_valid, 0,
5144 m_max_array_texture_layers);
5146 is_ok &= ExpectError(GL_INVALID_VALUE, "NamedFramebufferTextureLayer", true, true, false, true, true, "array",
5149 /* Check that INVALID_VALUE error is generated by NamedFramebufferTextureLayer if texture is a cube map array texture,
5150 and (layer / 6) is larger than the value of MAX_CUBE_MAP_TEXTURE_SIZE minus one (see section 9.8).
5151 Check that INVALID_VALUE error is generated by NamedFramebufferTextureLayer if texture is non-zero
5152 and layer is negative. */
5153 gl.namedFramebufferTextureLayer(m_fbo_valid, GL_COLOR_ATTACHMENT0, m_to_cubearray_valid, 0,
5154 m_max_cube_map_texture_size);
5156 is_ok &= ExpectError(GL_INVALID_VALUE, "NamedFramebufferTextureLayer", true, true, false, true, true,
5157 "cuba map array", false);
5159 /* Check that INVALID_OPERATION error is generated by NamedFramebufferTextureLayer if texture is non-zero
5160 and is not the name of a three-dimensional, two-dimensional multisample array, one- or two-dimensional array,
5161 or cube map array texture. */
5162 gl.namedFramebufferTextureLayer(m_fbo_valid, GL_COLOR_ATTACHMENT0, m_to_layer_invalid, 0, 0);
5164 is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferTextureLayer", true, true, false, false, true,
5176 /* Result's setup. */
5179 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
5185 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
5189 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
5196 /** Prepare test GL objects.
5198 void TextureAttachmentErrorsTest::PrepareObjects()
5200 /* Shortcut for GL functionality. */
5201 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5203 /* Valid objects. */
5204 gl.genFramebuffers(1, &m_fbo_valid);
5205 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
5207 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_valid);
5208 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
5210 gl.genTextures(1, &m_to_valid);
5211 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
5213 gl.bindTexture(GL_TEXTURE_2D, m_to_valid);
5214 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
5216 gl.genTextures(1, &m_tbo_valid);
5217 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
5219 gl.bindTexture(GL_TEXTURE_BUFFER, m_tbo_valid);
5220 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
5222 gl.genTextures(1, &m_to_3d_valid);
5223 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
5225 gl.bindTexture(GL_TEXTURE_3D, m_to_3d_valid);
5226 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
5228 gl.genTextures(1, &m_to_array_valid);
5229 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
5231 gl.bindTexture(GL_TEXTURE_2D_ARRAY, m_to_array_valid);
5232 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
5234 gl.genTextures(1, &m_to_cubearray_valid);
5235 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
5237 gl.bindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, m_to_cubearray_valid);
5238 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
5240 gl.genTextures(1, &m_to_layer_invalid);
5241 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
5243 gl.bindTexture(GL_TEXTURE_RECTANGLE, m_to_layer_invalid);
5244 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
5246 /* Invalid objects. */
5247 while (gl.isFramebuffer(++m_fbo_invalid))
5249 while (gl.isTexture(++m_to_invalid))
5252 /* Max color attachments query. */
5253 glw::GLint max_color_attachments = 8; /* Spec default. */
5254 gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
5255 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
5257 /* Invalid color attachment */
5258 m_color_attachment_invalid = GL_COLOR_ATTACHMENT0 + max_color_attachments;
5260 /* Invalid attachment. */
5261 bool is_attachment = true;
5263 while (is_attachment)
5265 ++m_attachment_invalid;
5267 is_attachment = false;
5269 if ((GL_DEPTH_ATTACHMENT == m_attachment_invalid) || (GL_STENCIL_ATTACHMENT == m_attachment_invalid) ||
5270 (GL_DEPTH_STENCIL_ATTACHMENT == m_attachment_invalid))
5272 is_attachment = true;
5275 for (glw::GLint i = 0; i < max_color_attachments; ++i)
5277 if (GL_COLOR_ATTACHMENT0 == m_attachment_invalid)
5279 is_attachment = true;
5284 /* Maximum values */
5285 gl.getIntegerv(GL_MAX_3D_TEXTURE_SIZE, &m_max_3d_texture_size);
5286 gl.getIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &m_max_array_texture_layers);
5287 gl.getIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &m_max_cube_map_texture_size);
5289 if (m_context.getContextInfo().isExtensionSupported("GL_NV_deep_texture3D"))
5291 gl.getIntegerv(GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV, &m_max_3d_texture_depth);
5295 m_max_3d_texture_depth = m_max_3d_texture_size;
5298 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
5300 /* Invalid level. */
5301 m_level_invalid = -1;
5304 /** Check if error is equal to the expected, log if not.
5306 * @param [in] expected_error Error to be expected.
5307 * @param [in] framebuffer Framebuffer name to be logged.
5308 * @param [in] attachment Attachment name to be logged.
5309 * @param [in] texture Texture name to be logged.
5310 * @param [in] level Level # to be logged.
5311 * @param [in] buffer_texture Is this buffer texture (special logging case).
5313 * @return True if test succeeded, false otherwise.
5315 bool TextureAttachmentErrorsTest::ExpectError(glw::GLenum expected_error, const glw::GLchar* function_name,
5316 bool framebuffer, bool attachment, bool color_attachment, bool texture,
5317 bool level, const glw::GLchar* texture_type, bool layer)
5319 /* Shortcut for GL functionality. */
5320 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5324 glw::GLenum error = GL_NO_ERROR;
5326 if (expected_error != (error = gl.getError()))
5328 m_context.getTestContext().getLog()
5329 << tcu::TestLog::Message << function_name << " called with " << (framebuffer ? "valid" : "invalid")
5330 << " framebuffer, " << (attachment ? "valid" : "invalid") << (color_attachment ? " color" : "")
5331 << " attachment, " << (texture ? "valid " : "invalid ") << texture_type << " texture, "
5332 << (level ? "valid" : "invalid") << " level" << (layer ? "" : ", with invalid layer number")
5333 << " was expected to generate " << glu::getErrorStr(expected_error) << ", but " << glu::getErrorStr(error)
5334 << " was observed instead." << tcu::TestLog::EndMessage;
5339 /* Clean additional possible errors. */
5340 while (gl.getError())
5346 /** @brief Clean up GL state.
5348 void TextureAttachmentErrorsTest::Clean()
5350 /* Shortcut for GL functionality. */
5351 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5353 /* Release GL objects. */
5356 gl.deleteFramebuffers(1, &m_fbo_valid);
5362 gl.deleteTextures(1, &m_to_valid);
5368 gl.deleteTextures(1, &m_tbo_valid);
5374 gl.deleteTextures(1, &m_to_3d_valid);
5378 if (m_to_array_valid)
5380 gl.deleteTextures(1, &m_to_array_valid);
5381 m_to_array_valid = 0;
5384 if (m_to_cubearray_valid)
5386 gl.deleteTextures(1, &m_to_cubearray_valid);
5387 m_to_cubearray_valid = 0;
5390 if (m_to_layer_invalid)
5392 gl.deleteTextures(1, &m_to_layer_invalid);
5393 m_to_layer_invalid = 0;
5396 /* Set initial values - all test shall have the same environment. */
5399 m_attachment_invalid = 0;
5400 m_level_invalid = 0;
5402 m_max_3d_texture_size = 2048;
5403 m_max_3d_texture_depth = m_max_3d_texture_size;
5404 m_max_array_texture_layers = 2048;
5405 m_max_cube_map_texture_size = 16384;
5407 /* Errors clean up. */
5408 while (gl.getError())
5412 /******************************** Draw Read Buffers Errors Test Implementation ********************************/
5414 /** @brief Draw Read Buffers Errors Test constructor.
5416 * @param [in] context OpenGL context.
5418 DrawReadBuffersErrorsTest::DrawReadBuffersErrorsTest(deqp::Context& context)
5419 : deqp::TestCase(context, "framebuffers_draw_read_buffers_errors", "Draw Read Buffers Errors Test Test")
5422 , m_attachment_color(GL_COLOR_ATTACHMENT0)
5423 , m_attachment_back_left(GL_BACK_LEFT)
5424 , m_attachment_right(GL_RIGHT)
5425 , m_attachment_left(GL_LEFT)
5426 , m_attachment_front(GL_FRONT)
5427 , m_attachment_front_and_back(GL_FRONT_AND_BACK)
5428 , m_attachment_back(GL_BACK)
5429 , m_attachment_invalid(0)
5430 , m_max_color_attachments(8) /* GL 4.5 default, updated later */
5432 m_attachments_invalid[0] = 0;
5433 m_attachments_invalid[1] = 0;
5435 m_attachments_back_invalid[0] = GL_BACK_LEFT;
5436 m_attachments_back_invalid[1] = GL_BACK;
5438 m_attachments_too_many_count = 0;
5440 m_attachments_too_many = DE_NULL;
5443 /** @brief Iterate Draw Read Buffers Errors Test cases.
5445 * @return Iteration result.
5447 tcu::TestNode::IterateResult DrawReadBuffersErrorsTest::iterate()
5449 /* Shortcut for GL functionality. */
5450 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5452 /* Get context setup. */
5453 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
5454 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
5456 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
5458 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
5463 /* Running tests. */
5465 bool is_error = false;
5469 /* Prepare objects. */
5472 /* Check that INVALID_OPERATION error is generated by
5473 NamedFramebufferDrawBuffer if framebuffer is not zero or the name of an
5474 existing framebuffer object. */
5475 gl.namedFramebufferDrawBuffer(m_fbo_invalid, m_attachment_color);
5477 is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferDrawBuffer",
5478 "framebuffer is not zero or the name of an existing framebuffer object.");
5480 /* Check that INVALID_ENUM is generated by NamedFramebufferDrawBuffer if
5481 buf is not an accepted value. */
5482 gl.namedFramebufferDrawBuffer(m_fbo_valid, m_attachment_invalid);
5484 is_ok &= ExpectError(GL_INVALID_ENUM, "NamedFramebufferDrawBuffer", "buf is not an accepted value.");
5486 /* Check that INVALID_OPERATION is generated by NamedFramebufferDrawBuffer
5487 if the GL is bound to a draw framebuffer object and the ith argument is
5488 a value other than COLOR_ATTACHMENTi or NONE. */
5489 gl.namedFramebufferDrawBuffer(m_fbo_valid, m_attachment_back_left);
5491 is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferDrawBuffer",
5492 "the GL is bound to a draw framebuffer object and the ith argument is a value other than "
5493 "COLOR_ATTACHMENTi or NONE.");
5495 /* Check that INVALID_OPERATION error is generated by
5496 NamedFramebufferDrawBuffers if framebuffer is not zero or the name of an
5497 existing framebuffer object. */
5498 gl.namedFramebufferDrawBuffers(m_fbo_invalid, 1, &m_attachment_color);
5500 is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferDrawBuffers",
5501 "framebuffer is not zero or the name of an existing framebuffer object.");
5503 /* Check that INVALID_VALUE is generated by NamedFramebufferDrawBuffers if n
5505 gl.namedFramebufferDrawBuffers(m_fbo_valid, -1, &m_attachment_color);
5507 is_ok &= ExpectError(GL_INVALID_VALUE, "NamedFramebufferDrawBuffers", "n is less than 0.");
5509 /* Check that INVALID_VALUE is generated by NamedFramebufferDrawBuffers if
5510 n is greater than MAX_DRAW_BUFFERS. */
5511 gl.namedFramebufferDrawBuffers(m_fbo_valid, m_attachments_too_many_count, m_attachments_too_many);
5513 is_ok &= ExpectError(GL_INVALID_VALUE, "NamedFramebufferDrawBuffers", "n is greater than MAX_DRAW_BUFFERS.");
5515 /* Check that INVALID_ENUM is generated by NamedFramebufferDrawBuffers if
5516 one of the values in bufs is not an accepted value. */
5517 gl.namedFramebufferDrawBuffers(m_fbo_valid, 1, &m_attachment_invalid);
5519 is_ok &= ExpectError(GL_INVALID_ENUM, "NamedFramebufferDrawBuffers",
5520 "one of the values in bufs is not an accepted value.");
5522 /* Check that INVALID_OPERATION is generated by NamedFramebufferDrawBuffers
5523 if a symbolic constant other than GL_NONE appears more than once in
5525 gl.namedFramebufferDrawBuffers(m_fbo_valid, 2, m_attachments_invalid);
5527 is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferDrawBuffers",
5528 "a symbolic constant other than GL_NONE appears more than once in bufs.");
5530 /* Check that INVALID_ENUM error is generated by NamedFramebufferDrawBuffers if any value in bufs is FRONT, LEFT, RIGHT, or FRONT_AND_BACK.
5531 This restriction applies to both the default framebuffer and framebuffer objects, and exists because these constants may themselves
5532 refer to multiple buffers, as shown in table 17.4. */
5533 gl.namedFramebufferDrawBuffers(m_fbo_valid, 1, &m_attachment_front);
5535 is_ok &= ExpectError(GL_INVALID_ENUM, "NamedFramebufferDrawBuffers",
5536 "a framebuffer object is tested and a value in bufs is FRONT.");
5538 gl.namedFramebufferDrawBuffers(m_fbo_valid, 1, &m_attachment_left);
5540 is_ok &= ExpectError(GL_INVALID_ENUM, "NamedFramebufferDrawBuffers",
5541 "a framebuffer object is tested and a value in bufs is LEFT.");
5543 gl.namedFramebufferDrawBuffers(m_fbo_valid, 1, &m_attachment_right);
5545 is_ok &= ExpectError(GL_INVALID_ENUM, "NamedFramebufferDrawBuffers",
5546 "a framebuffer object is tested and a value in bufs is RIGHT.");
5548 gl.namedFramebufferDrawBuffers(m_fbo_valid, 1, &m_attachment_front_and_back);
5550 is_ok &= ExpectError(GL_INVALID_ENUM, "NamedFramebufferDrawBuffers",
5551 "a framebuffer object is tested and a value in bufs is FRONT_AND_BACK.");
5553 gl.namedFramebufferDrawBuffers(0, 1, &m_attachment_front);
5555 is_ok &= ExpectError(GL_INVALID_ENUM, "NamedFramebufferDrawBuffers",
5556 "a default framebuffer is tested and a value in bufs is FRONT.");
5558 gl.namedFramebufferDrawBuffers(0, 1, &m_attachment_left);
5560 is_ok &= ExpectError(GL_INVALID_ENUM, "NamedFramebufferDrawBuffers",
5561 "a default framebuffer is tested and a value in bufs is LEFT.");
5563 gl.namedFramebufferDrawBuffers(0, 1, &m_attachment_right);
5565 is_ok &= ExpectError(GL_INVALID_ENUM, "NamedFramebufferDrawBuffers",
5566 "a default framebuffer is tested and a value in bufs is RIGHT.");
5568 gl.namedFramebufferDrawBuffers(0, 1, &m_attachment_front_and_back);
5570 is_ok &= ExpectError(GL_INVALID_ENUM, "NamedFramebufferDrawBuffers",
5571 "a default framebuffer is tested and a value in bufs is FRONT_AND_BACK.");
5573 /* Check that INVALID_OPERATION is generated by NamedFramebufferDrawBuffers
5574 if any value in bufs is BACK, and n is not one. */
5575 gl.namedFramebufferDrawBuffers(0, 2, m_attachments_back_invalid);
5577 is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferDrawBuffers",
5578 "any value in bufs is BACK, and n is not one.");
5580 /* Check that INVALID_OPERATION is generated by NamedFramebufferDrawBuffers if
5581 the API call refers to a framebuffer object and one or more of the
5582 values in bufs is anything other than NONE or one of the
5583 COLOR_ATTACHMENTn tokens. */
5584 gl.namedFramebufferDrawBuffers(m_fbo_valid, 1, &m_attachment_back_left);
5586 is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferDrawBuffers",
5587 "the API call refers to a framebuffer object and one or more of the values in bufs is "
5588 "anything other than NONE or one of the COLOR_ATTACHMENTn tokens.");
5590 /* Check that INVALID_OPERATION is generated by NamedFramebufferDrawBuffers if
5591 the API call refers to the default framebuffer and one or more of the
5592 values in bufs is one of the COLOR_ATTACHMENTn tokens. */
5593 gl.namedFramebufferDrawBuffers(0, 1, &m_attachment_color);
5595 is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferDrawBuffers",
5596 "the API call refers to the default framebuffer and one or more of the values in bufs is "
5597 "one of the COLOR_ATTACHMENTn tokens.");
5599 /* Check that INVALID_OPERATION is generated by NamedFramebufferReadBuffer
5600 if framebuffer is not zero or the name of an existing framebuffer
5602 gl.namedFramebufferReadBuffer(m_fbo_invalid, m_attachment_color);
5604 is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferReadBuffer",
5605 "framebuffer is not zero or the name of an existing framebuffer object.");
5607 /* Check that INVALID_ENUM is generated by NamedFramebufferReadBuffer if
5608 src is not one of the accepted values (tables 17.4 and 17.5 of OpenGL 4.5 Core Profile Specification). */
5609 gl.namedFramebufferReadBuffer(m_fbo_valid, m_attachment_invalid);
5611 is_ok &= ExpectError(
5612 GL_INVALID_ENUM, "NamedFramebufferReadBuffer",
5613 "src is not one of the accepted values (tables 17.4 and 17.5 of OpenGL 4.5 Core Profile Specification).");
5615 /* Check that INVALID_OPERATION error is generated by NamedFramebufferReadBuffer if the default framebuffer is
5616 affected and src is a value (other than NONE) that does not indicate any of the
5617 color buffers allocated to the default framebuffer. */
5618 gl.namedFramebufferReadBuffer(0, GL_COLOR_ATTACHMENT0);
5620 is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferReadBuffer",
5621 "the default framebuffer is affected and src is a value (other than NONE) that does not "
5622 "indicate any of the color buffers allocated to the default framebuffer.");
5624 /* Check that INVALID_OPERATION error is generated by NamedFramebufferReadBuffer if a framebuffer object is
5625 affected, and src is one of the constants from table 17.4 (other than NONE, or COLOR_ATTACHMENTm where m
5626 is greater than or equal to the value of MAX_COLOR_ATTACHMENTS). */
5627 gl.namedFramebufferReadBuffer(m_fbo_valid, m_attachment_front_and_back);
5629 is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferReadBuffer",
5630 "a framebuffer object is affected, and src is one of the constants from table 17.4.");
5632 gl.namedFramebufferReadBuffer(m_fbo_valid, GL_COLOR_ATTACHMENT0 + m_max_color_attachments);
5634 is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedFramebufferReadBuffer",
5635 "a framebuffer object is affected, and src is one of the COLOR_ATTACHMENTm where mis "
5636 "greater than or equal to the value of MAX_COLOR_ATTACHMENTS.");
5647 /* Result's setup. */
5650 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
5656 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
5660 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
5667 /** Check Prepare test's GL objects.
5669 void DrawReadBuffersErrorsTest::PrepareObjects()
5671 /* Shortcut for GL functionality. */
5672 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5674 /* Valid objects. */
5675 gl.genFramebuffers(1, &m_fbo_valid);
5676 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
5678 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_valid);
5679 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
5681 /* Invalid objects. */
5682 while (gl.isFramebuffer(++m_fbo_invalid))
5685 /* Invalid attachment. */
5686 gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &m_max_color_attachments);
5688 bool is_attachment = true;
5690 while (is_attachment)
5692 ++m_attachment_invalid;
5694 is_attachment = false;
5696 /* Valid attachments are those from tables 17.4, 17.5 and a 17.6 (valid for various functions and framebuffer types).
5697 (see OpenGL 4.5 Core Profile Specification) */
5698 switch (m_attachment_invalid)
5702 case GL_FRONT_RIGHT:
5709 case GL_FRONT_AND_BACK:
5710 is_attachment = true;
5713 for (glw::GLint i = 0; i < m_max_color_attachments; ++i)
5715 if ((glw::GLenum)(GL_COLOR_ATTACHMENT0 + i) == m_attachment_invalid)
5717 is_attachment = true;
5723 m_attachments_invalid[0] = GL_COLOR_ATTACHMENT0;
5724 m_attachments_invalid[1] = GL_COLOR_ATTACHMENT0;
5726 glw::GLint max_draw_buffers = 8; /* Spec default. */
5727 gl.getIntegerv(GL_MAX_DRAW_BUFFERS, &max_draw_buffers);
5729 m_attachments_too_many_count = max_draw_buffers + 1;
5731 m_attachments_too_many = new glw::GLenum[m_attachments_too_many_count];
5733 m_attachments_too_many[0] = GL_COLOR_ATTACHMENT0;
5735 for (glw::GLint i = 1; i < m_attachments_too_many_count; ++i)
5737 m_attachments_too_many[i] = GL_NONE;
5741 /** Check if error is equal to the expected, log if not.
5743 * @param [in] expected_error Error to be expected.
5744 * @param [in] function Function name which is being tested (to be logged).
5745 * @param [in] conditions Conditions when the expected error shall occure (to be logged).
5747 * @return True if there is no error, false otherwise.
5749 bool DrawReadBuffersErrorsTest::ExpectError(glw::GLenum expected_error, const glw::GLchar* function,
5750 const glw::GLchar* conditions)
5752 /* Shortcut for GL functionality. */
5753 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5757 glw::GLenum error = GL_NO_ERROR;
5759 if (expected_error != (error = gl.getError()))
5761 m_context.getTestContext().getLog() << tcu::TestLog::Message << function << " was expected to generate "
5762 << glu::getErrorStr(expected_error) << ", but " << glu::getErrorStr(error)
5763 << " was observed instead when " << conditions << tcu::TestLog::EndMessage;
5768 /* Clean additional possible errors. */
5769 while (gl.getError())
5775 /** @brief Clean up GL state.
5777 void DrawReadBuffersErrorsTest::Clean()
5779 /* Shortcut for GL functionality. */
5780 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5782 /* Release GL objects. */
5785 gl.deleteFramebuffers(1, &m_fbo_valid);
5789 /* Set initial values - all test shall have the same environment. */
5791 m_attachment_invalid = 0;
5792 m_attachments_invalid[0] = 0;
5793 m_attachments_invalid[1] = 0;
5795 delete m_attachments_too_many;
5797 m_attachments_too_many = DE_NULL;
5799 m_attachments_too_many_count = 0;
5801 /* Errors clean up. */
5802 while (gl.getError())
5806 /******************************** Invalidate Data and SubData Errors Test Implementation ********************************/
5808 /** @brief Invalidate SubData Errors Test constructor.
5810 * @param [in] context OpenGL context.
5812 InvalidateDataAndSubDataErrorsTest::InvalidateDataAndSubDataErrorsTest(deqp::Context& context)
5813 : deqp::TestCase(context, "invalidate_data_and_subdata_errors", "Invalidate Data and SubData Errors Test")
5817 , m_fbo_attachment_valid(0)
5818 , m_fbo_attachment_invalid(0)
5819 , m_color_attachment_invalid(0)
5820 , m_default_attachment_invalid(0)
5825 /** @brief Iterate Invalidate Data and SubData Errors Test cases.
5827 * @return Iteration result.
5829 tcu::TestNode::IterateResult InvalidateDataAndSubDataErrorsTest::iterate()
5831 /* Shortcut for GL functionality. */
5832 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5834 /* Get context setup. */
5835 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
5836 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
5838 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
5840 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
5845 /* Running tests. */
5847 bool is_error = false;
5851 /* Prepare objects. */
5854 /******* InvalidateNamedFramebufferData *******/
5856 /* Check that INVALID_OPERATION error is generated by InvalidateNamedFramebufferData if framebuffer is not zero or the name of an existing framebuffer object. */
5857 gl.invalidateNamedFramebufferData(m_fbo_invalid, 1, &m_fbo_attachment_valid);
5859 is_ok &= ExpectError(GL_INVALID_OPERATION, "InvalidateNamedFramebufferData",
5860 "framebuffer is not zero or the name of an existing framebuffer object.");
5862 /* Check that INVALID_ENUM error is generated by InvalidateNamedFramebufferData if a framebuffer object is affected, and
5863 any element of of attachments is not one of the values in table {COLOR_ATTACHMENTi, DEPTH_ATTACHMENT, STENCIL_ATTACHMENT, DEPTH_STENCIL_ATTACHMENT }. */
5864 gl.invalidateNamedFramebufferData(m_fbo_valid, 1, &m_fbo_attachment_invalid);
5866 is_ok &= ExpectError(GL_INVALID_ENUM, "InvalidateNamedFramebufferData",
5867 "a framebuffer object is affected, and any element of of attachments is not one of the "
5868 "values in table { COLOR_ATTACHMENTi, DEPTH_ATTACHMENT, STENCIL_ATTACHMENT, "
5869 "DEPTH_STENCIL_ATTACHMENT }.");
5871 /* Check that INVALID_OPERATION error is generated by InvalidateNamedFramebufferData if attachments contains COLOR_ATTACHMENTm
5872 where m is greater than or equal to the value of MAX_COLOR_ATTACHMENTS. */
5873 gl.invalidateNamedFramebufferData(m_fbo_valid, 1, &m_color_attachment_invalid);
5875 is_ok &= ExpectError(GL_INVALID_OPERATION, "InvalidateNamedFramebufferData",
5876 "attachments contains COLOR_ATTACHMENTm where m is greater than or equal to the value of "
5877 "MAX_COLOR_ATTACHMENTS");
5879 /* Check that INVALID_ENUM error is generated by
5880 InvalidateNamedFramebufferData if the default framebuffer is affected,
5881 and any elements of attachments are not one of:
5882 - FRONT_LEFT, FRONT_RIGHT, BACK_LEFT, and BACK_RIGHT, identifying that
5884 - COLOR, which is treated as BACK_LEFT for a double-buffered context
5885 and FRONT_LEFT for a single-buffered context,
5886 - DEPTH, identifying the depth buffer,
5887 - STENCIL, identifying the stencil buffer. */
5888 gl.invalidateNamedFramebufferData(0, 1, &m_default_attachment_invalid);
5890 is_ok &= ExpectError(GL_INVALID_ENUM, "InvalidateNamedFramebufferData",
5891 "the default framebuffer is affected, and any elements of attachments are not one of "
5892 "FRONT_LEFT, FRONT_RIGHT, BACK_LEFT, BACK_RIGHT, COLOR, DEPTH, STENCIL.");
5894 /******* InvalidateNamedFramebufferSubData *******/
5896 /* Check that INVALID_OPERATION error is generated by InvalidateNamedFramebufferSubData if framebuffer is not zero or the name of an existing framebuffer object. */
5897 gl.invalidateNamedFramebufferSubData(m_fbo_invalid, 1, &m_fbo_attachment_valid, 0, 0, 1, 1);
5899 is_ok &= ExpectError(GL_INVALID_OPERATION, "InvalidateNamedFramebufferSubData",
5900 "framebuffer is not zero or the name of an existing framebuffer object.");
5902 /* Check that INVALID_VALUE error is generated by InvalidateNamedFramebufferSubData if numAttachments, width, or height is negative. */
5903 gl.invalidateNamedFramebufferSubData(m_fbo_valid, -1, &m_fbo_attachment_valid, 0, 0, 1, 1);
5905 is_ok &= ExpectError(GL_INVALID_VALUE, "InvalidateNamedFramebufferSubData", "numAttachments is negative.");
5907 gl.invalidateNamedFramebufferSubData(m_fbo_valid, 1, &m_fbo_attachment_valid, 0, 0, -1, 1);
5909 is_ok &= ExpectError(GL_INVALID_VALUE, "InvalidateNamedFramebufferSubData", "width is negative.");
5911 gl.invalidateNamedFramebufferSubData(m_fbo_valid, 1, &m_fbo_attachment_valid, 0, 0, 1, -1);
5913 is_ok &= ExpectError(GL_INVALID_VALUE, "InvalidateNamedFramebufferSubData", "height is negative.");
5915 /* Check that INVALID_ENUM error is generated by InvalidateNamedFramebufferSubData if a framebuffer object is affected, and
5916 any element of of attachments is not one of the values in table {COLOR_ATTACHMENTi, DEPTH_ATTACHMENT, STENCIL_ATTACHMENT, DEPTH_STENCIL_ATTACHMENT }. */
5917 gl.invalidateNamedFramebufferSubData(m_fbo_valid, 1, &m_fbo_attachment_invalid, 0, 0, 1, 1);
5919 is_ok &= ExpectError(GL_INVALID_ENUM, "InvalidateNamedFramebufferSubData",
5920 "a framebuffer object is affected, and any element of of attachments is not one of the "
5921 "values in table { COLOR_ATTACHMENTi, DEPTH_ATTACHMENT, STENCIL_ATTACHMENT, "
5922 "DEPTH_STENCIL_ATTACHMENT }.");
5924 /* Check that INVALID_OPERATION error is generated by InvalidateNamedFramebufferSubData if attachments contains COLOR_ATTACHMENTm
5925 where m is greater than or equal to the value of MAX_COLOR_ATTACHMENTS. */
5926 gl.invalidateNamedFramebufferSubData(m_fbo_valid, 1, &m_color_attachment_invalid, 0, 0, 1, 1);
5928 is_ok &= ExpectError(GL_INVALID_OPERATION, "InvalidateNamedFramebufferSubData",
5929 "attachments contains COLOR_ATTACHMENTm where m is greater than or equal to the value of "
5930 "MAX_COLOR_ATTACHMENTS");
5932 /* Check that INVALID_ENUM error is generated by InvalidateNamedFramebufferSubData if the default framebuffer is affected,
5933 and any elements of attachments are not one of:
5934 - FRONT_LEFT, FRONT_RIGHT, BACK_LEFT, and BACK_RIGHT, identifying that
5936 - COLOR, which is treated as BACK_LEFT for a double-buffered context
5937 and FRONT_LEFT for a single-buffered context,
5938 - DEPTH, identifying the depth buffer,
5939 - STENCIL, identifying the stencil buffer. */
5940 gl.invalidateNamedFramebufferSubData(0, 1, &m_default_attachment_invalid, 0, 0, 1, 1);
5942 is_ok &= ExpectError(GL_INVALID_ENUM, "InvalidateNamedFramebufferSubData",
5943 "the default framebuffer is affected, and any elements of attachments are not one of "
5944 "FRONT_LEFT, FRONT_RIGHT, BACK_LEFT, BACK_RIGHT, COLOR, DEPTH, STENCIL.");
5955 /* Result's setup. */
5958 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
5964 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
5968 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
5975 /** Check Prepare test's GL objects.
5977 void InvalidateDataAndSubDataErrorsTest::PrepareObjects()
5979 /* Shortcut for GL functionality. */
5980 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
5982 /* Valid attachments. */
5983 m_fbo_attachment_valid = GL_COLOR_ATTACHMENT0;
5985 /* Valid objects. */
5986 gl.genFramebuffers(1, &m_fbo_valid);
5987 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
5989 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_valid);
5990 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
5992 gl.genRenderbuffers(1, &m_rbo);
5993 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
5995 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo);
5996 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer has failed");
5998 gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 1, 1);
5999 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
6001 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, m_fbo_attachment_valid, GL_RENDERBUFFER, m_rbo);
6002 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
6004 if (GL_FRAMEBUFFER_COMPLETE != gl.checkFramebufferStatus(GL_FRAMEBUFFER))
6009 /* Invalid objects. */
6010 while (gl.isFramebuffer(++m_fbo_invalid))
6013 /* Invalid framebuffer object attachment. */
6016 if (GL_COLOR_ATTACHMENT0 < m_fbo_attachment_invalid)
6018 /* If this unlikely happen this mean that we cannot create invalid attachment which is not DEPTH_ATTACHMENT, STENCIL_ATTACHMENT, DEPTH_STENCIL_ATTACHMENT and
6019 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
6020 INVALID_OPERATION shall be generated instead of INVALID_ENUM. Such a situation may need change in the test or in the specification. */
6024 switch (++m_fbo_attachment_invalid)
6026 case GL_DEPTH_ATTACHMENT:
6027 case GL_STENCIL_ATTACHMENT:
6028 case GL_DEPTH_STENCIL_ATTACHMENT:
6035 /* Invalid color attachment. */
6036 glw::GLint max_color_attachments = 8; /* Spec default. */
6038 gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
6039 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
6041 m_color_attachment_invalid = GL_COLOR_ATTACHMENT0 + max_color_attachments;
6043 /* Invalid default attachment. */
6046 switch (++m_default_attachment_invalid)
6049 case GL_FRONT_RIGHT:
6062 /** Check if error is equal to the expected, log if not.
6064 * @param [in] expected_error Error to be expected.
6065 * @param [in] function Function name which is being tested (to be logged).
6066 * @param [in] conditions Conditions when the expected error shall occure (to be logged).
6068 * @return True if there is no error, false otherwise.
6070 bool InvalidateDataAndSubDataErrorsTest::ExpectError(glw::GLenum expected_error, const glw::GLchar* function,
6071 const glw::GLchar* conditions)
6073 /* Shortcut for GL functionality. */
6074 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6078 glw::GLenum error = GL_NO_ERROR;
6080 if (expected_error != (error = gl.getError()))
6082 m_context.getTestContext().getLog() << tcu::TestLog::Message << function << " was expected to generate "
6083 << glu::getErrorStr(expected_error) << ", but " << glu::getErrorStr(error)
6084 << " was observed instead when " << conditions << tcu::TestLog::EndMessage;
6089 /* Clean additional possible errors. */
6090 while (gl.getError())
6096 /** @brief Clean up GL state.
6098 void InvalidateDataAndSubDataErrorsTest::Clean()
6100 /* Shortcut for GL functionality. */
6101 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6103 /* Release GL objects. */
6106 gl.deleteFramebuffers(1, &m_fbo_valid);
6112 gl.deleteRenderbuffers(1, &m_rbo);
6117 /* Set initial values - all test shall have the same environment. */
6119 m_fbo_attachment_valid = 0;
6120 m_fbo_attachment_invalid = 0;
6121 m_default_attachment_invalid = 0;
6122 m_color_attachment_invalid = 0;
6124 /* Errors clean up. */
6125 while (gl.getError())
6129 /******************************** Clear Named Framebuffer Errors Test Implementation ********************************/
6131 /** @brief Clear Named Framebuffer Errors Test constructor.
6133 * @param [in] context OpenGL context.
6135 ClearNamedFramebufferErrorsTest::ClearNamedFramebufferErrorsTest(deqp::Context& context)
6136 : deqp::TestCase(context, "framebuffers_clear_errors", "Clear Named Framebuffer Errors Test")
6139 , m_rbo_depth_stencil(0)
6142 /* Intentionally left blank. */
6145 /** @brief Iterate Clear Named Framebuffer Errors Test cases.
6147 * @return Iteration result.
6149 tcu::TestNode::IterateResult ClearNamedFramebufferErrorsTest::iterate()
6151 /* Shortcut for GL functionality. */
6152 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6154 /* Get context setup. */
6155 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
6156 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
6158 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
6160 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
6165 /* Running tests. */
6167 bool is_error = false;
6171 /* Prepare objects. */
6174 glw::GLint icolor[4] = {};
6175 glw::GLuint ucolor[4] = {};
6176 glw::GLfloat fcolor[4] = {};
6178 /* Check that INVALID_OPERATION is generated by ClearNamedFramebuffer* if
6179 framebuffer is not zero or the name of an existing framebuffer object. */
6180 gl.clearNamedFramebufferiv(m_fbo_invalid, GL_COLOR, 0, icolor);
6182 is_ok &= ExpectError(GL_INVALID_OPERATION, "ClearNamedFramebufferiv",
6183 "framebuffer is not zero or the name of an existing framebuffer object.");
6185 gl.clearNamedFramebufferuiv(m_fbo_invalid, GL_COLOR, 0, ucolor);
6187 is_ok &= ExpectError(GL_INVALID_OPERATION, "ClearNamedFramebufferuiv",
6188 "framebuffer is not zero or the name of an existing framebuffer object.");
6190 gl.clearNamedFramebufferfv(m_fbo_invalid, GL_COLOR, 0, fcolor);
6192 is_ok &= ExpectError(GL_INVALID_OPERATION, "ClearNamedFramebufferfv",
6193 "framebuffer is not zero or the name of an existing framebuffer object.");
6195 gl.clearNamedFramebufferfi(m_fbo_invalid, GL_DEPTH_STENCIL, 0, fcolor[0], icolor[0]);
6197 is_ok &= ExpectError(GL_INVALID_OPERATION, "ClearNamedFramebufferfi",
6198 "framebuffer is not zero or the name of an existing framebuffer object.");
6200 /* Check that INVALID_ENUM is generated by ClearNamedFramebufferiv if buffer
6201 is not COLOR or STENCIL. */
6202 gl.clearNamedFramebufferiv(m_fbo_valid, GL_DEPTH, 0, icolor);
6205 ExpectError(GL_INVALID_ENUM, "ClearNamedFramebufferiv", "buffer is not COLOR or STENCIL (it is DEPTH).");
6207 /* Check that INVALID_ENUM is generated by ClearNamedFramebufferuiv if buffer
6209 gl.clearNamedFramebufferuiv(m_fbo_valid, GL_DEPTH, 0, ucolor);
6211 is_ok &= ExpectError(GL_INVALID_ENUM, "ClearNamedFramebufferuiv", "buffer is not COLOR (it is DEPTH).");
6213 /* Check that INVALID_ENUM is generated by ClearNamedFramebufferfv buffer
6214 is not COLOR or DEPTH. */
6215 gl.clearNamedFramebufferfv(m_fbo_valid, GL_STENCIL, 0, fcolor);
6218 ExpectError(GL_INVALID_ENUM, "ClearNamedFramebufferfv", "buffer is not COLOR or DEPTH (it is STENCIL).");
6220 /* Check that INVALID_ENUM is generated by ClearNamedFramebufferfi if buffer
6221 is not DEPTH_STENCIL. */
6222 gl.clearNamedFramebufferfi(m_fbo_valid, GL_COLOR, 0, fcolor[0], icolor[0]);
6224 is_ok &= ExpectError(GL_INVALID_ENUM, "ClearNamedFramebufferfi", "buffer is not DEPTH_STENCIL.");
6226 /* Check that INVALID_VALUE is generated by ClearNamedFramebuffer* if buffer is COLOR drawbuffer is
6227 negative, or greater than the value of MAX_DRAW_BUFFERS minus one. */
6228 gl.clearNamedFramebufferiv(m_fbo_valid, GL_COLOR, -1, icolor);
6230 is_ok &= ExpectError(
6231 GL_INVALID_VALUE, "ClearNamedFramebufferiv",
6232 "buffer is COLOR drawbuffer is negative, or greater than the value of MAX_DRAW_BUFFERS minus one.");
6234 gl.clearNamedFramebufferuiv(m_fbo_valid, GL_COLOR, -1, ucolor);
6236 is_ok &= ExpectError(
6237 GL_INVALID_VALUE, "ClearNamedFramebufferuiv",
6238 "buffer is COLOR drawbuffer is negative, or greater than the value of MAX_DRAW_BUFFERS minus one.");
6240 /* Check that INVALID_VALUE is generated by ClearNamedFramebuffer* if buffer is DEPTH, STENCIL or
6241 DEPTH_STENCIL and drawbuffer is not zero. */
6243 gl.clearNamedFramebufferiv(m_fbo_valid, GL_STENCIL, 1, icolor);
6245 is_ok &= ExpectError(GL_INVALID_VALUE, "ClearNamedFramebufferiv",
6246 "buffer is DEPTH, STENCIL or DEPTH_STENCIL and drawbuffer is not zero.");
6248 gl.clearNamedFramebufferfv(m_fbo_valid, GL_DEPTH, 1, fcolor);
6250 is_ok &= ExpectError(GL_INVALID_VALUE, "ClearNamedFramebufferfv",
6251 "buffer is DEPTH, STENCIL or DEPTH_STENCIL and drawbuffer is not zero.");
6253 gl.clearNamedFramebufferfi(m_fbo_valid, GL_DEPTH_STENCIL, 1, fcolor[0], icolor[0]);
6255 is_ok &= ExpectError(GL_INVALID_VALUE, "ClearNamedFramebufferfi",
6256 "buffer is DEPTH, STENCIL or DEPTH_STENCIL and drawbuffer is not zero.");
6267 /* Result's setup. */
6270 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
6276 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
6280 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
6287 /** Check Prepare test's GL objects.
6289 void ClearNamedFramebufferErrorsTest::PrepareObjects()
6291 /* Shortcut for GL functionality. */
6292 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6294 /* Valid objects. */
6295 gl.genFramebuffers(1, &m_fbo_valid);
6296 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
6298 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_valid);
6299 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
6301 gl.genRenderbuffers(1, &m_rbo_color);
6302 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
6304 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo_color);
6305 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
6307 gl.renderbufferStorage(GL_RENDERBUFFER, GL_R8, 1, 1);
6308 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
6310 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo_color);
6311 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
6313 gl.genRenderbuffers(1, &m_rbo_depth_stencil);
6314 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
6316 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo_depth_stencil);
6317 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
6319 gl.renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 1, 1);
6320 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
6322 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_rbo_depth_stencil);
6323 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
6325 /* Invalid objects. */
6326 while (gl.isFramebuffer(++m_fbo_invalid))
6330 /** Check if error is equal to the expected, log if not.
6332 * @param [in] expected_error Error to be expected.
6333 * @param [in] function Function name which is being tested (to be logged).
6334 * @param [in] conditions Conditions when the expected error shall occure (to be logged).
6336 * @return True if there is no error, false otherwise.
6338 bool ClearNamedFramebufferErrorsTest::ExpectError(glw::GLenum expected_error, const glw::GLchar* function,
6339 const glw::GLchar* conditions)
6341 /* Shortcut for GL functionality. */
6342 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6346 glw::GLenum error = GL_NO_ERROR;
6348 if (expected_error != (error = gl.getError()))
6350 m_context.getTestContext().getLog() << tcu::TestLog::Message << function << " was expected to generate "
6351 << glu::getErrorStr(expected_error) << ", but " << glu::getErrorStr(error)
6352 << " was observed instead when " << conditions << tcu::TestLog::EndMessage;
6357 /* Clean additional possible errors. */
6358 while (gl.getError())
6364 /** @brief Clean up GL state.
6366 void ClearNamedFramebufferErrorsTest::Clean()
6368 /* Shortcut for GL functionality. */
6369 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6371 /* Release GL objects. */
6374 gl.deleteFramebuffers(1, &m_fbo_valid);
6380 gl.deleteRenderbuffers(1, &m_rbo_color);
6384 if (m_rbo_depth_stencil)
6386 gl.deleteRenderbuffers(1, &m_rbo_depth_stencil);
6387 m_rbo_depth_stencil = 0;
6390 /* Set initial values - all test shall have the same environment. */
6393 /* Errors clean up. */
6394 while (gl.getError())
6398 /******************************** Check Status Errors Test Implementation ********************************/
6400 /** @brief Clear Named Framebuffer Errors Test constructor.
6402 * @param [in] context OpenGL context.
6404 CheckStatusErrorsTest::CheckStatusErrorsTest(deqp::Context& context)
6405 : deqp::TestCase(context, "framebuffers_check_status_errors", "Check Status Errors Test")
6408 , m_target_invalid(0)
6410 /* Intentionally left blank. */
6413 /** @brief Iterate Clear Named Framebuffer Errors Test cases.
6415 * @return Iteration result.
6417 tcu::TestNode::IterateResult CheckStatusErrorsTest::iterate()
6419 /* Shortcut for GL functionality. */
6420 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6422 /* Get context setup. */
6423 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
6424 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
6426 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
6428 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
6433 /* Running tests. */
6435 bool is_error = false;
6439 /* Prepare objects. */
6442 /* Check that INVALID_ENUM is generated by CheckNamedFramebufferStatus if
6443 target is not DRAW_FRAMEBUFFER, READ_FRAMEBUFFER or FRAMEBUFFER. */
6444 gl.checkNamedFramebufferStatus(m_fbo_valid, m_target_invalid);
6446 is_ok &= ExpectError(GL_INVALID_ENUM, "CheckNamedFramebufferStatus",
6447 "target is not DRAW_FRAMEBUFFER, READ_FRAMEBUFFER or FRAMEBUFFER.");
6449 /* Check that INVALID_OPERATION is generated by CheckNamedFramebufferStatus
6450 if framebuffer is not zero or the name of an existing framebuffer
6452 gl.checkNamedFramebufferStatus(m_fbo_invalid, GL_FRAMEBUFFER);
6454 is_ok &= ExpectError(GL_INVALID_OPERATION, "CheckNamedFramebufferStatus",
6455 "framebuffer is not zero or the name of an existing framebuffer object.");
6466 /* Result's setup. */
6469 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
6475 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
6479 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
6486 /** Check Prepare test's GL objects.
6488 void CheckStatusErrorsTest::PrepareObjects()
6490 /* Shortcut for GL functionality. */
6491 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6493 /* Valid objects. */
6494 gl.genFramebuffers(1, &m_fbo_valid);
6495 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
6497 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_valid);
6498 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
6500 /* Invalid target. */
6501 bool is_target = true;
6509 if (GL_FRAMEBUFFER == m_target_invalid)
6514 if (GL_READ_FRAMEBUFFER == m_target_invalid)
6519 if (GL_DRAW_FRAMEBUFFER == m_target_invalid)
6524 /* Invalid objects. */
6525 while (gl.isFramebuffer(++m_fbo_invalid))
6529 /** Check if error is equal to the expected, log if not.
6531 * @param [in] expected_error Error to be expected.
6532 * @param [in] function Function name which is being tested (to be logged).
6533 * @param [in] conditions Conditions when the expected error shall occure (to be logged).
6535 * @return True if there is no error, false otherwise.
6537 bool CheckStatusErrorsTest::ExpectError(glw::GLenum expected_error, const glw::GLchar* function,
6538 const glw::GLchar* conditions)
6540 /* Shortcut for GL functionality. */
6541 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6545 glw::GLenum error = GL_NO_ERROR;
6547 if (expected_error != (error = gl.getError()))
6549 m_context.getTestContext().getLog() << tcu::TestLog::Message << function << " was expected to generate "
6550 << glu::getErrorStr(expected_error) << ", but " << glu::getErrorStr(error)
6551 << " was observed instead when " << conditions << tcu::TestLog::EndMessage;
6556 /* Clean additional possible errors. */
6557 while (gl.getError())
6563 /** @brief Clean up GL state.
6565 void CheckStatusErrorsTest::Clean()
6567 /* Shortcut for GL functionality. */
6568 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6570 /* Release GL objects. */
6573 gl.deleteFramebuffers(1, &m_fbo_valid);
6577 /* Set initial values - all test shall have the same environment. */
6579 m_target_invalid = 0;
6581 /* Errors clean up. */
6582 while (gl.getError())
6586 /******************************** Get Parameter Errors Test Implementation ********************************/
6588 /** @brief Get Parameter Errors Test constructor.
6590 * @param [in] context OpenGL context.
6592 GetParameterErrorsTest::GetParameterErrorsTest(deqp::Context& context)
6593 : deqp::TestCase(context, "framebuffers_get_parameter_errors", "Get Parameter Errors Test")
6596 , m_parameter_invalid(0)
6598 /* Intentionally left blank. */
6601 /** @brief Iterate Get Parameter Errors Test cases.
6603 * @return Iteration result.
6605 tcu::TestNode::IterateResult GetParameterErrorsTest::iterate()
6607 /* Shortcut for GL functionality. */
6608 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6610 /* Get context setup. */
6611 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
6612 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
6614 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
6616 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
6621 /* Running tests. */
6623 bool is_error = false;
6627 /* Prepare objects. */
6630 glw::GLint return_values_dummy_storage[4];
6632 /* Check that INVALID_OPERATION is generated by
6633 GetNamedFramebufferParameteriv if framebuffer is not zero or the name of
6634 an existing framebuffer object. */
6635 gl.getNamedFramebufferParameteriv(m_fbo_invalid, GL_SAMPLES, return_values_dummy_storage);
6637 is_ok &= ExpectError(GL_INVALID_OPERATION, "GetNamedFramebufferParameteriv",
6638 "framebuffer is not zero or the name of an existing framebuffer object.");
6640 /* Check that INVALID_ENUM is generated by GetNamedFramebufferParameteriv
6641 if pname is not one of the accepted parameter names. */
6642 gl.getNamedFramebufferParameteriv(m_fbo_valid, m_parameter_invalid, return_values_dummy_storage);
6644 is_ok &= ExpectError(GL_INVALID_ENUM, "GetNamedFramebufferParameteriv",
6645 "pname is not one of the accepted parameter names.");
6647 /* Check that INVALID_OPERATION is generated if a default framebuffer is
6648 queried, and pname is not one of DOUBLEBUFFER,
6649 IMPLEMENTATION_COLOR_READ_FORMAT, IMPLEMENTATION_COLOR_READ_TYPE,
6650 SAMPLES, SAMPLE_BUFFERS or STEREO. */
6651 gl.getNamedFramebufferParameteriv(0, GL_FRAMEBUFFER_DEFAULT_WIDTH, return_values_dummy_storage);
6653 is_ok &= ExpectError(GL_INVALID_OPERATION, "GetNamedFramebufferParameteriv",
6654 "a default framebuffer is queried, and pname is not one of DOUBLEBUFFER, "
6655 "IMPLEMENTATION_COLOR_READ_FORMAT, IMPLEMENTATION_COLOR_READ_TYPE, SAMPLES, "
6656 "SAMPLE_BUFFERS or STEREO.");
6667 /* Result's setup. */
6670 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
6676 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
6680 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
6687 /** Check Prepare test's GL objects.
6689 void GetParameterErrorsTest::PrepareObjects()
6691 /* Shortcut for GL functionality. */
6692 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6694 /* Valid objects. */
6695 gl.genFramebuffers(1, &m_fbo_valid);
6696 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
6698 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_valid);
6699 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
6701 /* Invalid target. */
6702 bool is_parameter = true;
6704 while (is_parameter)
6706 is_parameter = false;
6708 ++m_parameter_invalid;
6710 static const glw::GLenum valid_parameters[] = { GL_FRAMEBUFFER_DEFAULT_WIDTH,
6711 GL_FRAMEBUFFER_DEFAULT_HEIGHT,
6712 GL_FRAMEBUFFER_DEFAULT_LAYERS,
6713 GL_FRAMEBUFFER_DEFAULT_SAMPLES,
6714 GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS,
6716 GL_IMPLEMENTATION_COLOR_READ_FORMAT,
6717 GL_IMPLEMENTATION_COLOR_READ_TYPE,
6722 static const glw::GLuint valid_parameters_count = sizeof(valid_parameters) / sizeof(valid_parameters[0]);
6724 for (glw::GLuint i = 0; i < valid_parameters_count; ++i)
6726 if (valid_parameters[i] == m_parameter_invalid)
6728 is_parameter = true;
6733 /* Invalid objects. */
6734 while (gl.isFramebuffer(++m_fbo_invalid))
6738 /** Check if error is equal to the expected, log if not.
6740 * @param [in] expected_error Error to be expected.
6741 * @param [in] function Function name which is being tested (to be logged).
6742 * @param [in] conditions Conditions when the expected error shall occure (to be logged).
6744 * @return True if there is no error, false otherwise.
6746 bool GetParameterErrorsTest::ExpectError(glw::GLenum expected_error, const glw::GLchar* function,
6747 const glw::GLchar* conditions)
6749 /* Shortcut for GL functionality. */
6750 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6754 glw::GLenum error = GL_NO_ERROR;
6756 if (expected_error != (error = gl.getError()))
6758 m_context.getTestContext().getLog() << tcu::TestLog::Message << function << " was expected to generate "
6759 << glu::getErrorStr(expected_error) << ", but " << glu::getErrorStr(error)
6760 << " was observed instead when " << conditions << tcu::TestLog::EndMessage;
6765 /* Clean additional possible errors. */
6766 while (gl.getError())
6772 /** @brief Clean up GL state.
6774 void GetParameterErrorsTest::Clean()
6776 /* Shortcut for GL functionality. */
6777 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6779 /* Release GL objects. */
6782 gl.deleteFramebuffers(1, &m_fbo_valid);
6786 /* Set initial values - all test shall have the same environment. */
6788 m_parameter_invalid = 0;
6790 /* Errors clean up. */
6791 while (gl.getError())
6795 /******************************** Get Attachment Parameter Errors Test Implementation ********************************/
6797 /** @brief Get Attachment Parameter Errors Test constructor.
6799 * @param [in] context OpenGL context.
6801 GetAttachmentParameterErrorsTest::GetAttachmentParameterErrorsTest(deqp::Context& context)
6802 : deqp::TestCase(context, "framebuffers_get_attachment_parameter_errors", "Get Attachment Parameter Errors Test")
6805 , m_rbo_depth_stencil(0)
6807 , m_parameter_invalid(0)
6808 , m_attachment_invalid(0)
6809 , m_default_attachment_invalid(0)
6810 , m_max_color_attachments(8) /* Spec default. */
6812 /* Intentionally left blank. */
6815 /** @brief Iterate Get Attachment Parameter Errors Test cases.
6817 * @return Iteration result.
6819 tcu::TestNode::IterateResult GetAttachmentParameterErrorsTest::iterate()
6821 /* Shortcut for GL functionality. */
6822 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6824 /* Get context setup. */
6825 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
6826 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
6828 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
6830 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
6835 /* Running tests. */
6837 bool is_error = false;
6841 /* Prepare objects. */
6844 glw::GLint return_values_dummy_storage[4];
6846 /* Check that GL_INVALID_OPERATION is generated by
6847 GetNamedFramebufferAttachmentParameteriv if framebuffer is not zero or
6848 the name of an existing framebuffer object. */
6849 gl.getNamedFramebufferAttachmentParameteriv(
6850 m_fbo_invalid, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, return_values_dummy_storage);
6852 is_ok &= ExpectError(GL_INVALID_OPERATION, "GetNamedFramebufferAttachmentParameteriv",
6853 "framebuffer is not zero or the name of an existing framebuffer object.");
6855 /* Check that INVALID_ENUM is generated by
6856 GetNamedFramebufferAttachmentParameteriv if pname is not valid for the
6857 value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, as described above. */
6858 gl.getNamedFramebufferAttachmentParameteriv(
6859 m_fbo_valid, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, return_values_dummy_storage);
6861 is_ok &= ExpectError(
6862 GL_INVALID_ENUM, "GetNamedFramebufferAttachmentParameteriv",
6863 "pname is not valid for the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, as described above.");
6865 /* Check that INVALID_ENUM error is generated if a framebuffer object is queried, attachment
6866 is not one of the attachments in table 9.2 (COLOR_ATTACHMENTi, DEPTH_ATTACHMENT, STENCIL_ATTACHMENT, DEPTH_STENCIL_ATTACHMENT), and attachment is not
6867 COLOR_ATTACHMENTm where m is greater than or equal to the value of MAX_COLOR_ATTACHMENTS. */
6868 gl.getNamedFramebufferAttachmentParameteriv(
6869 m_fbo_valid, m_attachment_invalid, GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, return_values_dummy_storage);
6871 is_ok &= ExpectError(
6872 GL_INVALID_ENUM, "GetNamedFramebufferAttachmentParameteriv",
6873 "attachment is not one of the accepted framebuffer attachment points, as described in specification.");
6875 /* Check that INVALID_OPERATION is generated by
6876 GetNamedFramebufferAttachmentParameteriv if the value of
6877 FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is GL_NONE and pname is not
6878 FRAMEBUFFER_ATTACHMENT_OBJECT_NAME or
6879 FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE. */
6880 gl.getNamedFramebufferAttachmentParameteriv(
6881 m_fbo_valid, GL_COLOR_ATTACHMENT1, GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, return_values_dummy_storage);
6883 is_ok &= ExpectError(GL_INVALID_OPERATION, "GetNamedFramebufferAttachmentParameteriv",
6884 "the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is GL_NONE and pname is not "
6885 "FRAMEBUFFER_ATTACHMENT_OBJECT_NAME or FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE.");
6887 /* Check that INVALID_OPERATION is generated by
6888 GetNamedFramebufferAttachmentParameteriv if attachment is
6889 DEPTH_STENCIL_ATTACHMENT and pname is FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE. */
6890 gl.getNamedFramebufferAttachmentParameteriv(m_fbo_valid, GL_DEPTH_STENCIL_ATTACHMENT,
6891 GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE,
6892 return_values_dummy_storage);
6895 ExpectError(GL_INVALID_OPERATION, "GetNamedFramebufferAttachmentParameteriv",
6896 "attachment is DEPTH_STENCIL_ATTACHMENT and pname is FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE.");
6898 /* Check that an INVALID_ENUM error is generated if the default framebuffer is
6899 queried and attachment is not one the values FRONT, FRONT_LEFT, FRONT_RIGHT,
6900 BACK, BACK_LEFT, BACK_RIGHT, DEPTH, STENCIL. */
6901 gl.getNamedFramebufferAttachmentParameteriv(
6902 0, m_default_attachment_invalid, GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, return_values_dummy_storage);
6904 is_ok &= ExpectError(GL_INVALID_ENUM, "GetNamedFramebufferAttachmentParameteriv",
6905 "the default framebuffer is queried and attachment is not one the values FRONT, "
6906 "FRONT_LEFT, FRONT_RIGHT, BACK, BACK_LEFT, BACK_RIGHT, DEPTH, STENCIL.");
6908 /* Check that an INVALID_OPERATION error is generated if a framebuffer object is
6909 bound to target and attachment is COLOR_ATTACHMENTm where m is greater than or
6910 equal to the value of MAX_COLOR_ATTACHMENTS. */
6911 gl.getNamedFramebufferAttachmentParameteriv(m_fbo_valid, GL_COLOR_ATTACHMENT0 + m_max_color_attachments,
6912 GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE,
6913 return_values_dummy_storage);
6915 is_ok &= ExpectError(GL_INVALID_OPERATION, "GetNamedFramebufferAttachmentParameteriv",
6916 "a framebuffer object is bound to target and attachment is COLOR_ATTACHMENTm where m is "
6917 "equal to the value of MAX_COLOR_ATTACHMENTS.");
6919 gl.getNamedFramebufferAttachmentParameteriv(m_fbo_valid, GL_COLOR_ATTACHMENT0 + m_max_color_attachments + 1,
6920 GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE,
6921 return_values_dummy_storage);
6923 is_ok &= ExpectError(GL_INVALID_OPERATION, "GetNamedFramebufferAttachmentParameteriv",
6924 "a framebuffer object is bound to target and attachment is COLOR_ATTACHMENTm where m is "
6925 "greater than the value of MAX_COLOR_ATTACHMENTS.");
6936 /* Result's setup. */
6939 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
6945 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
6949 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
6956 /** Check Prepare test's GL objects.
6958 void GetAttachmentParameterErrorsTest::PrepareObjects()
6960 /* Shortcut for GL functionality. */
6961 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
6963 /* Valid objects. */
6964 gl.genFramebuffers(1, &m_fbo_valid);
6965 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
6967 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_valid);
6968 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
6970 gl.genRenderbuffers(1, &m_rbo_color);
6971 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
6973 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo_color);
6974 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
6976 gl.renderbufferStorage(GL_RENDERBUFFER, GL_R8, 1, 1);
6977 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
6979 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo_color);
6980 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
6982 gl.genRenderbuffers(1, &m_rbo_depth_stencil);
6983 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
6985 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo_depth_stencil);
6986 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
6988 gl.renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 1, 1);
6989 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
6991 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_rbo_depth_stencil);
6992 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer has failed");
6994 /* Max color attachments. */
6995 gl.getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &m_max_color_attachments);
6996 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
6998 /* Invalid attachment. */
6999 bool is_attachment = true;
7001 while (is_attachment)
7003 is_attachment = false;
7005 if ((GL_DEPTH_ATTACHMENT == m_attachment_invalid) || (GL_STENCIL_ATTACHMENT == m_attachment_invalid) ||
7006 (GL_DEPTH_STENCIL_ATTACHMENT == m_attachment_invalid))
7008 ++m_attachment_invalid;
7009 is_attachment = true;
7012 if (GL_COLOR_ATTACHMENT0 < m_attachment_invalid)
7014 /* If this unlikely happen this mean that we cannot create invalid attachment which is not DEPTH_ATTACHMENT, STENCIL_ATTACHMENT, DEPTH_STENCIL_ATTACHMENT and
7015 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
7016 INVALID_OPERATION shall be generated instead of INVALID_ENUM. Such a situation may need change in the test or in the specification. */
7021 /* Invalid default framebuffer attachment. */
7022 bool is_default_attachment = true;
7024 while (is_default_attachment)
7026 is_default_attachment = false;
7028 static const glw::GLenum valid_values[] = { GL_FRONT, GL_FRONT_LEFT, GL_FRONT_RIGHT, GL_BACK,
7029 GL_BACK_LEFT, GL_BACK_RIGHT, GL_DEPTH, GL_STENCIL };
7031 static const glw::GLuint valid_values_count = sizeof(valid_values) / sizeof(valid_values[0]);
7033 for (glw::GLuint i = 0; i < valid_values_count; ++i)
7035 if (valid_values[i] == m_default_attachment_invalid)
7037 m_default_attachment_invalid++;
7038 is_default_attachment = true;
7044 /* Invalid parameter. */
7045 bool is_parameter = true;
7047 while (is_parameter)
7049 is_parameter = false;
7051 ++m_parameter_invalid;
7053 static const glw::GLenum valid_parameters[] = { GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE,
7054 GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE,
7055 GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE,
7056 GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE,
7057 GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE,
7058 GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE,
7059 GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE,
7060 GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING,
7061 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME,
7062 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL,
7063 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE,
7064 GL_FRAMEBUFFER_ATTACHMENT_LAYERED,
7065 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER };
7067 static const glw::GLuint valid_parameters_count = sizeof(valid_parameters) / sizeof(valid_parameters[0]);
7069 for (glw::GLuint i = 0; i < valid_parameters_count; ++i)
7071 if (valid_parameters[i] == m_parameter_invalid)
7073 is_parameter = true;
7078 /* Invalid objects. */
7079 while (gl.isFramebuffer(++m_fbo_invalid))
7083 /** Check if error is equal to the expected, log if not.
7085 * @param [in] expected_error Error to be expected.
7086 * @param [in] function Function name which is being tested (to be logged).
7087 * @param [in] conditions Conditions when the expected error shall occure (to be logged).
7089 * @return True if there is no error, false otherwise.
7091 bool GetAttachmentParameterErrorsTest::ExpectError(glw::GLenum expected_error, const glw::GLchar* function,
7092 const glw::GLchar* conditions)
7094 /* Shortcut for GL functionality. */
7095 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7099 glw::GLenum error = GL_NO_ERROR;
7101 if (expected_error != (error = gl.getError()))
7103 m_context.getTestContext().getLog() << tcu::TestLog::Message << function << " was expected to generate "
7104 << glu::getErrorStr(expected_error) << ", but " << glu::getErrorStr(error)
7105 << " was observed instead when " << conditions << tcu::TestLog::EndMessage;
7110 /* Clean additional possible errors. */
7111 while (gl.getError())
7117 /** @brief Clean up GL state.
7119 void GetAttachmentParameterErrorsTest::Clean()
7121 /* Shortcut for GL functionality. */
7122 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7124 /* Release GL objects. */
7127 gl.deleteFramebuffers(1, &m_fbo_valid);
7133 gl.deleteRenderbuffers(1, &m_rbo_color);
7137 if (m_rbo_depth_stencil)
7139 gl.deleteRenderbuffers(1, &m_rbo_depth_stencil);
7140 m_rbo_depth_stencil = 0;
7143 /* Set initial values - all test shall have the same environment. */
7145 m_parameter_invalid = 0;
7146 m_attachment_invalid = 0;
7147 m_default_attachment_invalid = 0;
7148 m_max_color_attachments = 8;
7150 /* Errors clean up. */
7151 while (gl.getError())
7155 /******************************** Functional Test Implementation ********************************/
7157 /** @brief Get Attachment Parameter Errors Test constructor.
7159 * @param [in] context OpenGL context.
7161 FunctionalTest::FunctionalTest(deqp::Context& context)
7162 : deqp::TestCase(context, "framebuffers_renderbuffers_functional", "Functional Test")
7166 , m_rbo_depth_stencil(0)
7169 , m_vao_stencil_pass_quad(0)
7170 , m_vao_depth_pass_quad(0)
7171 , m_vao_color_pass_quad(0)
7172 , m_bo_stencil_pass_quad(0)
7173 , m_bo_depth_pass_quad(0)
7174 , m_bo_color_pass_quad(0)
7176 /* Intentionally left blank. */
7179 /** @brief Iterate Get Attachment Parameter Errors Test cases.
7181 * @return Iteration result.
7183 tcu::TestNode::IterateResult FunctionalTest::iterate()
7185 /* Get context setup. */
7186 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
7187 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
7189 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
7191 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
7196 /* Running tests. */
7198 bool is_error = false;
7203 is_ok &= PrepareFirstFramebuffer();
7204 is_ok &= PrepareSecondFramebuffer();
7205 is_ok &= ClearFramebuffers();
7207 PrepareBuffersAndVertexArrays();
7208 is_ok &= DrawAndBlit();
7209 is_ok &= CheckSecondFramebufferContent();
7220 /* Result's setup. */
7223 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
7229 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
7233 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
7240 /** Prepare first framebuffer.
7242 * @return True if there is no error, false otherwise.
7244 bool FunctionalTest::PrepareFirstFramebuffer()
7246 /* Shortcut for GL functionality. */
7247 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7249 /* Failure of this part shall result in test failure (it is DSA functionality failure). */
7252 gl.createFramebuffers(1, &m_fbo_1st);
7253 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateFramebuffers has failed");
7255 gl.createRenderbuffers(1, &m_rbo_color);
7256 gl.createRenderbuffers(1, &m_rbo_depth_stencil);
7257 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateRenderbuffers has failed");
7259 gl.namedRenderbufferStorage(m_rbo_color, GL_R8, 8, 8);
7260 gl.namedRenderbufferStorage(m_rbo_depth_stencil, GL_DEPTH24_STENCIL8, 8, 8);
7261 GLU_EXPECT_NO_ERROR(gl.getError(), "glNamedRenderbufferStorage has failed");
7263 gl.namedFramebufferRenderbuffer(m_fbo_1st, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo_color);
7264 gl.namedFramebufferRenderbuffer(m_fbo_1st, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_rbo_depth_stencil);
7265 GLU_EXPECT_NO_ERROR(gl.getError(), "glNamedFramebufferRenderbuffer has failed");
7267 if (GL_FRAMEBUFFER_COMPLETE != gl.checkNamedFramebufferStatus(m_fbo_1st, GL_FRAMEBUFFER))
7269 m_context.getTestContext().getLog() << tcu::TestLog::Message << "CheckNamedFramebufferStatus is incomplete."
7270 << tcu::TestLog::EndMessage;
7283 /** Prepare second framebuffer.
7285 * @return True if there is no error, false otherwise.
7287 bool FunctionalTest::PrepareSecondFramebuffer()
7289 /* Shortcut for GL functionality. */
7290 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7292 /* Failure of this part shall result in test internal error (it does not test the DSA functionality). */
7293 gl.genTextures(1, &m_to_color);
7294 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures has failed");
7296 gl.bindTexture(GL_TEXTURE_2D, m_to_color);
7297 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture has failed");
7299 gl.texStorage2D(GL_TEXTURE_2D, 1, GL_R8, 4, 3);
7300 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexStorage2D has failed");
7302 /* Failure of this part shall result in test failure (it is DSA functionality failure). */
7305 gl.createFramebuffers(1, &m_fbo_2nd);
7306 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateFramebuffers has failed");
7308 gl.namedFramebufferTexture(m_fbo_2nd, GL_COLOR_ATTACHMENT0, m_to_color, 0);
7309 GLU_EXPECT_NO_ERROR(gl.getError(), "glNamedFramebufferTexture has failed");
7311 if (GL_FRAMEBUFFER_COMPLETE != gl.checkNamedFramebufferStatus(m_fbo_2nd, GL_FRAMEBUFFER))
7313 m_context.getTestContext().getLog() << tcu::TestLog::Message << "CheckNamedFramebufferStatus is incomplete."
7314 << tcu::TestLog::EndMessage;
7327 /** Clear framebuffers.
7329 * @return True if there is no error, false otherwise.
7331 bool FunctionalTest::ClearFramebuffers()
7333 /* Shortcut for GL functionality. */
7334 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7336 /* Failure of this part shall result in test failure (it is DSA functionality failure). */
7339 glw::GLfloat color_value[] = { 0.f, 0.f, 0.f, 0.f };
7340 glw::GLfloat depth_value = 0.f;
7341 glw::GLint stencil_value = 0;
7343 /* 1st framebuffer. */
7344 gl.clearNamedFramebufferfv(m_fbo_1st, GL_COLOR, 0, color_value);
7345 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearNamedFramebufferfv has failed");
7347 gl.clearNamedFramebufferfi(m_fbo_1st, GL_DEPTH_STENCIL, 0, depth_value, stencil_value);
7348 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearNamedFramebufferfi has failed");
7350 /* 2nd framebuffer. */
7351 gl.clearNamedFramebufferfv(m_fbo_1st, GL_COLOR, 0, color_value);
7352 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearNamedFramebufferfv has failed");
7362 /** Prepare test's GLSL program.
7364 void FunctionalTest::PrepareProgram()
7366 /* Shortcut for GL functionality */
7367 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7371 glw::GLchar const* const source;
7372 glw::GLenum const type;
7374 } shader[] = { { s_vertex_shader, GL_VERTEX_SHADER, 0 }, { s_fragment_shader, GL_FRAGMENT_SHADER, 0 } };
7376 glw::GLuint const shader_count = sizeof(shader) / sizeof(shader[0]);
7380 /* Create program. */
7381 m_po = gl.createProgram();
7382 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateProgram call failed.");
7384 /* Shader compilation. */
7385 for (glw::GLuint i = 0; i < shader_count; ++i)
7387 if (DE_NULL != shader[i].source)
7389 shader[i].id = gl.createShader(shader[i].type);
7391 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateShader call failed.");
7393 gl.attachShader(m_po, shader[i].id);
7395 GLU_EXPECT_NO_ERROR(gl.getError(), "glAttachShader call failed.");
7397 gl.shaderSource(shader[i].id, 1, &(shader[i].source), NULL);
7399 GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource call failed.");
7401 gl.compileShader(shader[i].id);
7403 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompileShader call failed.");
7405 glw::GLint status = GL_FALSE;
7407 gl.getShaderiv(shader[i].id, GL_COMPILE_STATUS, &status);
7408 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
7410 if (GL_FALSE == status)
7412 glw::GLint log_size = 0;
7413 gl.getShaderiv(shader[i].id, GL_INFO_LOG_LENGTH, &log_size);
7414 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
7416 glw::GLchar* log_text = new glw::GLchar[log_size];
7418 gl.getShaderInfoLog(shader[i].id, log_size, NULL, &log_text[0]);
7420 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Shader compilation has failed.\n"
7421 << "Shader type: " << glu::getShaderTypeStr(shader[i].type)
7423 << "Shader compilation error log:\n"
7425 << "Shader source code:\n"
7426 << shader[i].source << "\n"
7427 << tcu::TestLog::EndMessage;
7431 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderInfoLog call failed.");
7439 gl.linkProgram(m_po);
7441 GLU_EXPECT_NO_ERROR(gl.getError(), "glTransformFeedbackVaryings call failed.");
7443 glw::GLint status = GL_FALSE;
7445 gl.getProgramiv(m_po, GL_LINK_STATUS, &status);
7447 if (GL_TRUE == status)
7449 for (glw::GLuint i = 0; i < shader_count; ++i)
7453 gl.detachShader(m_po, shader[i].id);
7455 GLU_EXPECT_NO_ERROR(gl.getError(), "glDetachShader call failed.");
7461 glw::GLint log_size = 0;
7463 gl.getProgramiv(m_po, GL_INFO_LOG_LENGTH, &log_size);
7465 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramiv call failed.");
7467 glw::GLchar* log_text = new glw::GLchar[log_size];
7469 gl.getProgramInfoLog(m_po, log_size, NULL, &log_text[0]);
7471 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Program linkage has failed due to:\n"
7473 << tcu::TestLog::EndMessage;
7477 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramInfoLog call failed.");
7486 gl.deleteProgram(m_po);
7492 for (glw::GLuint i = 0; i < shader_count; ++i)
7494 if (0 != shader[i].id)
7496 gl.deleteShader(shader[i].id);
7508 /** Prepare Vertex Array Objects (one for each draw pass).
7510 void FunctionalTest::PrepareBuffersAndVertexArrays()
7512 /* Shortcut for GL functionality. */
7513 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7515 /* Query program attribute. */
7516 glw::GLuint program_attribute = gl.getAttribLocation(m_po, s_attribute);
7517 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetAttribLocation call failed.");
7519 /* Create stencil pass buffer. */
7520 gl.genVertexArrays(1, &m_vao_stencil_pass_quad);
7521 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays call failed.");
7523 gl.bindVertexArray(m_vao_stencil_pass_quad);
7524 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray call failed.");
7526 gl.genBuffers(1, &m_bo_stencil_pass_quad);
7527 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenBuffers call failed.");
7529 gl.bindBuffer(GL_ARRAY_BUFFER, m_bo_stencil_pass_quad);
7530 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffers call failed.");
7532 gl.bufferData(GL_ARRAY_BUFFER, s_stencil_pass_quad_size, s_stencil_pass_quad, GL_STATIC_DRAW);
7533 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData call failed.");
7535 gl.vertexAttribPointer(program_attribute, 3, GL_FLOAT, GL_FALSE, 0, NULL);
7536 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer call failed.");
7538 gl.enableVertexAttribArray(program_attribute);
7539 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray call failed.");
7541 /* Create depth pass buffer. */
7542 gl.genVertexArrays(1, &m_vao_depth_pass_quad);
7543 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays call failed.");
7545 gl.bindVertexArray(m_vao_depth_pass_quad);
7546 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray call failed.");
7548 gl.genBuffers(1, &m_bo_depth_pass_quad);
7549 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenBuffers call failed.");
7551 gl.bindBuffer(GL_ARRAY_BUFFER, m_bo_depth_pass_quad);
7552 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffers call failed.");
7554 gl.bufferData(GL_ARRAY_BUFFER, s_depth_pass_quad_size, s_depth_pass_quad, GL_STATIC_DRAW);
7555 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData call failed.");
7557 gl.vertexAttribPointer(program_attribute, 3, GL_FLOAT, GL_FALSE, 0, NULL);
7558 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer call failed.");
7560 gl.enableVertexAttribArray(program_attribute);
7561 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray call failed.");
7563 /* Create color pass buffer. */
7564 gl.genVertexArrays(1, &m_vao_color_pass_quad);
7565 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays call failed.");
7567 gl.bindVertexArray(m_vao_color_pass_quad);
7568 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray call failed.");
7570 gl.genBuffers(1, &m_bo_color_pass_quad);
7571 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenBuffers call failed.");
7573 gl.bindBuffer(GL_ARRAY_BUFFER, m_bo_color_pass_quad);
7574 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffers call failed.");
7576 gl.bufferData(GL_ARRAY_BUFFER, s_color_pass_quad_size, s_color_pass_quad, GL_STATIC_DRAW);
7577 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData call failed.");
7579 gl.vertexAttribPointer(program_attribute, 3, GL_FLOAT, GL_FALSE, 0, NULL);
7580 GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer call failed.");
7582 gl.enableVertexAttribArray(program_attribute);
7583 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray call failed.");
7586 /** Do the test draww/blit calls.
7588 * @return True if there is no error in DSA functionality, false otherwise.
7590 bool FunctionalTest::DrawAndBlit()
7592 /* Shortcut for GL functionality. */
7593 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7595 gl.useProgram(m_po);
7596 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram call failed.");
7598 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_1st);
7599 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
7601 gl.viewport(0, 0, 8, 8);
7602 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
7604 /* Draw to stencil buffer. */
7605 gl.bindVertexArray(m_vao_stencil_pass_quad);
7606 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray call failed.");
7608 gl.stencilFunc(GL_NEVER, 0, 0xff);
7609 GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilFunc call failed.");
7611 gl.stencilOp(GL_INCR, GL_KEEP, GL_KEEP);
7612 GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilOp call failed.");
7614 gl.stencilMask(0xff);
7615 GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilMask call failed.");
7617 gl.colorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
7618 GLU_EXPECT_NO_ERROR(gl.getError(), "glColorMask call failed.");
7620 gl.depthMask(GL_FALSE);
7621 GLU_EXPECT_NO_ERROR(gl.getError(), "glDepthMask call failed.");
7623 gl.enable(GL_STENCIL_TEST);
7624 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable call failed.");
7626 gl.disable(GL_DEPTH_TEST);
7627 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable call failed.");
7629 gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
7630 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays call failed.");
7632 /* Draw to depth buffer. */
7633 gl.bindVertexArray(m_vao_depth_pass_quad);
7634 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray call failed.");
7636 gl.stencilFunc(GL_ALWAYS, 0, 0xff);
7637 GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilFunc call failed.");
7639 gl.stencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
7640 GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilOp call failed.");
7642 gl.stencilMask(0xff);
7643 GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilMask call failed.");
7645 gl.depthFunc(GL_ALWAYS);
7646 GLU_EXPECT_NO_ERROR(gl.getError(), "glDepthFunc call failed.");
7648 gl.disable(GL_STENCIL_TEST);
7649 GLU_EXPECT_NO_ERROR(gl.getError(), "glDisable call failed.");
7651 gl.enable(GL_DEPTH_TEST);
7652 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable call failed.");
7654 gl.depthMask(GL_TRUE);
7655 GLU_EXPECT_NO_ERROR(gl.getError(), "glDepthMask call failed.");
7657 gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
7658 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays call failed.");
7660 /* Draw to color buffer. */
7661 gl.bindVertexArray(m_vao_color_pass_quad);
7662 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray call failed.");
7664 gl.colorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
7665 GLU_EXPECT_NO_ERROR(gl.getError(), "glColorMask call failed.");
7667 gl.stencilFunc(GL_EQUAL, 1, 0xff);
7668 GLU_EXPECT_NO_ERROR(gl.getError(), "glStencilFunc call failed.");
7670 gl.enable(GL_STENCIL_TEST);
7671 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable call failed.");
7673 gl.enable(GL_DEPTH_TEST);
7674 GLU_EXPECT_NO_ERROR(gl.getError(), "glEnable call failed.");
7676 gl.depthFunc(GL_GREATER);
7677 GLU_EXPECT_NO_ERROR(gl.getError(), "glDepthFunc call failed.");
7679 gl.depthMask(GL_FALSE);
7680 GLU_EXPECT_NO_ERROR(gl.getError(), "glDepthMask call failed.");
7682 gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
7683 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays call failed.");
7685 /* Blit framebuffer content. */
7686 gl.blitNamedFramebuffer(m_fbo_1st, m_fbo_2nd, 0, 0, 8, 8, 0, 0, 4, 3, GL_COLOR_BUFFER_BIT, GL_NEAREST);
7696 /** Check resulting framebuffer content.
7698 * @return True if content matches the reference false otherwise.
7700 bool FunctionalTest::CheckSecondFramebufferContent()
7702 /* Shortcut for GL functionality. */
7703 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7705 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_2nd);
7706 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
7708 glw::GLubyte framebuffer_values[3][4] = {
7712 static const glw::GLubyte reference_values[3][4] = { { 0, 0, 0, 0 }, { 0, 0, 255, 0 }, { 0, 0, 0, 0 } };
7714 gl.readPixels(0, 0, 4, 3, GL_RED, GL_UNSIGNED_BYTE, framebuffer_values);
7715 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels call failed.");
7717 for (glw::GLuint j = 0; j < 3; ++j)
7719 for (glw::GLuint i = 0; i < 4; ++i)
7721 if (reference_values[j][i] != framebuffer_values[j][i])
7731 /** @brief Clean up GL state.
7733 void FunctionalTest::Clean()
7735 /* Shortcut for GL functionality. */
7736 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7738 /* Releas GL objects. */
7741 gl.deleteFramebuffers(1, &m_fbo_1st);
7748 gl.deleteFramebuffers(1, &m_fbo_2nd);
7755 gl.deleteRenderbuffers(1, &m_rbo_color);
7760 if (m_rbo_depth_stencil)
7762 gl.deleteRenderbuffers(1, &m_rbo_depth_stencil);
7764 m_rbo_depth_stencil = 0;
7769 gl.deleteTextures(1, &m_to_color);
7778 gl.deleteProgram(m_po);
7783 if (m_vao_stencil_pass_quad)
7785 gl.deleteBuffers(1, &m_vao_stencil_pass_quad);
7787 m_vao_stencil_pass_quad = 0;
7790 if (m_vao_depth_pass_quad)
7792 gl.deleteBuffers(1, &m_vao_depth_pass_quad);
7794 m_vao_depth_pass_quad = 0;
7797 if (m_vao_color_pass_quad)
7799 gl.deleteBuffers(1, &m_vao_color_pass_quad);
7801 m_vao_color_pass_quad = 0;
7804 if (m_bo_stencil_pass_quad)
7806 gl.deleteBuffers(1, &m_bo_stencil_pass_quad);
7808 m_bo_stencil_pass_quad = 0;
7811 if (m_bo_depth_pass_quad)
7813 gl.deleteBuffers(1, &m_bo_depth_pass_quad);
7815 m_bo_depth_pass_quad = 0;
7818 if (m_bo_color_pass_quad)
7820 gl.deleteBuffers(1, &m_bo_color_pass_quad);
7822 m_bo_color_pass_quad = 0;
7825 /* Reseting state. */
7826 gl.stencilFunc(GL_ALWAYS, 0, 0xff);
7827 gl.stencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
7828 gl.stencilMask(0xff);
7829 gl.colorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
7830 gl.depthFunc(GL_LESS);
7831 gl.depthMask(GL_TRUE);
7832 gl.disable(GL_STENCIL_TEST);
7833 gl.disable(GL_DEPTH_TEST);
7836 while (gl.getError())
7840 /** Vertex shader source code. */
7841 const glw::GLchar FunctionalTest::s_vertex_shader[] = "#version 330\n"
7843 "in vec3 position;\n"
7847 " gl_Position = vec4(position, 1.0);\n"
7850 /** Fragment shader source code. */
7851 const glw::GLchar FunctionalTest::s_fragment_shader[] = "#version 330\n"
7857 " color = vec4(1.0);\n"
7860 /** Vertex shader source code attribute name. */
7861 const glw::GLchar FunctionalTest::s_attribute[] = "position";
7863 /** Stencil pass' geometry to be passed to vertex shader attribute. */
7864 const glw::GLfloat FunctionalTest::s_stencil_pass_quad[] = { -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f,
7865 0.5f, -0.5f, 0.5f, 0.5f, 0.5f, 0.5f };
7867 /** Depth pass' geometry to be passed to vertex shader attribute. */
7868 const glw::GLfloat FunctionalTest::s_depth_pass_quad[] = { -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f,
7869 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f };
7871 /** Color pass' geometry to be passed to vertex shader attribute. */
7872 const glw::GLfloat FunctionalTest::s_color_pass_quad[] = { -1.0f, -1.0f, 0.0f, -1.0f, 1.0f, 0.0f,
7873 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 0.0f };
7875 const glw::GLuint FunctionalTest::s_stencil_pass_quad_size =
7876 sizeof(s_stencil_pass_quad); //!< Size of stencil pass' geometry.
7877 const glw::GLuint FunctionalTest::s_depth_pass_quad_size =
7878 sizeof(s_depth_pass_quad); //!< Size of depth pass' geometry.
7879 const glw::GLuint FunctionalTest::s_color_pass_quad_size =
7880 sizeof(s_color_pass_quad); //!< Size of color pass' geometry.
7882 } // namespace Framebuffers
7884 namespace Renderbuffers
7886 /******************************** Renderbuffer Creation Test Implementation ********************************/
7888 /** @brief Creation Test constructor.
7890 * @param [in] context OpenGL context.
7892 CreationTest::CreationTest(deqp::Context& context)
7893 : deqp::TestCase(context, "renderbuffers_creation", "Renderbuffer Objects Creation Test")
7895 /* Intentionally left blank. */
7898 /** @brief Iterate Creation Test cases.
7900 * @return Iteration result.
7902 tcu::TestNode::IterateResult CreationTest::iterate()
7904 /* Shortcut for GL functionality. */
7905 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
7907 /* Get context setup. */
7908 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
7909 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
7911 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
7913 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
7918 /* Running tests. */
7920 bool is_error = false;
7922 /* Renderbuffers' objects */
7923 static const glw::GLuint renderbuffers_count = 2;
7925 glw::GLuint renderbuffers_legacy[renderbuffers_count] = {};
7926 glw::GLuint renderbuffers_dsa[renderbuffers_count] = {};
7930 /* Check legacy state creation. */
7931 gl.genRenderbuffers(renderbuffers_count, renderbuffers_legacy);
7932 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
7934 for (glw::GLuint i = 0; i < renderbuffers_count; ++i)
7936 if (gl.isRenderbuffer(renderbuffers_legacy[i]))
7941 m_context.getTestContext().getLog()
7942 << tcu::TestLog::Message
7943 << "GenRenderbuffers has created default objects, but it should create only a names."
7944 << tcu::TestLog::EndMessage;
7948 /* Check direct state creation. */
7949 gl.createRenderbuffers(renderbuffers_count, renderbuffers_dsa);
7950 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateRenderbuffers has failed");
7952 for (glw::GLuint i = 0; i < renderbuffers_count; ++i)
7954 if (!gl.isRenderbuffer(renderbuffers_dsa[i]))
7959 m_context.getTestContext().getLog() << tcu::TestLog::Message
7960 << "CreateRenderbuffers has not created default objects."
7961 << tcu::TestLog::EndMessage;
7972 for (glw::GLuint i = 0; i < renderbuffers_count; ++i)
7974 if (renderbuffers_legacy[i])
7976 gl.deleteRenderbuffers(1, &renderbuffers_legacy[i]);
7978 renderbuffers_legacy[i] = 0;
7981 if (renderbuffers_dsa[i])
7983 gl.deleteRenderbuffers(1, &renderbuffers_dsa[i]);
7985 renderbuffers_dsa[i] = 0;
7989 /* Errors clean up. */
7990 while (gl.getError())
7993 /* Result's setup. */
7996 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
8002 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
8006 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
8013 /******************************** Renderbuffer Storage Test Implementation ********************************/
8015 /** @brief Renderbuffer Storage Test constructor.
8017 * @param [in] context OpenGL context.
8019 StorageTest::StorageTest(deqp::Context& context)
8020 : deqp::TestCase(context, "renderbuffers_storage", "Renderbuffer Objects Storage Test"), m_fbo(0), m_rbo(0)
8022 /* Intentionally left blank. */
8025 /** @brief Iterate Creation Test cases.
8027 * @return Iteration result.
8029 tcu::TestNode::IterateResult StorageTest::iterate()
8031 /* Shortcut for GL functionality. */
8032 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8034 /* Get context setup. */
8035 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
8036 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
8038 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
8040 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
8045 /* Running tests. */
8047 bool is_error = false;
8051 glw::GLint max_renderbuffer_size = 16384 /* Specification minimum. */;
8053 gl.getIntegerv(GL_MAX_RENDERBUFFER_SIZE, &max_renderbuffer_size);
8054 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv call failed.");
8060 } test_cases[] = { { 1, 1 },
8063 { (glw::GLuint)max_renderbuffer_size, 1 },
8064 { 1, (glw::GLuint)max_renderbuffer_size } };
8066 const glw::GLuint test_cases_count = sizeof(test_cases) / sizeof(test_cases[0]);
8068 for (glw::GLuint i = 0; i < test_cases_count; ++i)
8070 for (glw::GLuint j = 0; j < s_renderbuffer_internalformat_configuration_count; ++j)
8072 if (PrepareRenderbuffer(s_renderbuffer_internalformat_configuration[j], test_cases[i].width,
8073 test_cases[i].height))
8075 Clear(s_renderbuffer_internalformat_configuration[j].isColorIntegralFormat);
8076 is_ok &= Check(s_renderbuffer_internalformat_configuration[j], test_cases[i].width,
8077 test_cases[i].height);
8096 /* Result's setup. */
8099 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
8105 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
8109 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
8116 /** Prepare renderbuffer.
8118 * @param [in] format Internal format to be prepared.
8119 * @param [in] width Width of the framebuffer.
8120 * @param [in] height Height of the framebuffer.
8122 * @return True if there is no error, false otherwise.
8124 bool StorageTest::PrepareRenderbuffer(StorageTest::RenderbufferInternalFormatConfiguration format, glw::GLuint width,
8127 /* Shortcut for GL functionality. */
8128 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8130 gl.genFramebuffers(1, &m_fbo);
8131 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
8133 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
8134 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
8136 gl.createRenderbuffers(1, &m_rbo);
8137 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateRenderbuffers call failed.");
8139 gl.namedRenderbufferStorage(m_rbo, format.internalformat, width, height);
8141 if (glw::GLenum error = gl.getError())
8143 m_context.getTestContext().getLog()
8144 << tcu::TestLog::Message << "Renderbuffer storage test failed because NamedRenderbufferStorage generated "
8145 << glu::getErrorStr(error) << " error value. Renderbuffers format was "
8146 << glu::getInternalFormatParameterStr(format.internalformat) << ", width was " << width << ", height was "
8147 << height << "." << tcu::TestLog::EndMessage;
8151 if (format.hasRedComponent || format.hasGreenComponent || format.hasBlueComponent || format.hasAlphaComponent)
8153 gl.namedFramebufferRenderbuffer(m_fbo, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo);
8156 if (format.hasDepthComponent)
8158 gl.namedFramebufferRenderbuffer(m_fbo, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_rbo);
8161 if (format.hasStencilComponent)
8163 gl.namedFramebufferRenderbuffer(m_fbo, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_rbo);
8166 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
8169 m_context.getTestContext().getLog()
8170 << tcu::TestLog::Message
8171 << "Renderbuffer storage test failed due to incomplete framebuffer status. Renderbuffers format was "
8172 << glu::getInternalFormatParameterStr(format.internalformat) << ", width was " << width << ", height was "
8173 << height << "." << tcu::TestLog::EndMessage;
8181 /** Clear renderbuffer.
8183 * @param [in] isColorIntegralFormat Is this color integral format.
8185 void StorageTest::Clear(bool isColorIntegralFormat)
8187 /* Shortcut for GL functionality. */
8188 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8189 if (isColorIntegralFormat)
8191 gl.clearBufferiv(GL_COLOR, 0, s_reference_color_integer);
8192 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearBufferiv has failed");
8196 /* Setup clear values. */
8197 gl.clearColor(s_reference_color[0], s_reference_color[1], s_reference_color[2], s_reference_color[3]);
8198 gl.clearDepth(s_reference_depth);
8199 gl.clearStencil(s_reference_stencil);
8201 /* Clear rbo/fbo. */
8202 gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
8206 /** Check renderbuffer's content.
8208 * @param [in] format Internal format to be prepared.
8209 * @param [in] width Width of the framebuffer.
8210 * @param [in] height Height of the framebuffer.
8212 * @return True if content matches the reference, false otherwise.
8214 bool StorageTest::Check(StorageTest::RenderbufferInternalFormatConfiguration format, glw::GLuint width,
8217 /* Shortcut for GL functionality. */
8218 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8220 glw::GLuint size = width * height;
8222 if (format.hasRedComponent || format.hasGreenComponent || format.hasBlueComponent || format.hasAlphaComponent)
8224 if (format.isColorIntegralFormat)
8226 std::vector<glw::GLint> color(size * 4);
8228 gl.readPixels(0, 0, width, height, GL_RGBA_INTEGER, GL_INT, &color[0]);
8229 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels call failed.");
8231 const bool hasComponent[] = { format.hasRedComponent, format.hasGreenComponent, format.hasBlueComponent,
8232 format.hasAlphaComponent };
8234 static const char* componentName[] = { "red", "green", "blue", "alpha" };
8236 for (glw::GLuint i = 0; i < size; ++i)
8238 if (hasComponent[i % 4 /* color components count*/])
8240 if (de::abs(s_reference_color_integer[i % 4 /* color components count*/] - color[i]) >
8243 m_context.getTestContext().getLog()
8244 << tcu::TestLog::Message << "Renderbuffer storage was cleared with color "
8245 << componentName[i % 4 /* color components count*/] << " component equal to "
8246 << s_reference_color_integer << ", but fetched value " << color[i]
8247 << " is not the same. Renderbuffers format was " << format.internalformat_name
8248 << ", width was " << width << ", height was " << height << "." << tcu::TestLog::EndMessage;
8257 std::vector<glw::GLfloat> color(size * 4);
8259 gl.readPixels(0, 0, width, height, GL_RGBA, GL_FLOAT, &color[0]);
8260 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels call failed.");
8262 const bool hasComponent[] = { format.hasRedComponent, format.hasGreenComponent, format.hasBlueComponent,
8263 format.hasAlphaComponent };
8265 static const char* componentName[] = { "red", "green", "blue", "alpha" };
8267 for (glw::GLuint i = 0; i < size; ++i)
8269 if (hasComponent[i % 4 /* color components count*/])
8271 if (de::abs(s_reference_color[i % 4 /* color components count*/] - color[i]) >
8272 0.0625 /* precision */)
8274 m_context.getTestContext().getLog()
8275 << tcu::TestLog::Message << "Renderbuffer storage was cleared with color "
8276 << componentName[i % 4 /* color components count*/] << " component equal to "
8277 << s_reference_color[i % 4 /* color components count*/] << ", but fetched value "
8278 << color[i] << " is not the same. Renderbuffers format was " << format.internalformat_name
8279 << ", width was " << width << ", height was " << height << "." << tcu::TestLog::EndMessage;
8288 if (format.hasDepthComponent)
8290 std::vector<glw::GLfloat> depth(size);
8292 gl.readPixels(0, 0, width, height, GL_DEPTH_COMPONENT, GL_FLOAT, &depth[0]);
8293 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels call failed.");
8295 for (glw::GLuint i = 0; i < size; ++i)
8297 if (de::abs(s_reference_depth - depth[i]) > 0.0625 /* 1/16 precision */)
8299 m_context.getTestContext().getLog()
8300 << tcu::TestLog::Message << "Renderbuffer storage was cleared with depth component equal to "
8301 << s_reference_depth << ", but fetched value " << depth[i]
8302 << " is not the same. Renderbuffers format was " << format.internalformat_name << ", width was "
8303 << width << ", height was " << height << "." << tcu::TestLog::EndMessage;
8310 if (format.hasStencilComponent)
8312 std::vector<glw::GLint> stencil(size);
8314 gl.readPixels(0, 0, width, height, GL_STENCIL_INDEX, GL_INT, &stencil[0]);
8315 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels call failed.");
8317 for (glw::GLuint i = 0; i < size; ++i)
8319 if (s_reference_stencil != stencil[i])
8321 m_context.getTestContext().getLog()
8322 << tcu::TestLog::Message << "Renderbuffer storage was cleared with alpha component equal to "
8323 << s_reference_stencil << ", but fetched value " << stencil[i]
8324 << " is not the same. Renderbuffers format was " << format.internalformat_name << ", width was "
8325 << width << ", height was " << height << "." << tcu::TestLog::EndMessage;
8335 /** @brief Clean up GL state.
8337 void StorageTest::Clean()
8339 /* Shortcut for GL functionality. */
8340 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8342 /* Release objects. */
8345 gl.deleteRenderbuffers(1, &m_rbo);
8352 gl.deleteFramebuffers(1, &m_fbo);
8357 /* Returning to default clear values. */
8358 gl.clearColor(0.f, 0.f, 0.f, 0.f);
8362 /* Errors clean up. */
8363 while (gl.getError())
8367 /** Internal formats to be tested*/
8368 const struct StorageTest::RenderbufferInternalFormatConfiguration
8369 StorageTest::s_renderbuffer_internalformat_configuration[] = {
8370 { GL_R8, "GL_R8", true, false, false, false, false, false, false },
8371 { GL_R16, "GL_R16", true, false, false, false, false, false, false },
8372 { GL_RG8, "GL_RG8", true, true, false, false, false, false, false },
8373 { GL_RG16, "GL_RG16", true, true, false, false, false, false, false },
8374 { GL_RGB565, "GL_RGB56", true, true, true, false, false, false, false },
8375 { GL_RGBA4, "GL_RGBA4", true, true, true, true, false, false, false },
8376 { GL_RGB5_A1, "GL_RGB5_A1", true, true, true, true, false, false, false },
8377 { GL_RGBA8, "GL_RGBA8", true, true, true, true, false, false, false },
8378 { GL_RGB10_A2, "GL_RGB10_A2", true, true, true, true, false, false, false },
8379 { GL_RGB10_A2UI, "GL_RGB10_A2UI", true, true, true, true, false, false, true },
8380 { GL_RGBA16, "GL_RGBA16", true, true, true, true, false, false, false },
8381 { GL_SRGB8_ALPHA8, "GL_SRGB8_ALPHA8", true, true, true, true, false, false, false },
8382 { GL_R16F, "GL_R16F", true, false, false, false, false, false, false },
8383 { GL_RG16F, "GL_RG16F", true, true, false, false, false, false, false },
8384 { GL_RGBA16F, "GL_RGBA16F", true, true, true, true, false, false, false },
8385 { GL_R32F, "GL_R32F", true, false, false, false, false, false, false },
8386 { GL_RG32F, "GL_RG32F", true, true, false, false, false, false, false },
8387 { GL_RGBA32F, "GL_RGBA32F", true, true, true, true, false, false, false },
8388 { GL_R11F_G11F_B10F, "GL_R11F_G11F_B10F", true, true, true, false, false, false, false },
8389 { GL_R8I, "GL_R8I", true, false, false, false, false, false, true },
8390 { GL_R8UI, "GL_R8UI", true, false, false, false, false, false, true },
8391 { GL_R16I, "GL_R16I", true, false, false, false, false, false, true },
8392 { GL_R16UI, "GL_R16UI", true, false, false, false, false, false, true },
8393 { GL_R32I, "GL_R32I", true, false, false, false, false, false, true },
8394 { GL_R32UI, "GL_R32UI", true, false, false, false, false, false, true },
8395 { GL_RG8I, "GL_RG8I", true, true, false, false, false, false, true },
8396 { GL_RG8UI, "GL_RG8UI", true, true, false, false, false, false, true },
8397 { GL_RG16I, "GL_RG16I", true, true, false, false, false, false, true },
8398 { GL_RG16UI, "GL_RG16UI", true, true, false, false, false, false, true },
8399 { GL_RG32I, "GL_RG32I", true, true, false, false, false, false, true },
8400 { GL_RG32UI, "GL_RG32UI", true, true, false, false, false, false, true },
8401 { GL_RGBA8I, "GL_RGBA8I", true, true, true, true, false, false, true },
8402 { GL_RGBA8UI, "GL_RGBA8UI", true, true, true, true, false, false, true },
8403 { GL_RGBA16I, "GL_RGBA16I", true, true, true, true, false, false, true },
8404 { GL_RGBA16UI, "GL_RGBA16UI", true, true, true, true, false, false, true },
8405 { GL_RGBA32I, "GL_RGBA32I", true, true, true, true, false, false, true },
8406 { GL_RGBA32UI, "GL_RGBA32UI", true, true, true, true, false, false, true },
8407 { GL_DEPTH_COMPONENT16, "GL_DEPTH_COMPONENT16", false, false, false, false, true, false, false },
8408 { GL_DEPTH_COMPONENT24, "GL_DEPTH_COMPONENT24", false, false, false, false, true, false, false },
8409 { GL_DEPTH_COMPONENT32F, "GL_DEPTH_COMPONENT32F", false, false, false, false, true, false, false },
8410 { GL_DEPTH24_STENCIL8, "GL_DEPTH24_STENCIL8", false, false, false, false, true, true, false },
8411 { GL_DEPTH32F_STENCIL8, "GL_DEPTH32F_STENCIL8", false, false, false, false, true, true, false },
8412 { GL_STENCIL_INDEX8, "GL_STENCIL_INDEX8", false, false, false, false, false, true, false }
8415 /** Internal formats count */
8416 const glw::GLuint StorageTest::s_renderbuffer_internalformat_configuration_count =
8417 sizeof(s_renderbuffer_internalformat_configuration) / sizeof(s_renderbuffer_internalformat_configuration[0]);
8419 const glw::GLfloat StorageTest::s_reference_color[4] = { 0.25, 0.5, 0.75, 1.0 }; //!< Reference color.
8420 const glw::GLint StorageTest::s_reference_color_integer[4] = { 1, 2, 3, 4 }; //!< Reference integral color.
8421 const glw::GLfloat StorageTest::s_reference_depth = 0.5; //!< Reference depth.
8422 const glw::GLint StorageTest::s_reference_stencil = 7; //!< Reference stencil.
8424 /***************************** Renderbuffer Storage Multisample Test Implementation ***************************/
8426 /** @brief Renderbuffer Storage Multisample Test constructor.
8428 * @param [in] context OpenGL context.
8430 StorageMultisampleTest::StorageMultisampleTest(deqp::Context& context)
8431 : deqp::TestCase(context, "renderbuffers_storage_multisample", "Renderbuffer Objects Storage Multisample Test")
8433 for (glw::GLuint i = 0; i < 2; ++i)
8440 /** @brief Iterate Creation Test cases.
8442 * @return Iteration result.
8444 tcu::TestNode::IterateResult StorageMultisampleTest::iterate()
8446 /* Shortcut for GL functionality. */
8447 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8449 /* Get context setup. */
8450 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
8451 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
8453 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
8455 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
8460 /* Running tests. */
8462 bool is_error = false;
8466 glw::GLint max_renderbuffer_size = 16384 /* Specification minimum. */;
8468 gl.getIntegerv(GL_MAX_RENDERBUFFER_SIZE, &max_renderbuffer_size);
8469 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv call failed.");
8475 } test_cases[] = { { 1, 1 },
8476 { (glw::GLuint)max_renderbuffer_size / 2, 1 },
8477 { 1, (glw::GLuint)max_renderbuffer_size / 2 } };
8479 const glw::GLuint test_cases_count = sizeof(test_cases) / sizeof(test_cases[0]);
8481 for (glw::GLuint i = 0; i < test_cases_count; ++i)
8483 for (glw::GLuint j = 0; j < s_renderbuffer_internalformat_configuration_count; ++j)
8485 glw::GLint max_integer_samples = GetMaxConformantSampleCount(
8486 GL_RENDERBUFFER, s_renderbuffer_internalformat_configuration[j].internalformat);
8487 for (glw::GLint k = 0; k <= max_integer_samples; ++k)
8489 if (PrepareRenderbuffer(s_renderbuffer_internalformat_configuration[j], test_cases[i].width,
8490 test_cases[i].height, k))
8492 Bind(GL_DRAW_FRAMEBUFFER, 0);
8493 Clear(s_renderbuffer_internalformat_configuration[j].isColorIntegralFormat);
8494 Bind(GL_READ_FRAMEBUFFER, 0);
8495 Bind(GL_DRAW_FRAMEBUFFER, 1);
8496 Blit(test_cases[i].width, test_cases[i].height);
8497 Bind(GL_READ_FRAMEBUFFER, 1);
8498 is_ok &= Check(s_renderbuffer_internalformat_configuration[j], test_cases[i].width,
8499 test_cases[i].height);
8519 /* Result's setup. */
8522 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
8528 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
8532 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
8539 /** Prepare renderbuffer.
8541 * @param [in] format Internal format to be prepared.
8542 * @param [in] width Width of the framebuffer.
8543 * @param [in] height Height of the framebuffer.
8545 * @return True if there is no error, false otherwise.
8547 bool StorageMultisampleTest::PrepareRenderbuffer(StorageMultisampleTest::RenderbufferInternalFormatConfiguration format,
8548 glw::GLuint width, glw::GLuint height, glw::GLsizei samples)
8550 /* Shortcut for GL functionality. */
8551 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8553 gl.genFramebuffers(2, m_fbo);
8554 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
8556 gl.createRenderbuffers(2, m_rbo);
8557 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateRenderbuffers call failed.");
8559 for (glw::GLuint i = 0; i < 2; ++i)
8561 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo[i]);
8562 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
8566 /* 2nd is not multisampled. */
8567 gl.namedRenderbufferStorageMultisample(m_rbo[i], 0, format.internalformat, width, height);
8569 if (glw::GLenum error = gl.getError())
8571 m_context.getTestContext().getLog()
8572 << tcu::TestLog::Message << "Renderbuffer storage multisample test failed because "
8573 "NamedRenderbufferStorageMultisample generated "
8574 << glu::getErrorStr(error) << " error value. Renderbuffers format was "
8575 << format.internalformat_name << ", samples was " << 0 << ", width was " << width << ", height was "
8576 << height << "." << tcu::TestLog::EndMessage;
8582 /* 1st is multisampled. */
8583 gl.namedRenderbufferStorageMultisample(m_rbo[i], samples, format.internalformat, width, height);
8585 if (glw::GLenum error = gl.getError())
8587 m_context.getTestContext().getLog()
8588 << tcu::TestLog::Message << "Renderbuffer storage multisample test failed because "
8589 "NamedRenderbufferStorageMultisample generated "
8590 << glu::getErrorStr(error) << " error value. Renderbuffers format was "
8591 << format.internalformat_name << ", samples was " << samples << ", width was " << width
8592 << ", height was " << height << "." << tcu::TestLog::EndMessage;
8597 if (format.hasRedComponent || format.hasGreenComponent || format.hasBlueComponent || format.hasAlphaComponent)
8599 gl.namedFramebufferRenderbuffer(m_fbo[i], GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo[i]);
8602 if (format.hasDepthComponent)
8604 gl.namedFramebufferRenderbuffer(m_fbo[i], GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_rbo[i]);
8607 if (format.hasStencilComponent)
8609 gl.namedFramebufferRenderbuffer(m_fbo[i], GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_rbo[i]);
8612 glw::GLenum status = gl.checkFramebufferStatus(GL_FRAMEBUFFER);
8613 if (status != GL_FRAMEBUFFER_COMPLETE)
8616 m_context.getTestContext().getLog()
8617 << tcu::TestLog::Message << "Renderbuffer storage multisample test failed due to "
8618 << glu::getFramebufferStatusStr(status) << " framebuffer status. Renderbuffers format was "
8619 << format.internalformat_name << ", samples was " << (i ? 0 : samples) << ", width was " << width
8620 << ", height was " << height << "." << tcu::TestLog::EndMessage;
8629 /** Bind framebuffer to the target.
8631 * @param [in] target Bind to target.
8632 * @param [in] selector Index of the framebuffer in framebuffers' arrays.
8634 void StorageMultisampleTest::Bind(glw::GLenum target, glw::GLuint selector)
8636 /* Shortcut for GL functionality. */
8637 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8639 /* Binding framebuffer. */
8640 gl.bindFramebuffer(target, m_fbo[selector]);
8641 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
8644 /** Blit one framebuffer to the second.
8646 * @param [in] width Width of the framebuffer.
8647 * @param [in] height Height of the framebuffer.
8649 * @return True if there is no error, false otherwise.
8651 void StorageMultisampleTest::Blit(glw::GLuint width, glw::GLuint height)
8653 /* Shortcut for GL functionality. */
8654 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8656 /* Binding framebuffer. */
8657 gl.blitFramebuffer(0, 0, width, height, 0, 0, width, height,
8658 GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST);
8659 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
8662 /** Clear framebuffer.
8664 * @param [in] isColorIntegralFormat Is framebuffer a color integral type.
8666 void StorageMultisampleTest::Clear(bool isColorIntegralFormat)
8668 /* Shortcut for GL functionality. */
8669 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8671 if (isColorIntegralFormat)
8673 gl.clearBufferiv(GL_COLOR, 0, s_reference_color_integer);
8674 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearBufferiv has failed");
8678 /* Setup clear values. */
8679 gl.clearColor(s_reference_color[0], s_reference_color[1], s_reference_color[2], s_reference_color[3]);
8680 gl.clearDepth(s_reference_depth);
8681 gl.clearStencil(s_reference_stencil);
8683 /* Clear rbo/fbo. */
8684 gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
8688 /** Check renderbuffer's content.
8690 * @param [in] format Internal format to be prepared.
8691 * @param [in] width Width of the framebuffer.
8692 * @param [in] height Height of the framebuffer.
8694 * @return True if content matches the reference, false otherwise.
8696 bool StorageMultisampleTest::Check(StorageMultisampleTest::RenderbufferInternalFormatConfiguration format,
8697 glw::GLuint width, glw::GLuint height)
8699 /* Shortcut for GL functionality. */
8700 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8702 glw::GLuint size = width * height;
8704 if (format.hasRedComponent || format.hasGreenComponent || format.hasBlueComponent || format.hasAlphaComponent)
8706 if (format.isColorIntegralFormat)
8708 std::vector<glw::GLint> color(size * 4);
8710 gl.readPixels(0, 0, width, height, GL_RGBA_INTEGER, GL_INT, &color[0]);
8711 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels call failed.");
8713 const bool hasComponent[] = { format.hasRedComponent, format.hasGreenComponent, format.hasBlueComponent,
8714 format.hasAlphaComponent };
8716 static const char* componentName[] = { "red", "green", "blue", "alpha" };
8718 for (glw::GLuint i = 0; i < size; ++i)
8720 if (hasComponent[i % 4 /* color components count*/])
8722 if (de::abs(s_reference_color_integer[i % 4 /* color components count*/] - color[i]) >
8725 m_context.getTestContext().getLog()
8726 << tcu::TestLog::Message << "Renderbuffer storage multisample was cleared with color "
8727 << componentName[i % 4 /* color components count*/] << " component equal to "
8728 << s_reference_color_integer << ", but fetched value " << color[i]
8729 << " is not the same. Renderbuffers format was " << format.internalformat_name
8730 << ", width was " << width << ", height was " << height << "." << tcu::TestLog::EndMessage;
8739 std::vector<glw::GLfloat> color(size * 4);
8741 gl.readPixels(0, 0, width, height, GL_RGBA, GL_FLOAT, &color[0]);
8742 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels call failed.");
8744 const bool hasComponent[] = { format.hasRedComponent, format.hasGreenComponent, format.hasBlueComponent,
8745 format.hasAlphaComponent };
8747 static const char* componentName[] = { "red", "green", "blue", "alpha" };
8749 for (glw::GLuint i = 0; i < size; ++i)
8751 if (hasComponent[i % 4 /* color components count*/])
8753 if (de::abs(s_reference_color[i % 4 /* color components count*/] - color[i]) >
8754 0.0625 /* precision */)
8756 m_context.getTestContext().getLog()
8757 << tcu::TestLog::Message << "Renderbuffer storage multisample was cleared with color "
8758 << componentName[i % 4 /* color components count*/] << " component equal to "
8759 << s_reference_color[i % 4 /* color components count*/] << ", but fetched value "
8760 << color[i] << " is not the same. Renderbuffers format was " << format.internalformat_name
8761 << ", width was " << width << ", height was " << height << "." << tcu::TestLog::EndMessage;
8770 if (format.hasDepthComponent)
8772 std::vector<glw::GLfloat> depth(size);
8774 gl.readPixels(0, 0, width, height, GL_DEPTH_COMPONENT, GL_FLOAT, &depth[0]);
8775 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels call failed.");
8777 for (glw::GLuint i = 0; i < size; ++i)
8779 if (de::abs(s_reference_depth - depth[i]) > 0.0625 /* 1/16 precision */)
8781 m_context.getTestContext().getLog()
8782 << tcu::TestLog::Message
8783 << "Renderbuffer storage multisample was cleared with depth component equal to "
8784 << s_reference_depth << ", but fetched value " << depth[i]
8785 << " is not the same. Renderbuffers format was " << format.internalformat_name << ", width was "
8786 << width << ", height was " << height << "." << tcu::TestLog::EndMessage;
8793 if (format.hasStencilComponent)
8795 std::vector<glw::GLint> stencil(size);
8797 gl.readPixels(0, 0, width, height, GL_STENCIL_INDEX, GL_INT, &stencil[0]);
8798 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels call failed.");
8800 for (glw::GLuint i = 0; i < size; ++i)
8802 if (s_reference_stencil != stencil[i])
8804 m_context.getTestContext().getLog()
8805 << tcu::TestLog::Message
8806 << "Renderbuffer storage multisample was cleared with alpha component equal to "
8807 << s_reference_stencil << ", but fetched value " << stencil[i]
8808 << " is not the same. Renderbuffers format was " << format.internalformat_name << ", width was "
8809 << width << ", height was " << height << "." << tcu::TestLog::EndMessage;
8819 /** @brief Clean up GL state.
8821 void StorageMultisampleTest::Clean()
8823 /* Shortcut for GL functionality. */
8824 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8826 /* Release objects. */
8827 for (glw::GLuint i = 0; i < 2; ++i)
8831 gl.deleteRenderbuffers(1, &m_rbo[i]);
8838 gl.deleteFramebuffers(1, &m_fbo[i]);
8844 /* Returning to default clear values. */
8845 gl.clearColor(0.f, 0.f, 0.f, 0.f);
8849 /* Errors clean up. */
8850 while (gl.getError())
8854 /** @brief Retrieve max conformant sample count when GL_NV_internalformat_sample_query is supported
8856 * @param [in] target Target indicating usage of internal format
8857 * @param [in] internalFormat Internal format about which to retrieve information
8859 * @return Max conformant sample count
8861 glw::GLint StorageMultisampleTest::GetMaxConformantSampleCount(glw::GLenum target, glw::GLenum internalFormat)
8863 glw::GLint max_conformant_samples = 0;
8865 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8867 /* Return the max conformant sample count if extension is supported */
8868 if (m_context.getContextInfo().isExtensionSupported("GL_NV_internalformat_sample_query"))
8870 glw::GLint gl_sample_counts = 0;
8871 gl.getInternalformativ(target, internalFormat, GL_NUM_SAMPLE_COUNTS, 1, &gl_sample_counts);
8872 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetInternalformativ() failed for GL_NUM_SAMPLE_COUNTS pname");
8874 /* Check and return the max conformant sample count */
8875 glw::GLint* gl_supported_samples = new glw::GLint[gl_sample_counts];
8876 if (gl_supported_samples)
8878 gl.getInternalformativ(target, internalFormat, GL_SAMPLES, gl_sample_counts, gl_supported_samples);
8880 for (glw::GLint i = 0; i < gl_sample_counts; i++)
8882 glw::GLint isConformant = 0;
8883 gl.getInternalformatSampleivNV(target, internalFormat, gl_supported_samples[i], GL_CONFORMANT_NV, 1,
8885 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetInternalformatSampleivNV() call(s) failed");
8887 if (isConformant && gl_supported_samples[i] > max_conformant_samples)
8889 max_conformant_samples = gl_supported_samples[i];
8892 delete[] gl_supported_samples;
8897 /* Otherwise return GL_MAX_INTEGER_SAMPLES */
8898 gl.getIntegerv(GL_MAX_INTEGER_SAMPLES, &max_conformant_samples);
8899 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv() call failed for GL_MAX_INTEGER_SAMPLES pname.");
8902 return max_conformant_samples;
8905 /** Tested internal format */
8906 const struct StorageMultisampleTest::RenderbufferInternalFormatConfiguration
8907 StorageMultisampleTest::s_renderbuffer_internalformat_configuration[] = {
8908 { GL_R8, "GL_R8", true, false, false, false, false, false, false },
8909 { GL_R16, "GL_R16", true, false, false, false, false, false, false },
8910 { GL_RG8, "GL_RG8", true, true, false, false, false, false, false },
8911 { GL_RG16, "GL_RG16", true, true, false, false, false, false, false },
8912 { GL_RGB565, "GL_RGB56", true, true, true, false, false, false, false },
8913 { GL_RGBA4, "GL_RGBA4", true, true, true, true, false, false, false },
8914 { GL_RGB5_A1, "GL_RGB5_A1", true, true, true, true, false, false, false },
8915 { GL_RGBA8, "GL_RGBA8", true, true, true, true, false, false, false },
8916 { GL_RGB10_A2, "GL_RGB10_A2", true, true, true, true, false, false, false },
8917 { GL_RGB10_A2UI, "GL_RGB10_A2UI", true, true, true, true, false, false, true },
8918 { GL_RGBA16, "GL_RGBA16", true, true, true, true, false, false, false },
8919 { GL_SRGB8_ALPHA8, "GL_SRGB8_ALPHA8", true, true, true, true, false, false, false },
8920 { GL_R16F, "GL_R16F", true, false, false, false, false, false, false },
8921 { GL_RG16F, "GL_RG16F", true, true, false, false, false, false, false },
8922 { GL_RGBA16F, "GL_RGBA16F", true, true, true, true, false, false, false },
8923 { GL_R32F, "GL_R32F", true, false, false, false, false, false, false },
8924 { GL_RG32F, "GL_RG32F", true, true, false, false, false, false, false },
8925 { GL_RGBA32F, "GL_RGBA32F", true, true, true, true, false, false, false },
8926 { GL_R11F_G11F_B10F, "GL_R11F_G11F_B10F", true, true, true, false, false, false, false },
8927 { GL_R8I, "GL_R8I", true, false, false, false, false, false, true },
8928 { GL_R8UI, "GL_R8UI", true, false, false, false, false, false, true },
8929 { GL_R16I, "GL_R16I", true, false, false, false, false, false, true },
8930 { GL_R16UI, "GL_R16UI", true, false, false, false, false, false, true },
8931 { GL_R32I, "GL_R32I", true, false, false, false, false, false, true },
8932 { GL_R32UI, "GL_R32UI", true, false, false, false, false, false, true },
8933 { GL_RG8I, "GL_RG8I", true, true, false, false, false, false, true },
8934 { GL_RG8UI, "GL_RG8UI", true, true, false, false, false, false, true },
8935 { GL_RG16I, "GL_RG16I", true, true, false, false, false, false, true },
8936 { GL_RG16UI, "GL_RG16UI", true, true, false, false, false, false, true },
8937 { GL_RG32I, "GL_RG32I", true, true, false, false, false, false, true },
8938 { GL_RG32UI, "GL_RG32UI", true, true, false, false, false, false, true },
8939 { GL_RGBA8I, "GL_RGBA8I", true, true, true, true, false, false, true },
8940 { GL_RGBA8UI, "GL_RGBA8UI", true, true, true, true, false, false, true },
8941 { GL_RGBA16I, "GL_RGBA16I", true, true, true, true, false, false, true },
8942 { GL_RGBA16UI, "GL_RGBA16UI", true, true, true, true, false, false, true },
8943 { GL_RGBA32I, "GL_RGBA32I", true, true, true, true, false, false, true },
8944 { GL_RGBA32UI, "GL_RGBA32UI", true, true, true, true, false, false, true },
8945 { GL_DEPTH_COMPONENT16, "GL_DEPTH_COMPONENT16", false, false, false, false, true, false, false },
8946 { GL_DEPTH_COMPONENT24, "GL_DEPTH_COMPONENT24", false, false, false, false, true, false, false },
8947 { GL_DEPTH_COMPONENT32F, "GL_DEPTH_COMPONENT32F", false, false, false, false, true, false, false },
8948 { GL_DEPTH24_STENCIL8, "GL_DEPTH24_STENCIL8", false, false, false, false, true, true, false },
8949 { GL_DEPTH32F_STENCIL8, "GL_DEPTH32F_STENCIL8", false, false, false, false, true, true, false },
8950 { GL_STENCIL_INDEX8, "GL_STENCIL_INDEX8", false, false, false, false, false, true, false }
8953 /** Tesetd internal format count */
8954 const glw::GLuint StorageMultisampleTest::s_renderbuffer_internalformat_configuration_count =
8955 sizeof(s_renderbuffer_internalformat_configuration) / sizeof(s_renderbuffer_internalformat_configuration[0]);
8957 const glw::GLfloat StorageMultisampleTest::s_reference_color[4] = { 0.25, 0.5, 0.75, 1.0 }; //!< Reference color value.
8958 const glw::GLint StorageMultisampleTest::s_reference_color_integer[4] = {
8960 }; //!< Reference color value for integral color internal formats.
8961 const glw::GLfloat StorageMultisampleTest::s_reference_depth = 0.5; //!< Reference depth value.
8962 const glw::GLint StorageMultisampleTest::s_reference_stencil = 7; //!< Reference stencil value.
8964 /******************************** Get Named Renderbuffer Parameters Test Implementation ********************************/
8966 /** @brief Get Named Renderbuffer Parameters Test constructor.
8968 * @param [in] context OpenGL context.
8970 GetParametersTest::GetParametersTest(deqp::Context& context)
8971 : deqp::TestCase(context, "renderbuffers_get_parameters", "Get Named Renderbuffer Parameters Test")
8975 /* Intentionally left blank. */
8978 /** @brief Iterate Check Status Test cases.
8980 * @return Iteration result.
8982 tcu::TestNode::IterateResult GetParametersTest::iterate()
8984 /* Shortcut for GL functionality. */
8985 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
8987 /* Get context setup. */
8988 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
8989 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
8991 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
8993 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
8998 /* Running tests. */
9000 bool is_error = false;
9002 /* Test renderbuffer. */
9003 glw::GLuint renderbuffer = 0;
9008 static const glw::GLenum internalformats[] = { GL_RGBA8, GL_DEPTH_COMPONENT24, GL_STENCIL_INDEX8,
9009 GL_DEPTH24_STENCIL8 };
9011 static const glw::GLuint internalformats_count = sizeof(internalformats) / sizeof(internalformats[0]);
9013 for (glw::GLuint i = 0; i < internalformats_count; ++i)
9015 gl.genRenderbuffers(1, &renderbuffer);
9016 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers has failed");
9018 gl.bindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
9019 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer has failed");
9021 gl.renderbufferStorage(GL_RENDERBUFFER, internalformats[i], 1, 2);
9022 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage has failed");
9024 static const glw::GLenum pnames[] = { GL_RENDERBUFFER_WIDTH, GL_RENDERBUFFER_HEIGHT,
9025 GL_RENDERBUFFER_INTERNAL_FORMAT, GL_RENDERBUFFER_SAMPLES,
9026 GL_RENDERBUFFER_RED_SIZE, GL_RENDERBUFFER_GREEN_SIZE,
9027 GL_RENDERBUFFER_BLUE_SIZE, GL_RENDERBUFFER_ALPHA_SIZE,
9028 GL_RENDERBUFFER_DEPTH_SIZE, GL_RENDERBUFFER_STENCIL_SIZE };
9030 static const glw::GLchar* pnames_strings[] = {
9031 "GL_RENDERBUFFER_WIDTH", "GL_RENDERBUFFER_HEIGHT", "GL_RENDERBUFFER_INTERNAL_FORMAT",
9032 "GL_RENDERBUFFER_SAMPLES", "GL_RENDERBUFFER_RED_SIZE", "GL_RENDERBUFFER_GREEN_SIZE",
9033 "GL_RENDERBUFFER_BLUE_SIZE", "GL_RENDERBUFFER_ALPHA_SIZE", "GL_RENDERBUFFER_DEPTH_SIZE",
9034 "GL_RENDERBUFFER_STENCIL_SIZE"
9037 for (glw::GLuint j = 0; j < internalformats_count; ++j)
9039 glw::GLint parameter_legacy = 0;
9040 glw::GLint parameter_dsa = 0;
9042 gl.getRenderbufferParameteriv(GL_RENDERBUFFER, pnames[j], ¶meter_legacy);
9043 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetRenderbufferParameteriv has failed");
9045 gl.getNamedRenderbufferParameteriv(renderbuffer, pnames[j], ¶meter_dsa);
9047 if (glw::GLenum error = gl.getError())
9049 m_context.getTestContext().getLog()
9050 << tcu::TestLog::Message << "GetNamedRenderbufferParameteriv unexpectedly generated "
9051 << glu::getErrorStr(error) << " error when called with " << pnames_strings[i]
9052 << " parameter name of renderbuffer with internalformat = "
9053 << glu::getInternalFormatParameterStr(internalformats[i]) << ", width = 1, height = 2."
9054 << tcu::TestLog::EndMessage;
9061 if (parameter_legacy != parameter_dsa)
9063 m_context.getTestContext().getLog()
9064 << tcu::TestLog::Message << "GetNamedRenderbufferParameteriv returned " << parameter_dsa
9065 << ", but " << parameter_legacy << " was expected for " << pnames_strings[i]
9066 << " parameter name of renderbuffer with internalformat = "
9067 << glu::getInternalFormatParameterStr(internalformats[i]) << ", width = 1, height = 2."
9068 << tcu::TestLog::EndMessage;
9074 gl.deleteRenderbuffers(1, &renderbuffer);
9075 GLU_EXPECT_NO_ERROR(gl.getError(), "glDeleteRenderbuffers has failed");
9089 gl.deleteRenderbuffers(1, &renderbuffer);
9092 while (gl.getError())
9095 /* Result's setup. */
9098 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
9104 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
9108 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
9115 /******************************** Renderbuffer Creation Errors Test Implementation ********************************/
9117 /** @brief Creation Errors Test constructor.
9119 * @param [in] context OpenGL context.
9121 CreationErrorsTest::CreationErrorsTest(deqp::Context& context)
9122 : deqp::TestCase(context, "renderbuffers_creation_errors", "Renderbuffer Objects Creation Errors Test")
9124 /* Intentionally left blank. */
9127 /** @brief Iterate Creation Test cases.
9129 * @return Iteration result.
9131 tcu::TestNode::IterateResult CreationErrorsTest::iterate()
9133 /* Shortcut for GL functionality. */
9134 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
9136 /* Get context setup. */
9137 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
9138 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
9140 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
9142 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
9147 /* Running tests. */
9150 /* Framebuffer object */
9151 glw::GLuint renderbuffer = 0;
9153 /* Check direct state creation of negative numbers of framebuffers. */
9154 gl.createRenderbuffers(-1, &renderbuffer);
9156 glw::GLenum error = GL_NO_ERROR;
9158 if (GL_INVALID_VALUE != (error = gl.getError()))
9160 m_context.getTestContext().getLog()
9161 << tcu::TestLog::Message << "CreateRenderbuffers generated " << glu::getErrorStr(error)
9162 << " error when called with negative number of renderbuffers, but GL_INVALID_VALUE was expected."
9163 << tcu::TestLog::EndMessage;
9168 /* Cleanup (sanity). */
9171 gl.deleteRenderbuffers(1, &renderbuffer);
9174 /* Errors clean up. */
9175 while (gl.getError())
9178 /* Result's setup. */
9181 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
9185 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
9191 /******************************** Storage Errors Test Implementation ********************************/
9193 /** @brief Storage Errors Test constructor.
9195 * @param [in] context OpenGL context.
9197 StorageErrorsTest::StorageErrorsTest(deqp::Context& context)
9198 : deqp::TestCase(context, "renderbuffers_storage_errors", "Storage Errors Test")
9201 , m_internalformat_invalid(0)
9203 /* Intentionally left blank. */
9206 /** @brief Iterate Creation Test cases.
9208 * @return Iteration result.
9210 tcu::TestNode::IterateResult StorageErrorsTest::iterate()
9212 /* Shortcut for GL functionality. */
9213 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
9215 /* Get context setup. */
9216 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
9217 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
9219 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
9221 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
9226 /* Running tests. */
9228 bool is_error = false;
9232 /* Prepare objects. */
9235 /* Check that INVALID_OPERATION is generated by NamedRenderbufferStorage if
9236 renderbuffer is not the name of an existing renderbuffer object. */
9237 gl.namedRenderbufferStorage(m_rbo_invalid, GL_RGBA8, 1, 1);
9239 is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedRenderbufferStorage",
9240 "renderbuffer is not the name of an existing renderbuffer object.");
9242 /* Check that INVALID_VALUE is generated by NamedRenderbufferStorage if
9243 either of width or height is negative, or greater than the value of
9244 MAX_RENDERBUFFER_SIZE. */
9245 gl.namedRenderbufferStorage(m_rbo_valid, GL_RGBA8, -1, 1);
9247 is_ok &= ExpectError(GL_INVALID_VALUE, "NamedRenderbufferStorage", "either of width is negative.");
9249 gl.namedRenderbufferStorage(m_rbo_valid, GL_RGBA8, 1, -1);
9251 is_ok &= ExpectError(GL_INVALID_VALUE, "NamedRenderbufferStorage", "either of height is negative.");
9253 /* Check that INVALID_ENUM is generated by NamedRenderbufferStorage if
9254 internalformat is not a color-renderable, depth-renderable, or
9255 stencil-renderable format. */
9256 gl.namedRenderbufferStorage(m_rbo_valid, m_internalformat_invalid, 1, 1);
9258 is_ok &= ExpectError(GL_INVALID_ENUM, "NamedRenderbufferStorage", "internalformat is not a color-renderable, "
9259 "depth-renderable, or stencil-renderable "
9260 "format (it is COMPRESSED_RED).");
9271 /* Result's setup. */
9274 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
9280 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
9284 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
9291 /** Check Prepare test's GL objects.
9293 void StorageErrorsTest::PrepareObjects()
9295 /* Shortcut for GL functionality. */
9296 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
9298 /* Valid objects. */
9299 gl.genRenderbuffers(1, &m_rbo_valid);
9300 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
9302 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo_valid);
9303 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
9305 /* Invalid objects. */
9306 while (gl.isRenderbuffer(++m_rbo_invalid))
9310 /** Check if error is equal to the expected, log if not.
9312 * @param [in] expected_error Error to be expected.
9313 * @param [in] function Function name which is being tested (to be logged).
9314 * @param [in] conditions Conditions when the expected error shall occure (to be logged).
9316 * @return True if there is no error, false otherwise.
9318 bool StorageErrorsTest::ExpectError(glw::GLenum expected_error, const glw::GLchar* function,
9319 const glw::GLchar* conditions)
9321 /* Shortcut for GL functionality. */
9322 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
9326 glw::GLenum error = GL_NO_ERROR;
9328 if (expected_error != (error = gl.getError()))
9330 m_context.getTestContext().getLog() << tcu::TestLog::Message << function << " was expected to generate "
9331 << glu::getErrorStr(expected_error) << ", but " << glu::getErrorStr(error)
9332 << " was observed instead when " << conditions << tcu::TestLog::EndMessage;
9337 /* Clean additional possible errors. */
9338 while (gl.getError())
9344 /** @brief Clean up GL state.
9346 void StorageErrorsTest::Clean()
9348 /* Shortcut for GL functionality. */
9349 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
9351 /* Release GL objects. */
9354 gl.deleteRenderbuffers(1, &m_rbo_valid);
9358 /* COmpressed internal formats are not color renderable (OpenGL 4.5 Core PRofile SPecification Chapter 9.4 )*/
9359 m_internalformat_invalid = GL_COMPRESSED_RED;
9361 /* Set initial values - all test shall have the same environment. */
9365 /* Errors clean up. */
9366 while (gl.getError())
9370 /******************************** Storage Multisample Errors Test Implementation ********************************/
9372 /** @brief Storage Errors Test constructor.
9374 * @param [in] context OpenGL context.
9376 StorageMultisampleErrorsTest::StorageMultisampleErrorsTest(deqp::Context& context)
9377 : deqp::TestCase(context, "renderbuffers_storage_multisample_errors", "Storage Multisample Errors Test")
9380 , m_internalformat_invalid(0)
9382 , m_max_integer_samples(0)
9384 /* Intentionally left blank. */
9387 /** @brief Iterate Creation Test cases.
9389 * @return Iteration result.
9391 tcu::TestNode::IterateResult StorageMultisampleErrorsTest::iterate()
9393 /* Shortcut for GL functionality. */
9394 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
9396 /* Get context setup. */
9397 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
9398 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
9400 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
9402 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
9407 /* Running tests. */
9409 bool is_error = false;
9413 /* Prepare objects. */
9416 /* Check that INVALID_OPERATION is generated by NamedRenderbufferStorage if
9417 renderbuffer is not the name of an existing renderbuffer object. */
9418 gl.namedRenderbufferStorageMultisample(m_rbo_invalid, 1, GL_RGBA8, 1, 1);
9420 is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedRenderbufferStorageMultisample",
9421 "renderbuffer is not the name of an existing renderbuffer object.");
9423 /* Check that INVALID_VALUE is generated by
9424 NamedRenderbufferStorageMultisample if samples is greater than
9425 the maximum number of SAMPLES reported for GL_RGBA8. */
9426 gl.namedRenderbufferStorageMultisample(m_rbo_valid, m_max_samples + 1, GL_RGBA8, 1, 1);
9428 is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedRenderbufferStorageMultisample",
9429 "samples is greater than MAX_SAMPLES.");
9431 /* Check that INVALID_VALUE is generated by NamedRenderbufferStorage if
9432 either of width or height is negative, or greater than the value of
9433 MAX_RENDERBUFFER_SIZE. */
9434 gl.namedRenderbufferStorageMultisample(m_rbo_valid, 1, GL_RGBA8, -1, 1);
9436 is_ok &= ExpectError(GL_INVALID_VALUE, "NamedRenderbufferStorageMultisample", "either of width is negative.");
9438 gl.namedRenderbufferStorageMultisample(m_rbo_valid, 1, GL_RGBA8, 1, -1);
9440 is_ok &= ExpectError(GL_INVALID_VALUE, "NamedRenderbufferStorageMultisample", "either of height is negative.");
9442 /* Check that INVALID_OPERATION is generated by
9443 NamedRenderbufferStorageMultisample if internalformat is a signed or
9444 unsigned integer format and samples is greater than the maximum number
9445 of samples reported for GL_RGB10_A2UI */
9446 gl.namedRenderbufferStorageMultisample(m_rbo_valid, m_max_integer_samples + 1, GL_RGB10_A2UI, 1, 1);
9448 is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedRenderbufferStorageMultisample",
9449 "internalformat is a signed or unsigned integer format and samples is greater than the "
9450 "value of MAX_INTEGER_SAMPLES.");
9452 /* Check that INVALID_ENUM is generated by NamedRenderbufferStorage if
9453 internalformat is not a color-renderable, depth-renderable, or
9454 stencil-renderable format. */
9455 gl.namedRenderbufferStorageMultisample(m_rbo_valid, 1, m_internalformat_invalid, 1, 1);
9457 is_ok &= ExpectError(GL_INVALID_ENUM, "NamedRenderbufferStorageMultisample",
9458 "internalformat is not a color-renderable, depth-renderable, or stencil-renderable format "
9459 "(it is COMPRESSED_RED).");
9470 /* Result's setup. */
9473 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
9479 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
9483 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
9490 /** Check Prepare test's GL objects.
9492 void StorageMultisampleErrorsTest::PrepareObjects()
9494 /* Shortcut for GL functionality. */
9495 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
9497 /* Valid objects. */
9498 gl.genRenderbuffers(1, &m_rbo_valid);
9499 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
9501 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo_valid);
9502 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
9505 gl.getInternalformativ(GL_RENDERBUFFER, GL_RGBA8, GL_SAMPLES, 1, &m_max_samples);
9506 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetInternalformativ has failed");
9508 gl.getInternalformativ(GL_RENDERBUFFER, GL_RGB10_A2UI, GL_SAMPLES, 1, &m_max_integer_samples);
9509 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetInternalformativ has failed");
9511 /* Invalid objects. */
9512 while (gl.isRenderbuffer(++m_rbo_invalid))
9516 /** Check if error is equal to the expected, log if not.
9518 * @param [in] expected_error Error to be expected.
9519 * @param [in] function Function name which is being tested (to be logged).
9520 * @param [in] conditions Conditions when the expected error shall occure (to be logged).
9522 * @return True if there is no error, false otherwise.
9524 bool StorageMultisampleErrorsTest::ExpectError(glw::GLenum expected_error, const glw::GLchar* function,
9525 const glw::GLchar* conditions)
9527 /* Shortcut for GL functionality. */
9528 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
9532 glw::GLenum error = GL_NO_ERROR;
9534 if (expected_error != (error = gl.getError()))
9536 m_context.getTestContext().getLog() << tcu::TestLog::Message << function << " was expected to generate "
9537 << glu::getErrorStr(expected_error) << ", but " << glu::getErrorStr(error)
9538 << " was observed instead when " << conditions << tcu::TestLog::EndMessage;
9543 /* Clean additional possible errors. */
9544 while (gl.getError())
9550 /** @brief Clean up GL state.
9552 void StorageMultisampleErrorsTest::Clean()
9554 /* Shortcut for GL functionality. */
9555 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
9557 /* Release GL objects. */
9560 gl.deleteRenderbuffers(1, &m_rbo_valid);
9564 /* COmpressed internal formats are not color renderable (OpenGL 4.5 Core PRofile SPecification Chapter 9.4 )*/
9565 m_internalformat_invalid = GL_COMPRESSED_RED;
9567 /* Set initial values - all test shall have the same environment. */
9571 m_max_integer_samples = 0;
9573 /* Errors clean up. */
9574 while (gl.getError())
9578 /******************************** Get Parameter Errors Test Implementation ********************************/
9580 /** @brief Parameter Errors Test constructor.
9582 * @param [in] context OpenGL context.
9584 GetParameterErrorsTest::GetParameterErrorsTest(deqp::Context& context)
9585 : deqp::TestCase(context, "renderbuffers_get_parameters_errors", "Get Parameter Errors Test")
9588 , m_parameter_invalid(0)
9590 /* Intentionally left blank. */
9593 /** @brief Iterate Parameter Errors Test cases.
9595 * @return Iteration result.
9597 tcu::TestNode::IterateResult GetParameterErrorsTest::iterate()
9599 /* Shortcut for GL functionality. */
9600 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
9602 /* Get context setup. */
9603 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
9604 bool is_arb_direct_state_access = m_context.getContextInfo().isExtensionSupported("GL_ARB_direct_state_access");
9606 if ((!is_at_least_gl_45) && (!is_arb_direct_state_access))
9608 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
9613 /* Running tests. */
9615 bool is_error = false;
9619 /* Prepare objects. */
9622 glw::GLint return_value_dummy_storage;
9624 /* Check that INVALID_OPERATION is generated by
9625 GetNamedRenderbufferParameteriv if renderbuffer is not the name of an
9626 existing renderbuffer object. */
9627 gl.getNamedRenderbufferParameteriv(m_rbo_invalid, GL_RENDERBUFFER_WIDTH, &return_value_dummy_storage);
9629 is_ok &= ExpectError(GL_INVALID_OPERATION, "GetNamedRenderbufferParameteriv",
9630 "renderbuffer is not the name of an existing renderbuffer object.");
9632 /* Check that INVALID_ENUM is generated by GetNamedRenderbufferParameteriv
9633 if parameter name is not one of the accepted parameter names described
9634 in specification. */
9635 gl.getNamedRenderbufferParameteriv(m_rbo_valid, m_parameter_invalid, &return_value_dummy_storage);
9637 is_ok &= ExpectError(GL_INVALID_ENUM, "GetNamedRenderbufferParameteriv",
9638 "parameter name is not one of the accepted parameter names described in specification.");
9649 /* Result's setup. */
9652 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
9658 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error");
9662 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
9669 /** Check Prepare test's GL objects.
9671 void GetParameterErrorsTest::PrepareObjects()
9673 /* Shortcut for GL functionality. */
9674 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
9676 /* Valid objects. */
9677 gl.genRenderbuffers(1, &m_rbo_valid);
9678 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers has failed");
9680 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo_valid);
9681 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
9683 /* Invalid parameter. */
9684 bool is_parameter = true;
9686 while (is_parameter)
9688 is_parameter = false;
9690 ++m_parameter_invalid;
9692 static const glw::GLenum valid_parameters[] = { GL_RENDERBUFFER_WIDTH, GL_RENDERBUFFER_HEIGHT,
9693 GL_RENDERBUFFER_INTERNAL_FORMAT, GL_RENDERBUFFER_SAMPLES,
9694 GL_RENDERBUFFER_RED_SIZE, GL_RENDERBUFFER_GREEN_SIZE,
9695 GL_RENDERBUFFER_BLUE_SIZE, GL_RENDERBUFFER_ALPHA_SIZE,
9696 GL_RENDERBUFFER_DEPTH_SIZE, GL_RENDERBUFFER_STENCIL_SIZE };
9698 static const glw::GLuint valid_parameters_count = sizeof(valid_parameters) / sizeof(valid_parameters[0]);
9700 for (glw::GLuint i = 0; i < valid_parameters_count; ++i)
9702 if (valid_parameters[i] == m_parameter_invalid)
9704 is_parameter = true;
9709 /* Invalid objects. */
9710 while (gl.isRenderbuffer(++m_rbo_invalid))
9714 /** Check if error is equal to the expected, log if not.
9716 * @param [in] expected_error Error to be expected.
9717 * @param [in] function Function name which is being tested (to be logged).
9718 * @param [in] conditions Conditions when the expected error shall occure (to be logged).
9720 * @return True if there is no error, false otherwise.
9722 bool GetParameterErrorsTest::ExpectError(glw::GLenum expected_error, const glw::GLchar* function,
9723 const glw::GLchar* conditions)
9725 /* Shortcut for GL functionality. */
9726 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
9730 glw::GLenum error = GL_NO_ERROR;
9732 if (expected_error != (error = gl.getError()))
9734 m_context.getTestContext().getLog() << tcu::TestLog::Message << function << " was expected to generate "
9735 << glu::getErrorStr(expected_error) << ", but " << glu::getErrorStr(error)
9736 << " was observed instead when " << conditions << tcu::TestLog::EndMessage;
9741 /* Clean additional possible errors. */
9742 while (gl.getError())
9748 /** @brief Clean up GL state.
9750 void GetParameterErrorsTest::Clean()
9752 /* Shortcut for GL functionality. */
9753 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
9755 /* Release GL objects. */
9758 gl.deleteRenderbuffers(1, &m_rbo_valid);
9762 /* Set initial values - all test shall have the same environment. */
9766 /* Errors clean up. */
9767 while (gl.getError())
9771 } // namespace Renderbuffers
9772 } // namespace DirectStateAccess
9773 } // namespace gl4cts