Implemented glInvalidateFramebuffer and glInvalidateSubFramebuffer.

TRAC #23133 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods Author: Geoff Lang git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2335 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 1654faf4
...@@ -3257,6 +3257,79 @@ void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1 ...@@ -3257,6 +3257,79 @@ void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1
} }
} }
void Context::invalidateFrameBuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments,
GLint x, GLint y, GLsizei width, GLsizei height)
{
Framebuffer *frameBuffer = NULL;
switch (target)
{
case GL_FRAMEBUFFER:
case GL_DRAW_FRAMEBUFFER:
frameBuffer = getDrawFramebuffer();
break;
case GL_READ_FRAMEBUFFER:
frameBuffer = getReadFramebuffer();
break;
default:
UNREACHABLE();
}
if (frameBuffer && frameBuffer->completeness() == GL_FRAMEBUFFER_COMPLETE)
{
for (int i = 0; i < numAttachments; ++i)
{
rx::RenderTarget *renderTarget = NULL;
if (attachments[i] >= GL_COLOR_ATTACHMENT0 && attachments[i] <= GL_COLOR_ATTACHMENT15)
{
gl::Renderbuffer *renderBuffer = frameBuffer->getColorbuffer(attachments[i] - GL_COLOR_ATTACHMENT0);
if (renderBuffer)
{
renderTarget = renderBuffer->getRenderTarget();
}
}
else if (attachments[i] == GL_COLOR)
{
gl::Renderbuffer *renderBuffer = frameBuffer->getColorbuffer(0);
if (renderBuffer)
{
renderTarget = renderBuffer->getRenderTarget();
}
}
else
{
gl::Renderbuffer *renderBuffer = NULL;
switch (attachments[i])
{
case GL_DEPTH_ATTACHMENT:
case GL_DEPTH:
renderBuffer = frameBuffer->getDepthbuffer();
break;
case GL_STENCIL_ATTACHMENT:
case GL_STENCIL:
renderBuffer = frameBuffer->getStencilbuffer();
break;
case GL_DEPTH_STENCIL_ATTACHMENT:
renderBuffer = frameBuffer->getDepthOrStencilbuffer();
break;
default:
UNREACHABLE();
}
if (renderBuffer)
{
renderTarget = renderBuffer->getDepthStencil();
}
}
if (renderTarget)
{
renderTarget->invalidate(x, y, width, height);
}
}
}
}
} }
extern "C" extern "C"
......
...@@ -463,6 +463,9 @@ class Context ...@@ -463,6 +463,9 @@ class Context
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask); GLbitfield mask);
void invalidateFrameBuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments,
GLint x, GLint y, GLsizei width, GLsizei height);
private: private:
DISALLOW_COPY_AND_ASSIGN(Context); DISALLOW_COPY_AND_ASSIGN(Context);
......
...@@ -629,6 +629,67 @@ bool validReadFormatType(GLenum format, GLenum type) ...@@ -629,6 +629,67 @@ bool validReadFormatType(GLenum format, GLenum type)
return true; return true;
} }
bool validateInvalidateFramebufferParameters(gl::Context *context, GLenum target, GLsizei numAttachments,
const GLenum* attachments)
{
bool defaultFramebuffer = false;
switch (target)
{
case GL_DRAW_FRAMEBUFFER:
case GL_FRAMEBUFFER:
defaultFramebuffer = context->getDrawFramebufferHandle() == 0;
break;
case GL_READ_FRAMEBUFFER:
defaultFramebuffer = context->getReadFramebufferHandle() == 0;
break;
default:
return gl::error(GL_INVALID_ENUM, false);
}
for (int i = 0; i < numAttachments; ++i)
{
if (attachments[i] >= GL_COLOR_ATTACHMENT0 && attachments[i] <= GL_COLOR_ATTACHMENT15)
{
if (defaultFramebuffer)
{
return gl::error(GL_INVALID_ENUM, false);
}
if (attachments[i] >= GL_COLOR_ATTACHMENT0 + context->getMaximumRenderTargets())
{
return gl::error(GL_INVALID_OPERATION, false);
}
}
else
{
switch (attachments[i])
{
case GL_DEPTH_ATTACHMENT:
case GL_STENCIL_ATTACHMENT:
case GL_DEPTH_STENCIL_ATTACHMENT:
if (defaultFramebuffer)
{
return gl::error(GL_INVALID_ENUM, false);
}
break;
case GL_COLOR:
case GL_DEPTH:
case GL_STENCIL:
if (!defaultFramebuffer)
{
return gl::error(GL_INVALID_ENUM, false);
}
break;
default:
return gl::error(GL_INVALID_ENUM, false);
}
}
}
return true;
}
extern "C" extern "C"
{ {
...@@ -10700,9 +10761,15 @@ void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, co ...@@ -10700,9 +10761,15 @@ void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, co
{ {
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
} }
}
UNIMPLEMENTED(); if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
{
return;
}
int maxDimension = context->getMaximumRenderbufferDimension();
context->invalidateFrameBuffer(target, numAttachments, attachments, 0, 0, maxDimension, maxDimension);
}
} }
catch(std::bad_alloc&) catch(std::bad_alloc&)
{ {
...@@ -10726,9 +10793,14 @@ void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, ...@@ -10726,9 +10793,14 @@ void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments,
{ {
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
} }
}
UNIMPLEMENTED(); if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
{
return;
}
context->invalidateFrameBuffer(target, numAttachments, attachments, x, y, width, height);
}
} }
catch(std::bad_alloc&) catch(std::bad_alloc&)
{ {
......
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