Commit 2dadd1d0 by Jamie Madill Committed by Commit Bot

D3D11: Fix inactive attrib VAO perf regression.

In the case there are any dirty inactive attributes, we were continually invalidating the Vertex Buffer and Input Layout bindings. This fixes the invalidation to only happen when there are any dirty active attributes. This regressed in "Move Buffer Subject/Observer to front end." Bug: chromium:829906 Bug: angleproject:2389 Change-Id: I8ed616bb696e0be548344192037ad6cc6f9c595c Reviewed-on: https://chromium-review.googlesource.com/1006998Reviewed-by: 's avatarLuc Ferron <lucferron@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent c4f27e4b
...@@ -109,21 +109,35 @@ gl::Error VertexArray11::syncStateForDraw(const gl::Context *context, ...@@ -109,21 +109,35 @@ gl::Error VertexArray11::syncStateForDraw(const gl::Context *context,
Renderer11 *renderer = GetImplAs<Context11>(context)->getRenderer(); Renderer11 *renderer = GetImplAs<Context11>(context)->getRenderer();
StateManager11 *stateManager = renderer->getStateManager(); StateManager11 *stateManager = renderer->getStateManager();
const gl::Program *program = context->getGLState().getProgram(); const gl::State &glState = context->getGLState();
const gl::Program *program = glState.getProgram();
ASSERT(program); ASSERT(program);
mAppliedNumViewsToDivisor = (program->usesMultiview() ? program->getNumViews() : 1); mAppliedNumViewsToDivisor = (program->usesMultiview() ? program->getNumViews() : 1);
if (mAttribsToTranslate.any()) if (mAttribsToTranslate.any())
{ {
ANGLE_TRY(updateDirtyAttribs(context)); const gl::AttributesMask &activeLocations =
stateManager->invalidateInputLayout(); glState.getProgram()->getActiveAttribLocationsMask();
gl::AttributesMask activeDirtyAttribs = (mAttribsToTranslate & activeLocations);
if (activeDirtyAttribs.any())
{
ANGLE_TRY(updateDirtyAttribs(context, activeDirtyAttribs));
stateManager->invalidateInputLayout();
}
} }
if (mDynamicAttribsMask.any()) if (mDynamicAttribsMask.any())
{ {
ANGLE_TRY( const gl::AttributesMask &activeLocations =
updateDynamicAttribs(context, stateManager->getVertexDataManager(), drawCallParams)); glState.getProgram()->getActiveAttribLocationsMask();
stateManager->invalidateInputLayout(); gl::AttributesMask activeDynamicAttribs = (mDynamicAttribsMask & activeLocations);
if (activeDynamicAttribs.any())
{
ANGLE_TRY(updateDynamicAttribs(context, stateManager->getVertexDataManager(),
drawCallParams, activeDynamicAttribs));
stateManager->invalidateInputLayout();
}
} }
if (drawCallParams.isDrawElements()) if (drawCallParams.isDrawElements())
...@@ -210,17 +224,14 @@ bool VertexArray11::hasActiveDynamicAttrib(const gl::Context *context) ...@@ -210,17 +224,14 @@ bool VertexArray11::hasActiveDynamicAttrib(const gl::Context *context)
return activeDynamicAttribs.any(); return activeDynamicAttribs.any();
} }
gl::Error VertexArray11::updateDirtyAttribs(const gl::Context *context) gl::Error VertexArray11::updateDirtyAttribs(const gl::Context *context,
const gl::AttributesMask &activeDirtyAttribs)
{ {
const auto &glState = context->getGLState(); const auto &glState = context->getGLState();
const auto &activeLocations = glState.getProgram()->getActiveAttribLocationsMask(); const auto &attribs = mState.getVertexAttributes();
const auto &attribs = mState.getVertexAttributes(); const auto &bindings = mState.getVertexBindings();
const auto &bindings = mState.getVertexBindings();
// Skip attrib locations the program doesn't use, saving for the next frame. for (size_t dirtyAttribIndex : activeDirtyAttribs)
gl::AttributesMask dirtyActiveAttribs = (mAttribsToTranslate & activeLocations);
for (size_t dirtyAttribIndex : dirtyActiveAttribs)
{ {
mAttribsToTranslate.reset(dirtyAttribIndex); mAttribsToTranslate.reset(dirtyAttribIndex);
...@@ -258,21 +269,15 @@ gl::Error VertexArray11::updateDirtyAttribs(const gl::Context *context) ...@@ -258,21 +269,15 @@ gl::Error VertexArray11::updateDirtyAttribs(const gl::Context *context)
gl::Error VertexArray11::updateDynamicAttribs(const gl::Context *context, gl::Error VertexArray11::updateDynamicAttribs(const gl::Context *context,
VertexDataManager *vertexDataManager, VertexDataManager *vertexDataManager,
const gl::DrawCallParams &drawCallParams) const gl::DrawCallParams &drawCallParams,
const gl::AttributesMask &activeDynamicAttribs)
{ {
const auto &glState = context->getGLState(); const auto &glState = context->getGLState();
const auto &activeLocations = glState.getProgram()->getActiveAttribLocationsMask(); const auto &attribs = mState.getVertexAttributes();
const auto &attribs = mState.getVertexAttributes(); const auto &bindings = mState.getVertexBindings();
const auto &bindings = mState.getVertexBindings();
ANGLE_TRY(drawCallParams.ensureIndexRangeResolved(context)); ANGLE_TRY(drawCallParams.ensureIndexRangeResolved(context));
auto activeDynamicAttribs = (mDynamicAttribsMask & activeLocations);
if (activeDynamicAttribs.none())
{
return gl::NoError();
}
for (size_t dynamicAttribIndex : activeDynamicAttribs) for (size_t dynamicAttribIndex : activeDynamicAttribs)
{ {
auto *dynamicAttrib = &mTranslatedAttribs[dynamicAttribIndex]; auto *dynamicAttrib = &mTranslatedAttribs[dynamicAttribIndex];
......
...@@ -62,10 +62,12 @@ class VertexArray11 : public VertexArrayImpl ...@@ -62,10 +62,12 @@ class VertexArray11 : public VertexArrayImpl
void updateVertexAttribStorage(StateManager11 *stateManager, void updateVertexAttribStorage(StateManager11 *stateManager,
size_t dirtyBit, size_t dirtyBit,
size_t attribIndex); size_t attribIndex);
gl::Error updateDirtyAttribs(const gl::Context *context); gl::Error updateDirtyAttribs(const gl::Context *context,
const gl::AttributesMask &activeDirtyAttribs);
gl::Error updateDynamicAttribs(const gl::Context *context, gl::Error updateDynamicAttribs(const gl::Context *context,
VertexDataManager *vertexDataManager, VertexDataManager *vertexDataManager,
const gl::DrawCallParams &drawCallParams); const gl::DrawCallParams &drawCallParams,
const gl::AttributesMask &activeDynamicAttribs);
std::vector<VertexStorageType> mAttributeStorageTypes; std::vector<VertexStorageType> mAttributeStorageTypes;
std::vector<TranslatedAttribute> mTranslatedAttribs; std::vector<TranslatedAttribute> mTranslatedAttribs;
......
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