Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bufferless rendering #6791

Closed
anandthakker opened this issue Jun 9, 2018 · 3 comments
Closed

Bufferless rendering #6791

anandthakker opened this issue Jun 9, 2018 · 3 comments
Labels
cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.) needs discussion 💬 needs investigation 🔍 Issues that require further research (e.g. it's not clear whether it's GL JS or something else) performance ⚡ Speed, stability, CPU usage, memory usage, or power usage refactoring 🏗️

Comments

@anandthakker
Copy link
Contributor

Currently, vector tile buffers are important for rendering in GL because:

  • rendered geometry != source geometry: a feature whose source geometry is located within A may be rendered partially or wholly outside of A's bounds, in some neighboring tile B. For example, a line inside A may have a line-width that extends past the boundary into B.
  • We draw one tile at a time, and for each tile, we only draw the region within that tile's bounds, using the stencil buffer to mask away anything that would fall outside of it. When we draw tile A, the part of the rendered line that bleeds outside of its boundaries is masked away. Thus, when we draw tile B, we must have access to the geometry of that feature from A so that we can draw the portion of it that falls within B's bounds.

This approach also help us avoid the problem of clipping detection, distinguishing "real" vertices from clipping artifacts. If a line that crossed a tile boundary were clipped hard to its edge, we wouldn't know whether to draw a line cap there or not. This problem can be pretty easily solved if we distinguish real vertices and clipping artifacts in VT3, so the focus of this ticket is on the rendered vs. source geometry issue.

Downsides of the current approach:

  • We draw the everything in the tile, including whatever's in the buffer, and then mask away everything in the buffer. This is wasteful.
  • We make one draw call per tile, per layer.
  • Buffers in vector tiles add up to a lot of duplicated data and therefore cost bandwidth, storage (including offline storage on mobile devices), and memory.

The purpose of this ticket is to track the question: can come up with an approach to rendering that doesn't rely on buffers, using [version 3 of the vector tile spec] as an opportunity to introduce any changes that such an approach might require?

cc @kkaefer @ansis @mourner @jfirebaugh

@anandthakker
Copy link
Contributor Author

anandthakker commented Jun 9, 2018

One approach that I think @kkaefer has proposed and that @jfirebaugh and I started investigating recently:

Alter how we divide responsibility between tiles: instead of each tile being responsible for the features that are rendered within its boundaries, each tile would be responsible for the features whose source geometries are located within its boundaries.

This approach has some tricky challenges (dealbreakers?):

Another approach that we've mentioned but not really investigated would be to abandon tile-by-tile layout altogether, which would allow us to reassemble geometries that have been split across tiles... but it's hard to imagine how we could do this with acceptable performance.

@dagjomar
Copy link
Contributor

Is there a hybrid solution possible? Instead of tile-by-tile, is it possible to have performance gains by doing something like combining 4x4 tiles and rendering them as a "single tile" Like a "big virtual" tile?

@mourner mourner added performance ⚡ Speed, stability, CPU usage, memory usage, or power usage needs discussion 💬 refactoring 🏗️ cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.) needs investigation 🔍 Issues that require further research (e.g. it's not clear whether it's GL JS or something else) labels Jun 15, 2018
@mourner
Copy link
Member

mourner commented Mar 1, 2019

Looks like we don't have a way forward with this, at least for the nearest year or two. I'm going to close for now and reopen in future in case a glimmer of hope appears for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.) needs discussion 💬 needs investigation 🔍 Issues that require further research (e.g. it's not clear whether it's GL JS or something else) performance ⚡ Speed, stability, CPU usage, memory usage, or power usage refactoring 🏗️
Projects
None yet
Development

No branches or pull requests

3 participants