Skip to content

Commit

Permalink
Minor inlining optimization to Context draw calls.
Browse files Browse the repository at this point in the history
Reduces draw call overhead by up to 3%.

Bug: angleproject:2966
Change-Id: Ie7ddb61b905fefe59a06a1528f0a3fde4accaf74
Reviewed-on: https://chromium-review.googlesource.com/c/1333608
Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
  • Loading branch information
null77 authored and Commit Bot committed Nov 15, 2018
1 parent 3e92206 commit d9ee8bf
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 27 deletions.
45 changes: 22 additions & 23 deletions src/libANGLE/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3523,6 +3523,27 @@ bool Context::noopDrawInstanced(PrimitiveMode mode, GLsizei count, GLsizei insta
return (instanceCount == 0) || noopDraw(mode, count);
}

ANGLE_INLINE angle::Result Context::syncDirtyBits()
{
const State::DirtyBits &dirtyBits = mGLState.getDirtyBits();
ANGLE_TRY(mImplementation->syncState(this, dirtyBits, mAllDirtyBits));
mGLState.clearDirtyBits();
return angle::Result::Continue();
}

ANGLE_INLINE angle::Result Context::syncDirtyBits(const State::DirtyBits &bitMask)
{
const State::DirtyBits &dirtyBits = (mGLState.getDirtyBits() & bitMask);
ANGLE_TRY(mImplementation->syncState(this, dirtyBits, bitMask));
mGLState.clearDirtyBits(dirtyBits);
return angle::Result::Continue();
}

ANGLE_INLINE angle::Result Context::syncDirtyObjects(const State::DirtyObjects &objectMask)
{
return mGLState.syncDirtyObjects(this, objectMask);
}

angle::Result Context::prepareForDraw(PrimitiveMode mode)
{
if (mGLES1Renderer)
Expand All @@ -3538,8 +3559,7 @@ angle::Result Context::prepareForDraw(PrimitiveMode mode)
ANGLE_TRY(mGLState.getDrawFramebuffer()->ensureDrawAttachmentsInitialized(this));
}

ANGLE_TRY(syncDirtyBits());
return angle::Result::Continue();
return syncDirtyBits();
}

Error Context::prepareForClear(GLbitfield mask)
Expand All @@ -3566,27 +3586,6 @@ Error Context::syncState(const State::DirtyBits &bitMask, const State::DirtyObje
return NoError();
}

angle::Result Context::syncDirtyBits()
{
const State::DirtyBits &dirtyBits = mGLState.getDirtyBits();
ANGLE_TRY(mImplementation->syncState(this, dirtyBits, mAllDirtyBits));
mGLState.clearDirtyBits();
return angle::Result::Continue();
}

angle::Result Context::syncDirtyBits(const State::DirtyBits &bitMask)
{
const State::DirtyBits &dirtyBits = (mGLState.getDirtyBits() & bitMask);
ANGLE_TRY(mImplementation->syncState(this, dirtyBits, bitMask));
mGLState.clearDirtyBits(dirtyBits);
return angle::Result::Continue();
}

angle::Result Context::syncDirtyObjects(const State::DirtyObjects &objectMask)
{
return mGLState.syncDirtyObjects(this, objectMask);
}

void Context::blitFramebuffer(GLint srcX0,
GLint srcY0,
GLint srcX1,
Expand Down
6 changes: 3 additions & 3 deletions src/libANGLE/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2774,10 +2774,10 @@ void State::getBooleani_v(GLenum target, GLuint index, GLboolean *data)
}
}

angle::Result State::syncDirtyObjects(const Context *context, const DirtyObjects &bitset)
angle::Result State::syncDirtyObjectsImpl(const Context *context, const DirtyObjects &dirtyObjects)
{
const DirtyObjects &dirtyObjects = mDirtyObjects & bitset;
for (auto dirtyObject : dirtyObjects)
ASSERT(dirtyObjects.any());
for (size_t dirtyObject : dirtyObjects)
{
switch (dirtyObject)
{
Expand Down
16 changes: 15 additions & 1 deletion src/libANGLE/State.h
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,20 @@ class State : angle::NonCopyable
using DirtyObjects = angle::BitSet<DIRTY_OBJECT_MAX>;
void clearDirtyObjects() { mDirtyObjects.reset(); }
void setAllDirtyObjects() { mDirtyObjects.set(); }
angle::Result syncDirtyObjects(const Context *context, const DirtyObjects &bitset);

ANGLE_INLINE angle::Result syncDirtyObjects(const Context *context, const DirtyObjects &bitset)
{
const DirtyObjects &dirtyObjects = mDirtyObjects & bitset;
if (dirtyObjects.any())
{
return syncDirtyObjectsImpl(context, dirtyObjects);
}
else
{
return angle::Result::Continue();
}
}

angle::Result syncDirtyObject(const Context *context, GLenum target);
void setObjectDirty(GLenum target);
void setSamplerDirty(size_t samplerIndex);
Expand Down Expand Up @@ -537,6 +550,7 @@ class State : angle::NonCopyable
angle::Result updateActiveTexture(const Context *context,
size_t textureIndex,
Texture *texture);
angle::Result syncDirtyObjectsImpl(const Context *context, const DirtyObjects &dirtyObjects);

// Dispatch table for buffer update functions.
static const angle::PackedEnumMap<BufferBinding, BufferBindingSetter> kBufferSetters;
Expand Down

0 comments on commit d9ee8bf

Please sign in to comment.