Commit 337bd698 by Shahbaz Youssefi Committed by Commit Bot

Disable vertex attributes if not active in program

Even if explicitly enabled. Bug: angleproject:2138 Change-Id: I598d21296bb6843e05cdeab146c1ff3da3a1174b Reviewed-on: https://chromium-review.googlesource.com/1185743Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent dc248f71
...@@ -310,8 +310,12 @@ void VertexArray::enableAttribute(size_t attribIndex, bool enabledState) ...@@ -310,8 +310,12 @@ void VertexArray::enableAttribute(size_t attribIndex, bool enabledState)
VertexAttribute &attrib = mState.mVertexAttributes[attribIndex]; VertexAttribute &attrib = mState.mVertexAttributes[attribIndex];
if (mState.mEnabledAttributesMask.test(attribIndex) == enabledState)
{
return;
}
attrib.enabled = enabledState; attrib.enabled = enabledState;
mState.mVertexAttributesTypeMask.setIndex(GetVertexAttributeBaseType(attrib), attribIndex);
setDirtyAttribBit(attribIndex, DIRTY_ATTRIB_ENABLED); setDirtyAttribBit(attribIndex, DIRTY_ATTRIB_ENABLED);
......
...@@ -1945,8 +1945,8 @@ void StateManagerGL::syncState(const gl::Context *context, const gl::State::Dirt ...@@ -1945,8 +1945,8 @@ void StateManagerGL::syncState(const gl::Context *context, const gl::State::Dirt
const VertexArrayGL *vaoGL = GetImplAs<VertexArrayGL>(state.getVertexArray()); const VertexArrayGL *vaoGL = GetImplAs<VertexArrayGL>(state.getVertexArray());
bindVertexArray(vaoGL->getVertexArrayID(), vaoGL->getAppliedElementArrayBufferID()); bindVertexArray(vaoGL->getVertexArrayID(), vaoGL->getAppliedElementArrayBufferID());
propagateNumViewsToVAO(state.getProgram(), propagateProgramToVAO(state.getProgram(),
GetImplAs<VertexArrayGL>(state.getVertexArray())); GetImplAs<VertexArrayGL>(state.getVertexArray()));
break; break;
} }
case gl::State::DIRTY_BIT_DRAW_INDIRECT_BUFFER_BINDING: case gl::State::DIRTY_BIT_DRAW_INDIRECT_BUFFER_BINDING:
...@@ -1978,8 +1978,8 @@ void StateManagerGL::syncState(const gl::Context *context, const gl::State::Dirt ...@@ -1978,8 +1978,8 @@ void StateManagerGL::syncState(const gl::Context *context, const gl::State::Dirt
case gl::State::DIRTY_BIT_PROGRAM_EXECUTABLE: case gl::State::DIRTY_BIT_PROGRAM_EXECUTABLE:
mProgramTexturesAndSamplersDirty = true; mProgramTexturesAndSamplersDirty = true;
mProgramStorageBuffersDirty = true; mProgramStorageBuffersDirty = true;
propagateNumViewsToVAO(state.getProgram(), propagateProgramToVAO(state.getProgram(),
GetImplAs<VertexArrayGL>(state.getVertexArray())); GetImplAs<VertexArrayGL>(state.getVertexArray()));
updateMultiviewBaseViewLayerIndexUniform( updateMultiviewBaseViewLayerIndexUniform(
state.getProgram(), state.getProgram(),
state.getDrawFramebuffer()->getImplementation()->getState()); state.getDrawFramebuffer()->getImplementation()->getState());
...@@ -2238,9 +2238,15 @@ void StateManagerGL::applyViewportOffsetsAndSetViewports(const gl::Rectangle &vi ...@@ -2238,9 +2238,15 @@ void StateManagerGL::applyViewportOffsetsAndSetViewports(const gl::Rectangle &vi
setViewportArrayv(0u, viewportArray); setViewportArrayv(0u, viewportArray);
} }
void StateManagerGL::propagateNumViewsToVAO(const gl::Program *program, VertexArrayGL *vao) void StateManagerGL::propagateProgramToVAO(const gl::Program *program, VertexArrayGL *vao)
{ {
if (mIsMultiviewEnabled && vao != nullptr) if (vao == nullptr)
{
return;
}
// Number of views:
if (mIsMultiviewEnabled)
{ {
int programNumViews = 1; int programNumViews = 1;
if (program && program->usesMultiview()) if (program && program->usesMultiview())
...@@ -2249,6 +2255,12 @@ void StateManagerGL::propagateNumViewsToVAO(const gl::Program *program, VertexAr ...@@ -2249,6 +2255,12 @@ void StateManagerGL::propagateNumViewsToVAO(const gl::Program *program, VertexAr
} }
vao->applyNumViewsToDivisor(programNumViews); vao->applyNumViewsToDivisor(programNumViews);
} }
// Attribute enabled mask:
if (program)
{
vao->applyActiveAttribLocationsMask(program->getActiveAttribLocationsMask());
}
} }
void StateManagerGL::updateMultiviewBaseViewLayerIndexUniform( void StateManagerGL::updateMultiviewBaseViewLayerIndexUniform(
......
...@@ -193,7 +193,7 @@ class StateManagerGL final : angle::NonCopyable ...@@ -193,7 +193,7 @@ class StateManagerGL final : angle::NonCopyable
const gl::Framebuffer &drawFramebuffer); const gl::Framebuffer &drawFramebuffer);
void applyViewportOffsetsAndSetViewports(const gl::Rectangle &viewport, void applyViewportOffsetsAndSetViewports(const gl::Rectangle &viewport,
const gl::Framebuffer &drawFramebuffer); const gl::Framebuffer &drawFramebuffer);
void propagateNumViewsToVAO(const gl::Program *program, VertexArrayGL *vao); void propagateProgramToVAO(const gl::Program *program, VertexArrayGL *vao);
void updateProgramTextureAndSamplerBindings(const gl::Context *context); void updateProgramTextureAndSamplerBindings(const gl::Context *context);
void updateProgramStorageBufferBindings(const gl::Context *context); void updateProgramStorageBufferBindings(const gl::Context *context);
......
...@@ -417,7 +417,8 @@ GLuint VertexArrayGL::getAppliedElementArrayBufferID() const ...@@ -417,7 +417,8 @@ GLuint VertexArrayGL::getAppliedElementArrayBufferID() const
void VertexArrayGL::updateAttribEnabled(size_t attribIndex) void VertexArrayGL::updateAttribEnabled(size_t attribIndex)
{ {
const bool enabled = mState.getVertexAttribute(attribIndex).enabled; const bool enabled = mState.getVertexAttribute(attribIndex).enabled &
mProgramActiveAttribLocationsMask.test(attribIndex);
if (mAppliedAttributes[attribIndex].enabled == enabled) if (mAppliedAttributes[attribIndex].enabled == enabled)
{ {
return; return;
...@@ -731,4 +732,15 @@ void VertexArrayGL::applyNumViewsToDivisor(int numViews) ...@@ -731,4 +732,15 @@ void VertexArrayGL::applyNumViewsToDivisor(int numViews)
} }
} }
void VertexArrayGL::applyActiveAttribLocationsMask(const gl::AttributesMask &activeMask)
{
gl::AttributesMask updateMask = mProgramActiveAttribLocationsMask ^ activeMask;
mProgramActiveAttribLocationsMask = activeMask;
for (size_t attribIndex : updateMask)
{
updateAttribEnabled(attribIndex);
}
}
} // namespace rx } // namespace rx
...@@ -50,6 +50,7 @@ class VertexArrayGL : public VertexArrayImpl ...@@ -50,6 +50,7 @@ class VertexArrayGL : public VertexArrayImpl
const gl::VertexArray::DirtyBindingBitsArray &bindingBits) override; const gl::VertexArray::DirtyBindingBitsArray &bindingBits) override;
void applyNumViewsToDivisor(int numViews); void applyNumViewsToDivisor(int numViews);
void applyActiveAttribLocationsMask(const gl::AttributesMask &activeMask);
private: private:
gl::Error syncDrawState(const gl::Context *context, gl::Error syncDrawState(const gl::Context *context,
...@@ -115,6 +116,10 @@ class VertexArrayGL : public VertexArrayImpl ...@@ -115,6 +116,10 @@ class VertexArrayGL : public VertexArrayImpl
GLuint mVertexArrayID; GLuint mVertexArrayID;
int mAppliedNumViews; int mAppliedNumViews;
// Remember the program's active attrib location mask so that attributes can be enabled/disabled
// based on whether they are active in the program
gl::AttributesMask mProgramActiveAttribLocationsMask;
mutable gl::BindingPointer<gl::Buffer> mAppliedElementArrayBuffer; mutable gl::BindingPointer<gl::Buffer> mAppliedElementArrayBuffer;
mutable std::vector<gl::VertexAttribute> mAppliedAttributes; mutable std::vector<gl::VertexAttribute> mAppliedAttributes;
......
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