Fixes FBO completeness check

TRAC #12571 Automatically passes default framebuffer, and fails framebuffers which have no color attachments. Signed-off-by: Andrew Lewycky Signed-off-by: Daniel Koch Author: Shannon Woods git-svn-id: https://angleproject.googlecode.com/svn/trunk@361 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent da13f3e9
......@@ -236,7 +236,7 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface)
IDirect3DSurface9 *defaultRenderTarget = surface->getRenderTarget();
IDirect3DSurface9 *depthStencil = surface->getDepthStencil();
Framebuffer *framebufferZero = new Framebuffer();
Framebuffer *framebufferZero = new Framebuffer(0);
Colorbuffer *colorbufferZero = new Colorbuffer(defaultRenderTarget);
DepthStencilbuffer *depthStencilbufferZero = new DepthStencilbuffer(depthStencil);
......@@ -874,7 +874,7 @@ void Context::bindFramebuffer(GLuint framebuffer)
{
if (!getFramebuffer(framebuffer))
{
mFramebufferMap[framebuffer] = new Framebuffer();
mFramebufferMap[framebuffer] = new Framebuffer(framebuffer);
}
mState.framebuffer = framebuffer;
......
......@@ -16,7 +16,7 @@
namespace gl
{
Framebuffer::Framebuffer()
Framebuffer::Framebuffer(GLuint handle) : mHandle(handle)
{
mColorbufferType = GL_NONE;
mColorbufferHandle = 0;
......@@ -225,84 +225,91 @@ GLenum Framebuffer::completeness()
int width = 0;
int height = 0;
if (mColorbufferType != GL_NONE)
if (mHandle != 0)
{
Colorbuffer *colorbuffer = getColorbuffer();
if (!colorbuffer)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
if (colorbuffer->getWidth() == 0 || colorbuffer->getHeight() == 0)
if (mColorbufferType != GL_NONE)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
width = colorbuffer->getWidth();
height = colorbuffer->getHeight();
}
Colorbuffer *colorbuffer = getColorbuffer();
DepthStencilbuffer *depthbuffer = NULL;
DepthStencilbuffer *stencilbuffer = NULL;
if (mDepthbufferType != GL_NONE)
{
depthbuffer = context->getDepthbuffer(mDepthbufferHandle);
if (!depthbuffer)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
if (!colorbuffer)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
if (depthbuffer->getWidth() == 0 || depthbuffer->getHeight() == 0)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
if (colorbuffer->getWidth() == 0 || colorbuffer->getHeight() == 0)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
if (width == 0)
{
width = depthbuffer->getWidth();
height = depthbuffer->getHeight();
width = colorbuffer->getWidth();
height = colorbuffer->getHeight();
}
else if (width != depthbuffer->getWidth() || height != depthbuffer->getHeight())
else
{
return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
}
}
if (mStencilbufferType != GL_NONE)
{
stencilbuffer = context->getStencilbuffer(mStencilbufferHandle);
DepthStencilbuffer *depthbuffer = NULL;
DepthStencilbuffer *stencilbuffer = NULL;
if (!stencilbuffer)
if (mDepthbufferType != GL_NONE)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
depthbuffer = context->getDepthbuffer(mDepthbufferHandle);
if (!depthbuffer)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
if (depthbuffer->getWidth() == 0 || depthbuffer->getHeight() == 0)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
if (width == 0)
{
width = depthbuffer->getWidth();
height = depthbuffer->getHeight();
}
else if (width != depthbuffer->getWidth() || height != depthbuffer->getHeight())
{
return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
}
}
if (stencilbuffer->getWidth() == 0 || stencilbuffer->getHeight() == 0)
if (mStencilbufferType != GL_NONE)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
stencilbuffer = context->getStencilbuffer(mStencilbufferHandle);
if (!stencilbuffer)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
if (stencilbuffer->getWidth() == 0 || stencilbuffer->getHeight() == 0)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
if (width == 0)
{
width = stencilbuffer->getWidth();
height = stencilbuffer->getHeight();
}
else if (width != stencilbuffer->getWidth() || height != stencilbuffer->getHeight())
{
return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
}
}
if (width == 0)
{
width = stencilbuffer->getWidth();
height = stencilbuffer->getHeight();
}
else if (width != stencilbuffer->getWidth() || height != stencilbuffer->getHeight())
{
return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
}
}
if (mDepthbufferType == GL_RENDERBUFFER && mStencilbufferType == GL_RENDERBUFFER)
{
if (depthbuffer->getFormat() != GL_DEPTH24_STENCIL8_OES ||
stencilbuffer->getFormat() != GL_DEPTH24_STENCIL8_OES ||
depthbuffer->getSerial() != stencilbuffer->getSerial())
if (mDepthbufferType == GL_RENDERBUFFER && mStencilbufferType == GL_RENDERBUFFER)
{
return GL_FRAMEBUFFER_UNSUPPORTED;
if (depthbuffer->getFormat() != GL_DEPTH24_STENCIL8_OES ||
stencilbuffer->getFormat() != GL_DEPTH24_STENCIL8_OES ||
depthbuffer->getSerial() != stencilbuffer->getSerial())
{
return GL_FRAMEBUFFER_UNSUPPORTED;
}
}
}
......
......@@ -26,7 +26,7 @@ class DepthStencilbuffer;
class Framebuffer
{
public:
Framebuffer();
explicit Framebuffer(GLuint handle);
~Framebuffer();
......@@ -68,6 +68,8 @@ class Framebuffer
GLuint mStencilbufferHandle;
GLenum mStencilbufferType;
GLuint mHandle;
};
}
......
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