SSAO only samples mip 0 leading to worse than expected performance. #11222
Labels
A-Rendering
Drawing game state to the screen
C-Bug
An unexpected or incorrect behavior
C-Performance
A change motivated by improving speed, memory usage or compile times
P-High
This is particularly urgent, and deserves immediate attention
Milestone
Bevy version
0.12/main/probably every version since ssao was added
Relevant system information
AdapterInfo { name: "AMD Radeon RX 6800 XT", vendor: 4098, device: 29631, device_type: DiscreteGpu, driver: "AMD proprietary driver", driver_info: "22.11.2", backend: Vulkan }
Also happens on dx12.
What you did
Add SSAO to a scene or run the ssao example, profile it with radeon gpu profiler to see how long the ssao passes take, compare performance with the XeGTAO sample it's based on (https://github.com/GameTechDev/XeGTAO), then spend a few days trying to figure out why bevy's is so much slower.
What went wrong
This line always gives a negative mip value because the samples are all between 0..1 (and thus the length of the samples has a negative
log2
value), which causes it to be clamped to 0.0 so we're always sampling mip 0 which has a huge performance impact.XeGTAO uses a "working depth buffer" that seems to have a range of 0-10000, with the closest thing in the demo scene being ~1.4.
Additional information
Simply multiplying the sample on that line by 10000 doesn't really appear to have a visual effect in static scenes (but improves performance from 3.2ms to 1ms for the main SSAO pass on my gpu at 4k), but in the ssao example it artifacts pretty badly.I believe the fix for the artifacting is to improve the denoiser (eg. by just copying the xegtao one).Turns out it's using pixel space to calculate the mip level, so we need to multiply by the resolution instead of a magical 10000 value.
Ssao.mp4
The text was updated successfully, but these errors were encountered: