Description
Doing some memory allocations timeline testing in Chrome has revealed a few spots where Lightning is performing a lot of heap allocations unnecessarily leading to a lot of garbage being generated per frame.
The Rounded Rectangle Shader is a key part where this occurs.
Each uniform is set using the variadic function _setUniform
and the values are passed as individual parameters, but then put into an array to be passed to uniform4fv
, etc. The issue with that, is putting those values into an array allocates an array of those floats. So in our application that leads to ~300kb/s of GC pressure.
Providing the ability to disable the WebGLStateManager and refactoring the uniforms to directly use functions like uniform4f
when the parameters are not already in a vector leads to far less GC pressure, and in our experience can drastically improve performance.
Understanding that it may be a design of tradeoffs, wanted to open an issue for discussion here to see if there was anything we could be missing.