You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
In addition, to the allocations from the use of setUniform, a shader like RoundedRectangle allocate on every frame in the map function converting the radius to the final int32's.
For some shaders the arrays can definitely be cached, but in a lot of cases they can also be entirely avoided if you add the exact functions you wanted to call rather than going through the API of setUniform that only allows a single value parameter
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 touniform4fv
, 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.
The text was updated successfully, but these errors were encountered: