Commit 528ce3c1 by Geoff Lang

Merge some special cases of the default framebuffer into the Framebuffer class.

BUG=angle:841 Change-Id: Id4b5ac38926bc90fa015584d966aaef3a7101849 Reviewed-on: https://chromium-review.googlesource.com/232390Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 2212b3d5
...@@ -242,10 +242,16 @@ FramebufferAttachment *Framebuffer::getAttachment(GLenum attachment) const ...@@ -242,10 +242,16 @@ FramebufferAttachment *Framebuffer::getAttachment(GLenum attachment) const
{ {
switch (attachment) switch (attachment)
{ {
case GL_COLOR:
case GL_BACK:
return getColorbuffer(0);
case GL_DEPTH:
case GL_DEPTH_ATTACHMENT: case GL_DEPTH_ATTACHMENT:
return getDepthbuffer(); return getDepthbuffer();
case GL_STENCIL:
case GL_STENCIL_ATTACHMENT: case GL_STENCIL_ATTACHMENT:
return getStencilbuffer(); return getStencilbuffer();
case GL_DEPTH_STENCIL:
case GL_DEPTH_STENCIL_ATTACHMENT: case GL_DEPTH_STENCIL_ATTACHMENT:
return getDepthStencilBuffer(); return getDepthStencilBuffer();
default: default:
...@@ -303,6 +309,13 @@ bool Framebuffer::usingExtendedDrawBuffers() const ...@@ -303,6 +309,13 @@ bool Framebuffer::usingExtendedDrawBuffers() const
GLenum Framebuffer::completeness(const gl::Data &data) const GLenum Framebuffer::completeness(const gl::Data &data) const
{ {
// The default framebuffer *must* always be complete, though it may not be
// subject to the same rules as application FBOs. ie, it could have 0x0 size.
if (mId == 0)
{
return GL_FRAMEBUFFER_COMPLETE;
}
int width = 0; int width = 0;
int height = 0; int height = 0;
unsigned int colorbufferSize = 0; unsigned int colorbufferSize = 0;
...@@ -546,26 +559,6 @@ Error Framebuffer::invalidateSub(GLsizei numAttachments, const GLenum *attachmen ...@@ -546,26 +559,6 @@ Error Framebuffer::invalidateSub(GLsizei numAttachments, const GLenum *attachmen
return Error(GL_NO_ERROR); return Error(GL_NO_ERROR);
} }
DefaultFramebuffer::DefaultFramebuffer(rx::FramebufferImpl *impl, rx::DefaultAttachmentImpl *colorAttachment,
rx::DefaultAttachmentImpl *depthAttachment, rx::DefaultAttachmentImpl *stencilAttachment)
: Framebuffer(impl, 0)
{
ASSERT(colorAttachment);
mColorbuffers[0] = new DefaultAttachment(GL_BACK, colorAttachment);
if (depthAttachment)
{
mDepthbuffer = new DefaultAttachment(GL_DEPTH, depthAttachment);
}
if (stencilAttachment)
{
mStencilbuffer = new DefaultAttachment(GL_STENCIL, stencilAttachment);
}
mDrawBufferStates[0] = GL_BACK;
mReadBufferState = GL_BACK;
}
int Framebuffer::getSamples(const gl::Data &data) const int Framebuffer::getSamples(const gl::Data &data) const
{ {
if (completeness(data) == GL_FRAMEBUFFER_COMPLETE) if (completeness(data) == GL_FRAMEBUFFER_COMPLETE)
...@@ -639,17 +632,22 @@ void Framebuffer::setAttachment(GLenum attachment, FramebufferAttachment *attach ...@@ -639,17 +632,22 @@ void Framebuffer::setAttachment(GLenum attachment, FramebufferAttachment *attach
SafeDelete(mColorbuffers[colorAttachment]); SafeDelete(mColorbuffers[colorAttachment]);
mColorbuffers[colorAttachment] = attachmentObj; mColorbuffers[colorAttachment] = attachmentObj;
} }
else if (attachment == GL_DEPTH_ATTACHMENT) else if (attachment == GL_BACK)
{
SafeDelete(mColorbuffers[0]);
mColorbuffers[0] = attachmentObj;
}
else if (attachment == GL_DEPTH_ATTACHMENT || attachment == GL_DEPTH)
{ {
SafeDelete(mDepthbuffer); SafeDelete(mDepthbuffer);
mDepthbuffer = attachmentObj; mDepthbuffer = attachmentObj;
} }
else if (attachment == GL_STENCIL_ATTACHMENT) else if (attachment == GL_STENCIL_ATTACHMENT || attachment == GL_STENCIL)
{ {
SafeDelete(mStencilbuffer); SafeDelete(mStencilbuffer);
mStencilbuffer = attachmentObj; mStencilbuffer = attachmentObj;
} }
else if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) else if (attachment == GL_DEPTH_STENCIL_ATTACHMENT || attachment == GL_DEPTH_STENCIL)
{ {
SafeDelete(mDepthbuffer); SafeDelete(mDepthbuffer);
SafeDelete(mStencilbuffer); SafeDelete(mStencilbuffer);
...@@ -682,30 +680,24 @@ void Framebuffer::setAttachment(GLenum attachment, FramebufferAttachment *attach ...@@ -682,30 +680,24 @@ void Framebuffer::setAttachment(GLenum attachment, FramebufferAttachment *attach
} }
} }
GLenum DefaultFramebuffer::completeness(const gl::Data &) const DefaultFramebuffer::DefaultFramebuffer(rx::FramebufferImpl *impl, rx::DefaultAttachmentImpl *colorAttachment,
rx::DefaultAttachmentImpl *depthAttachment, rx::DefaultAttachmentImpl *stencilAttachment)
: Framebuffer(impl, 0)
{ {
// The default framebuffer *must* always be complete, though it may not be ASSERT(colorAttachment);
// subject to the same rules as application FBOs. ie, it could have 0x0 size. setAttachment(GL_BACK, new DefaultAttachment(GL_BACK, colorAttachment));
return GL_FRAMEBUFFER_COMPLETE;
}
FramebufferAttachment *DefaultFramebuffer::getAttachment(GLenum attachment) const if (depthAttachment)
{
switch (attachment)
{ {
case GL_COLOR: setAttachment(GL_DEPTH, new DefaultAttachment(GL_DEPTH, depthAttachment));
case GL_BACK: }
return getColorbuffer(0); if (stencilAttachment)
case GL_DEPTH: {
return getDepthbuffer(); setAttachment(GL_STENCIL, new DefaultAttachment(GL_STENCIL, stencilAttachment));
case GL_STENCIL:
return getStencilbuffer();
case GL_DEPTH_STENCIL:
return getDepthStencilBuffer();
default:
UNREACHABLE();
return NULL;
} }
mDrawBufferStates[0] = GL_BACK;
mReadBufferState = GL_BACK;
} }
} }
...@@ -67,7 +67,7 @@ class ANGLE_EXPORT Framebuffer ...@@ -67,7 +67,7 @@ class ANGLE_EXPORT Framebuffer
GLenum getReadColorbufferType() const; GLenum getReadColorbufferType() const;
FramebufferAttachment *getFirstColorbuffer() const; FramebufferAttachment *getFirstColorbuffer() const;
virtual FramebufferAttachment *getAttachment(GLenum attachment) const; FramebufferAttachment *getAttachment(GLenum attachment) const;
GLenum getDrawBufferState(unsigned int colorAttachment) const; GLenum getDrawBufferState(unsigned int colorAttachment) const;
void setDrawBufferState(unsigned int colorAttachment, GLenum drawBuffer); void setDrawBufferState(unsigned int colorAttachment, GLenum drawBuffer);
...@@ -78,7 +78,7 @@ class ANGLE_EXPORT Framebuffer ...@@ -78,7 +78,7 @@ class ANGLE_EXPORT Framebuffer
int getSamples(const gl::Data &data) const; int getSamples(const gl::Data &data) const;
bool usingExtendedDrawBuffers() const; bool usingExtendedDrawBuffers() const;
virtual GLenum completeness(const gl::Data &data) const; GLenum completeness(const gl::Data &data) const;
bool hasValidDepthStencil() const; bool hasValidDepthStencil() const;
Error invalidate(const Caps &caps, GLsizei numAttachments, const GLenum *attachments); Error invalidate(const Caps &caps, GLsizei numAttachments, const GLenum *attachments);
...@@ -90,6 +90,8 @@ class ANGLE_EXPORT Framebuffer ...@@ -90,6 +90,8 @@ class ANGLE_EXPORT Framebuffer
ColorbufferInfo getColorbuffersForRender(const rx::Workarounds &workarounds) const; ColorbufferInfo getColorbuffersForRender(const rx::Workarounds &workarounds) const;
protected: protected:
void setAttachment(GLenum attachment, FramebufferAttachment *attachmentObj);
rx::FramebufferImpl *mImpl; rx::FramebufferImpl *mImpl;
GLuint mId; GLuint mId;
...@@ -102,8 +104,6 @@ class ANGLE_EXPORT Framebuffer ...@@ -102,8 +104,6 @@ class ANGLE_EXPORT Framebuffer
private: private:
DISALLOW_COPY_AND_ASSIGN(Framebuffer); DISALLOW_COPY_AND_ASSIGN(Framebuffer);
void setAttachment(GLenum attachment, FramebufferAttachment *attachmentObj);
}; };
class DefaultFramebuffer : public Framebuffer class DefaultFramebuffer : public Framebuffer
...@@ -112,9 +112,6 @@ class DefaultFramebuffer : public Framebuffer ...@@ -112,9 +112,6 @@ class DefaultFramebuffer : public Framebuffer
DefaultFramebuffer(rx::FramebufferImpl *impl, rx::DefaultAttachmentImpl *colorAttachment, DefaultFramebuffer(rx::FramebufferImpl *impl, rx::DefaultAttachmentImpl *colorAttachment,
rx::DefaultAttachmentImpl *depthAttachment, rx::DefaultAttachmentImpl *stencilAttachment); rx::DefaultAttachmentImpl *depthAttachment, rx::DefaultAttachmentImpl *stencilAttachment);
GLenum completeness(const gl::Data &data) const override;
virtual FramebufferAttachment *getAttachment(GLenum attachment) const;
private: private:
DISALLOW_COPY_AND_ASSIGN(DefaultFramebuffer); DISALLOW_COPY_AND_ASSIGN(DefaultFramebuffer);
}; };
......
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