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

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

@⁠moe-miau on GitHub · 2026-11-25 04:52 UTC · original
moe-miau:fix/gpu-as-view-address → main · +49 −3 · 1 files · 1 commits · open

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

**@⁠moe-miau** on GitHub · 2026-11-25 04:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/2098) `moe-miau:fix/gpu-as-view-address` → `main` · +49 −3 · 1 files · 1 commits · open ## 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)
A ray tracing acceleration structure's shader view has no resource: its
description holds the structure's address (D3D12's `Location`, dwords 4
and 5 of the title's view words). The view addresses only knew buffer
views, so such a slot's entry was 0, and a program that takes its BVH's
address from that view (the world's ray traced pass, `f607780aa8e502d0`,
built.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:54:44 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 10:37 UTC · original · edited 2026-11-26 01:21 UTC

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

**@⁠Marvisak** on GitHub · 2026-11-25 10:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/2098#issuecomment-7159943463) · edited 2026-11-26 01:21 UTC <!-- 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)_
Author
Owner

@⁠moe-miau on GitHub · 2026-11-25 16:49 UTC · original

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.

**@⁠moe-miau** on GitHub · 2026-11-25 16:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/2098#issuecomment-7168594278) 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.
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/2098/head:github-bot/gh-2098'
git switch 'github-bot/gh-2098'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2098'
git switch 'github-bot/gh-2098'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2098'
git switch 'github-bot/gh-2098'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2098'
git switch 'main'
git merge --squash 'github-bot/gh-2098'
git switch 'main'
git merge --ff-only 'github-bot/gh-2098'
git switch 'main'
git merge 'github-bot/gh-2098'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2098
No description provided.