Commit 7a38f3f5 by Geoff Lang Committed by Angle LUCI CQ

GL: Skip redundant flushes.

Skip flushes when there is no work submitted since the last flush. Clone of geofflang's: https://chromium-review.googlesource.com/2911879 Bug: chromium:1181068 Change-Id: Idd8a1c61b814d746bf1e0225cfc4ca375a7bb224 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2915675 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent efd8da4d
......@@ -80,6 +80,8 @@ angle::Result BufferGL::setData(const gl::Context *context,
mBufferSize = size;
contextGL->markWorkSubmitted();
return angle::Result::Continue;
}
......@@ -89,6 +91,7 @@ angle::Result BufferGL::setSubData(const gl::Context *context,
size_t size,
size_t offset)
{
ContextGL *contextGL = GetImplAs<ContextGL>(context);
const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context);
const angle::FeaturesGL &features = GetFeaturesGL(context);
......@@ -102,6 +105,8 @@ angle::Result BufferGL::setSubData(const gl::Context *context,
memcpy(mShadowCopy.data() + offset, data, size);
}
contextGL->markWorkSubmitted();
return angle::Result::Continue;
}
......@@ -111,6 +116,7 @@ angle::Result BufferGL::copySubData(const gl::Context *context,
GLintptr destOffset,
GLsizeiptr size)
{
ContextGL *contextGL = GetImplAs<ContextGL>(context);
const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context);
const angle::FeaturesGL &features = GetFeaturesGL(context);
......@@ -130,11 +136,14 @@ angle::Result BufferGL::copySubData(const gl::Context *context,
memcpy(mShadowCopy.data() + destOffset, sourceGL->mShadowCopy.data() + sourceOffset, size);
}
contextGL->markWorkSubmitted();
return angle::Result::Continue;
}
angle::Result BufferGL::map(const gl::Context *context, GLenum access, void **mapPtr)
{
ContextGL *contextGL = GetImplAs<ContextGL>(context);
const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context);
const angle::FeaturesGL &features = GetFeaturesGL(context);
......@@ -162,6 +171,8 @@ angle::Result BufferGL::map(const gl::Context *context, GLenum access, void **ma
mMapOffset = 0;
mMapSize = mBufferSize;
contextGL->markWorkSubmitted();
return angle::Result::Continue;
}
......@@ -171,6 +182,7 @@ angle::Result BufferGL::mapRange(const gl::Context *context,
GLbitfield access,
void **mapPtr)
{
ContextGL *contextGL = GetImplAs<ContextGL>(context);
const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context);
const angle::FeaturesGL &features = GetFeaturesGL(context);
......@@ -191,11 +203,14 @@ angle::Result BufferGL::mapRange(const gl::Context *context,
mMapOffset = offset;
mMapSize = length;
contextGL->markWorkSubmitted();
return angle::Result::Continue;
}
angle::Result BufferGL::unmap(const gl::Context *context, GLboolean *result)
{
ContextGL *contextGL = GetImplAs<ContextGL>(context);
const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context);
const angle::FeaturesGL &features = GetFeaturesGL(context);
......@@ -219,6 +234,9 @@ angle::Result BufferGL::unmap(const gl::Context *context, GLboolean *result)
}
mIsMapped = false;
contextGL->markWorkSubmitted();
return angle::Result::Continue;
}
......@@ -229,6 +247,7 @@ angle::Result BufferGL::getIndexRange(const gl::Context *context,
bool primitiveRestartEnabled,
gl::IndexRange *outRange)
{
ContextGL *contextGL = GetImplAs<ContextGL>(context);
const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context);
const angle::FeaturesGL &features = GetFeaturesGL(context);
......@@ -260,6 +279,8 @@ angle::Result BufferGL::getIndexRange(const gl::Context *context,
}
}
contextGL->markWorkSubmitted();
return angle::Result::Continue;
}
......
......@@ -329,6 +329,8 @@ angle::Result ContextGL::drawArrays(const gl::Context *context,
ANGLE_GL_TRY(context, getFunctions()->drawArraysInstanced(ToGLenum(mode), first, count,
instanceCount));
}
mRenderer->markWorkSubmitted();
return angle::Result::Continue;
}
......@@ -348,6 +350,8 @@ angle::Result ContextGL::drawArraysInstanced(const gl::Context *context,
ANGLE_TRY(setDrawArraysState(context, first, count, adjustedInstanceCount));
ANGLE_GL_TRY(context, getFunctions()->drawArraysInstanced(ToGLenum(mode), first, count,
adjustedInstanceCount));
mRenderer->markWorkSubmitted();
return angle::Result::Continue;
}
......@@ -469,6 +473,8 @@ angle::Result ContextGL::drawArraysInstancedBaseInstance(const gl::Context *cont
resetUpdatedAttributes(attribToResetMask);
}
mRenderer->markWorkSubmitted();
return angle::Result::Continue;
}
......@@ -500,6 +506,8 @@ angle::Result ContextGL::drawElements(const gl::Context *context,
getFunctions()->drawElementsInstanced(ToGLenum(mode), count, ToGLenum(type),
drawIndexPtr, instanceCount));
}
mRenderer->markWorkSubmitted();
return angle::Result::Continue;
}
......@@ -532,6 +540,8 @@ angle::Result ContextGL::drawElementsBaseVertex(const gl::Context *context,
ToGLenum(mode), count, ToGLenum(type), drawIndexPtr,
instanceCount, baseVertex));
}
mRenderer->markWorkSubmitted();
return angle::Result::Continue;
}
......@@ -579,6 +589,8 @@ angle::Result ContextGL::drawElementsInstancedBaseVertex(const gl::Context *cont
ANGLE_GL_TRY(context, getFunctions()->drawElementsInstancedBaseVertex(
ToGLenum(mode), count, ToGLenum(type), drawIndexPointer,
adjustedInstanceCount, baseVertex));
mRenderer->markWorkSubmitted();
return angle::Result::Continue;
}
......@@ -625,6 +637,8 @@ angle::Result ContextGL::drawElementsInstancedBaseVertexBaseInstance(const gl::C
resetUpdatedAttributes(attribToResetMask);
}
mRenderer->markWorkSubmitted();
return angle::Result::Continue;
}
......@@ -654,6 +668,8 @@ angle::Result ContextGL::drawRangeElements(const gl::Context *context,
getFunctions()->drawElementsInstanced(ToGLenum(mode), count, ToGLenum(type),
drawIndexPointer, instanceCount));
}
mRenderer->markWorkSubmitted();
return angle::Result::Continue;
}
......@@ -685,6 +701,8 @@ angle::Result ContextGL::drawRangeElementsBaseVertex(const gl::Context *context,
ToGLenum(mode), count, ToGLenum(type), drawIndexPointer,
instanceCount, baseVertex));
}
mRenderer->markWorkSubmitted();
return angle::Result::Continue;
}
......@@ -693,6 +711,8 @@ angle::Result ContextGL::drawArraysIndirect(const gl::Context *context,
const void *indirect)
{
ANGLE_GL_TRY(context, getFunctions()->drawArraysIndirect(ToGLenum(mode), indirect));
mRenderer->markWorkSubmitted();
return angle::Result::Continue;
}
......@@ -712,6 +732,8 @@ angle::Result ContextGL::multiDrawArrays(const gl::Context *context,
const GLsizei *counts,
GLsizei drawcount)
{
mRenderer->markWorkSubmitted();
return rx::MultiDrawArraysGeneral(this, context, mode, firsts, counts, drawcount);
}
......@@ -722,6 +744,8 @@ angle::Result ContextGL::multiDrawArraysInstanced(const gl::Context *context,
const GLsizei *instanceCounts,
GLsizei drawcount)
{
mRenderer->markWorkSubmitted();
return rx::MultiDrawArraysInstancedGeneral(this, context, mode, firsts, counts, instanceCounts,
drawcount);
}
......@@ -733,6 +757,8 @@ angle::Result ContextGL::multiDrawElements(const gl::Context *context,
const GLvoid *const *indices,
GLsizei drawcount)
{
mRenderer->markWorkSubmitted();
return rx::MultiDrawElementsGeneral(this, context, mode, counts, type, indices, drawcount);
}
......@@ -744,6 +770,8 @@ angle::Result ContextGL::multiDrawElementsInstanced(const gl::Context *context,
const GLsizei *instanceCounts,
GLsizei drawcount)
{
mRenderer->markWorkSubmitted();
return rx::MultiDrawElementsInstancedGeneral(this, context, mode, counts, type, indices,
instanceCounts, drawcount);
}
......@@ -756,6 +784,8 @@ angle::Result ContextGL::multiDrawArraysInstancedBaseInstance(const gl::Context
const GLuint *baseInstances,
GLsizei drawcount)
{
mRenderer->markWorkSubmitted();
return rx::MultiDrawArraysInstancedBaseInstanceGeneral(
this, context, mode, firsts, counts, instanceCounts, baseInstances, drawcount);
}
......@@ -771,6 +801,8 @@ angle::Result ContextGL::multiDrawElementsInstancedBaseVertexBaseInstance(
const GLuint *baseInstances,
GLsizei drawcount)
{
mRenderer->markWorkSubmitted();
return rx::MultiDrawElementsInstancedBaseVertexBaseInstanceGeneral(
this, context, mode, counts, type, indices, instanceCounts, baseVertices, baseInstances,
drawcount);
......@@ -942,4 +974,9 @@ void ContextGL::flushIfNecessaryBeforeDeleteTextures()
mRenderer->flushIfNecessaryBeforeDeleteTextures();
}
void ContextGL::markWorkSubmitted()
{
mRenderer->markWorkSubmitted();
}
} // namespace rx
......@@ -269,6 +269,8 @@ class ContextGL : public ContextImpl
void setNeedsFlushBeforeDeleteTextures();
void flushIfNecessaryBeforeDeleteTextures();
void markWorkSubmitted();
private:
angle::Result setDrawArraysState(const gl::Context *context,
GLint first,
......
......@@ -39,6 +39,8 @@
#include "libANGLE/renderer/gl/renderergl_utils.h"
#include "libANGLE/renderer/renderer_utils.h"
#include <iostream>
namespace
{
......@@ -215,8 +217,14 @@ RendererGL::~RendererGL()
angle::Result RendererGL::flush()
{
if (!mWorkDoneSinceLastFlush && !mNeedsFlushBeforeDeleteTextures)
{
return angle::Result::Continue;
}
mFunctions->flush();
mNeedsFlushBeforeDeleteTextures = false;
mWorkDoneSinceLastFlush = false;
return angle::Result::Continue;
}
......@@ -229,6 +237,7 @@ angle::Result RendererGL::finish()
mFunctions->finish();
mNeedsFlushBeforeDeleteTextures = false;
mWorkDoneSinceLastFlush = false;
if (mFeatures.finishDoesNotCauseQueriesToBeAvailable.enabled && mUseDebugOutput)
{
......@@ -335,23 +344,27 @@ angle::Result RendererGL::dispatchCompute(const gl::Context *context,
GLuint numGroupsZ)
{
mFunctions->dispatchCompute(numGroupsX, numGroupsY, numGroupsZ);
mWorkDoneSinceLastFlush = true;
return angle::Result::Continue;
}
angle::Result RendererGL::dispatchComputeIndirect(const gl::Context *context, GLintptr indirect)
{
mFunctions->dispatchComputeIndirect(indirect);
mWorkDoneSinceLastFlush = true;
return angle::Result::Continue;
}
angle::Result RendererGL::memoryBarrier(GLbitfield barriers)
{
mFunctions->memoryBarrier(barriers);
mWorkDoneSinceLastFlush = true;
return angle::Result::Continue;
}
angle::Result RendererGL::memoryBarrierByRegion(GLbitfield barriers)
{
mFunctions->memoryBarrierByRegion(barriers);
mWorkDoneSinceLastFlush = true;
return angle::Result::Continue;
}
......@@ -431,6 +444,11 @@ void RendererGL::setNeedsFlushBeforeDeleteTextures()
mNeedsFlushBeforeDeleteTextures = true;
}
void RendererGL::markWorkSubmitted()
{
mWorkDoneSinceLastFlush = true;
}
void RendererGL::flushIfNecessaryBeforeDeleteTextures()
{
if (mNeedsFlushBeforeDeleteTextures)
......
......@@ -135,6 +135,8 @@ class RendererGL : angle::NonCopyable
void setNeedsFlushBeforeDeleteTextures();
void flushIfNecessaryBeforeDeleteTextures();
void markWorkSubmitted();
void handleGPUSwitch();
protected:
......@@ -164,6 +166,8 @@ class RendererGL : angle::NonCopyable
mutable gl::Limitations mNativeLimitations;
mutable MultiviewImplementationTypeGL mMultiviewImplementationType;
bool mWorkDoneSinceLastFlush = false;
// The thread-to-context mapping for the currently active worker threads.
angle::HashMap<std::thread::id, std::unique_ptr<WorkerContext>> mCurrentWorkerContexts;
// The worker contexts available to use.
......
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