GPU: an acceleration structure's view address is its location #2096

Open
moe-miau wants to merge 1 commit from upstream-pr/2098 into main
moe-miau commented 2026-11-25 04:52:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by moe-miau on 2026-11-25T04:52:34Z.


What

A ray tracing acceleration structure's shader view has no resource. The title creates it with pResource = NULL, and its description holds the structure's address: D3D12's Location, dwords 4 and 5 of the title's view words. HostHeap's view addresses only knew buffer views, through buffer_range. For such a slot the entry was 0.

The world's ray traced pass, f607780aa8e502d0 (program A of #1968), takes its BVH's address from exactly this view. It loads the descriptor at table offset 0x80 and masks dwords 0-1 into a 40-bit base (s_and_b32 s4, s20, 0xffffff00, s_and_b32 s5, s21, 0xff), which Lower::view_addresses serves from the view addresses. It then walks the BVH with image_bvh64_intersect_ray, in a loop the title bounds at 65,535 iterations per wave (s_cmpk_lt_u32 s27, 0xffff). With an entry of 0 it walks whatever lies at address 0, not the BVH the title built.

In the logs, A's view at s1+32 is buffer None words [0, 11, 5768, 0, 1595719680, 13, ...]: dimension 11 (D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE), location 0xd_5f1c_0000.

Change

  • descriptor/host.rs: view_address(view). An acceleration structure's shader view gives its location; any other view its buffer's first byte, as before, or 0. write_address uses it.
  • Test descriptor::host::tests::an_acceleration_structures_view_address_is_its_location: the entry for such a view is its location, a placed buffer view keeps its own address, and no view gives zeros. It fails on main (left: [.., 0, 0]) and passes with the change.

Relation to #1906

#1906 gives a table made afresh in the dynamic slots its view-address entries. Without it, A's table on a capped heap reads past the end of the buffer, which is the hang several testers confirmed it removes. #1906 writes those entries through the same write_address, so with #1906 alone A's BVH base is 0. This PR is the other half: the entry is the structure's location. The two touch neighbouring lines: merged together, they conflict only in write_address's doc comment, where both sentences belong.

Tested

Windows 11 26300, RTX 4070 SUPER 12 GB, driver 32.0.16.1742, Ryzen 7 7700X. Title 1.0.2.1, Series X profile, diag build. Scripted Enter presses to the intro cutscene at about 90 s, 6-minute runs. Base: main 940d32f + #1775 + #1762 + #1906 (astrosteveo's rebase 01ba70d). #1968's program C was not reached in these runs (never bound).

base base + this PR
end no removal in 6 min no removal in 6 min
A's dispatches (records read back after the clamp) 0-2 groups each 0-2 groups each
slowest submission 1,240 ms 1,293 ms

What this does not show on this card: a difference in the picture. In a third run with this PR, a local log read the two acceleration structures A binds (0xd_5f1c_0000, 0xd_6016_0000, taken from an earlier run's log; the title's addresses have been the same in every run so far) every time A was dispatched: 553 times over 3.5 minutes. They held only zeros, in the host copy A reads and in title memory. The world's BVH is never built here. Five of the BVH builder's programs (XboxBvhBuilder.dll: 14394a322f6dd5c2, 28918b7150a7aad5, caa78b8ca62bc3d6, e63d22c4def9ba6a, f6eb6498409ca974) are 64-lane programs this card refuses.

So on NVIDIA this change gives A the right address, and its effect waits for the builder to run there. On a GPU that runs the builder (64-lane hosts), A should now walk the BVH the title built instead of address 0. I have no such GPU to check that.

  • cargo test -p victory-gpu --locked: 142 passed, 2 failed, 2 ignored. The two failures (descriptor::host::tests::dynamic_slots_are_held_until_released, memory::tests::lists_share_a_table_and_copies_keep_their_views) fail the same way on main on this card (the 1,000,000 view heap cap).
  • cargo clippy --workspace --all-targets --locked -- -D warnings, also with --all-features: clean. cargo xtask policy: 182 files ok.

AI-assisted (Claude Code). Runs done on my machine.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:5485401485 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2098). Originally posted by [moe-miau](https://github.com/moe-miau) on 2026-11-25T04:52:34Z. --- ## What A ray tracing acceleration structure's shader view has no resource. The title creates it with `pResource = NULL`, and its description holds the structure's address: D3D12's `Location`, dwords 4 and 5 of the title's view words. `HostHeap`'s view addresses only knew buffer views, through `buffer_range`. For such a slot the entry was 0. The world's ray traced pass, `f607780aa8e502d0` (program A of #1968), takes its BVH's address from exactly this view. It loads the descriptor at table offset 0x80 and masks dwords 0-1 into a 40-bit base (`s_and_b32 s4, s20, 0xffffff00`, `s_and_b32 s5, s21, 0xff`), which `Lower::view_addresses` serves from the view addresses. It then walks the BVH with `image_bvh64_intersect_ray`, in a loop the title bounds at 65,535 iterations per wave (`s_cmpk_lt_u32 s27, 0xffff`). With an entry of 0 it walks whatever lies at address 0, not the BVH the title built. In the logs, A's view at `s1+32` is `buffer None words [0, 11, 5768, 0, 1595719680, 13, ...]`: dimension 11 (`D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE`), location `0xd_5f1c_0000`. ## Change - `descriptor/host.rs`: `view_address(view)`. An acceleration structure's shader view gives its location; any other view its buffer's first byte, as before, or 0. `write_address` uses it. - Test `descriptor::host::tests::an_acceleration_structures_view_address_is_its_location`: the entry for such a view is its location, a placed buffer view keeps its own address, and no view gives zeros. It fails on `main` (`left: [.., 0, 0]`) and passes with the change. ## Relation to #1906 #1906 gives a table made afresh in the dynamic slots its view-address entries. Without it, A's table on a capped heap reads past the end of the buffer, which is the hang several testers confirmed it removes. #1906 writes those entries through the same `write_address`, so with #1906 alone A's BVH base is 0. This PR is the other half: the entry is the structure's location. The two touch neighbouring lines: merged together, they conflict only in `write_address`'s doc comment, where both sentences belong. ## Tested Windows 11 26300, RTX 4070 SUPER 12 GB, driver 32.0.16.1742, Ryzen 7 7700X. Title 1.0.2.1, Series X profile, diag build. Scripted Enter presses to the intro cutscene at about 90 s, 6-minute runs. Base: `main` `940d32f` + #1775 + #1762 + #1906 (astrosteveo's rebase `01ba70d`). #1968's program C was not reached in these runs (never bound). | | base | base + this PR | |---|---|---| | end | no removal in 6 min | no removal in 6 min | | A's dispatches (records read back after the clamp) | 0-2 groups each | 0-2 groups each | | slowest submission | 1,240 ms | 1,293 ms | **What this does not show on this card:** a difference in the picture. In a third run with this PR, a local log read the two acceleration structures A binds (`0xd_5f1c_0000`, `0xd_6016_0000`, taken from an earlier run's log; the title's addresses have been the same in every run so far) every time A was dispatched: 553 times over 3.5 minutes. They held only zeros, in the host copy A reads and in title memory. The world's BVH is never built here. Five of the BVH builder's programs (`XboxBvhBuilder.dll`: `14394a322f6dd5c2`, `28918b7150a7aad5`, `caa78b8ca62bc3d6`, `e63d22c4def9ba6a`, `f6eb6498409ca974`) are 64-lane programs this card refuses. So on NVIDIA this change gives A the right address, and its effect waits for the builder to run there. On a GPU that runs the builder (64-lane hosts), A should now walk the BVH the title built instead of address 0. I have no such GPU to check that. - `cargo test -p victory-gpu --locked`: 142 passed, 2 failed, 2 ignored. The two failures (`descriptor::host::tests::dynamic_slots_are_held_until_released`, `memory::tests::lists_share_a_table_and_copies_keep_their_views`) fail the same way on `main` on this card (the 1,000,000 view heap cap). - `cargo clippy --workspace --all-targets --locked -- -D warnings`, also with `--all-features`: clean. `cargo xtask policy`: 182 files ok. AI-assisted (Claude Code). Runs done on my machine. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
DenRakEiw commented 2026-11-25 04:56:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T04:56:54Z.

Review: APPROVED


Verified locally merged onto origin/main (940d32f, Windows 11 x64, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu --lib an_acceleration_structures_view_address_is_its_location — passed
  • cargo clippy -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean view_address handling returning an acceleration structure's GPU location with targeted unit test coverage. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6052066466 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2098#pullrequestreview-6052066466). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T04:56:54Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu --lib an_acceleration_structures_view_address_is_its_location` — passed - `cargo clippy -p victory-gpu --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean `view_address` handling returning an acceleration structure's GPU location with targeted unit test coverage. Looks good. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-25 05:02:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T05:02:22Z.

Review: COMMENTED


Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Acceleration structure view address = its location — BLAS/TLAS address fix; correctness for ray-tracing descriptor paths.

<!-- greyfinch-sync:Marvisak/VIctory:review:6052105217 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2098#pullrequestreview-6052105217). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T05:02:22Z. **Review:** COMMENTED --- Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. Acceleration structure view address = its location — BLAS/TLAS address fix; correctness for ray-tracing descriptor paths.
Marvisak commented 2026-11-25 11:05:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T10:37:13Z.


Automated triage for the maintainers.

Merge candidate. The head is rebased (543d868) and merges cleanly into current main. The change is the same as before. In descriptor/host.rs, write_address now takes its address from the new view_address. For an SRV of dimension D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE, that is the description's Location (dwords 4-5, which matches the D3D12_SHADER_RESOURCE_VIEW_DESC layout). Every other view keeps buffer_range as before. Such a view has no resource, so main wrote 0 for it. #1906, now in main, writes the dynamic-slot entries through the same function, so this is the other half of that fix. The unit test runs without a device and checks the acceleration-structure entry, a placed buffer view and an empty slot. CI (check) passes on this head.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7159943463 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2098#issuecomment-7159943463). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T10:37:13Z. --- <!-- victory-triage v1 head=543d8688068b658ca4bf9602887097b215fec838 verdict=merge-candidate at=2026-11-26T01:21:06Z --> Automated triage for the maintainers. **Merge candidate.** The head is rebased (`543d868`) and merges cleanly into current `main`. The change is the same as before. In `descriptor/host.rs`, `write_address` now takes its address from the new `view_address`. For an SRV of dimension `D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE`, that is the description's `Location` (dwords 4-5, which matches the `D3D12_SHADER_RESOURCE_VIEW_DESC` layout). Every other view keeps `buffer_range` as before. Such a view has no resource, so `main` wrote 0 for it. #1906, now in `main`, writes the dynamic-slot entries through the same function, so this is the other half of that fix. The unit test runs without a device and checks the acceleration-structure entry, a placed buffer view and an empty slot. CI (`check`) passes on this head. --- _Generated by [Claude Code](https://claude.ai/code)_
moe-miau commented 2026-11-25 17:05:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by moe-miau on 2026-11-25T16:49:46Z.


Rebased onto main 67e8ae1 (head 33a65d1). main now writes 16-byte view-address entries with texture size words (texture_words); the only conflict was write_address, which keeps main's new form and takes its address from view_address. The test now checks 16-byte entries (an acceleration structure's and a placed buffer's address in dwords 0-1, zeros after). cargo test -p victory-gpu: 194 passed, 2 failed (dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views, the same as main on this RTX 4070 SUPER); both clippy configurations and cargo xtask policy clean.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7168594278 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2098#issuecomment-7168594278). Originally posted by [moe-miau](https://github.com/moe-miau) on 2026-11-25T16:49:46Z. --- Rebased onto `main` `67e8ae1` (head `33a65d1`). `main` now writes 16-byte view-address entries with texture size words (`texture_words`); the only conflict was `write_address`, which keeps `main`'s new form and takes its address from `view_address`. The test now checks 16-byte entries (an acceleration structure's and a placed buffer's address in dwords 0-1, zeros after). `cargo test -p victory-gpu`: 194 passed, 2 failed (`dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views`, the same as `main` on this RTX 4070 SUPER); both clippy configurations and `cargo xtask policy` clean.
fuzeofficlal commented 2026-11-26 19:38:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T19:38:10Z.

Review: APPROVED


Reviewed and verified 543d8688068b658ca4bf9602887097b215fec838 merged onto origin/main (63bcca43c6a00a758510398fa43096ce7e4f7df0) on Windows 11 x64 (RTX 5090 + Microsoft WARP, --features diagnostics with VICTORY_D3D12_DEBUG=1, Rust 1.98.1 MSVC).

Code & Layout Audit

  • view_address (crates/victory-gpu/src/descriptor/host.rs:1159-1168) extracts u64::from(desc[4]) | u64::from(desc[5]) << 32 when View::Shader(_, Some(desc)) has desc[1] == D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE.0 as u32 (11), falling back to buffer_range(view) for all other views.
  • Verified against the Windows D3D12 ABI (size_of::<D3D12_SHADER_RESOURCE_VIEW_DESC>() == 40): transmuting a real D3D12_SHADER_RESOURCE_VIEW_DESC with RaytracingAccelerationStructure.Location = 0xd_5f1c_0000 places dimension 11 in words[1] and the 64-bit Location in words[4..6] (following the 4-byte alignment padding at words[3]).
  • write_address (L1077-1086) writes the 48-bit address into dwords 0-1 (masking dword 1 with & 0xFFFF, zeros in dwords 2-3), while make_view returns None for the resourceless RTAS view without triggering any D3D12 validation errors.

Local Verification

  • cargo xtask policy — pass (191 files ok).
  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default and --all-features) — 0 warnings.
  • cargo test --locked -p victory-gpu --features diagnostics --lib descriptor::host::tests::an_acceleration_structures_view_address_is_its_location (RTX 5090 and WARP) — passed.
  • Additional synthetic probe verifying the D3D12_SHADER_RESOURCE_VIEW_DESC transmute ABI, 48-bit high-word masking, zero location, and make_view + write_address under VICTORY_D3D12_DEBUG=1 — passed on both RTX 5090 and WARP with GetDeviceRemovedReason() == Ok(()) and 0 ID3D12InfoQueue messages.

Looks good to merge.

<!-- greyfinch-sync:Marvisak/VIctory:review:6079633974 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2098#pullrequestreview-6079633974). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T19:38:10Z. **Review:** APPROVED --- Reviewed and verified `543d8688068b658ca4bf9602887097b215fec838` merged onto `origin/main` (`63bcca43c6a00a758510398fa43096ce7e4f7df0`) on Windows 11 x64 (RTX 5090 + Microsoft WARP, `--features diagnostics` with `VICTORY_D3D12_DEBUG=1`, Rust 1.98.1 MSVC). ### Code & Layout Audit - `view_address` (`crates/victory-gpu/src/descriptor/host.rs:1159-1168`) extracts `u64::from(desc[4]) | u64::from(desc[5]) << 32` when `View::Shader(_, Some(desc))` has `desc[1] == D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE.0 as u32` (11), falling back to `buffer_range(view)` for all other views. - Verified against the Windows D3D12 ABI (`size_of::<D3D12_SHADER_RESOURCE_VIEW_DESC>() == 40`): transmuting a real `D3D12_SHADER_RESOURCE_VIEW_DESC` with `RaytracingAccelerationStructure.Location = 0xd_5f1c_0000` places dimension `11` in `words[1]` and the 64-bit `Location` in `words[4..6]` (following the 4-byte alignment padding at `words[3]`). - `write_address` (`L1077-1086`) writes the 48-bit address into dwords 0-1 (masking dword 1 with `& 0xFFFF`, zeros in dwords 2-3), while `make_view` returns `None` for the resourceless RTAS view without triggering any D3D12 validation errors. ### Local Verification - `cargo xtask policy` — pass (`191 files ok`). - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` (default and `--all-features`) — 0 warnings. - `cargo test --locked -p victory-gpu --features diagnostics --lib descriptor::host::tests::an_acceleration_structures_view_address_is_its_location` (RTX 5090 and WARP) — passed. - Additional synthetic probe verifying the `D3D12_SHADER_RESOURCE_VIEW_DESC` transmute ABI, 48-bit high-word masking, zero location, and `make_view` + `write_address` under `VICTORY_D3D12_DEBUG=1` — passed on both RTX 5090 and WARP with `GetDeviceRemovedReason() == Ok(())` and 0 `ID3D12InfoQueue` messages. Looks good to merge.
zed6000 commented 2026-11-27 15:03:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by zed6000 on 2026-11-27T15:03:10Z.


Supporting evidence from an AMD RX 7900 XTX run of the intro. It explains why the game's interiors and faces look so dark: there is no indirect light. This PR fixes the first link of that chain. I haven't run it.

  • Views of acceleration structures get address 0 today. 13 compute pipelines bind acceleration-structure views. write_address takes the address from buffer_range, which is None for such a view, so in one run all 8,192 of the 8,192 such table entries were written with address 0, although the title named a location each time. This PR gives them their location.
  • The structures are still empty, so this PR alone should not change the picture. 5 distinct structure locations were used, and none has a non-zero byte in its first 256 bytes of title memory. The builder's output never reaches title memory. Every world frame with title-memory lists has a "memory with no copy" miss, withholding stays on, 0 pages are copied back, and 348,000 to 812,000 page writes are withheld per run. That withholding is the remaining blocker for the ray-traced indirect light.
  • What it looks like: the indirect diffuse buffer holds one flat sky colour right after a cut, then isn't rewritten later in the shot. Surfaces outside direct light are near black: a white wall outside any light cone is about 150 times darker than a lit cheek. Albedo itself is normal, and we found no dropped passes and no translation failures.

Measured on a branch that carries several other open PRs, not plain main.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7221562859 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2098#issuecomment-7221562859). Originally posted by [zed6000](https://github.com/zed6000) on 2026-11-27T15:03:10Z. --- Supporting evidence from an AMD RX 7900 XTX run of the intro. It explains why the game's interiors and faces look so dark: there is no indirect light. This PR fixes the first link of that chain. I haven't run it. - **Views of acceleration structures get address 0 today.** 13 compute pipelines bind acceleration-structure views. `write_address` takes the address from `buffer_range`, which is `None` for such a view, so in one run all 8,192 of the 8,192 such table entries were written with address 0, although the title named a location each time. This PR gives them their location. - **The structures are still empty, so this PR alone should not change the picture.** 5 distinct structure locations were used, and none has a non-zero byte in its first 256 bytes of title memory. The builder's output never reaches title memory. Every world frame with title-memory lists has a "memory with no copy" miss, withholding stays on, 0 pages are copied back, and 348,000 to 812,000 page writes are withheld per run. That withholding is the remaining blocker for the ray-traced indirect light. - **What it looks like:** the indirect diffuse buffer holds one flat sky colour right after a cut, then isn't rewritten later in the shot. Surfaces outside direct light are near black: a white wall outside any light cone is about 150 times darker than a lit cheek. Albedo itself is normal, and we found no dropped passes and no translation failures. Measured on a branch that carries several other open PRs, not plain `main`.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2098:upstream-pr/2098'
git switch 'upstream-pr/2098'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2098'
git switch 'upstream-pr/2098'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2098'
git switch 'upstream-pr/2098'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2098'
git switch 'main'
git merge --squash 'upstream-pr/2098'
git switch 'main'
git merge --ff-only 'upstream-pr/2098'
git switch 'main'
git merge 'upstream-pr/2098'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!2096
No description provided.