Proposal: zero-copy section-backed ID3D12Heap placement and fence-based in-place hazard tracking #57

Open
opened 2026-12-04 14:43:47 +00:00 by github-bot · 0 comments
Owner

@⁠ending3729 on GitHub · 2026-12-04 14:42 UTC · original

Note: This proposal and the linked reference branches were prepared with Antigravity (Gemini 4) and verified locally via cargo clippy --workspace --all-targets --all-features --locked -- -D warnings and cargo test --workspace --locked.

Per CONTRIBUTING.md and ROADMAP.md, I am opening this proposal instead of an unclaimed PR because the implementation touches shadow.rs and host.rs, which are currently locked in @monte-alt's active Phase 2B/3 queue.

Background

Vesper already splits large lazy physical allocations into 64 MiB sections (VSP-03 / PR #17), which avoids long Windows section-lock walks. However, on Windows those sections are still created with SEC_RESERVE, which D3D12 OpenExistingHeapFromFileMapping refuses. As a result, views backed by those sections still fall back to host/card shadow copies, snapshots, and CPU-side page diffs.

Proposed Design (3 Stacked Pieces)

  1. Demand-allocated SEC_COMMIT chunks (with SEC_RESERVE fallback) in xmem.rs
    • Materialize 64 MiB chunks lazily on first map/use with SEC_COMMIT (falling back to SEC_RESERVE if commit headroom is tight), keep allocations <= 256 MiB as a single contiguous section for 32-bit heaps, and decrement POOL_COMMITTED when a chunk drops after free + unmap.
    • Reference: https://github.com/ending3729/cool_fox/tree/feat/xmem-chunked-pools (188ce99)
  2. Zero-copy OpenExistingHeapFromFileMapping placement in inplace.rs / shadow.rs
  3. Fence-based in-place hazard tracking in host.rs / draw.rs / card_steps.rs
    • Under LATE_WAIT / RELAY, record per-flight GPU in-place read and write ranges (InPlaceHazards) and wait only on conflicting flight fences (RAW/WAW/WAR) via a unified Step::cpu_access helper, blocking unsafe joinable CPU writes (Step::Placed, Step::Host, Step::Refresh), replaying in-place CBVs across ValueWait cuts (FreshTable), and retaining bindless in-place reads/UAVs across same-frame lists.
    • Reference: https://github.com/ending3729/cool_fox/tree/feat/inplace-fence-hazards (7f58eab)

(Note: The reference branches above were written and CI-verified on a cool_fox fork with cargo clippy --workspace --all-targets --all-features --locked -- -D warnings and cargo test --workspace --locked. I do not have title files locally, so a rebase onto vesper would rely on local unit/WARP tests plus a community tester on AMD Radeon hardware for 1440p HW RT before/after telemetry.)

Questions for @monte-alt

  1. Does section-backed OpenExistingHeapFromFileMapping placement + fence-based InPlaceHazards fit your post-Phase 2B/3 direction for shadow.rs / host.rs?
  2. Would you like this tracked as a VSP-XX roadmap item so it can be claimed once the active queue lock on shadow.rs / host.rs lifts?
**@⁠ending3729** on GitHub · 2026-12-04 14:42 UTC · [original](https://github.com/monte-alt/vesper/issues/57) > *Note: This proposal and the linked reference branches were prepared with Antigravity (Gemini 4) and verified locally via `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` and `cargo test --workspace --locked`.* Per `CONTRIBUTING.md` and `ROADMAP.md`, I am opening this proposal instead of an unclaimed PR because the implementation touches `shadow.rs` and `host.rs`, which are currently locked in `@monte-alt`'s active Phase 2B/3 queue. ### Background Vesper already splits large lazy physical allocations into `64 MiB` sections (`VSP-03` / PR #17), which avoids long Windows section-lock walks. However, on Windows those sections are still created with `SEC_RESERVE`, which D3D12 `OpenExistingHeapFromFileMapping` refuses. As a result, views backed by those sections still fall back to host/card shadow copies, snapshots, and CPU-side page diffs. ### Proposed Design (3 Stacked Pieces) 1. **Demand-allocated `SEC_COMMIT` chunks (with `SEC_RESERVE` fallback) in `xmem.rs`** - Materialize `64 MiB` chunks lazily on first map/use with `SEC_COMMIT` (falling back to `SEC_RESERVE` if commit headroom is tight), keep allocations `<= 256 MiB` as a single contiguous section for 32-bit heaps, and decrement `POOL_COMMITTED` when a chunk drops after free + unmap. - Reference: https://github.com/ending3729/cool_fox/tree/feat/xmem-chunked-pools (`188ce99`) 2. **Zero-copy `OpenExistingHeapFromFileMapping` placement in `inplace.rs` / `shadow.rs`** - Place contiguous `Cover::Run` `xmem` views directly into section-backed `ID3D12Heap`s, guarded by `PLACING` / `STATS` freeing barriers and `host::retire_cached` so section heaps are never closed or freed out from under active placement or in-flight command lists. - Reference: https://github.com/ending3729/cool_fox/tree/feat/inplace-section-heaps-placement (`e68ec1d`) 3. **Fence-based in-place hazard tracking in `host.rs` / `draw.rs` / `card_steps.rs`** - Under `LATE_WAIT` / `RELAY`, record per-flight GPU in-place read and write ranges (`InPlaceHazards`) and wait only on conflicting flight fences (RAW/WAW/WAR) via a unified `Step::cpu_access` helper, blocking unsafe `joinable` CPU writes (`Step::Placed`, `Step::Host`, `Step::Refresh`), replaying in-place CBVs across `ValueWait` cuts (`FreshTable`), and retaining bindless in-place reads/UAVs across same-frame lists. - Reference: https://github.com/ending3729/cool_fox/tree/feat/inplace-fence-hazards (`7f58eab`) *(Note: The reference branches above were written and CI-verified on a `cool_fox` fork with `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` and `cargo test --workspace --locked`. I do not have title files locally, so a rebase onto `vesper` would rely on local unit/WARP tests plus a community tester on AMD Radeon hardware for 1440p HW RT before/after telemetry.)* ### Questions for `@monte-alt` 1. Does section-backed `OpenExistingHeapFromFileMapping` placement + fence-based `InPlaceHazards` fit your post-Phase 2B/3 direction for `shadow.rs` / `host.rs`? 2. Would you like this tracked as a `VSP-XX` roadmap item so it can be claimed once the active queue lock on `shadow.rs` / `host.rs` lifts?
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-04 14:43:47 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.