-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unnecessary heap allocations per frame for WebGL renderer. #374
Comments
As recommended in the Lightning 2 ticket, adding the explicit GL functions that take stack parameters would also resolve this, such as |
Nice - thanks for resurfacing this @itsjamie ! Tagging @erikhaandrikman and @jfboeve - lets discuss this next sync. |
Exactly like that. 👍 |
ok - will noodle on that and get a PR up soonish. |
- Removed the setUniform method from the WebGLContextWrapper class. - Updated the setUniform method to handle different types of uniforms, including single argument uniforms like uniform1f, uniform1fv, etc. - Added support for setting uniform values using the appropriate WebGLRenderingContext methods based on the uniform type. Related to #374
#381) Fixes #374 Could not fall back to `arguments` as that isn't allowed in strict mode, working around that only made it worse. Moved everything up early in the chain to call the respective uniform method directly, with minimal overhead which should avoid the additional GC pressure as described in #374 Only thing I need to figure out what the impact is of losing the `setUniform` argument caching that was originally there, worst case we have to implement a cache check at each individual uniform method. @jfboeve the Dynamic Shader was a bit of a thing - please 👀 if this makes sense. I don't know if the additional argument uniforms can actually happen in the Dynamic Shader case (I assumed so).
rdkcentral/Lightning#494
Reopening this issue which impacted Lightning 2 and still impacts Lightning 3.
renderer/src/core/renderers/webgl/WebGlCoreShader.ts
Lines 313 to 320 in 3a1fb19
renderer/src/core/renderers/webgl/WebGlCoreShader.ts
Lines 313 to 320 in 3a1fb19
The direct usage of the generic version of this function leads to each of those spread and rest operators creating new arrays that have to be garbage collected after each frame that includes these shaders.
If
...args
was replaced witharguments
usage, it is possible you could keep the generic function without the explicit array being created from the rest operator usage.For general applications this is fine, but the moment you have an animation that includes a re-render this can quickly grow into forcing many garbage collection cycles.
The text was updated successfully, but these errors were encountered: