Skip drawing to a zero-area render target

TRAC #12172 This also generates a GL_INVALID_FRAMEBUFFER_OPERATION error when glClear attempt to operate on an invalid or incomplete framebuffer. Signed-off-by: Shannon Woods Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@241 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 3e4c6004
...@@ -1479,6 +1479,8 @@ bool Context::applyRenderTarget(bool ignoreViewport) ...@@ -1479,6 +1479,8 @@ bool Context::applyRenderTarget(bool ignoreViewport)
if (!framebufferObject || framebufferObject->completeness() != GL_FRAMEBUFFER_COMPLETE) if (!framebufferObject || framebufferObject->completeness() != GL_FRAMEBUFFER_COMPLETE)
{ {
error(GL_INVALID_FRAMEBUFFER_OPERATION);
return false; return false;
} }
...@@ -1511,6 +1513,11 @@ bool Context::applyRenderTarget(bool ignoreViewport) ...@@ -1511,6 +1513,11 @@ bool Context::applyRenderTarget(bool ignoreViewport)
viewport.MaxZ = clamp01(mState.zFar); viewport.MaxZ = clamp01(mState.zFar);
} }
if (viewport.Width <= 0 || viewport.Height <= 0)
{
return false; // Nothing to render
}
device->SetViewport(&viewport); device->SetViewport(&viewport);
if (mState.scissorTest) if (mState.scissorTest)
...@@ -1999,6 +2006,15 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum ...@@ -1999,6 +2006,15 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum
void Context::clear(GLbitfield mask) void Context::clear(GLbitfield mask)
{ {
Framebuffer *framebufferObject = getFramebuffer();
if (!framebufferObject || framebufferObject->completeness() != GL_FRAMEBUFFER_COMPLETE)
{
error(GL_INVALID_FRAMEBUFFER_OPERATION);
return;
}
egl::Display *display = getDisplay(); egl::Display *display = getDisplay();
IDirect3DDevice9 *device = getDevice(); IDirect3DDevice9 *device = getDevice();
DWORD flags = 0; DWORD flags = 0;
...@@ -2018,7 +2034,6 @@ void Context::clear(GLbitfield mask) ...@@ -2018,7 +2034,6 @@ void Context::clear(GLbitfield mask)
} }
} }
Framebuffer *framebufferObject = getFramebuffer();
IDirect3DSurface9 *depthStencil = framebufferObject->getDepthStencil(); IDirect3DSurface9 *depthStencil = framebufferObject->getDepthStencil();
GLuint stencilUnmasked = 0x0; GLuint stencilUnmasked = 0x0;
...@@ -2043,7 +2058,10 @@ void Context::clear(GLbitfield mask) ...@@ -2043,7 +2058,10 @@ void Context::clear(GLbitfield mask)
return error(GL_INVALID_VALUE); return error(GL_INVALID_VALUE);
} }
applyRenderTarget(true); // Clips the clear to the scissor rectangle but not the viewport if (!applyRenderTarget(true)) // Clips the clear to the scissor rectangle but not the viewport
{
return;
}
D3DCOLOR color = D3DCOLOR_ARGB(unorm<8>(mState.colorClearValue.alpha), D3DCOLOR color = D3DCOLOR_ARGB(unorm<8>(mState.colorClearValue.alpha),
unorm<8>(mState.colorClearValue.red), unorm<8>(mState.colorClearValue.red),
...@@ -2177,7 +2195,7 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count) ...@@ -2177,7 +2195,7 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count)
if (!applyRenderTarget(false)) if (!applyRenderTarget(false))
{ {
return error(GL_INVALID_FRAMEBUFFER_OPERATION); return;
} }
applyState(mode); applyState(mode);
...@@ -2224,7 +2242,7 @@ void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const void* ...@@ -2224,7 +2242,7 @@ void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const void*
if (!applyRenderTarget(false)) if (!applyRenderTarget(false))
{ {
return error(GL_INVALID_FRAMEBUFFER_OPERATION); return;
} }
applyState(mode); applyState(mode);
......
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