Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Store vertex attribute binding to prevent duplicate binds#9181

Merged
kkaefer merged 1 commit into
masterfrom
dont-rebind-vertex-arrays
Jun 13, 2017
Merged

Store vertex attribute binding to prevent duplicate binds#9181
kkaefer merged 1 commit into
masterfrom
dont-rebind-vertex-arrays

Conversation

@kkaefer
Copy link
Copy Markdown
Member

@kkaefer kkaefer commented Jun 4, 2017

We have an oldBinding value that we use for checking whether the vertex attribute was already
bound to the current VAO, but we never set the state. Additionally, we're also checking whether
the previous state was already any binding (optional is set), and don't re-enable the vertex
attribute array. Additionally, we now only disable the vertex attribute array when the previous
state was in fact an array attribute. We still don't deduplicate constant glVertexAttrib* calls,
but that's a little trickier.

@kkaefer kkaefer requested a review from jfirebaugh June 4, 2017 00:54
@kkaefer kkaefer added Core The cross-platform C++ core, aka mbgl performance Speed, stability, CPU usage, memory usage, or power usage labels Jun 4, 2017
Comment thread src/mbgl/gl/attribute.cpp Outdated
if (oldBinding) {
MBGL_CHECK_ERROR(glDisableVertexAttribArray(location));
oldBinding = {};
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails when we're not using VAOs. In that case, we're resetting the binding for every segment we're drawing to force a rebind, so oldBinding will always be empty and we may fail to disable the vertex attribute array for a certain location.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, so revert all of these changes, leaving only the oldBinding = *this; change?

We have an "oldBinding" value that we use for checking whether the vertex attribute was already
bound to the current VAO, but we never set the state. Additionally, we're also checking whether
the previous state was already any binding (optional is set), and don't re-enable the vertex
attribute array. Additionally, we now only disable the vertex attribute array when the previous
state was in fact an array attribute. We still don't deduplicate constant glVertexAttrib* calls,
but that's a little trickier.
@kkaefer kkaefer force-pushed the dont-rebind-vertex-arrays branch from 96b30a0 to 2a5879e Compare June 13, 2017 09:27
@kkaefer
Copy link
Copy Markdown
Member Author

kkaefer commented Jun 13, 2017

Ready for review

@kkaefer kkaefer merged commit 9a05eba into master Jun 13, 2017
@jfirebaugh jfirebaugh deleted the dont-rebind-vertex-arrays branch June 23, 2017 14:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Core The cross-platform C++ core, aka mbgl performance Speed, stability, CPU usage, memory usage, or power usage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants