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

Figure out how to make disabled attributes performant in IE #1714

Closed
lucaswoj opened this issue Nov 13, 2015 · 2 comments
Closed

Figure out how to make disabled attributes performant in IE #1714

lucaswoj opened this issue Nov 13, 2015 · 2 comments

Comments

@lucaswoj
Copy link
Contributor

uniforms allow us to specify global values to WebGL shaders. attributes allow us to specify per-feature values.

If all features have the same value (i.e. all circles are red), we can disable the attributes using gl.disableVertexAttribArray and set a global value as if it were a uniform.

We converted most data-driven styling related uniforms to attributes in #1257. Then, there were reports of big performance regressions in IE #1336, so we reverted our changes in #1415

One of the big remaining challenges for implementing data driven styling is figuring out how to make disabled attributes performant in IE.

cc @jfirebaugh @tmcw @ansis

@ansis
Copy link
Contributor

ansis commented Feb 26, 2016

Aside from using array buffers to feed attribute data to the vertex shader, OpenGL also supports attributes which remain constant for all vertices used in a draw call. Direct3D 9 doesn’t have a similar concept, at least not explicitly.

Constant attributes are implementated using separate (static) vertex buffers, and uses a stride of 0 to ensure that every vertex retrieves the same data.

https://chromium.googlesource.com/angle/angle/+/master/doc/BufferImplementation.md#Constant-attributes

I haven't read through the ANGLE source yet to see what they are doing but we might be able to improve performance by managing this buffer ourselves since we know the values earlier.

@ansis
Copy link
Contributor

ansis commented Feb 26, 2016

IE doesn't use ANGLE but I think it has an internal translation to Direct3D so it probably has a similar problem.

We can't manually manage a buffer with a stride of 0 because in webgl a 0 stride means "use a stride that matches the type and size". I don't think we can make it read the same buffer value for each vertex from webgl.

If that's the case, I think the only way we can improve performance on our side is by generating a new shader for each unique combination of constant vs enabled attributes. There are many possible combinations but in practice there probably won't be that many different combinations in a single style. We'd use glsl preprocessor directives to implement the variations in the shaders. When the style is loaded or changed we'd calculate which shader variations are needed and then compile them by prepending some #defines to the shader source.

We could use this approach only for IE/Windows and use constant attributes everywhere else, but we should strongly consider using this approach everywhere so that we don't have different implementations and bugs on different platforms.

lucaswoj pushed a commit that referenced this issue Apr 4, 2016
lucaswoj pushed a commit that referenced this issue Apr 5, 2016
lucaswoj pushed a commit that referenced this issue Apr 5, 2016
lucaswoj pushed a commit that referenced this issue Apr 6, 2016
lucaswoj pushed a commit that referenced this issue Apr 6, 2016
lucaswoj pushed a commit that referenced this issue Apr 6, 2016
lucaswoj pushed a commit that referenced this issue Apr 6, 2016
lucaswoj pushed a commit that referenced this issue Apr 7, 2016
lucaswoj pushed a commit that referenced this issue Apr 7, 2016
lucaswoj pushed a commit that referenced this issue Apr 7, 2016
lucaswoj pushed a commit that referenced this issue Apr 8, 2016
lucaswoj pushed a commit that referenced this issue Apr 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants