fix(gpu): bound root/VB/IB/raw views, RT scratch barriers, and wide dispatch limits (#288, #280) #455

Open
github-bot wants to merge 1 commit from github-bot/gh-455 into main AGit
Owner

@⁠ZerefDragnee1l on GitHub · 2026-12-06 01:05 UTC · original
ZerefDragnee1l:fix/amd-rdna2-world-load-page-faults → main · +431 −288 · 5 files · 1 commits · open

Addresses GPU-side page-fault (0x887A0005 / 0x887A0006) vectors reported on AMD RDNA2/RDNA3 GPUs at world load (#288, #280, #234, #111), with 0% shader cache invalidation (all shader-translator fixes are separated into a companion PR).

(Companion PR #447 also fixes COPY-queue list7.Barrier Enhanced Barrier access flags.)

Changes

  1. Never leave root CBVs or system root SRVs unbound (draw.rs):
    • When an unset or unresolvable root CBV lacks backing memory, bind crate::shadow::zeros() via root_at(..., Arg::Cbv, ...) (or drop the draw/dispatch if unavailable) instead of leaving root descriptor SGPRs uninitialized.
    • Drop the draw/dispatch if SLOT_MEMORY, SLOT_TABLES, SLOT_STRIDES, or SLOT_SHIFTS is None.
  2. Clamp Vertex & Index buffer views to shadow copy bounds (draw.rs):
    • Clamps SizeInBytes (and refresh length) to u64::from(v.size).min(shadow.left(v.address)), preventing IA fetches past smaller shadow windows.
  3. Bounds-clamp dynamic raw_at / raw_uav_at and non-byte-view SRV 4 GiB limits (descriptor/host.rs, byteviews.rs):
    • Clamps NumElements in raw_at and raw_uav_at to buffer.GetDesc().Width.saturating_sub(offset) / 4 (and 0xFFFF_FFC0 when !byteviews::supported(&host.device) for raw_at), falling back to a null raw view if 0.
    • Enforces the 4 GiB (0xFFFF_FFC0) by-element SRV limit in buffer_view_ok when unordered == false and byte-offset views are unsupported (matching byteviews.rs).
  4. Ray-tracing world-load safety & perf (rt.rs):
    • Guards TRIANGLES vertex() with if (vertices == 0u) return float3(0.0, 0.0, 0.0); so vertices - 1u never underflows to 0xFFFFFFFF during BLAS copy dispatches while still writing geometry header dwords.
    • Inserts intra-batch UAV barriers between BLAS (Bottom) -> TLAS (Top) builds and whenever two BLAS builds share a non-zero scratch VA in the same batch.
    • Retains from.lease on the command list in copied(), retires gone structures in ended(), and reuses RecordScratch temporary buffers cleanly via RAII drop guard.
  5. Clamp CARD_COMPARE_WIDE dispatch count (host.rs):
    • Passes groups = pieces.clamp(1, 65535) as a 7th root constant and loops in CARD_COMPARE_WIDE (matching CARD_FETCH) instead of dispatching pieces directly past D3D12's 65,535 limit.

Verification

  • Ran cargo check -p larp on this branch (exited 0, 0 errors, 0 warnings in modified files).

Scope note regarding issue #379

  • Outside PR #455's coverage / not claimed to fix #379: Issue #379 reports a deterministic view heap base + 0xF0000000 (slot 0x07800000) GPU page fault during world-load DispatchMeshIndirectMulti that persisted on v1.1.6-amd.
  • PR #455 bounds buffer/resource VAs (raw_at/raw_uav_at/buffer_view_ok including the 0xFFFF_FFC0 cap when byteviews::supported == false, VB/IB SizeInBytes, root CBV/SRV/UAV addresses), RT scratch barriers, and cardhash >65,535-group dispatches. None of those bounds modify root descriptor-table handles or DispatchMeshIndirectMulti indirect descriptor fetches that could synthesize a descriptor heap VA 0xEE17B800 past the heap's end.
**@⁠ZerefDragnee1l** on GitHub · 2026-12-06 01:05 UTC · [original](https://github.com/gamingwithhomie/larp/pull/455) `ZerefDragnee1l:fix/amd-rdna2-world-load-page-faults` → `main` · +431 −288 · 5 files · 1 commits · open Addresses GPU-side page-fault (`0x887A0005` / `0x887A0006`) vectors reported on AMD RDNA2/RDNA3 GPUs at world load (#288, #280, #234, #111), with **0% shader cache invalidation** (all shader-translator fixes are separated into a companion PR). *(Companion PR #447 also fixes `COPY`-queue `list7.Barrier` Enhanced Barrier access flags.)* ## Changes 1. **Never leave root CBVs or system root SRVs unbound (`draw.rs`):** - When an unset or unresolvable root CBV lacks backing memory, bind `crate::shadow::zeros()` via `root_at(..., Arg::Cbv, ...)` (or drop the draw/dispatch if unavailable) instead of leaving root descriptor SGPRs uninitialized. - Drop the draw/dispatch if `SLOT_MEMORY`, `SLOT_TABLES`, `SLOT_STRIDES`, or `SLOT_SHIFTS` is `None`. 2. **Clamp Vertex & Index buffer views to shadow copy bounds (`draw.rs`):** - Clamps `SizeInBytes` (and `refresh` length) to `u64::from(v.size).min(shadow.left(v.address))`, preventing IA fetches past smaller shadow windows. 3. **Bounds-clamp dynamic `raw_at` / `raw_uav_at` and non-byte-view SRV 4 GiB limits (`descriptor/host.rs`, `byteviews.rs`):** - Clamps `NumElements` in `raw_at` and `raw_uav_at` to `buffer.GetDesc().Width.saturating_sub(offset) / 4` (and `0xFFFF_FFC0` when `!byteviews::supported(&host.device)` for `raw_at`), falling back to a null raw view if 0. - Enforces the 4 GiB (`0xFFFF_FFC0`) by-element SRV limit in `buffer_view_ok` when `unordered == false` and byte-offset views are unsupported (matching `byteviews.rs`). 4. **Ray-tracing world-load safety & perf (`rt.rs`):** - Guards `TRIANGLES` `vertex()` with `if (vertices == 0u) return float3(0.0, 0.0, 0.0);` so `vertices - 1u` never underflows to `0xFFFFFFFF` during BLAS copy dispatches while still writing geometry header dwords. - Inserts intra-batch UAV barriers between BLAS (`Bottom`) -> TLAS (`Top`) builds and whenever two BLAS builds share a non-zero scratch VA in the same batch. - Retains `from.lease` on the command list in `copied()`, retires `gone` structures in `ended()`, and reuses `RecordScratch` temporary buffers cleanly via RAII drop guard. 5. **Clamp `CARD_COMPARE_WIDE` dispatch count (`host.rs`):** - Passes `groups = pieces.clamp(1, 65535)` as a 7th root constant and loops in `CARD_COMPARE_WIDE` (matching `CARD_FETCH`) instead of dispatching `pieces` directly past D3D12's 65,535 limit. ## Verification - Ran `cargo check -p larp` on this branch (exited `0`, 0 errors, 0 warnings in modified files). ### Scope note regarding issue #379 - **Outside PR #455's coverage / not claimed to fix #379**: Issue #379 reports a deterministic `view heap base + 0xF0000000` (slot `0x07800000`) GPU page fault during world-load `DispatchMeshIndirectMulti` that persisted on `v1.1.6-amd`. - PR #455 bounds **buffer/resource VAs** (`raw_at`/`raw_uav_at`/`buffer_view_ok` including the `0xFFFF_FFC0` cap when `byteviews::supported == false`, VB/IB `SizeInBytes`, root CBV/SRV/UAV addresses), RT scratch barriers, and `cardhash` >65,535-group dispatches. None of those bounds modify root descriptor-table handles or `DispatchMeshIndirectMulti` indirect descriptor fetches that could synthesize a descriptor heap VA `0xEE17B800` past the heap's end.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-06 01:11:15 +00:00
Author
Owner

@⁠vanya890 on GitHub · 2026-12-06 01:21 UTC · original

One report worth checking against this change is issue #379: RX 6900 XT RDNA2 faults at exactly view heap base + 0xF0000000 during world-load DispatchMeshIndirectMulti, with earlier runs also showing out-of-range view-heap slots. Your raw-view and wide-dispatch bounds are relevant, but the issue author says the same failure persisted in a newer v1.1.6-amd test.

Could you map the reported VA/slot to one of the bounds this PR changes, or explain why it is outside this patch's coverage? That would help avoid implying this PR fixes #379 solely because both reports involve AMD page faults.

**@⁠vanya890** on GitHub · 2026-12-06 01:21 UTC · [original](https://github.com/gamingwithhomie/larp/pull/455#issuecomment-7449118806) One report worth checking against this change is issue #379: RX 6900 XT RDNA2 faults at exactly `view heap base + 0xF0000000` during world-load `DispatchMeshIndirectMulti`, with earlier runs also showing out-of-range view-heap slots. Your raw-view and wide-dispatch bounds are relevant, but the issue author says the same failure persisted in a newer v1.1.6-amd test. Could you map the reported VA/slot to one of the bounds this PR changes, or explain why it is outside this patch's coverage? That would help avoid implying this PR fixes #379 solely because both reports involve AMD page faults.
Author
Owner

@⁠ZerefDragnee1l on GitHub · 2026-12-06 01:37 UTC · original

Good catch raising #379 — I want to be explicit that issue #379 is outside PR #455's coverage, and this PR does not claim to fix #379:

  1. What PR #455 actually bounds:

    • Buffer / resource VAs (not descriptor-heap offsets): HostHeap::raw_at / raw_uav_at and buffer_view_ok (clamping NumElements to backing Width, plus 0xFFFF_FFC0 max width when byteviews::supported == false on RDNA 2), VB/IB descriptor SizeInBytes in draw.rs, and root CBV/SRV/UAV byte bounds + RT scratch barriers in host.rs / rt.rs.
    • Wide internal cardhash dispatches: splits >65,535-group Dispatch calls in host.rs.
  2. Why #379's fault is outside this patch:

    • In #379 (RX 6900 XT RDNA 2), DRED shows an offending VA at exact view heap base + 0xF0000000 (0xEE17B800 / slot 0x07800000 past the view heap's end) with DispatchMeshIndirectMulti markers in progress, and persisted on v1.1.6-amd.
    • None of the bounds added in PR #455 clamp root descriptor-table GPU virtual addresses (SetGraphicsRootDescriptorTable / heap base + offset) or rewrite DispatchMeshIndirectMulti indirect arguments/fetches (moreover, translated shader heap_handle already clamps to VIEW_LIMIT, so a slot-0x07800000 view-heap VA points toward an unbound/stale descriptor table handle, indirect command payload, or driver/hardware fetch path that this PR does not touch).
    • Separately, #379 also notes a useful diagnostic gap ("a host command list did not reset" not appending removal_data in fail()), which is worth addressing in its own focused change.

PR description updated accordingly so #379 is not conflated with this PR.

**@⁠ZerefDragnee1l** on GitHub · 2026-12-06 01:37 UTC · [original](https://github.com/gamingwithhomie/larp/pull/455#issuecomment-7449324660) Good catch raising #379 — I want to be explicit that **issue #379 is outside PR #455's coverage**, and this PR does **not** claim to fix #379: 1. **What PR #455 actually bounds**: - **Buffer / resource VAs** (not descriptor-heap offsets): `HostHeap::raw_at` / `raw_uav_at` and `buffer_view_ok` (clamping `NumElements` to backing `Width`, plus `0xFFFF_FFC0` max width when `byteviews::supported == false` on RDNA 2), VB/IB descriptor `SizeInBytes` in `draw.rs`, and root CBV/SRV/UAV byte bounds + RT scratch barriers in `host.rs` / `rt.rs`. - **Wide internal `cardhash` dispatches**: splits >65,535-group `Dispatch` calls in `host.rs`. 2. **Why #379's fault is outside this patch**: - In #379 (RX 6900 XT RDNA 2), DRED shows an offending VA at **exact `view heap base + 0xF0000000`** (`0xEE17B800` / slot `0x07800000` past the view heap's end) with `DispatchMeshIndirectMulti` markers in progress, and persisted on `v1.1.6-amd`. - None of the bounds added in PR #455 clamp root descriptor-table GPU virtual addresses (`SetGraphicsRootDescriptorTable` / heap base + offset) or rewrite `DispatchMeshIndirectMulti` indirect arguments/fetches (moreover, translated shader `heap_handle` already clamps to `VIEW_LIMIT`, so a slot-0x07800000 view-heap VA points toward an unbound/stale descriptor table handle, indirect command payload, or driver/hardware fetch path that this PR does not touch). - Separately, #379 also notes a useful diagnostic gap (`"a host command list did not reset"` not appending `removal_data` in `fail()`), which is worth addressing in its own focused change. PR description updated accordingly so #379 is not conflated with this PR.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/455/head:github-bot/gh-455'
git switch 'github-bot/gh-455'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-455'
git switch 'github-bot/gh-455'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-455'
git switch 'github-bot/gh-455'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-455'
git switch 'main'
git merge --squash 'github-bot/gh-455'
git switch 'main'
git merge --ff-only 'github-bot/gh-455'
git switch 'main'
git merge 'github-bot/gh-455'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.