Reorder state synchronization for resource init.
Some backends may change state while initializing resources. Make sure
that all resources are initialized before synchronizing the backend
state for the given operation.
BUG=angleproject:2107
Change-Id: Ie75ac3eee986e41dfe3dd11a94a706e19df7497e
Reviewed-on: https://chromium-review.googlesource.com/678481
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/libANGLE/Context.cpp b/src/libANGLE/Context.cpp
index f5718f7..449fad2 100644
--- a/src/libANGLE/Context.cpp
+++ b/src/libANGLE/Context.cpp
@@ -2907,7 +2907,7 @@
Error Context::prepareForDraw()
{
- ANGLE_TRY(syncRendererState());
+ ANGLE_TRY(syncRendererDirtyObjects());
if (isRobustResourceInitEnabled())
{
@@ -2915,28 +2915,68 @@
ANGLE_TRY(mGLState.getDrawFramebuffer()->ensureDrawAttachmentsInitialized(this));
}
+ ANGLE_TRY(syncRendererDirtyBits());
+ return NoError();
+}
+
+Error Context::prepareForClear(GLbitfield mask)
+{
+ ANGLE_TRY(syncRendererDirtyObjects(mClearDirtyObjects));
+ ANGLE_TRY(mGLState.getDrawFramebuffer()->ensureClearAttachmentsInitialized(this, mask));
+ ANGLE_TRY(syncRendererDirtyBits(mClearDirtyBits));
+ return NoError();
+}
+
+Error Context::prepareForClearBuffer(GLenum buffer, GLint drawbuffer)
+{
+ ANGLE_TRY(syncRendererDirtyObjects(mClearDirtyObjects));
+ ANGLE_TRY(mGLState.getDrawFramebuffer()->ensureClearBufferAttachmentsInitialized(this, buffer,
+ drawbuffer));
+ ANGLE_TRY(syncRendererDirtyBits(mClearDirtyBits));
return NoError();
}
Error Context::syncRendererState()
{
- ANGLE_TRY(mGLState.syncDirtyObjects(this));
- const State::DirtyBits &dirtyBits = mGLState.getDirtyBits();
- mImplementation->syncState(this, dirtyBits);
- mGLState.clearDirtyBits();
+ ANGLE_TRY(syncRendererDirtyObjects());
+ ANGLE_TRY(syncRendererDirtyBits());
return NoError();
}
Error Context::syncRendererState(const State::DirtyBits &bitMask,
const State::DirtyObjects &objectMask)
{
- ANGLE_TRY(mGLState.syncDirtyObjects(this, objectMask));
+ ANGLE_TRY(syncRendererDirtyObjects(objectMask));
+ ANGLE_TRY(syncRendererDirtyBits(bitMask));
+ return NoError();
+}
+
+Error Context::syncRendererDirtyBits()
+{
+ const State::DirtyBits &dirtyBits = mGLState.getDirtyBits();
+ mImplementation->syncState(this, dirtyBits);
+ mGLState.clearDirtyBits();
+ return NoError();
+}
+
+Error Context::syncRendererDirtyBits(const State::DirtyBits &bitMask)
+{
const State::DirtyBits &dirtyBits = (mGLState.getDirtyBits() & bitMask);
mImplementation->syncState(this, dirtyBits);
mGLState.clearDirtyBits(dirtyBits);
return NoError();
}
+Error Context::syncRendererDirtyObjects()
+{
+ return mGLState.syncDirtyObjects(this);
+}
+
+Error Context::syncRendererDirtyObjects(const State::DirtyObjects &objectMask)
+{
+ return mGLState.syncDirtyObjects(this, objectMask);
+}
+
void Context::blitFramebuffer(GLint srcX0,
GLint srcY0,
GLint srcX1,
@@ -2968,26 +3008,29 @@
void Context::clear(GLbitfield mask)
{
- ANGLE_CONTEXT_TRY(syncStateForClear());
- handleError(mGLState.getDrawFramebuffer()->clear(this, mask));
+ ANGLE_CONTEXT_TRY(prepareForClear(mask));
+ ANGLE_CONTEXT_TRY(mGLState.getDrawFramebuffer()->clear(this, mask));
}
void Context::clearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *values)
{
- ANGLE_CONTEXT_TRY(syncStateForClear());
- handleError(mGLState.getDrawFramebuffer()->clearBufferfv(this, buffer, drawbuffer, values));
+ ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer));
+ ANGLE_CONTEXT_TRY(
+ mGLState.getDrawFramebuffer()->clearBufferfv(this, buffer, drawbuffer, values));
}
void Context::clearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *values)
{
- ANGLE_CONTEXT_TRY(syncStateForClear());
- handleError(mGLState.getDrawFramebuffer()->clearBufferuiv(this, buffer, drawbuffer, values));
+ ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer));
+ ANGLE_CONTEXT_TRY(
+ mGLState.getDrawFramebuffer()->clearBufferuiv(this, buffer, drawbuffer, values));
}
void Context::clearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *values)
{
- ANGLE_CONTEXT_TRY(syncStateForClear());
- handleError(mGLState.getDrawFramebuffer()->clearBufferiv(this, buffer, drawbuffer, values));
+ ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer));
+ ANGLE_CONTEXT_TRY(
+ mGLState.getDrawFramebuffer()->clearBufferiv(this, buffer, drawbuffer, values));
}
void Context::clearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
@@ -3002,8 +3045,8 @@
return;
}
- ANGLE_CONTEXT_TRY(syncStateForClear());
- handleError(framebufferObject->clearBufferfi(this, buffer, drawbuffer, depth, stencil));
+ ANGLE_CONTEXT_TRY(prepareForClearBuffer(buffer, drawbuffer));
+ ANGLE_CONTEXT_TRY(framebufferObject->clearBufferfi(this, buffer, drawbuffer, depth, stencil));
}
void Context::readPixels(GLint x,
@@ -3637,11 +3680,6 @@
return syncRendererState(mTexImageDirtyBits, mTexImageDirtyObjects);
}
-Error Context::syncStateForClear()
-{
- return syncRendererState(mClearDirtyBits, mClearDirtyObjects);
-}
-
Error Context::syncStateForBlit()
{
return syncRendererState(mBlitDirtyBits, mBlitDirtyObjects);