Skip to content
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

Remove uniform wrapper and use concise setUniform<1f,2f,3f,4f> methods #381

Merged
merged 9 commits into from
Sep 20, 2024

Conversation

wouterlucas
Copy link
Contributor

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).

This commit updates the setUniform methods in the WebGLContextWrapper class to use the individual WebGL uniform setter functions instead of the generic `gl.uniform` function. This change improves code readability and ensures that the correct uniform setter is used for each type of uniform variable.
- 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
@wouterlucas wouterlucas added this pull request to the merge queue Sep 20, 2024
Merged via the queue into main with commit d54f4f8 Sep 20, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unnecessary heap allocations per frame for WebGL renderer.
3 participants