deck.gl icon indicating copy to clipboard operation
deck.gl copied to clipboard

[For Discussion] Improve project shader module uniform setting using UBO

Open 1chandu opened this issue 7 years ago • 6 comments

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

1chandu avatar Mar 28 '18 00:03 1chandu

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?

ibgreen avatar Mar 28 '18 02:03 ibgreen

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.

1chandu avatar Mar 28 '18 05:03 1chandu

CC: @tsherif

1chandu avatar Jan 14 '20 23:01 1chandu

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:

  1. Have shader transpilation handle switching from uniform blocks to bare uniforms in the shaders.
  2. 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.

tsherif avatar Jan 15 '20 14:01 tsherif

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 avatar Jan 14 '22 14:01 Oussema-Dallel

@Oussema-Dallel This issue is a feature proposal. Please open your own issue or discussion thread if you need help with a current release.

Pessimistress avatar Feb 04 '22 05:02 Pessimistress