-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Description
When working on the Multiview PR #16316 I've noticed that updating array of matrices uniforms impact the performance quite a lot.
This is mainly because of the cache, checking both elements are the same and then copying the array if not, seems to be a hot spot.
I'll try to get some numbers to compare using cache vs not using for arrays. I believe it could be interesting to consider avoid caching arrays or maybe provide a way to define that you don't want to cache some uniforms if you already know they'll be changing per frame.
Looking at the Babylon's sourcecode it seems they just cache simple data https://github.com/BabylonJS/Babylon.js/blob/master/src/Materials/effect.ts#L1113-L1122 but not arrays https://github.com/BabylonJS/Babylon.js/blob/master/src/Materials/effect.ts#L1131-L1174.
So some ideas:
- Avoid using cache for Array uniforms
- Allow the user to define which uniforms must not use cache
- Add a new boolean param to
setValueto force non-cache update, eg:uniform.setValue(gl, 'name', [a,b], true)