Commit ef9fcd91 by Jamie Madill Committed by Commit Bot

Clear draw attachments as a dirty object.

This allows us to skip 1/2 of the robust resource init check in Context::setupDraw. The plan is to remove the other half in a follow-up CL. Most of the work of this CL was already handled. We just need to add the right dirty object mask to the Context's draw dirty objects list. We can mask out this check when robust resource is not enabled. Bug: angleproject:2966 Change-Id: I97ec2497c95e5cdf52988e1ce85f7602206935f0 Reviewed-on: https://chromium-review.googlesource.com/c/1343140 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org>
parent 2c0e06d9
...@@ -1475,8 +1475,6 @@ void Context::getIntegervImpl(GLenum pname, GLint *params) ...@@ -1475,8 +1475,6 @@ void Context::getIntegervImpl(GLenum pname, GLint *params)
case GL_MAX_DRAW_BUFFERS_EXT: case GL_MAX_DRAW_BUFFERS_EXT:
*params = mCaps.maxDrawBuffers; *params = mCaps.maxDrawBuffers;
break; break;
// case GL_FRAMEBUFFER_BINDING: // now equivalent to
// GL_DRAW_FRAMEBUFFER_BINDING_ANGLE
case GL_SUBPIXEL_BITS: case GL_SUBPIXEL_BITS:
*params = 4; *params = 4;
break; break;
...@@ -3472,6 +3470,12 @@ void Context::updateCaps() ...@@ -3472,6 +3470,12 @@ void Context::updateCaps()
mThreadPool = angle::WorkerThreadPool::Create(mExtensions.parallelShaderCompile); mThreadPool = angle::WorkerThreadPool::Create(mExtensions.parallelShaderCompile);
// Reinitialize some dirty bits that depend on extensions.
mDrawDirtyObjects.set(State::DIRTY_OBJECT_DRAW_ATTACHMENTS,
mGLState.isRobustResourceInitEnabled());
mBlitDirtyObjects.set(State::DIRTY_OBJECT_DRAW_ATTACHMENTS,
mGLState.isRobustResourceInitEnabled());
// Reinitialize state cache after extension changes. // Reinitialize state cache after extension changes.
mStateCache.initialize(this); mStateCache.initialize(this);
} }
...@@ -3518,7 +3522,7 @@ angle::Result Context::prepareForDraw(PrimitiveMode mode) ...@@ -3518,7 +3522,7 @@ angle::Result Context::prepareForDraw(PrimitiveMode mode)
if (isRobustResourceInitEnabled()) if (isRobustResourceInitEnabled())
{ {
ANGLE_TRY(mGLState.clearUnclearedActiveTextures(this)); ANGLE_TRY(mGLState.clearUnclearedActiveTextures(this));
ANGLE_TRY(mGLState.getDrawFramebuffer()->ensureDrawAttachmentsInitialized(this)); ASSERT(!mGLState.getDrawFramebuffer()->hasResourceThatNeedsInit());
} }
ANGLE_TRY(syncDirtyBits()); ANGLE_TRY(syncDirtyBits());
...@@ -3964,7 +3968,7 @@ void Context::drawBuffers(GLsizei n, const GLenum *bufs) ...@@ -3964,7 +3968,7 @@ void Context::drawBuffers(GLsizei n, const GLenum *bufs)
Framebuffer *framebuffer = mGLState.getDrawFramebuffer(); Framebuffer *framebuffer = mGLState.getDrawFramebuffer();
ASSERT(framebuffer); ASSERT(framebuffer);
framebuffer->setDrawBuffers(n, bufs); framebuffer->setDrawBuffers(n, bufs);
mGLState.setObjectDirty(GL_DRAW_FRAMEBUFFER); mGLState.setDrawFramebufferDirty();
mStateCache.onDrawFramebufferChange(this); mStateCache.onDrawFramebufferChange(this);
} }
...@@ -7251,7 +7255,8 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu ...@@ -7251,7 +7255,8 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
case GL_NUM_SHADER_BINARY_FORMATS: case GL_NUM_SHADER_BINARY_FORMATS:
case GL_NUM_COMPRESSED_TEXTURE_FORMATS: case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
case GL_ARRAY_BUFFER_BINDING: case GL_ARRAY_BUFFER_BINDING:
case GL_FRAMEBUFFER_BINDING: case GL_FRAMEBUFFER_BINDING: // GL_FRAMEBUFFER_BINDING now equivalent to
// GL_DRAW_FRAMEBUFFER_BINDING_ANGLE
case GL_RENDERBUFFER_BINDING: case GL_RENDERBUFFER_BINDING:
case GL_CURRENT_PROGRAM: case GL_CURRENT_PROGRAM:
case GL_PACK_ALIGNMENT: case GL_PACK_ALIGNMENT:
...@@ -7553,7 +7558,7 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu ...@@ -7553,7 +7558,7 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
// Check for ES3.0+ parameter names which are also exposed as ES2 extensions // Check for ES3.0+ parameter names which are also exposed as ES2 extensions
switch (pname) switch (pname)
{ {
// case GL_DRAW_FRAMEBUFFER_BINDING_ANGLE // equivalent to FRAMEBUFFER_BINDING // GL_DRAW_FRAMEBUFFER_BINDING_ANGLE equivalent to FRAMEBUFFER_BINDING
case GL_READ_FRAMEBUFFER_BINDING_ANGLE: case GL_READ_FRAMEBUFFER_BINDING_ANGLE:
if ((getClientMajorVersion() < 3) && !getExtensions().framebufferBlit) if ((getClientMajorVersion() < 3) && !getExtensions().framebufferBlit)
{ {
...@@ -8104,7 +8109,7 @@ void Context::onSubjectStateChange(const Context *context, ...@@ -8104,7 +8109,7 @@ void Context::onSubjectStateChange(const Context *context,
case kDrawFramebufferSubjectIndex: case kDrawFramebufferSubjectIndex:
if (message == angle::SubjectMessage::STORAGE_CHANGED) if (message == angle::SubjectMessage::STORAGE_CHANGED)
{ {
mGLState.setObjectDirty(GL_DRAW_FRAMEBUFFER); mGLState.setDrawFramebufferDirty();
} }
mStateCache.onDrawFramebufferChange(this); mStateCache.onDrawFramebufferChange(this);
break; break;
......
...@@ -338,6 +338,8 @@ class Framebuffer final : public angle::ObserverInterface, ...@@ -338,6 +338,8 @@ class Framebuffer final : public angle::ObserverInterface,
using DirtyBits = angle::BitSet<DIRTY_BIT_MAX>; using DirtyBits = angle::BitSet<DIRTY_BIT_MAX>;
bool hasAnyDirtyBit() const { return mDirtyBits.any(); } bool hasAnyDirtyBit() const { return mDirtyBits.any(); }
bool hasResourceThatNeedsInit() const { return mState.mResourceNeedsInit.any(); }
angle::Result syncState(const Context *context); angle::Result syncState(const Context *context);
// Observer implementation // Observer implementation
......
...@@ -1092,7 +1092,7 @@ void State::detachTexture(const Context *context, const TextureMap &zeroTextures ...@@ -1092,7 +1092,7 @@ void State::detachTexture(const Context *context, const TextureMap &zeroTextures
if (mDrawFramebuffer && mDrawFramebuffer->detachTexture(context, texture)) if (mDrawFramebuffer && mDrawFramebuffer->detachTexture(context, texture))
{ {
mDirtyObjects.set(DIRTY_OBJECT_DRAW_FRAMEBUFFER); setDrawFramebufferDirty();
} }
} }
...@@ -1167,7 +1167,7 @@ void State::detachRenderbuffer(const Context *context, GLuint renderbuffer) ...@@ -1167,7 +1167,7 @@ void State::detachRenderbuffer(const Context *context, GLuint renderbuffer)
{ {
if (drawFramebuffer->detachRenderbuffer(context, renderbuffer)) if (drawFramebuffer->detachRenderbuffer(context, renderbuffer))
{ {
mDirtyObjects.set(DIRTY_OBJECT_DRAW_FRAMEBUFFER); setDrawFramebufferDirty();
} }
} }
} }
...@@ -1194,9 +1194,17 @@ void State::setDrawFramebufferBinding(Framebuffer *framebuffer) ...@@ -1194,9 +1194,17 @@ void State::setDrawFramebufferBinding(Framebuffer *framebuffer)
mDrawFramebuffer = framebuffer; mDrawFramebuffer = framebuffer;
mDirtyBits.set(DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING); mDirtyBits.set(DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING);
if (mDrawFramebuffer && mDrawFramebuffer->hasAnyDirtyBit()) if (mDrawFramebuffer)
{ {
mDirtyObjects.set(DIRTY_OBJECT_DRAW_FRAMEBUFFER); if (mDrawFramebuffer->hasAnyDirtyBit())
{
mDirtyObjects.set(DIRTY_OBJECT_DRAW_FRAMEBUFFER);
}
if (mRobustResourceInit && mDrawFramebuffer->hasResourceThatNeedsInit())
{
mDirtyObjects.set(DIRTY_OBJECT_DRAW_ATTACHMENTS);
}
} }
} }
...@@ -2485,12 +2493,20 @@ angle::Result State::syncReadFramebuffer(const Context *context) ...@@ -2485,12 +2493,20 @@ angle::Result State::syncReadFramebuffer(const Context *context)
return mReadFramebuffer->syncState(context); return mReadFramebuffer->syncState(context);
} }
angle::Result State::syncWriteFramebuffer(const Context *context) angle::Result State::syncDrawFramebuffer(const Context *context)
{ {
ASSERT(mDrawFramebuffer); ASSERT(mDrawFramebuffer);
return mDrawFramebuffer->syncState(context); return mDrawFramebuffer->syncState(context);
} }
angle::Result State::syncDrawAttachments(const Context *context)
{
ASSERT(mDrawFramebuffer);
ASSERT(!mDrawFramebuffer->hasAnyDirtyBit());
ASSERT(mRobustResourceInit);
return mDrawFramebuffer->ensureDrawAttachmentsInitialized(context);
}
angle::Result State::syncVertexArray(const Context *context) angle::Result State::syncVertexArray(const Context *context)
{ {
ASSERT(mVertexArray); ASSERT(mVertexArray);
...@@ -2627,11 +2643,11 @@ void State::setObjectDirty(GLenum target) ...@@ -2627,11 +2643,11 @@ void State::setObjectDirty(GLenum target)
mDirtyObjects.set(DIRTY_OBJECT_READ_FRAMEBUFFER); mDirtyObjects.set(DIRTY_OBJECT_READ_FRAMEBUFFER);
break; break;
case GL_DRAW_FRAMEBUFFER: case GL_DRAW_FRAMEBUFFER:
mDirtyObjects.set(DIRTY_OBJECT_DRAW_FRAMEBUFFER); setDrawFramebufferDirty();
break; break;
case GL_FRAMEBUFFER: case GL_FRAMEBUFFER:
mDirtyObjects.set(DIRTY_OBJECT_READ_FRAMEBUFFER); mDirtyObjects.set(DIRTY_OBJECT_READ_FRAMEBUFFER);
mDirtyObjects.set(DIRTY_OBJECT_DRAW_FRAMEBUFFER); setDrawFramebufferDirty();
break; break;
case GL_VERTEX_ARRAY: case GL_VERTEX_ARRAY:
mDirtyObjects.set(DIRTY_OBJECT_VERTEX_ARRAY); mDirtyObjects.set(DIRTY_OBJECT_VERTEX_ARRAY);
......
...@@ -485,6 +485,7 @@ class State : angle::NonCopyable ...@@ -485,6 +485,7 @@ class State : angle::NonCopyable
{ {
DIRTY_OBJECT_READ_FRAMEBUFFER = 0, DIRTY_OBJECT_READ_FRAMEBUFFER = 0,
DIRTY_OBJECT_DRAW_FRAMEBUFFER, DIRTY_OBJECT_DRAW_FRAMEBUFFER,
DIRTY_OBJECT_DRAW_ATTACHMENTS,
DIRTY_OBJECT_VERTEX_ARRAY, DIRTY_OBJECT_VERTEX_ARRAY,
DIRTY_OBJECT_SAMPLERS, DIRTY_OBJECT_SAMPLERS,
// Use a very coarse bit for any program or texture change. // Use a very coarse bit for any program or texture change.
...@@ -509,6 +510,12 @@ class State : angle::NonCopyable ...@@ -509,6 +510,12 @@ class State : angle::NonCopyable
void setObjectDirty(GLenum target); void setObjectDirty(GLenum target);
void setSamplerDirty(size_t samplerIndex); void setSamplerDirty(size_t samplerIndex);
ANGLE_INLINE void setDrawFramebufferDirty()
{
mDirtyObjects.set(DIRTY_OBJECT_DRAW_FRAMEBUFFER);
mDirtyObjects.set(DIRTY_OBJECT_DRAW_ATTACHMENTS);
}
// This actually clears the current value dirty bits. // This actually clears the current value dirty bits.
// TODO(jmadill): Pass mutable dirty bits into Impl. // TODO(jmadill): Pass mutable dirty bits into Impl.
AttributesMask getAndResetDirtyCurrentValues() const; AttributesMask getAndResetDirtyCurrentValues() const;
...@@ -558,7 +565,8 @@ class State : angle::NonCopyable ...@@ -558,7 +565,8 @@ class State : angle::NonCopyable
// Functions to synchronize dirty states // Functions to synchronize dirty states
angle::Result syncReadFramebuffer(const Context *context); angle::Result syncReadFramebuffer(const Context *context);
angle::Result syncWriteFramebuffer(const Context *context); angle::Result syncDrawFramebuffer(const Context *context);
angle::Result syncDrawAttachments(const Context *context);
angle::Result syncVertexArray(const Context *context); angle::Result syncVertexArray(const Context *context);
angle::Result syncSamplers(const Context *context); angle::Result syncSamplers(const Context *context);
angle::Result syncProgramTextures(const Context *context); angle::Result syncProgramTextures(const Context *context);
...@@ -566,15 +574,17 @@ class State : angle::NonCopyable ...@@ -566,15 +574,17 @@ class State : angle::NonCopyable
using DirtyObjectHandler = angle::Result (State::*)(const Context *context); using DirtyObjectHandler = angle::Result (State::*)(const Context *context);
static constexpr DirtyObjectHandler kDirtyObjectHandlers[DIRTY_OBJECT_MAX] = { static constexpr DirtyObjectHandler kDirtyObjectHandlers[DIRTY_OBJECT_MAX] = {
&State::syncReadFramebuffer, &State::syncWriteFramebuffer, &State::syncVertexArray, &State::syncReadFramebuffer, &State::syncDrawFramebuffer, &State::syncDrawAttachments,
&State::syncSamplers, &State::syncProgramTextures, &State::syncProgram}; &State::syncVertexArray, &State::syncSamplers, &State::syncProgramTextures,
&State::syncProgram};
static_assert(DIRTY_OBJECT_READ_FRAMEBUFFER == 0, "check DIRTY_OBJECT_READ_FRAMEBUFFER index"); static_assert(DIRTY_OBJECT_READ_FRAMEBUFFER == 0, "check DIRTY_OBJECT_READ_FRAMEBUFFER index");
static_assert(DIRTY_OBJECT_DRAW_FRAMEBUFFER == 1, "check DIRTY_OBJECT_DRAW_FRAMEBUFFER index"); static_assert(DIRTY_OBJECT_DRAW_FRAMEBUFFER == 1, "check DIRTY_OBJECT_DRAW_FRAMEBUFFER index");
static_assert(DIRTY_OBJECT_VERTEX_ARRAY == 2, "check DIRTY_OBJECT_VERTEX_ARRAY index"); static_assert(DIRTY_OBJECT_DRAW_ATTACHMENTS == 2, "check DIRTY_OBJECT_DRAW_ATTACHMENTS index");
static_assert(DIRTY_OBJECT_SAMPLERS == 3, "check DIRTY_OBJECT_SAMPLERS index"); static_assert(DIRTY_OBJECT_VERTEX_ARRAY == 3, "check DIRTY_OBJECT_VERTEX_ARRAY index");
static_assert(DIRTY_OBJECT_PROGRAM_TEXTURES == 4, "check DIRTY_OBJECT_PROGRAM_TEXTURES index"); static_assert(DIRTY_OBJECT_SAMPLERS == 4, "check DIRTY_OBJECT_SAMPLERS index");
static_assert(DIRTY_OBJECT_PROGRAM == 5, "check DIRTY_OBJECT_PROGRAM index"); static_assert(DIRTY_OBJECT_PROGRAM_TEXTURES == 5, "check DIRTY_OBJECT_PROGRAM_TEXTURES index");
static_assert(DIRTY_OBJECT_PROGRAM == 6, "check DIRTY_OBJECT_PROGRAM index");
// Dispatch table for buffer update functions. // Dispatch table for buffer update functions.
static const angle::PackedEnumMap<BufferBinding, BufferBindingSetter> kBufferSetters; static const angle::PackedEnumMap<BufferBinding, BufferBindingSetter> kBufferSetters;
......
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