processing / p5.js

p5.js is a client-side JS platform that empowers artists, designers, students, and anyone to learn to code and express themselves creatively on the web. It is based on the core principles of Processing. http://twitter.com/p5xjs —
http://p5js.org/
GNU Lesser General Public License v2.1
21.7k stars 3.33k forks source link

Uniform Buffer Objects in webGL2? #6439

Open aferriss opened 1 year ago

aferriss commented 1 year ago

Topic

I was doing some logging in the setUniform function and noticing how many uniforms we're setting, even when just drawing a single object with nothing but flat lighting. Would it improve our perf at all if we switched to using uniform buffer objects instead of setting each uniform one by one for the fill / stroke / material shaders?

This might introduce more complexity than its worth, but I thought it would be good to flag nonetheless!

davepagurek commented 1 year ago

Sounds like maybe the next step for this would be to see if we can make a test sketch to benchmark on (possibly without even using p5?) to see how much of a gain we could get? Looking at chrome://tracing, it seems like on my machine at least, a lot of GPU work accumulates in the command queue and executes all in one batch at the end, so potentially the browser is already is batching its uniform setting. I definitely haven't tested that specific scenario though, so it would be cool to see for sure!