Exit light calculation early when pixel outside of light bounding rectangle #90920
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.
Potential fix for #81152
Fixes: #90905
Right now when rendering a CanvasItem for each pixel in the fragment shader we loop over all lights that intersect that CanvasItem and calculate their contribution to the pixel. If the pixel is outside of the light's texture, we set the alpha value of the final result to 0 which results in that light not contributing to the pixel.
Unfortunately, this means that we read from the light's texture still and run the light shader for that light, even though it won't have any effect.
Normally, using a continue op in a loop is not a good idea is it can stop the compiler from doing certain beneficial optimizations. But in this case, the compiler can't optimize this loop for many other reasons, so this ends up being a net win.
Performance testing
Further testing
This PR would benefit from being tested on even lower end mobile, on web export,
and on a desktop device with a dedicated GPU(done)Light2DTestUpdated.zip