Implement multiple render target support in glBlitFramebufferANGLE.

TRAC #22679 Signed-off-by: Geoff Lang Signed-off-by: Shannon Woods Author: Jamie Madill git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2095 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 1d64b626
...@@ -2655,7 +2655,6 @@ void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1 ...@@ -2655,7 +2655,6 @@ void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask) GLbitfield mask)
{ {
// TODO: mrt support for blit
Framebuffer *readFramebuffer = getReadFramebuffer(); Framebuffer *readFramebuffer = getReadFramebuffer();
Framebuffer *drawFramebuffer = getDrawFramebuffer(); Framebuffer *drawFramebuffer = getDrawFramebuffer();
...@@ -2670,10 +2669,19 @@ void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1 ...@@ -2670,10 +2669,19 @@ void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
} }
int readBufferWidth = readFramebuffer->getColorbuffer(0)->getWidth(); Renderbuffer *readColorBuffer = readFramebuffer->getReadColorbuffer();
int readBufferHeight = readFramebuffer->getColorbuffer(0)->getHeight(); Renderbuffer *drawColorBuffer = drawFramebuffer->getFirstColorBuffer();
int drawBufferWidth = drawFramebuffer->getColorbuffer(0)->getWidth();
int drawBufferHeight = drawFramebuffer->getColorbuffer(0)->getHeight(); if (drawColorBuffer == NULL)
{
ERR("Draw buffers formats don't match, which is not supported in this implementation of BlitFramebufferANGLE");
return gl::error(GL_INVALID_OPERATION);
}
int readBufferWidth = readColorBuffer->getWidth();
int readBufferHeight = readColorBuffer->getHeight();
int drawBufferWidth = drawColorBuffer->getWidth();
int drawBufferHeight = drawColorBuffer->getHeight();
Rectangle sourceRect; Rectangle sourceRect;
Rectangle destRect; Rectangle destRect;
...@@ -2832,12 +2840,29 @@ void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1 ...@@ -2832,12 +2840,29 @@ void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1
if (mask & GL_COLOR_BUFFER_BIT) if (mask & GL_COLOR_BUFFER_BIT)
{ {
const bool validReadType = readFramebuffer->getColorbufferType(0) == GL_TEXTURE_2D || const GLenum readColorbufferType = readFramebuffer->getReadColorbufferType();
readFramebuffer->getColorbufferType(0) == GL_RENDERBUFFER; const bool validReadType = (readColorbufferType == GL_TEXTURE_2D) || (readColorbufferType == GL_RENDERBUFFER);
const bool validDrawType = drawFramebuffer->getColorbufferType(0) == GL_TEXTURE_2D || bool validDrawType = true;
drawFramebuffer->getColorbufferType(0) == GL_RENDERBUFFER; bool validDrawFormat = true;
if (!validReadType || !validDrawType ||
readFramebuffer->getColorbuffer(0)->getActualFormat() != drawFramebuffer->getColorbuffer(0)->getActualFormat()) for (unsigned int colorAttachment = 0; colorAttachment < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
{
if (drawFramebuffer->isEnabledColorAttachment(colorAttachment))
{
if (drawFramebuffer->getColorbufferType(colorAttachment) != GL_TEXTURE_2D &&
drawFramebuffer->getColorbufferType(colorAttachment) != GL_RENDERBUFFER)
{
validDrawType = false;
}
if (drawFramebuffer->getColorbuffer(colorAttachment)->getActualFormat() != readColorBuffer->getActualFormat())
{
validDrawFormat = false;
}
}
}
if (!validReadType || !validDrawType || !validDrawFormat)
{ {
ERR("Color buffer format conversion in BlitFramebufferANGLE not supported by this implementation"); ERR("Color buffer format conversion in BlitFramebufferANGLE not supported by this implementation");
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
......
...@@ -209,6 +209,12 @@ Renderbuffer *Framebuffer::getReadColorbuffer() const ...@@ -209,6 +209,12 @@ Renderbuffer *Framebuffer::getReadColorbuffer() const
return mColorbufferPointers[0].get(); return mColorbufferPointers[0].get();
} }
GLenum Framebuffer::getReadColorbufferType() const
{
// Will require more logic if glReadBuffers is supported
return mColorbufferTypes[0];
}
Renderbuffer *Framebuffer::getFirstColorBuffer() const Renderbuffer *Framebuffer::getFirstColorBuffer() const
{ {
for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++) for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
......
...@@ -50,6 +50,7 @@ class Framebuffer ...@@ -50,6 +50,7 @@ class Framebuffer
Renderbuffer *getStencilbuffer() const; Renderbuffer *getStencilbuffer() const;
Renderbuffer *getDepthOrStencilbuffer() const; Renderbuffer *getDepthOrStencilbuffer() const;
Renderbuffer *getReadColorbuffer() const; Renderbuffer *getReadColorbuffer() const;
GLenum getReadColorbufferType() const;
Renderbuffer *getFirstColorBuffer() const; Renderbuffer *getFirstColorBuffer() const;
GLenum getColorbufferType(unsigned int colorAttachment) const; GLenum getColorbufferType(unsigned int colorAttachment) const;
......
...@@ -2920,11 +2920,9 @@ bool Renderer11::getRenderTargetResource(gl::Renderbuffer *colorbuffer, unsigned ...@@ -2920,11 +2920,9 @@ bool Renderer11::getRenderTargetResource(gl::Renderbuffer *colorbuffer, unsigned
bool Renderer11::blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect, bool Renderer11::blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect,
bool blitRenderTarget, bool blitDepthStencil) bool blitRenderTarget, bool blitDepthStencil)
{ {
// TODO: mrt blit support
if (blitRenderTarget) if (blitRenderTarget)
{ {
gl::Renderbuffer *readBuffer = readTarget->getReadColorbuffer(); gl::Renderbuffer *readBuffer = readTarget->getReadColorbuffer();
gl::Renderbuffer *drawBuffer = drawTarget->getColorbuffer(0);
if (!readBuffer) if (!readBuffer)
{ {
...@@ -2932,18 +2930,27 @@ bool Renderer11::blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &read ...@@ -2932,18 +2930,27 @@ bool Renderer11::blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &read
return gl::error(GL_OUT_OF_MEMORY, false); return gl::error(GL_OUT_OF_MEMORY, false);
} }
if (!drawBuffer)
{
ERR("Failed to retrieve the draw buffer from the draw framebuffer.");
return gl::error(GL_OUT_OF_MEMORY, false);
}
RenderTarget *readRenderTarget = readBuffer->getRenderTarget(); RenderTarget *readRenderTarget = readBuffer->getRenderTarget();
RenderTarget *drawRenderTarget = drawBuffer->getRenderTarget();
if (!blitRenderbufferRect(readRect, drawRect, readRenderTarget, drawRenderTarget)) for (unsigned int colorAttachment = 0; colorAttachment < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
{ {
return false; if (drawTarget->isEnabledColorAttachment(colorAttachment))
{
gl::Renderbuffer *drawBuffer = drawTarget->getColorbuffer(colorAttachment);
if (!drawBuffer)
{
ERR("Failed to retrieve the draw buffer from the draw framebuffer.");
return gl::error(GL_OUT_OF_MEMORY, false);
}
RenderTarget *drawRenderTarget = drawBuffer->getRenderTarget();
if (!blitRenderbufferRect(readRect, drawRect, readRenderTarget, drawRenderTarget))
{
return false;
}
}
} }
} }
......
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