[For Discussion] Improve project shader module uniform setting using UBO
Background
Project shader module uniforms are tied to a viewport object that is common to all layers. We can collect all these uniforms and load into a WebGL Buffer object and update module shaders to read them from uniform buffer. LayerManger can update this UBO every time viewport is changed. This way irrespective of number of layers, we will only upload uniforms once to the GPU and also avoid multiple glUniform calls with one buffer.subData.
Though, this will be only limited to WebGL2, we should be able to handle this in Module code to switch between WebGL1 and WebGL2 shader versions.
CC: @ibgreen @Pessimistress @jianhuang01
To Do List
- [ ] Add label and assign to milestone
- [ ] Coding
- [ ] Doc update
- [ ] Whats new update
- [ ] Test
Nice. Some thoughts:
- We already have a class for doing the memory layout for the uniform buffers, although it is not well tested in practice.
- We probably want some kind of stress test to show that we gain perf with uniform buffers.
- How about other modules? Wouldn't lighting also typically have the same settings across layers?
How about other modules? Wouldn't lighting also typically have the same settings across layers?
Yeah, as long as uniforms doesn't change across the layers, we can apply this for any module.
CC: @tsherif
After the 8.0 optimizations, uniform updates are currently the biggest performance bottleneck on the deck stress test, so I think this would be a major win where WebGL 2 is supported. If possible I think the cleanest way to do this would be:
- Have shader transpilation handle switching from uniform blocks to bare uniforms in the shaders.
- Create a wrapper around uniforms that can handle switching between updating uniform buffers and setting program uniforms.
The could a apply more broadly than the project module. We would generally get a win with UBOs for any uniforms that are infrequently updated for a given object.
Hi all, I have an error in my application where it says for example: "drawing SolidPolygonLayer({id: '8-2136-1418-12-polygons-fill'}) to screen: Uniform length cannot change." This happens when I load two Geojson layers where one have a heatmap color(getFillColor depends on the values supplied from data) and the other have a uniform color. Meaning, this dosen't happen when I call multiple geojson-layers with the same color schema. Could this be related, and could you give me more insights on why this is happening. Thanks!
@Oussema-Dallel This issue is a feature proposal. Please open your own issue or discussion thread if you need help with a current release.