Shaders: an address in two root constants is a root view (#614) #667

Closed
AlanQiang0418 wants to merge 1 commit from upstream-pr/667 into main
AlanQiang0418 commented 2026-11-24 06:25:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AlanQiang0418 on 2026-11-24T06:25:25Z.


Part 2 of #614: the ray-tracing builder passes buffer addresses as a pair of root constants instead of root views, and its programs fail with an address from a root parameter that is no address.

What

  • Tracking (resource.rs): a root constant is an address's low half when the next dword of the same parameter is its high half. Address::dword says which dword. Halves split over two parameters stay refused.
  • Lowering (emit/lower.rs, emit/mod.rs, emit/shader.rs): such an address is bound as a root CBV or raw SRV, like root descriptors, at a register that names the parameter and the dword: RootView, (dword + 1) << 8 | slot. A root descriptor's register is still its slot. Root view registers are 16 bits now.
  • GPU (draw.rs, pipeline/host.rs): the address is read from the two constants the title set, then bound through the existing root_view path (alignment, scratch copy).
  • Shader cache: format VSH2 (16-bit registers), so old entries are translated again.

Tests

Synthetic programs only, no game data. Windows 11, RTX 5080 (driver 621.14), and WARP.

  • resource.rs: an address in constants 2 and 3 is traced to that view; halves in two parameters are refused.
  • lower.rs: a compute program reading through a descriptor built around two constants lowers to a root CBV at the new register. The module passes dxil.dll validation, and Host::compute_pipeline accepts it on the RTX 5080 and on WARP.
  • draw.rs: the address comes from the right constants; a missing high half, the wrong parameter kind and the other pipeline kind give none.
  • shader_cache.rs: the round trip includes a 16-bit register.
  • cargo test -p victory-shader -p victory-gpu: 72 + 44 passed. Clippy is clean for the changed code, and cargo xtask policy passes.

Not covered

  • Most of the builder's buffers are written, so those programs still need root UAVs (#294); they now stop at a root UAV or typed root view. The spill table (#302) is also needed before any of this runs in the title.
  • The 12 programs in #614 whose addresses come from neither kind of root parameter.
  • Not checked in the title.

Overlap

  • #294 also takes VSH2 and widens root views, so whichever lands second needs a rebase.
  • #645 also edits Tracer::address/sum in resource.rs and stops treating root constants as a base. This PR gives constant-pair addresses their own path in address().

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6576007493 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/667). Originally posted by [AlanQiang0418](https://github.com/AlanQiang0418) on 2026-11-24T06:25:25Z. --- Part 2 of #614: the ray-tracing builder passes buffer addresses as a pair of root constants instead of root views, and its programs fail with `an address from a root parameter that is no address`. ## What - **Tracking** (`resource.rs`): a root constant is an address's low half when the next dword of the same parameter is its high half. `Address::dword` says which dword. Halves split over two parameters stay refused. - **Lowering** (`emit/lower.rs`, `emit/mod.rs`, `emit/shader.rs`): such an address is bound as a root CBV or raw SRV, like root descriptors, at a register that names the parameter and the dword: `RootView`, `(dword + 1) << 8 | slot`. A root descriptor's register is still its slot. Root view registers are 16 bits now. - **GPU** (`draw.rs`, `pipeline/host.rs`): the address is read from the two constants the title set, then bound through the existing `root_view` path (alignment, scratch copy). - **Shader cache**: format `VSH2` (16-bit registers), so old entries are translated again. ## Tests Synthetic programs only, no game data. Windows 11, RTX 5080 (driver 621.14), and WARP. - `resource.rs`: an address in constants 2 and 3 is traced to that view; halves in two parameters are refused. - `lower.rs`: a compute program reading through a descriptor built around two constants lowers to a root CBV at the new register. The module passes `dxil.dll` validation, and `Host::compute_pipeline` accepts it on the RTX 5080 and on WARP. - `draw.rs`: the address comes from the right constants; a missing high half, the wrong parameter kind and the other pipeline kind give none. - `shader_cache.rs`: the round trip includes a 16-bit register. - `cargo test -p victory-shader -p victory-gpu`: 72 + 44 passed. Clippy is clean for the changed code, and `cargo xtask policy` passes. ## Not covered - Most of the builder's buffers are written, so those programs still need root UAVs (#294); they now stop at `a root UAV or typed root view`. The spill table (#302) is also needed before any of this runs in the title. - The 12 programs in #614 whose addresses come from neither kind of root parameter. - Not checked in the title. ## Overlap - #294 also takes `VSH2` and widens root views, so whichever lands second needs a rebase. - #645 also edits `Tracer::address`/`sum` in `resource.rs` and stops treating root constants as a base. This PR gives constant-pair addresses their own path in `address()`. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
LAKSHYA-cmd-tech commented 2026-11-24 06:54:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by LAKSHYA-cmd-tech on 2026-11-24T06:37:11Z.

Review: APPROVED


LGTM! Tested on Windows 11 with MSVC Rust 1.98.1. cargo test -p victory-shader passed (72 passed) and cargo test -p victory-gpu passed (44 passed, 1 benchmark ignored). Tracing addresses passed in root constants into root views cleanly satisfies DXIL validation and D3D12 pipeline creation for ray-tracing builder shaders.

<!-- greyfinch-sync:Marvisak/VIctory:review:6034746477 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/667#pullrequestreview-6034746477). Originally posted by [LAKSHYA-cmd-tech](https://github.com/LAKSHYA-cmd-tech) on 2026-11-24T06:37:11Z. **Review:** APPROVED --- LGTM! Tested on Windows 11 with MSVC Rust 1.98.1. cargo test -p victory-shader passed (72 passed) and cargo test -p victory-gpu passed (44 passed, 1 benchmark ignored). Tracing addresses passed in root constants into root views cleanly satisfies DXIL validation and D3D12 pipeline creation for ray-tracing builder shaders.
catminou4 commented 2026-11-24 06:54:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T06:42:15Z.

Review: APPROVED


Verified locally on macOS 26 arm64, rustc 1.98.1 (aarch64-apple-darwin, rust-toolchain.toml) at head 995f7f3:

  • cargo test -p victory-shader --locked: 59 passed, 0 failed (includes the new diff_tests for an address in two root constants)

The victory-gpu side of this PR is Windows-only and can't be exercised on this machine, but the shader-crate changes — the part with the test coverage — are fully green. Approving on that basis; the GPU path still needs a Windows run before merge if the maintainer wants runtime confirmation.

<!-- greyfinch-sync:Marvisak/VIctory:review:6034789311 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/667#pullrequestreview-6034789311). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T06:42:15Z. **Review:** APPROVED --- Verified locally on macOS 26 arm64, rustc 1.98.1 (aarch64-apple-darwin, rust-toolchain.toml) at head 995f7f3: - `cargo test -p victory-shader --locked`: **59 passed, 0 failed** (includes the new diff_tests for an address in two root constants) The `victory-gpu` side of this PR is Windows-only and can't be exercised on this machine, but the shader-crate changes — the part with the test coverage — are fully green. Approving on that basis; the GPU path still needs a Windows run before merge if the maintainer wants runtime confirmation.
upstream-sync closed this pull request 2026-11-25 01:04:42 +00:00
Marvisak commented 2026-11-25 01:07:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:27:06Z.


Automated triage for the maintainers. Closing because this change is already in main, or main has since replaced the code it patches.

An address in two root constants: main reads such addresses as title memory through the page table (resource.rs address(): 'an address from a root parameter that is no address' becomes MEMORY; 27c3dc9d). Same case as #710.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148523436 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/667#issuecomment-7148523436). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:27:06Z. --- Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. An address in two root constants: main reads such addresses as title memory through the page table (resource.rs address(): 'an address from a root parameter that is no address' becomes MEMORY; 27c3dc9d). Same case as #710. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

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!667
No description provided.