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

Use ANGLE_instanced_arrays extension to reduce buffer sizes for layers with property functions #1898

Open
mourner opened this issue Jan 6, 2016 · 4 comments
Labels
performance ⚡ Speed, stability, CPU usage, memory usage, or power usage

Comments

@mourner
Copy link
Member

mourner commented Jan 6, 2016

https://www.khronos.org/registry/webgl/extensions/ANGLE_instanced_arrays/

According to this presentation about WebGL2, this feature (available for WebGL 1.0 as extension) can lead to significant performance gains. Interesting bit:

Google Maps uses and requires instancing support — Reduces vertex buffer size by 6x (!)

The concept is:

To draw 1000 soldiers
1000 draw calls, with different position, posture, etc
Or, with instancing, only 1 draw call
Big perf improvement

cc @ansis @kkaefer @jfirebaugh @lucaswoj what do you think? Can we use it?

Also related: #1361 (mentioned in the slides as a notable perf feature too)

@mourner mourner added the performance ⚡ Speed, stability, CPU usage, memory usage, or power usage label Jan 6, 2016
@lucaswoj
Copy link
Contributor

lucaswoj commented Jan 7, 2016

If you are fill-rate bound or vertex-bound then instancing won't solve your problems. But if your seeing your app get hung up on making lots of draw calls while your GPU spins it's wheels waiting for Javascript to catch up, this is the API for you!

My impression is that it'd be worth prototyping and benchmarking a ANGLE_instanced_arrays-based rendering path for symbols, as they are nearly identical geometries, drawn multiple times, with multiple render calls.

I'm not clear if there's a way we could use this API to reduce the # of WebGL API calls for any other layer types.

@lucaswoj
Copy link
Contributor

lucaswoj commented Jan 7, 2016

I wonder how exactly Google Maps uses this feature...

@ansis
Copy link
Contributor

ansis commented Jan 7, 2016

It could be very useful for reducing buffer sizes for data driven styling.

For example, if you had per-feature colours you could using instancing to store the colors per-triangle instead of per-vertex and use 1/3 the space. (I think you could potentially save even more space by making an instance 2 triangles and adding degenerate triangles to polygons with an odd number)

According to webglstats.com support is around 90% in browsers. I think all iOS devices support it. It's an extension on Android but it's hard to get stats on how well it's supported. If we use it we'd have to accept supporting less devices (what % less?) OR having two separate paths/a polyfill (how bad would this be?).

@mourner
Copy link
Member Author

mourner commented Jan 12, 2016

If GMaps requires it, I'd assume that support is good enough for us to require as well.

ansis added a commit that referenced this issue Apr 12, 2016
- avoids the need to namespace attribute names with string concatenation
- this let's us use attribute.name as the shader attribute name
- this will let us use instanced rendering (#1898) with a shorter buffer
  when that extension is available.
ansis added a commit that referenced this issue Apr 12, 2016
- avoids the need to namespace attribute names with string concatenation
- this let's us use attribute.name as the shader attribute name
- this will let us use instanced rendering (#1898) with a shorter buffer
  when that extension is available.
ansis added a commit that referenced this issue Apr 12, 2016
- avoids the need to namespace attribute names with string concatenation
- this let's us use attribute.name as the shader attribute name
- this will let us use instanced rendering (#1898) with a shorter buffer
  when that extension is available.
lucaswoj pushed a commit that referenced this issue Apr 12, 2016
- avoids the need to namespace attribute names with string concatenation
- this let's us use attribute.name as the shader attribute name
- this will let us use instanced rendering (#1898) with a shorter buffer
  when that extension is available.
lucaswoj pushed a commit that referenced this issue Apr 12, 2016
- avoids the need to namespace attribute names with string concatenation
- this let's us use attribute.name as the shader attribute name
- this will let us use instanced rendering (#1898) with a shorter buffer
  when that extension is available.
@ansis ansis changed the title Investigate the use of ANGLE_instanced_arrays extension use ANGLE_instanced_arrays extension for data driven styles Apr 12, 2016
@lucaswoj lucaswoj changed the title use ANGLE_instanced_arrays extension for data driven styles Use ANGLE_instanced_arrays extension for data driven styles Jul 29, 2016
lucaswoj pushed a commit that referenced this issue Dec 13, 2016
- avoids the need to namespace attribute names with string concatenation
- this let's us use attribute.name as the shader attribute name
- this will let us use instanced rendering (#1898) with a shorter buffer
  when that extension is available.
@lucaswoj lucaswoj changed the title Use ANGLE_instanced_arrays extension for data driven styles Use ANGLE_instanced_arrays extension to reduce buffer sizes for layers with property functions Mar 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance ⚡ Speed, stability, CPU usage, memory usage, or power usage
Projects
None yet
Development

No branches or pull requests

3 participants