Commit 222a81cf by Geoff Lang Committed by Angle LUCI CQ

Reland: GL: Skip redundant flushes.

Skip flushes when there is no work submitted since the last flush. Bug: chromium:1181068 Change-Id: Iab31f8949f7eb07dffb7b0930069cbb3ca69ef57 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2956453Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent ebf75698
...@@ -80,6 +80,8 @@ angle::Result BufferGL::setData(const gl::Context *context, ...@@ -80,6 +80,8 @@ angle::Result BufferGL::setData(const gl::Context *context,
mBufferSize = size; mBufferSize = size;
contextGL->markWorkSubmitted();
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -89,6 +91,7 @@ angle::Result BufferGL::setSubData(const gl::Context *context, ...@@ -89,6 +91,7 @@ angle::Result BufferGL::setSubData(const gl::Context *context,
size_t size, size_t size,
size_t offset) size_t offset)
{ {
ContextGL *contextGL = GetImplAs<ContextGL>(context);
const FunctionsGL *functions = GetFunctionsGL(context); const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context); StateManagerGL *stateManager = GetStateManagerGL(context);
const angle::FeaturesGL &features = GetFeaturesGL(context); const angle::FeaturesGL &features = GetFeaturesGL(context);
...@@ -102,6 +105,8 @@ angle::Result BufferGL::setSubData(const gl::Context *context, ...@@ -102,6 +105,8 @@ angle::Result BufferGL::setSubData(const gl::Context *context,
memcpy(mShadowCopy.data() + offset, data, size); memcpy(mShadowCopy.data() + offset, data, size);
} }
contextGL->markWorkSubmitted();
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -111,6 +116,7 @@ angle::Result BufferGL::copySubData(const gl::Context *context, ...@@ -111,6 +116,7 @@ angle::Result BufferGL::copySubData(const gl::Context *context,
GLintptr destOffset, GLintptr destOffset,
GLsizeiptr size) GLsizeiptr size)
{ {
ContextGL *contextGL = GetImplAs<ContextGL>(context);
const FunctionsGL *functions = GetFunctionsGL(context); const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context); StateManagerGL *stateManager = GetStateManagerGL(context);
const angle::FeaturesGL &features = GetFeaturesGL(context); const angle::FeaturesGL &features = GetFeaturesGL(context);
...@@ -130,11 +136,14 @@ angle::Result BufferGL::copySubData(const gl::Context *context, ...@@ -130,11 +136,14 @@ angle::Result BufferGL::copySubData(const gl::Context *context,
memcpy(mShadowCopy.data() + destOffset, sourceGL->mShadowCopy.data() + sourceOffset, size); memcpy(mShadowCopy.data() + destOffset, sourceGL->mShadowCopy.data() + sourceOffset, size);
} }
contextGL->markWorkSubmitted();
return angle::Result::Continue; return angle::Result::Continue;
} }
angle::Result BufferGL::map(const gl::Context *context, GLenum access, void **mapPtr) angle::Result BufferGL::map(const gl::Context *context, GLenum access, void **mapPtr)
{ {
ContextGL *contextGL = GetImplAs<ContextGL>(context);
const FunctionsGL *functions = GetFunctionsGL(context); const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context); StateManagerGL *stateManager = GetStateManagerGL(context);
const angle::FeaturesGL &features = GetFeaturesGL(context); const angle::FeaturesGL &features = GetFeaturesGL(context);
...@@ -162,6 +171,8 @@ angle::Result BufferGL::map(const gl::Context *context, GLenum access, void **ma ...@@ -162,6 +171,8 @@ angle::Result BufferGL::map(const gl::Context *context, GLenum access, void **ma
mMapOffset = 0; mMapOffset = 0;
mMapSize = mBufferSize; mMapSize = mBufferSize;
contextGL->markWorkSubmitted();
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -171,6 +182,7 @@ angle::Result BufferGL::mapRange(const gl::Context *context, ...@@ -171,6 +182,7 @@ angle::Result BufferGL::mapRange(const gl::Context *context,
GLbitfield access, GLbitfield access,
void **mapPtr) void **mapPtr)
{ {
ContextGL *contextGL = GetImplAs<ContextGL>(context);
const FunctionsGL *functions = GetFunctionsGL(context); const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context); StateManagerGL *stateManager = GetStateManagerGL(context);
const angle::FeaturesGL &features = GetFeaturesGL(context); const angle::FeaturesGL &features = GetFeaturesGL(context);
...@@ -191,11 +203,14 @@ angle::Result BufferGL::mapRange(const gl::Context *context, ...@@ -191,11 +203,14 @@ angle::Result BufferGL::mapRange(const gl::Context *context,
mMapOffset = offset; mMapOffset = offset;
mMapSize = length; mMapSize = length;
contextGL->markWorkSubmitted();
return angle::Result::Continue; return angle::Result::Continue;
} }
angle::Result BufferGL::unmap(const gl::Context *context, GLboolean *result) angle::Result BufferGL::unmap(const gl::Context *context, GLboolean *result)
{ {
ContextGL *contextGL = GetImplAs<ContextGL>(context);
const FunctionsGL *functions = GetFunctionsGL(context); const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context); StateManagerGL *stateManager = GetStateManagerGL(context);
const angle::FeaturesGL &features = GetFeaturesGL(context); const angle::FeaturesGL &features = GetFeaturesGL(context);
...@@ -219,6 +234,9 @@ angle::Result BufferGL::unmap(const gl::Context *context, GLboolean *result) ...@@ -219,6 +234,9 @@ angle::Result BufferGL::unmap(const gl::Context *context, GLboolean *result)
} }
mIsMapped = false; mIsMapped = false;
contextGL->markWorkSubmitted();
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -229,6 +247,7 @@ angle::Result BufferGL::getIndexRange(const gl::Context *context, ...@@ -229,6 +247,7 @@ angle::Result BufferGL::getIndexRange(const gl::Context *context,
bool primitiveRestartEnabled, bool primitiveRestartEnabled,
gl::IndexRange *outRange) gl::IndexRange *outRange)
{ {
ContextGL *contextGL = GetImplAs<ContextGL>(context);
const FunctionsGL *functions = GetFunctionsGL(context); const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context); StateManagerGL *stateManager = GetStateManagerGL(context);
const angle::FeaturesGL &features = GetFeaturesGL(context); const angle::FeaturesGL &features = GetFeaturesGL(context);
...@@ -260,6 +279,8 @@ angle::Result BufferGL::getIndexRange(const gl::Context *context, ...@@ -260,6 +279,8 @@ angle::Result BufferGL::getIndexRange(const gl::Context *context,
} }
} }
contextGL->markWorkSubmitted();
return angle::Result::Continue; return angle::Result::Continue;
} }
......
...@@ -329,6 +329,8 @@ angle::Result ContextGL::drawArrays(const gl::Context *context, ...@@ -329,6 +329,8 @@ angle::Result ContextGL::drawArrays(const gl::Context *context,
ANGLE_GL_TRY(context, getFunctions()->drawArraysInstanced(ToGLenum(mode), first, count, ANGLE_GL_TRY(context, getFunctions()->drawArraysInstanced(ToGLenum(mode), first, count,
instanceCount)); instanceCount));
} }
mRenderer->markWorkSubmitted();
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -348,6 +350,8 @@ angle::Result ContextGL::drawArraysInstanced(const gl::Context *context, ...@@ -348,6 +350,8 @@ angle::Result ContextGL::drawArraysInstanced(const gl::Context *context,
ANGLE_TRY(setDrawArraysState(context, first, count, adjustedInstanceCount)); ANGLE_TRY(setDrawArraysState(context, first, count, adjustedInstanceCount));
ANGLE_GL_TRY(context, getFunctions()->drawArraysInstanced(ToGLenum(mode), first, count, ANGLE_GL_TRY(context, getFunctions()->drawArraysInstanced(ToGLenum(mode), first, count,
adjustedInstanceCount)); adjustedInstanceCount));
mRenderer->markWorkSubmitted();
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -469,6 +473,8 @@ angle::Result ContextGL::drawArraysInstancedBaseInstance(const gl::Context *cont ...@@ -469,6 +473,8 @@ angle::Result ContextGL::drawArraysInstancedBaseInstance(const gl::Context *cont
resetUpdatedAttributes(attribToResetMask); resetUpdatedAttributes(attribToResetMask);
} }
mRenderer->markWorkSubmitted();
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -500,6 +506,8 @@ angle::Result ContextGL::drawElements(const gl::Context *context, ...@@ -500,6 +506,8 @@ angle::Result ContextGL::drawElements(const gl::Context *context,
getFunctions()->drawElementsInstanced(ToGLenum(mode), count, ToGLenum(type), getFunctions()->drawElementsInstanced(ToGLenum(mode), count, ToGLenum(type),
drawIndexPtr, instanceCount)); drawIndexPtr, instanceCount));
} }
mRenderer->markWorkSubmitted();
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -532,6 +540,8 @@ angle::Result ContextGL::drawElementsBaseVertex(const gl::Context *context, ...@@ -532,6 +540,8 @@ angle::Result ContextGL::drawElementsBaseVertex(const gl::Context *context,
ToGLenum(mode), count, ToGLenum(type), drawIndexPtr, ToGLenum(mode), count, ToGLenum(type), drawIndexPtr,
instanceCount, baseVertex)); instanceCount, baseVertex));
} }
mRenderer->markWorkSubmitted();
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -579,6 +589,8 @@ angle::Result ContextGL::drawElementsInstancedBaseVertex(const gl::Context *cont ...@@ -579,6 +589,8 @@ angle::Result ContextGL::drawElementsInstancedBaseVertex(const gl::Context *cont
ANGLE_GL_TRY(context, getFunctions()->drawElementsInstancedBaseVertex( ANGLE_GL_TRY(context, getFunctions()->drawElementsInstancedBaseVertex(
ToGLenum(mode), count, ToGLenum(type), drawIndexPointer, ToGLenum(mode), count, ToGLenum(type), drawIndexPointer,
adjustedInstanceCount, baseVertex)); adjustedInstanceCount, baseVertex));
mRenderer->markWorkSubmitted();
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -625,6 +637,8 @@ angle::Result ContextGL::drawElementsInstancedBaseVertexBaseInstance(const gl::C ...@@ -625,6 +637,8 @@ angle::Result ContextGL::drawElementsInstancedBaseVertexBaseInstance(const gl::C
resetUpdatedAttributes(attribToResetMask); resetUpdatedAttributes(attribToResetMask);
} }
mRenderer->markWorkSubmitted();
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -654,6 +668,8 @@ angle::Result ContextGL::drawRangeElements(const gl::Context *context, ...@@ -654,6 +668,8 @@ angle::Result ContextGL::drawRangeElements(const gl::Context *context,
getFunctions()->drawElementsInstanced(ToGLenum(mode), count, ToGLenum(type), getFunctions()->drawElementsInstanced(ToGLenum(mode), count, ToGLenum(type),
drawIndexPointer, instanceCount)); drawIndexPointer, instanceCount));
} }
mRenderer->markWorkSubmitted();
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -685,6 +701,8 @@ angle::Result ContextGL::drawRangeElementsBaseVertex(const gl::Context *context, ...@@ -685,6 +701,8 @@ angle::Result ContextGL::drawRangeElementsBaseVertex(const gl::Context *context,
ToGLenum(mode), count, ToGLenum(type), drawIndexPointer, ToGLenum(mode), count, ToGLenum(type), drawIndexPointer,
instanceCount, baseVertex)); instanceCount, baseVertex));
} }
mRenderer->markWorkSubmitted();
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -693,6 +711,8 @@ angle::Result ContextGL::drawArraysIndirect(const gl::Context *context, ...@@ -693,6 +711,8 @@ angle::Result ContextGL::drawArraysIndirect(const gl::Context *context,
const void *indirect) const void *indirect)
{ {
ANGLE_GL_TRY(context, getFunctions()->drawArraysIndirect(ToGLenum(mode), indirect)); ANGLE_GL_TRY(context, getFunctions()->drawArraysIndirect(ToGLenum(mode), indirect));
mRenderer->markWorkSubmitted();
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -712,6 +732,8 @@ angle::Result ContextGL::multiDrawArrays(const gl::Context *context, ...@@ -712,6 +732,8 @@ angle::Result ContextGL::multiDrawArrays(const gl::Context *context,
const GLsizei *counts, const GLsizei *counts,
GLsizei drawcount) GLsizei drawcount)
{ {
mRenderer->markWorkSubmitted();
return rx::MultiDrawArraysGeneral(this, context, mode, firsts, counts, drawcount); return rx::MultiDrawArraysGeneral(this, context, mode, firsts, counts, drawcount);
} }
...@@ -722,6 +744,8 @@ angle::Result ContextGL::multiDrawArraysInstanced(const gl::Context *context, ...@@ -722,6 +744,8 @@ angle::Result ContextGL::multiDrawArraysInstanced(const gl::Context *context,
const GLsizei *instanceCounts, const GLsizei *instanceCounts,
GLsizei drawcount) GLsizei drawcount)
{ {
mRenderer->markWorkSubmitted();
return rx::MultiDrawArraysInstancedGeneral(this, context, mode, firsts, counts, instanceCounts, return rx::MultiDrawArraysInstancedGeneral(this, context, mode, firsts, counts, instanceCounts,
drawcount); drawcount);
} }
...@@ -733,6 +757,8 @@ angle::Result ContextGL::multiDrawElements(const gl::Context *context, ...@@ -733,6 +757,8 @@ angle::Result ContextGL::multiDrawElements(const gl::Context *context,
const GLvoid *const *indices, const GLvoid *const *indices,
GLsizei drawcount) GLsizei drawcount)
{ {
mRenderer->markWorkSubmitted();
return rx::MultiDrawElementsGeneral(this, context, mode, counts, type, indices, drawcount); return rx::MultiDrawElementsGeneral(this, context, mode, counts, type, indices, drawcount);
} }
...@@ -744,6 +770,8 @@ angle::Result ContextGL::multiDrawElementsInstanced(const gl::Context *context, ...@@ -744,6 +770,8 @@ angle::Result ContextGL::multiDrawElementsInstanced(const gl::Context *context,
const GLsizei *instanceCounts, const GLsizei *instanceCounts,
GLsizei drawcount) GLsizei drawcount)
{ {
mRenderer->markWorkSubmitted();
return rx::MultiDrawElementsInstancedGeneral(this, context, mode, counts, type, indices, return rx::MultiDrawElementsInstancedGeneral(this, context, mode, counts, type, indices,
instanceCounts, drawcount); instanceCounts, drawcount);
} }
...@@ -756,6 +784,8 @@ angle::Result ContextGL::multiDrawArraysInstancedBaseInstance(const gl::Context ...@@ -756,6 +784,8 @@ angle::Result ContextGL::multiDrawArraysInstancedBaseInstance(const gl::Context
const GLuint *baseInstances, const GLuint *baseInstances,
GLsizei drawcount) GLsizei drawcount)
{ {
mRenderer->markWorkSubmitted();
return rx::MultiDrawArraysInstancedBaseInstanceGeneral( return rx::MultiDrawArraysInstancedBaseInstanceGeneral(
this, context, mode, firsts, counts, instanceCounts, baseInstances, drawcount); this, context, mode, firsts, counts, instanceCounts, baseInstances, drawcount);
} }
...@@ -771,6 +801,8 @@ angle::Result ContextGL::multiDrawElementsInstancedBaseVertexBaseInstance( ...@@ -771,6 +801,8 @@ angle::Result ContextGL::multiDrawElementsInstancedBaseVertexBaseInstance(
const GLuint *baseInstances, const GLuint *baseInstances,
GLsizei drawcount) GLsizei drawcount)
{ {
mRenderer->markWorkSubmitted();
return rx::MultiDrawElementsInstancedBaseVertexBaseInstanceGeneral( return rx::MultiDrawElementsInstancedBaseVertexBaseInstanceGeneral(
this, context, mode, counts, type, indices, instanceCounts, baseVertices, baseInstances, this, context, mode, counts, type, indices, instanceCounts, baseVertices, baseInstances,
drawcount); drawcount);
...@@ -942,4 +974,9 @@ void ContextGL::flushIfNecessaryBeforeDeleteTextures() ...@@ -942,4 +974,9 @@ void ContextGL::flushIfNecessaryBeforeDeleteTextures()
mRenderer->flushIfNecessaryBeforeDeleteTextures(); mRenderer->flushIfNecessaryBeforeDeleteTextures();
} }
void ContextGL::markWorkSubmitted()
{
mRenderer->markWorkSubmitted();
}
} // namespace rx } // namespace rx
...@@ -269,6 +269,8 @@ class ContextGL : public ContextImpl ...@@ -269,6 +269,8 @@ class ContextGL : public ContextImpl
void setNeedsFlushBeforeDeleteTextures(); void setNeedsFlushBeforeDeleteTextures();
void flushIfNecessaryBeforeDeleteTextures(); void flushIfNecessaryBeforeDeleteTextures();
void markWorkSubmitted();
const gl::Debug &getDebug() const { return mState.getDebug(); } const gl::Debug &getDebug() const { return mState.getDebug(); }
private: private:
......
...@@ -69,9 +69,11 @@ FenceNVSyncGL::~FenceNVSyncGL() ...@@ -69,9 +69,11 @@ FenceNVSyncGL::~FenceNVSyncGL()
angle::Result FenceNVSyncGL::set(const gl::Context *context, GLenum condition) angle::Result FenceNVSyncGL::set(const gl::Context *context, GLenum condition)
{ {
ASSERT(condition == GL_ALL_COMPLETED_NV); ASSERT(condition == GL_ALL_COMPLETED_NV);
mSyncObject = mFunctions->fenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); ContextGL *contextGL = GetImplAs<ContextGL>(context);
ANGLE_CHECK(GetImplAs<ContextGL>(context), mSyncObject != 0, mSyncObject = mFunctions->fenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
"glFenceSync failed to create a GLsync object.", GL_OUT_OF_MEMORY); ANGLE_CHECK(contextGL, mSyncObject != 0, "glFenceSync failed to create a GLsync object.",
GL_OUT_OF_MEMORY);
contextGL->markWorkSubmitted();
return angle::Result::Continue; return angle::Result::Continue;
} }
......
...@@ -502,6 +502,7 @@ angle::Result FramebufferGL::invalidateSub(const gl::Context *context, ...@@ -502,6 +502,7 @@ angle::Result FramebufferGL::invalidateSub(const gl::Context *context,
angle::Result FramebufferGL::clear(const gl::Context *context, GLbitfield mask) angle::Result FramebufferGL::clear(const gl::Context *context, GLbitfield mask)
{ {
ContextGL *contextGL = GetImplAs<ContextGL>(context);
const FunctionsGL *functions = GetFunctionsGL(context); const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context); StateManagerGL *stateManager = GetStateManagerGL(context);
...@@ -520,6 +521,7 @@ angle::Result FramebufferGL::clear(const gl::Context *context, GLbitfield mask) ...@@ -520,6 +521,7 @@ angle::Result FramebufferGL::clear(const gl::Context *context, GLbitfield mask)
GL_NONE, 0, nullptr, 0.0f, 0); GL_NONE, 0, nullptr, 0.0f, 0);
} }
contextGL->markWorkSubmitted();
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -528,6 +530,7 @@ angle::Result FramebufferGL::clearBufferfv(const gl::Context *context, ...@@ -528,6 +530,7 @@ angle::Result FramebufferGL::clearBufferfv(const gl::Context *context,
GLint drawbuffer, GLint drawbuffer,
const GLfloat *values) const GLfloat *values)
{ {
ContextGL *contextGL = GetImplAs<ContextGL>(context);
const FunctionsGL *functions = GetFunctionsGL(context); const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context); StateManagerGL *stateManager = GetStateManagerGL(context);
...@@ -547,6 +550,7 @@ angle::Result FramebufferGL::clearBufferfv(const gl::Context *context, ...@@ -547,6 +550,7 @@ angle::Result FramebufferGL::clearBufferfv(const gl::Context *context,
reinterpret_cast<const uint8_t *>(values), 0.0f, 0); reinterpret_cast<const uint8_t *>(values), 0.0f, 0);
} }
contextGL->markWorkSubmitted();
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -555,6 +559,7 @@ angle::Result FramebufferGL::clearBufferuiv(const gl::Context *context, ...@@ -555,6 +559,7 @@ angle::Result FramebufferGL::clearBufferuiv(const gl::Context *context,
GLint drawbuffer, GLint drawbuffer,
const GLuint *values) const GLuint *values)
{ {
ContextGL *contextGL = GetImplAs<ContextGL>(context);
const FunctionsGL *functions = GetFunctionsGL(context); const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context); StateManagerGL *stateManager = GetStateManagerGL(context);
...@@ -574,6 +579,7 @@ angle::Result FramebufferGL::clearBufferuiv(const gl::Context *context, ...@@ -574,6 +579,7 @@ angle::Result FramebufferGL::clearBufferuiv(const gl::Context *context,
reinterpret_cast<const uint8_t *>(values), 0.0f, 0); reinterpret_cast<const uint8_t *>(values), 0.0f, 0);
} }
contextGL->markWorkSubmitted();
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -582,6 +588,7 @@ angle::Result FramebufferGL::clearBufferiv(const gl::Context *context, ...@@ -582,6 +588,7 @@ angle::Result FramebufferGL::clearBufferiv(const gl::Context *context,
GLint drawbuffer, GLint drawbuffer,
const GLint *values) const GLint *values)
{ {
ContextGL *contextGL = GetImplAs<ContextGL>(context);
const FunctionsGL *functions = GetFunctionsGL(context); const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context); StateManagerGL *stateManager = GetStateManagerGL(context);
...@@ -601,6 +608,7 @@ angle::Result FramebufferGL::clearBufferiv(const gl::Context *context, ...@@ -601,6 +608,7 @@ angle::Result FramebufferGL::clearBufferiv(const gl::Context *context,
reinterpret_cast<const uint8_t *>(values), 0.0f, 0); reinterpret_cast<const uint8_t *>(values), 0.0f, 0);
} }
contextGL->markWorkSubmitted();
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -610,6 +618,7 @@ angle::Result FramebufferGL::clearBufferfi(const gl::Context *context, ...@@ -610,6 +618,7 @@ angle::Result FramebufferGL::clearBufferfi(const gl::Context *context,
GLfloat depth, GLfloat depth,
GLint stencil) GLint stencil)
{ {
ContextGL *contextGL = GetImplAs<ContextGL>(context);
const FunctionsGL *functions = GetFunctionsGL(context); const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context); StateManagerGL *stateManager = GetStateManagerGL(context);
...@@ -629,6 +638,7 @@ angle::Result FramebufferGL::clearBufferfi(const gl::Context *context, ...@@ -629,6 +638,7 @@ angle::Result FramebufferGL::clearBufferfi(const gl::Context *context,
nullptr, depth, stencil); nullptr, depth, stencil);
} }
contextGL->markWorkSubmitted();
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -733,6 +743,7 @@ angle::Result FramebufferGL::blit(const gl::Context *context, ...@@ -733,6 +743,7 @@ angle::Result FramebufferGL::blit(const gl::Context *context,
GLbitfield mask, GLbitfield mask,
GLenum filter) GLenum filter)
{ {
ContextGL *contextGL = GetImplAs<ContextGL>(context);
const FunctionsGL *functions = GetFunctionsGL(context); const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context); StateManagerGL *stateManager = GetStateManagerGL(context);
const angle::FeaturesGL &features = GetFeaturesGL(context); const angle::FeaturesGL &features = GetFeaturesGL(context);
...@@ -851,6 +862,7 @@ angle::Result FramebufferGL::blit(const gl::Context *context, ...@@ -851,6 +862,7 @@ angle::Result FramebufferGL::blit(const gl::Context *context,
finalSourceArea.y1(), finalDestArea.x, finalDestArea.y, finalSourceArea.y1(), finalDestArea.x, finalDestArea.y,
finalDestArea.x1(), finalDestArea.y1(), blitMask, filter); finalDestArea.x1(), finalDestArea.y1(), blitMask, filter);
contextGL->markWorkSubmitted();
return angle::Result::Continue; return angle::Result::Continue;
} }
......
...@@ -181,6 +181,9 @@ angle::Result StandardQueryGL::resume(const gl::Context *context) ...@@ -181,6 +181,9 @@ angle::Result StandardQueryGL::resume(const gl::Context *context)
mFunctions->genQueries(1, &mActiveQuery); mFunctions->genQueries(1, &mActiveQuery);
mStateManager->beginQuery(mType, this, mActiveQuery); mStateManager->beginQuery(mType, this, mActiveQuery);
ContextGL *contextGL = GetImplAs<ContextGL>(context);
contextGL->markWorkSubmitted();
} }
return angle::Result::Continue; return angle::Result::Continue;
...@@ -239,13 +242,20 @@ class SyncProviderGL ...@@ -239,13 +242,20 @@ class SyncProviderGL
class SyncProviderGLSync : public SyncProviderGL class SyncProviderGLSync : public SyncProviderGL
{ {
public: public:
SyncProviderGLSync(const FunctionsGL *functions) : mFunctions(functions), mSync(nullptr) SyncProviderGLSync(const FunctionsGL *functions) : mFunctions(functions), mSync(nullptr) {}
{
mSync = mFunctions->fenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
}
~SyncProviderGLSync() override { mFunctions->deleteSync(mSync); } ~SyncProviderGLSync() override { mFunctions->deleteSync(mSync); }
angle::Result init(const gl::Context *context, gl::QueryType type) override
{
ContextGL *contextGL = GetImplAs<ContextGL>(context);
mSync = mFunctions->fenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
ANGLE_CHECK(contextGL, mSync != 0, "glFenceSync failed to create a GLsync object.",
GL_OUT_OF_MEMORY);
contextGL->markWorkSubmitted();
return angle::Result::Continue;
}
angle::Result flush(const gl::Context *context, bool force, bool *finished) override angle::Result flush(const gl::Context *context, bool force, bool *finished) override
{ {
if (force) if (force)
...@@ -337,12 +347,12 @@ angle::Result SyncQueryGL::end(const gl::Context *context) ...@@ -337,12 +347,12 @@ angle::Result SyncQueryGL::end(const gl::Context *context)
else if (nativegl::SupportsOcclusionQueries(mFunctions)) else if (nativegl::SupportsOcclusionQueries(mFunctions))
{ {
mSyncProvider.reset(new SyncProviderGLQuery(mFunctions)); mSyncProvider.reset(new SyncProviderGLQuery(mFunctions));
ANGLE_TRY(mSyncProvider->init(context, gl::QueryType::AnySamples));
} }
else else
{ {
ANGLE_GL_UNREACHABLE(GetImplAs<ContextGL>(context)); ANGLE_GL_UNREACHABLE(GetImplAs<ContextGL>(context));
} }
ANGLE_TRY(mSyncProvider->init(context, gl::QueryType::AnySamples));
return angle::Result::Continue; return angle::Result::Continue;
} }
......
...@@ -215,8 +215,14 @@ RendererGL::~RendererGL() ...@@ -215,8 +215,14 @@ RendererGL::~RendererGL()
angle::Result RendererGL::flush() angle::Result RendererGL::flush()
{ {
if (!mWorkDoneSinceLastFlush && !mNeedsFlushBeforeDeleteTextures)
{
return angle::Result::Continue;
}
mFunctions->flush(); mFunctions->flush();
mNeedsFlushBeforeDeleteTextures = false; mNeedsFlushBeforeDeleteTextures = false;
mWorkDoneSinceLastFlush = false;
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -229,6 +235,7 @@ angle::Result RendererGL::finish() ...@@ -229,6 +235,7 @@ angle::Result RendererGL::finish()
mFunctions->finish(); mFunctions->finish();
mNeedsFlushBeforeDeleteTextures = false; mNeedsFlushBeforeDeleteTextures = false;
mWorkDoneSinceLastFlush = false;
if (mFeatures.finishDoesNotCauseQueriesToBeAvailable.enabled && mUseDebugOutput) if (mFeatures.finishDoesNotCauseQueriesToBeAvailable.enabled && mUseDebugOutput)
{ {
...@@ -335,23 +342,27 @@ angle::Result RendererGL::dispatchCompute(const gl::Context *context, ...@@ -335,23 +342,27 @@ angle::Result RendererGL::dispatchCompute(const gl::Context *context,
GLuint numGroupsZ) GLuint numGroupsZ)
{ {
mFunctions->dispatchCompute(numGroupsX, numGroupsY, numGroupsZ); mFunctions->dispatchCompute(numGroupsX, numGroupsY, numGroupsZ);
mWorkDoneSinceLastFlush = true;
return angle::Result::Continue; return angle::Result::Continue;
} }
angle::Result RendererGL::dispatchComputeIndirect(const gl::Context *context, GLintptr indirect) angle::Result RendererGL::dispatchComputeIndirect(const gl::Context *context, GLintptr indirect)
{ {
mFunctions->dispatchComputeIndirect(indirect); mFunctions->dispatchComputeIndirect(indirect);
mWorkDoneSinceLastFlush = true;
return angle::Result::Continue; return angle::Result::Continue;
} }
angle::Result RendererGL::memoryBarrier(GLbitfield barriers) angle::Result RendererGL::memoryBarrier(GLbitfield barriers)
{ {
mFunctions->memoryBarrier(barriers); mFunctions->memoryBarrier(barriers);
mWorkDoneSinceLastFlush = true;
return angle::Result::Continue; return angle::Result::Continue;
} }
angle::Result RendererGL::memoryBarrierByRegion(GLbitfield barriers) angle::Result RendererGL::memoryBarrierByRegion(GLbitfield barriers)
{ {
mFunctions->memoryBarrierByRegion(barriers); mFunctions->memoryBarrierByRegion(barriers);
mWorkDoneSinceLastFlush = true;
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -431,6 +442,11 @@ void RendererGL::setNeedsFlushBeforeDeleteTextures() ...@@ -431,6 +442,11 @@ void RendererGL::setNeedsFlushBeforeDeleteTextures()
mNeedsFlushBeforeDeleteTextures = true; mNeedsFlushBeforeDeleteTextures = true;
} }
void RendererGL::markWorkSubmitted()
{
mWorkDoneSinceLastFlush = true;
}
void RendererGL::flushIfNecessaryBeforeDeleteTextures() void RendererGL::flushIfNecessaryBeforeDeleteTextures()
{ {
if (mNeedsFlushBeforeDeleteTextures) if (mNeedsFlushBeforeDeleteTextures)
......
...@@ -135,6 +135,8 @@ class RendererGL : angle::NonCopyable ...@@ -135,6 +135,8 @@ class RendererGL : angle::NonCopyable
void setNeedsFlushBeforeDeleteTextures(); void setNeedsFlushBeforeDeleteTextures();
void flushIfNecessaryBeforeDeleteTextures(); void flushIfNecessaryBeforeDeleteTextures();
void markWorkSubmitted();
void handleGPUSwitch(); void handleGPUSwitch();
protected: protected:
...@@ -164,6 +166,8 @@ class RendererGL : angle::NonCopyable ...@@ -164,6 +166,8 @@ class RendererGL : angle::NonCopyable
mutable gl::Limitations mNativeLimitations; mutable gl::Limitations mNativeLimitations;
mutable MultiviewImplementationTypeGL mMultiviewImplementationType; mutable MultiviewImplementationTypeGL mMultiviewImplementationType;
bool mWorkDoneSinceLastFlush = false;
// The thread-to-context mapping for the currently active worker threads. // The thread-to-context mapping for the currently active worker threads.
angle::HashMap<std::thread::id, std::unique_ptr<WorkerContext>> mCurrentWorkerContexts; angle::HashMap<std::thread::id, std::unique_ptr<WorkerContext>> mCurrentWorkerContexts;
// The worker contexts available to use. // The worker contexts available to use.
......
...@@ -36,9 +36,11 @@ void SyncGL::onDestroy(const gl::Context *context) ...@@ -36,9 +36,11 @@ void SyncGL::onDestroy(const gl::Context *context)
angle::Result SyncGL::set(const gl::Context *context, GLenum condition, GLbitfield flags) angle::Result SyncGL::set(const gl::Context *context, GLenum condition, GLbitfield flags)
{ {
ASSERT(condition == GL_SYNC_GPU_COMMANDS_COMPLETE && flags == 0); ASSERT(condition == GL_SYNC_GPU_COMMANDS_COMPLETE && flags == 0);
mSyncObject = mFunctions->fenceSync(condition, flags); ContextGL *contextGL = GetImplAs<ContextGL>(context);
ANGLE_CHECK(GetImplAs<ContextGL>(context), mSyncObject != 0, mSyncObject = mFunctions->fenceSync(condition, flags);
"glFenceSync failed to create a GLsync object.", GL_OUT_OF_MEMORY); ANGLE_CHECK(contextGL, mSyncObject != 0, "glFenceSync failed to create a GLsync object.",
GL_OUT_OF_MEMORY);
contextGL->markWorkSubmitted();
return angle::Result::Continue; return angle::Result::Continue;
} }
......
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