Use a vec4 instead of an array in canvas shader instance buffer #100028
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 avoids a pathological performance cliff on Adreno devices
I noticed a regression between dev2 and dev3 in 2D rendering performance. I finally took the time to investigate it last night. I found that on my Pixel 4 (Adreno 640) frame time roughly tripled (from 15 FPS down to 5 FPS) in the isometric 2D demo.
The regression was most likely caused by the move to batching which is very weird as batching barely affects the shader code.
I ran a profiler over the demo and found something very odd. The profiler showed shader processor memory bandwidth use go from 16mb/s to 6.5GB/s. I expected that this scene would be ALU bound due to the high number of lights.
After a lot of investigation, I accidentally stumbled on the cause. Adreno doesn't like having an array inside a struct inside of an array. We can easily fix that since vectors can be indexed like arrays. Simply by changing the
lights
member into auvec4
we reclaim all the performance we lost. Non-Adreno devices don't care one way or the other, so this ends up being a very safe fix.