Open lyuma opened 2 years ago
@lyuma looks like MRP link is broken
A number like 2048 or 1024 feels like it should take 16 to 64 megabytes of whatever kind of RAM, not gigabytes. We need to measure this differently, or with an additional number in the setting mentioning VRAM size, i feel.
So it looks like it is using about 1.2 GB's. The expected size of a 1024 reflection probe is: 1024px x 1024px x 6 sides x 8 array layers x 64 bits x ~1.33 for mipmaps = ~536 mbs. So it looks like we are allocating about twice as much memory as needed.
@arkology Uploaded the MRP again.
Can I ask why there are 8 array layers allocated at a time?
If this is really the case, I think it shows why compressed reflection probes are necessary. 512x512 reflection probes just don't cut it for some scenes, and I shouldn't have to pay 500MB to have a single 1024x1024 reflection probe.
Can I ask why there are 8 array layers allocated at a time?
It matches the 8 roughness_layers which is the default amount in project settings. You need a layer for each different roughness level. This is what allows you to smoothly blend between 0 and 1 roughness.
To use a mipmapped single texture instead of a texture array you can set texture-array-reflections to false.
I think a satisfactory resolution to this issue would be for us to raise the quality of non-array reflections to the point that we could make it default. Non-array reflections are significantly faster to generate and take up much less space (one eighth as much by default), but the quality suffers
@lyuma The Discord download link for the MRP is no longer working, as Discord prevented all old download links from working outside of Discord. Could you reupload the MRP somewhere else?
there was a second github link hidden next to the discord one. I diffed them and can confirm they are the same so I removed the broken discord link to avoid confusion https://github.com/godotengine/godot/files/9440590/reflectionprobe_vram.zip
(it seems you can paste a dead discord link into a discord message, and the client will resolve it into a working link. that's how I re-gained access to it. it might have to be the same server, in this case V-Sekai)
I can reproduce this on 4.3.beta1. I stepped through RenderDoc and didn't find anything obvious about accidentally duplicating the reflection atlas or something.
Here's the system VRAM utilization difference[^1] with various settings and the default window size of 1152x648. This encapsules the entire project's VRAM utilization (the editor is not running in the background). Texture arrays are always enabled:
[^1]: Measured using watch -n0.1 nvidia-smi
and running the project with godot --quit-after 50
.
Settings | VRAM usage |
---|---|
1024x1024, Count = 64 | 5,696 MB |
512x512, Count = 64 | 1,594 MB |
1024x1024, Count = 1 | 564 MB |
No reflection probe | 308 MB |
The same with 1x1 window size (to rule out any framebuffer VRAM usage based on viewport size):
Settings | VRAM usage |
---|---|
1024x1024, Count = 64 | 5,428 MB |
512x512, Count = 64 | 1,582 MB |
1024x1024, Count = 1 | 553 MB |
No reflection probe | 287 MB |
The issue is in the Reflection Count project setting. It defaults to 64 to allow for 64 reflection probes to be drawn at a time. (Note that if you set it to 0
, the engine will crash on startup. We should tweak the property hint to prevent that.)
If you decrease it to 1, VRAM usage is much more reasonable and in line with what I'd expect. If you use high-resolution reflection probes, you'll probably use fewer of them – especially in a racing game where you generally use a single probe for all cars centered around the player's.
I guess we should document this caveat about reflection resolutions higher than the default: if you want lower VRAM utilization, you should decrease reflection count at the same time you're increasing resolution.
Godot version
4.0.dev 11abffbf + patches
System information
Windows 10, Vulkan Nvidia Rtx 2080 Ti
Issue description
I've been noticing extraordinarily huge VRAM usage when playing a test scene in my game, upwards of 5GB.
This issue is about Reflection Probes having an effect on memory usage. There's a sister issue #64677 about WorldEnvironment radiance size.
The test project I use has reflection size set to 1024. This causes half my VRAM to be consumed. Normally a 1024x1024x6 reflection probe should only take about 25MB or so.
Godot's default reflection size is 256, which is 16 times less VRAM, but even at 256, it is taking way more than it should be (you can still see a spike when toggling on the reflection probe).
Here is a screenshot of task manager
Steps to reproduce
Minimal reproduction project
reflectionprobe_vram.zip