Commit 0b169304 by Alexis Hetu Committed by Alexis Hétu

Default framebuffer type fix

In OpenGL ES 3.0, the default framebuffer should use GL_FRAMEBUFFER_DEFAULT instead of GL_RENDERBUFFER for default buffer. I also added the Framebuffer::IsRenderbuffer() utility function to make the transition easier. Change-Id: I041e610738a4a656555ae7fa7ba41ba68b1fe9ea Reviewed-on: https://swiftshader-review.googlesource.com/4763Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 9bdbaa0c
......@@ -4076,10 +4076,10 @@ void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1
if(mask & GL_COLOR_BUFFER_BIT)
{
const bool validReadType = readFramebuffer->getColorbufferType(getReadFramebufferColorIndex()) == GL_TEXTURE_2D ||
readFramebuffer->getColorbufferType(getReadFramebufferColorIndex()) == GL_RENDERBUFFER;
const bool validDrawType = drawFramebuffer->getColorbufferType(0) == GL_TEXTURE_2D ||
drawFramebuffer->getColorbufferType(0) == GL_RENDERBUFFER;
GLenum readColorbufferType = readFramebuffer->getColorbufferType(getReadFramebufferColorIndex());
GLenum drawColorbufferType = drawFramebuffer->getColorbufferType(0);
const bool validReadType = readColorbufferType == GL_TEXTURE_2D || Framebuffer::IsRenderbuffer(readColorbufferType);
const bool validDrawType = drawColorbufferType == GL_TEXTURE_2D || Framebuffer::IsRenderbuffer(drawColorbufferType);
if(!validReadType || !validDrawType)
{
return error(GL_INVALID_OPERATION);
......
......@@ -22,6 +22,11 @@
namespace es2
{
bool Framebuffer::IsRenderbuffer(GLenum type)
{
return type == GL_RENDERBUFFER || type == GL_FRAMEBUFFER_DEFAULT;
}
Framebuffer::Framebuffer()
{
for(int i = 0; i < IMPLEMENTATION_MAX_COLOR_ATTACHMENTS; ++i)
......@@ -58,7 +63,7 @@ Renderbuffer *Framebuffer::lookupRenderbuffer(GLenum type, GLuint handle, GLint
{
buffer = NULL;
}
else if(type == GL_RENDERBUFFER)
else if(IsRenderbuffer(type))
{
buffer = context->getRenderbuffer(handle);
}
......@@ -142,20 +147,20 @@ void Framebuffer::detachRenderbuffer(GLuint renderbuffer)
{
for(int i = 0; i < IMPLEMENTATION_MAX_COLOR_ATTACHMENTS; ++i)
{
if(mColorbufferPointer[i].name() == renderbuffer && mColorbufferType[i] == GL_RENDERBUFFER)
if(mColorbufferPointer[i].name() == renderbuffer && IsRenderbuffer(mColorbufferType[i]))
{
mColorbufferType[i] = GL_NONE;
mColorbufferPointer[i] = NULL;
}
}
if(mDepthbufferPointer.name() == renderbuffer && mDepthbufferType == GL_RENDERBUFFER)
if(mDepthbufferPointer.name() == renderbuffer && IsRenderbuffer(mDepthbufferType))
{
mDepthbufferType = GL_NONE;
mDepthbufferPointer = NULL;
}
if(mStencilbufferPointer.name() == renderbuffer && mStencilbufferType == GL_RENDERBUFFER)
if(mStencilbufferPointer.name() == renderbuffer && IsRenderbuffer(mStencilbufferType))
{
mStencilbufferType = GL_NONE;
mStencilbufferPointer = NULL;
......@@ -314,7 +319,7 @@ GLenum Framebuffer::completeness(int &width, int &height, int &samples)
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
if(mColorbufferType[i] == GL_RENDERBUFFER)
if(IsRenderbuffer(mColorbufferType[i]))
{
if(!es2::IsColorRenderable(colorbuffer->getFormat(), egl::getClientVersion()))
{
......@@ -376,7 +381,7 @@ GLenum Framebuffer::completeness(int &width, int &height, int &samples)
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
if(mDepthbufferType == GL_RENDERBUFFER)
if(IsRenderbuffer(mDepthbufferType))
{
if(!es2::IsDepthRenderable(depthbuffer->getFormat()))
{
......@@ -426,7 +431,7 @@ GLenum Framebuffer::completeness(int &width, int &height, int &samples)
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
if(mStencilbufferType == GL_RENDERBUFFER)
if(IsRenderbuffer(mStencilbufferType))
{
if(!es2::IsStencilRenderable(stencilbuffer->getFormat()))
{
......@@ -604,8 +609,9 @@ GLenum Framebuffer::getImplementationColorReadType()
DefaultFramebuffer::DefaultFramebuffer(Colorbuffer *colorbuffer, DepthStencilbuffer *depthStencil)
{
GLenum defaultRenderbufferType = egl::getClientVersion() < 3 ? GL_RENDERBUFFER : GL_FRAMEBUFFER_DEFAULT;
mColorbufferPointer[0] = new Renderbuffer(0, colorbuffer);
mColorbufferType[0] = GL_RENDERBUFFER;
mColorbufferType[0] = defaultRenderbufferType;
for(int i = 1; i < IMPLEMENTATION_MAX_COLOR_ATTACHMENTS; ++i)
{
......@@ -617,8 +623,8 @@ DefaultFramebuffer::DefaultFramebuffer(Colorbuffer *colorbuffer, DepthStencilbuf
mDepthbufferPointer = depthStencilRenderbuffer;
mStencilbufferPointer = depthStencilRenderbuffer;
mDepthbufferType = (depthStencilRenderbuffer->getDepthSize() != 0) ? GL_RENDERBUFFER : GL_NONE;
mStencilbufferType = (depthStencilRenderbuffer->getStencilSize() != 0) ? GL_RENDERBUFFER : GL_NONE;
mDepthbufferType = (depthStencilRenderbuffer->getDepthSize() != 0) ? defaultRenderbufferType : GL_NONE;
mStencilbufferType = (depthStencilRenderbuffer->getStencilSize() != 0) ? defaultRenderbufferType : GL_NONE;
}
}
......@@ -78,6 +78,8 @@ public:
virtual bool isDefaultFramebuffer() const { return false; }
static bool IsRenderbuffer(GLenum type);
protected:
GLenum mColorbufferType[MAX_COLOR_ATTACHMENTS];
gl::BindingPointer<Renderbuffer> mColorbufferPointer[MAX_COLOR_ATTACHMENTS];
......
......@@ -2990,7 +2990,7 @@ void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenu
}
GLenum attachmentObjectType = GL_NONE; // Type category
if(attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
if(attachmentType == GL_NONE || Framebuffer::IsRenderbuffer(attachmentType))
{
attachmentObjectType = attachmentType;
}
......@@ -3008,7 +3008,7 @@ void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenu
*params = attachmentObjectType;
break;
case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
if(attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE)
if(Framebuffer::IsRenderbuffer(attachmentObjectType) || attachmentObjectType == GL_TEXTURE)
{
*params = attachmentHandle;
}
......
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