gfx-rs / wgpu

A cross-platform, safe, pure-Rust graphics API.
https://wgpu.rs
Apache License 2.0
11.46k stars 855 forks source link

Properly configure the memory allocators #5869

Open nical opened 5 days ago

nical commented 5 days ago

The vulkan backend uses the gpu-alloc crate and sets the memory allocator to the i_am_prototyping configuration which is explicitly not meant to make it to production. The starting device memory chunk size for that config is 8 MiB and doubles every time a new chunk must be allocated.

The d3d12 backend uses the default settings provided by gpu-allocator (different crate), which is fixed 256 MiB memory chunks for device memory and 64 MiB for host memory. 256 MiB appears to also be the default size for VMA.

For reference, it looks like Dawn uses a fixed memory chunk size of 8MiB with a buddy allocator.

I think that wgpu should expose this configuration to the outside while providing some reasonable defaults. Firefox (which may create many devices at the same time) will want much smaller chunk sizes by default than a typical big game.