Experiment: Port VMA/D3D12MA to Rust in place of existing allocator stack - #9794
Experiment: Port VMA/D3D12MA to Rust in place of existing allocator stack#9794cwfitzgerald wants to merge 5 commits into
Conversation
|
Would it be better to just do FFI with the crates? That way we can update easier as new versions are published. |
|
@JMS55 the main problem would be re-introducing a c dependency, all the auditing that would require, etc. |
1848bce to
7e12a4e
Compare
|
Just so the passing reader is clear, I'm aware that this PR is |
8eccc56 to
e651490
Compare
|
This is diabolical and I love it lol. I cannot imagine how a vibe-coded rust port of a well established C library would be easier to audit or preferable to have in our dependency tree but thats not my domain lol |
Well that's why I'm not merging it right now, it needs review and iteration so it's not vibed just AI assisted :) In general C/C++ is a ton harder to audit as there's UB lurking at every corner. Here unsafe is the only place that UB can really manifest outside of the allocator itself misbehaving (which is why we have tests). By the time this lands at least two people will have reviewed every bit of this change (me and the reviewer). |
e651490 to
016f811
Compare
Port the Vulkan backend off gpu-allocator onto the new in-repo wgpu-block-pool / wgpu-offset-allocator crates via a new vulkan/suballocation.rs (VMA-style memory-type selection, per-heap block sizing, dedicated-allocation heuristics, budget gating, persistent mapping). Vulkan no longer references lib.rs's shared AllocationSizes; it uses a local BlockSizePolicy instead. Also hardens acceleration-structure buffer alignment and fixes device-memory leaks on error paths. The dx12 backend still uses gpu-allocator, so the shared gpu_allocator glue in lib.rs (gated on any(dx12, vulkan)) is kept; the gpu-allocator crate remains a wgpu-hal dependency (its vulkan feature is dropped, its d3d12 feature retained). Removing that glue is a follow-up once dx12 is ported too.
Delete the shared gpu-allocator glue from wgpu-hal/src/lib.rs, inline a local AllocationSizes into the dx12 backend, drop gpu-allocator from the workspace and wgpu-hal manifests, and add the feature changelog entry.
016f811 to
990cf94
Compare
Connections
#9745
Description
We've had lots of trouble with gpu-allocator causing weird allocation behavior. It also didn't have very complicated allocation logic so didn't get the advantages of state of the art things. This adds an LLM-powered port of VMA/D3D12MA to replace that and create consistent behavior.
Testing
In place testing, prop testing, adverserial llm reviews and diff-to-vma reviews.
Squash or Rebase?
Don't merge this.
Checklist
wgpumay be affected behaviorally.CHANGELOG.mdentries for the user-facing effects of this change are present.