Check for depth/stencil buffer in default FBO
authorJuan A. Suarez Romero <jasuarez@igalia.com>
Mon, 15 Jan 2018 11:10:46 +0000 (11:10 +0000)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Wed, 14 Feb 2018 08:28:13 +0000 (03:28 -0500)
The affected tests invoke gl.getNamedFramebufferAttachmentParameteriv()
with GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE to get the depth bits used in
the default FBO. And something similar is done for the stencil bits.

But wrongly it assumes that if the FBO does not have an associated depth
or stencil buffer, it would return 0. Rather, this function returns an
error if it is invoked in a FBO without a depth/stencil buffer attached.

So better check first if the default FBO has a depth/stencil buffer
attached, and if so then invoke the above functions to get the
depth/stencil bits.

Components: OpenGL

VK-GL-CTS issue: 969

Affects:
KHR-*.internalformat.renderbuffer.*

Change-Id: I74d28d5d089790fed4dd2728cb5143e7c03d7442

external/openglcts/modules/common/glcInternalformatTests.cpp

index 74b8ea2..f5deb48 100644 (file)
@@ -979,8 +979,8 @@ tcu::TestNode::IterateResult RenderbufferCase::iterate(void)
        testSurface[0].setSize(m_renderWidth, m_renderHeight);
        testSurface[1].setSize(m_renderWidth, m_renderHeight);
 
-       GLint defaultFramebufferDepthBits   = 16;
-       GLint defaultFramebufferStencilBits = 8;
+       GLint defaultFramebufferDepthBits   = 0;
+       GLint defaultFramebufferStencilBits = 0;
        if (glu::isContextTypeES(m_context.getRenderContext().getType()))
        {
                gl.getIntegerv(GL_DEPTH_BITS, &defaultFramebufferDepthBits);
@@ -988,10 +988,21 @@ tcu::TestNode::IterateResult RenderbufferCase::iterate(void)
        }
        else
        {
-               gl.getNamedFramebufferAttachmentParameteriv(0, GL_DEPTH, GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE,
-                                                                                                       &defaultFramebufferDepthBits);
-               gl.getNamedFramebufferAttachmentParameteriv(0, GL_STENCIL, GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE,
-                                                                                                       &defaultFramebufferStencilBits);
+               GLint hasDepthBuffer    = 0;
+               GLint hasStencilBuffer  = 0;
+
+               gl.getNamedFramebufferAttachmentParameteriv(0, GL_DEPTH, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
+                                                                                                       &hasDepthBuffer);
+               gl.getNamedFramebufferAttachmentParameteriv(0, GL_STENCIL, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
+                                                                                                       &hasStencilBuffer);
+
+               if (hasDepthBuffer != GL_NONE)
+                       gl.getNamedFramebufferAttachmentParameteriv(0, GL_DEPTH, GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE,
+                                                                                                               &defaultFramebufferDepthBits);
+
+               if (hasStencilBuffer != GL_NONE)
+                       gl.getNamedFramebufferAttachmentParameteriv(0, GL_STENCIL, GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE,
+                                                                                                               &defaultFramebufferStencilBits);
        }
 
        // Create program that will render texture to screen