Commit 55ba29c5 by Geoff Lang

Implement the DEPTH_STENCIL attachment point for FBOs.

Trac #23469 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods Author: Geoff Lang
parent 1c3192ef
#define MAJOR_VERSION 2
#define MINOR_VERSION 0
#define BUILD_VERSION 0
#define BUILD_REVISION 1996
#define BUILD_REVISION 1997
#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)
......
......@@ -90,6 +90,24 @@ void Framebuffer::setStencilbuffer(GLenum type, GLuint stencilbuffer)
mStencilbufferPointer.set(lookupRenderbuffer(type, stencilbuffer));
}
void Framebuffer::setDepthStencilBuffer(GLenum type, GLuint depthStencilBuffer)
{
Renderbuffer *renderBuffer = lookupRenderbuffer(type, depthStencilBuffer);
if (renderBuffer && renderBuffer->getDepthSize() > 0 && renderBuffer->getStencilSize() > 0)
{
mDepthbufferType = type;
mDepthbufferPointer.set(renderBuffer);
mStencilbufferType = type;
mStencilbufferPointer.set(renderBuffer);
}
else
{
mDepthbufferType = GL_NONE;
mStencilbufferType = GL_NONE;
}
}
void Framebuffer::detachTexture(GLuint texture)
{
for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
......@@ -245,6 +263,11 @@ GLenum Framebuffer::getStencilbufferType() const
return mStencilbufferType;
}
GLenum Framebuffer::getDepthStencilbufferType() const
{
return (mDepthbufferPointer.id() == mStencilbufferPointer.id()) ? mDepthbufferType : GL_NONE;
}
GLuint Framebuffer::getColorbufferHandle(unsigned int colorAttachment) const
{
ASSERT(colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS);
......@@ -261,6 +284,11 @@ GLuint Framebuffer::getStencilbufferHandle() const
return mStencilbufferPointer.id();
}
GLenum Framebuffer::getDepthStencilbufferHandle() const
{
return (mDepthbufferPointer.id() == mStencilbufferPointer.id()) ? mDepthbufferPointer.id() : 0;
}
GLenum Framebuffer::getDrawBufferState(unsigned int colorAttachment) const
{
return mDrawBufferStates[colorAttachment];
......
......@@ -37,6 +37,7 @@ class Framebuffer
void setColorbuffer(unsigned int colorAttachment, GLenum type, GLuint colorbuffer);
void setDepthbuffer(GLenum type, GLuint depthbuffer);
void setStencilbuffer(GLenum type, GLuint stencilbuffer);
void setDepthStencilBuffer(GLenum type, GLuint depthStencilBuffer);
void detachTexture(GLuint texture);
void detachRenderbuffer(GLuint renderbuffer);
......@@ -56,10 +57,12 @@ class Framebuffer
GLenum getColorbufferType(unsigned int colorAttachment) const;
GLenum getDepthbufferType() const;
GLenum getStencilbufferType() const;
GLenum getDepthStencilbufferType() const;
GLuint getColorbufferHandle(unsigned int colorAttachment) const;
GLuint getDepthbufferHandle() const;
GLuint getStencilbufferHandle() const;
GLenum getDepthStencilbufferHandle() const;
GLenum getDrawBufferState(unsigned int colorAttachment) const;
void setDrawBufferState(unsigned int colorAttachment, GLenum drawBuffer);
......
......@@ -4170,6 +4170,12 @@ void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum t
case GL_DEPTH_ATTACHMENT:
case GL_STENCIL_ATTACHMENT:
break;
case GL_DEPTH_STENCIL_ATTACHMENT:
if (context->getClientVersion() < 3)
{
return gl::error(GL_INVALID_ENUM);
}
break;
default:
return gl::error(GL_INVALID_ENUM);
}
......@@ -4266,8 +4272,9 @@ void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum t
{
switch (attachment)
{
case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture); break;
case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture); break;
case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture); break;
case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture); break;
case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer->setDepthStencilBuffer(textarget, texture); break;
}
}
}
......@@ -5065,6 +5072,17 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac
attachmentType = framebuffer->getStencilbufferType();
attachmentHandle = framebuffer->getStencilbufferHandle();
break;
case GL_DEPTH_STENCIL_ATTACHMENT:
if (context->getClientVersion() < 3)
{
return gl::error(GL_INVALID_ENUM);
}
if (framebuffer->getDepthbufferHandle() != framebuffer->getStencilbufferHandle())
{
return gl::error(GL_INVALID_OPERATION);
}
attachmentType = framebuffer->getDepthStencilbufferType();
attachmentHandle = framebuffer->getDepthStencilbufferHandle();
default: return gl::error(GL_INVALID_ENUM);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment