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

[core] Reduce number of vertex attributes passed to shaders - #8267

Merged
jfirebaugh merged 1 commit into
masterfrom
fewer-vertex-attrs
Mar 8, 2017
Merged

jfirebaugh merged 1 commit into
masterfrom
fewer-vertex-attrs

Conversation

@mollymerp

@mollymerp mollymerp commented Mar 3, 2017 •

Copy link
Copy Markdown
Contributor

fixes #8183
related gl-js PR: mapbox/mapbox-gl-js#4363

@anandthakker and I worked on this for the past couple days 🤖

cc @jfirebaugh

@mollymerp mollymerp added the Core The cross-platform C++ core, aka mbgl label Mar 3, 2017
@mention-bot

Copy link
Copy Markdown

@mollymerp, thanks for your PR! By analyzing this pull request, we identified @jfirebaugh to be potential reviewers.

@mollymerp mollymerp changed the title Reduce number of vertex attributes passed to shaders [core] Reduce number of vertex attributes passed to shaders Mar 3, 2017
@1ec5 1ec5 added this to the android-v5.0.0 milestone Mar 4, 2017
@1ec5 1ec5 added the release blocker Blocks the next final release label Mar 4, 2017
@anandthakker

anandthakker commented Mar 5, 2017 •

Copy link
Copy Markdown
Contributor

Couple outstanding TODOs:

  • Add some code comments, particularly (a) providing explanation for what "MinMax" is all about, and (b) documenting the rationale and scheme for encoding colors into a pair of floats.
  • Retarget to the release branch.
  • (minor, possibly punt for now) Use c++ template trickery to concatenate these arrays statically rather than with a loop.
  • Avoid using double-sized vectors for source functions (zoom-constant functions)

@jfirebaugh

Copy link
Copy Markdown
Contributor

When source functions are used, this implementation will create vertex buffers that contain both min and max values, when only the min value is used. In other words, the buffers are twice as big as they need to be. We discussed an implementation where the vertex buffer contains only the min value, even though the shader continues to use a vec2.

@anandthakker

Copy link
Copy Markdown
Contributor

Ah, yep @jfirebaugh meant to put that on the todo list -- updated now.

@anandthakker
anandthakker changed the base branch from master to release-ios-v3.5.0-android-v5.0.0 March 8, 2017 13:20
@anandthakker
anandthakker requested a review from jfirebaugh March 8, 2017 16:31
Comment thread src/mbgl/programs/attributes.hpp Outdated

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.

This can return Attr::name() directly.

Comment thread src/mbgl/programs/attributes.hpp Outdated

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.

Nit: whitespace changes.

@anandthakker
anandthakker changed the base branch from release-ios-v3.5.0-android-v5.0.0 to master March 8, 2017 22:12
@anandthakker

Copy link
Copy Markdown
Contributor

Rebased back to master. Because of #8316 -- and the fact that we had multiple commits that modified the shaders, it was easier to first squash to a single commit before rebasing. (The history wasn't especially useful in this case anyway.)

@jfirebaugh
jfirebaugh force-pushed the fewer-vertex-attrs branch from be7a504 to 46d4653 Compare March 8, 2017 22:30
Some devices supported by Mapbox GL provide only 8 vertex attributes; this change packs existing attributes to get us just under that limit.

For properties using a composite function, pack the min and max values into a single attribute with two logical components instead of using two separate attributes and buffers. Special logic is included for color attributes, whose integer components must be packed into the available bits of floating-point attributes. (We don't have access to ivec types in GL ES 2.0.)

For source functions, continue to bind just a one-component attribute even though the GLSL type is vec2 (or vec4 for colors). The type-checking done by gl::Attribute is relaxed slightly to accommodate this.
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 release blocker Blocks the next final release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reduce the number of vertex attributes used for data-driven styling.

5 participants