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) ...@@ -236,7 +236,7 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface)
IDirect3DSurface9 *defaultRenderTarget = surface->getRenderTarget(); IDirect3DSurface9 *defaultRenderTarget = surface->getRenderTarget();
IDirect3DSurface9 *depthStencil = surface->getDepthStencil(); IDirect3DSurface9 *depthStencil = surface->getDepthStencil();
Framebuffer *framebufferZero = new Framebuffer(); Framebuffer *framebufferZero = new Framebuffer(0);
Colorbuffer *colorbufferZero = new Colorbuffer(defaultRenderTarget); Colorbuffer *colorbufferZero = new Colorbuffer(defaultRenderTarget);
DepthStencilbuffer *depthStencilbufferZero = new DepthStencilbuffer(depthStencil); DepthStencilbuffer *depthStencilbufferZero = new DepthStencilbuffer(depthStencil);
...@@ -874,7 +874,7 @@ void Context::bindFramebuffer(GLuint framebuffer) ...@@ -874,7 +874,7 @@ void Context::bindFramebuffer(GLuint framebuffer)
{ {
if (!getFramebuffer(framebuffer)) if (!getFramebuffer(framebuffer))
{ {
mFramebufferMap[framebuffer] = new Framebuffer(); mFramebufferMap[framebuffer] = new Framebuffer(framebuffer);
} }
mState.framebuffer = framebuffer; mState.framebuffer = framebuffer;
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
namespace gl namespace gl
{ {
Framebuffer::Framebuffer() Framebuffer::Framebuffer(GLuint handle) : mHandle(handle)
{ {
mColorbufferType = GL_NONE; mColorbufferType = GL_NONE;
mColorbufferHandle = 0; mColorbufferHandle = 0;
...@@ -225,84 +225,91 @@ GLenum Framebuffer::completeness() ...@@ -225,84 +225,91 @@ GLenum Framebuffer::completeness()
int width = 0; int width = 0;
int height = 0; int height = 0;
if (mColorbufferType != GL_NONE) if (mHandle != 0)
{ {
Colorbuffer *colorbuffer = getColorbuffer(); if (mColorbufferType != GL_NONE)
if (!colorbuffer)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
if (colorbuffer->getWidth() == 0 || colorbuffer->getHeight() == 0)
{ {
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; Colorbuffer *colorbuffer = getColorbuffer();
}
width = colorbuffer->getWidth();
height = colorbuffer->getHeight();
}
DepthStencilbuffer *depthbuffer = NULL; if (!colorbuffer)
DepthStencilbuffer *stencilbuffer = NULL; {
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
if (mDepthbufferType != GL_NONE) }
{
depthbuffer = context->getDepthbuffer(mDepthbufferHandle);
if (!depthbuffer)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
if (depthbuffer->getWidth() == 0 || depthbuffer->getHeight() == 0) if (colorbuffer->getWidth() == 0 || colorbuffer->getHeight() == 0)
{ {
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
} }
if (width == 0) width = colorbuffer->getWidth();
{ height = colorbuffer->getHeight();
width = depthbuffer->getWidth();
height = depthbuffer->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) DepthStencilbuffer *depthbuffer = NULL;
{ DepthStencilbuffer *stencilbuffer = NULL;
stencilbuffer = context->getStencilbuffer(mStencilbufferHandle);
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) if (mDepthbufferType == GL_RENDERBUFFER && mStencilbufferType == GL_RENDERBUFFER)
{
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())
{ {
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; ...@@ -26,7 +26,7 @@ class DepthStencilbuffer;
class Framebuffer class Framebuffer
{ {
public: public:
Framebuffer(); explicit Framebuffer(GLuint handle);
~Framebuffer(); ~Framebuffer();
...@@ -68,6 +68,8 @@ class Framebuffer ...@@ -68,6 +68,8 @@ class Framebuffer
GLuint mStencilbufferHandle; GLuint mStencilbufferHandle;
GLenum mStencilbufferType; 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