WebGLUniformsGroups: Fix programs sharing multiple ubo and support array uniforms #25084
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes the fact that the UBO cache system was previously based per block and not per program which was breaking as soon as more than one UBO was used (wrong index). I updated the example by adding the lights UBO on the second material, to reproduce the issue just set back the old cache system in
WebGLState.js
:uboBindings.get( program )
=>uboBindings.get( uniformsGroup )
and you will see that the programs fail based randomly.It seems that with multiple UBOs attached this change will trigger
uniformBlockBinding
per frame, I wonder about the performance implication of this call.The PR also introduces the support for uniform array structure. For example:
Also, it might be interesting to add a note that it is necessary to only use vec4 with UBO and std140.
Most GPUs (Apple for example) do not render a correct result if a non-vec4 is being used when using a uniform array and std140.