Commit c6aef6dd by Alexey Knyazev Committed by Commit Bot

Skip indexed clears on disabled draw buffers

Fixes ClearTestES3.ClearDisabledNonZeroAttachmentNoAssert Also fixed an assert in RenderTargetCache::updateColorRenderTarget Bug: angleproject:4607 Change-Id: Ic527eabacd424786736876136590b8409c9b49d1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2172091 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent e7b9118b
......@@ -300,6 +300,11 @@ bool IsClearBufferMaskedOut(const Context *context, GLenum buffer, GLint drawbuf
}
}
bool IsClearBufferDisabled(const FramebufferState &mState, GLenum buffer, GLint drawbuffer)
{
return buffer == GL_COLOR && !mState.getEnabledDrawBuffers()[drawbuffer];
}
} // anonymous namespace
// This constructor is only used for default framebuffers.
......@@ -1534,7 +1539,8 @@ angle::Result Framebuffer::clearBufferfv(const Context *context,
GLint drawbuffer,
const GLfloat *values)
{
if (context->getState().isRasterizerDiscardEnabled() ||
if (IsClearBufferDisabled(mState, buffer, drawbuffer) ||
context->getState().isRasterizerDiscardEnabled() ||
IsClearBufferMaskedOut(context, buffer, drawbuffer))
{
return angle::Result::Continue;
......@@ -1550,7 +1556,8 @@ angle::Result Framebuffer::clearBufferuiv(const Context *context,
GLint drawbuffer,
const GLuint *values)
{
if (context->getState().isRasterizerDiscardEnabled() ||
if (IsClearBufferDisabled(mState, buffer, drawbuffer) ||
context->getState().isRasterizerDiscardEnabled() ||
IsClearBufferMaskedOut(context, buffer, drawbuffer))
{
return angle::Result::Continue;
......@@ -1566,7 +1573,8 @@ angle::Result Framebuffer::clearBufferiv(const Context *context,
GLint drawbuffer,
const GLint *values)
{
if (context->getState().isRasterizerDiscardEnabled() ||
if (IsClearBufferDisabled(mState, buffer, drawbuffer) ||
context->getState().isRasterizerDiscardEnabled() ||
IsClearBufferMaskedOut(context, buffer, drawbuffer))
{
return angle::Result::Continue;
......
......@@ -133,7 +133,7 @@ angle::Result RenderTargetCache<RenderTargetT>::updateColorRenderTarget(
{
// If the color render target we're updating is also the read buffer, make sure we update the
// read render target also so it's not stale.
if (state.getReadIndex() == colorIndex)
if (state.getReadBufferState() != GL_NONE && state.getReadIndex() == colorIndex)
{
ANGLE_TRY(updateReadColorRenderTarget(context, state));
}
......
......@@ -1547,6 +1547,38 @@ TEST_P(ClearTest, InceptionScissorClears)
EXPECT_EQ(expectedColors, actualColors);
}
// Test that clearBuffer with disabled non-zero drawbuffer or disabled read source doesn't cause an
// assert.
TEST_P(ClearTestES3, ClearDisabledNonZeroAttachmentNoAssert)
{
// http://anglebug.com/4612
ANGLE_SKIP_TEST_IF(IsOSX() && IsDesktopOpenGL());
GLFramebuffer fb;
glBindFramebuffer(GL_FRAMEBUFFER, fb);
GLRenderbuffer rb;
glBindRenderbuffer(GL_RENDERBUFFER, rb);
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 16, 16);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_RENDERBUFFER, rb);
glDrawBuffers(0, nullptr);
glReadBuffer(GL_NONE);
ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
float clearColorf[4] = {0.5, 0.5, 0.5, 0.5};
glClearBufferfv(GL_COLOR, 1, clearColorf);
GLuint clearColorui[4] = {255, 255, 255, 255};
glClearBufferuiv(GL_COLOR, 1, clearColorui);
GLint clearColori[4] = {-127, -127, -127, -127};
glClearBufferiv(GL_COLOR, 1, clearColori);
EXPECT_GL_NO_ERROR();
}
#ifdef Bool
// X11 craziness.
# undef Bool
......
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