Skip to content

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

Open
moe-miau wants to merge 1 commit into
Marvisak:mainfrom
moe-miau:fix/gpu-as-view-address
Open

moe-miau wants to merge 1 commit into
Marvisak:mainfrom
moe-miau:fix/gpu-as-view-address

Conversation

@moe-miau

@moe-miau moe-miau commented Nov 25, 2026 •

Copy link
Copy Markdown

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

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

AwsAli05 added a commit to AwsAli05/VIctory that referenced this pull request Nov 25, 2026
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 25, 2026
clquwu added a commit to clquwu/leonida-ultimate that referenced this pull request Nov 25, 2026
…, D16S8/R16 UAV views, audit defects & Stage 2 device fixes

- Placed texture Map()/Unmap() return va_ directly with xmem page disarm (LEONIDA_LINEAR_MAP_FIRST=1 opt-out) and pre-draw per-frame xs_refresh_placed_textures on first direct ExecuteCommandLists after PresentX (ubiquitarianism/leonida@545e8d51, five-star-recomp@38a8436, GPL-3.0).
- Preserve xbox_d16s8 (118) view formats 118/119/120 in proxy SRV/DSV/placed-view paths; create depth16 UAV plane 0 as R16_TYPELESS and allow R16_UNORM (56) on R16_TYPELESS/118 depth UAVs.
- Fix cc4553c review defects: lock-held arena_release_locked + had_retired retry in arena_allocate_reclaiming; slot 127 depth fallback unconditional clear/castable sanitization; view-flag-agnostic slot 62 copy lookup + richer skip diagnostics.
- Force integer RT blendEnable=VK_FALSE (Marvisak/VIctory#2042, GPL-3.0); off-element placed structured buffer V# + PC RAW fallback (five-star-recomp@955a679, GPL-3.0); console typeless-on-typeless view fallback (Marvisak/VIctory#2190, GPL-3.0) + CBV ring tail zeroing (Marvisak/VIctory#1629, GPL-3.0); refuse MEM_MAPPED in create_host_buffer with LEONIDA_IMPORT_REMAPPABLE=1 opt-out (Neonbridge@838c433, GPL-3.0); AS SRV Location resolution (Marvisak/VIctory#2098, GPL-3.0); 3D R9G9B9E5 RT+UAV RGBA16F view format fix; true placed-texture upload totals telemetry + boot_bench parser.

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

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

@moe-miau

Copy link
Copy Markdown
Author

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.

zebraso added a commit to zebraso/VIctory that referenced this pull request Nov 25, 2026
zebraso added a commit to zebraso/VIctory that referenced this pull request Nov 25, 2026
zebraso added a commit to zebraso/VIctory that referenced this pull request Nov 25, 2026
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 25, 2026
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 <noreply@anthropic.com>
@moe-miau
moe-miau force-pushed the fix/gpu-as-view-address branch from 33a65d1 to 543d868 Compare November 25, 2026 22:41
Steenax6 added a commit to Steenax6/VIctory-NVID that referenced this pull request Nov 26, 2026
…iew is its location

A translated program that uses a view's descriptor as a pointer is given
the view's title address (USER_VIEW_ADDRESS). For a ray-tracing
acceleration structure's shader view that was 0: the view has no
resource, and the structure's address is in its description (Location,
dwords 4 and 5). The world's ray-traced pass, which takes its tree's
address that way, walked from address 0 instead of the tree the builder
made. draw::view_address now gives the location for such views and the
memory's first byte for buffer views, as before.

Source: Marvisak/VIctory PR Marvisak#2098, with its test (our tree computes view
addresses in State::host_word, not in a table of view addresses).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants