gfx-rs / wgpu

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

`wgpu_hal::dx12` should not allocate a 256KiB buffer just to hold zeroes #5886

Open jimblandy opened 3 months ago

jimblandy commented 3 months ago

In wgpu_hal, dx12::Device should not spend 256KiB of GPU memory on Device::zero_buffer, whose only reason for existence is to serve as the source of CopyBufferRegion calls in <dx12::Device as CommandEncoder>::clear_buffer.

It seems like the only other feasible way to zero a buffer in Direct3D 12 is with a compute shader.

jimblandy commented 3 months ago

Correction - it's only 256KiB, not 256MiB.

magcius commented 3 months ago

There's also https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12graphicscommandlist-clearunorderedaccessviewuint