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

Closed
github-bot wants to merge 1 commit from gh-pr/667/head into gh-pr/667/base
Owner

@⁠AlanQiang0418 on GitHub · 2026-11-24 06:25 UTC · original
AlanQiang0418:claude/root-constant-addresses → main · +289 −50 · 9 files · 1 commits · closed without merging

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

**@⁠AlanQiang0418** on GitHub · 2026-11-24 06:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/667) `AlanQiang0418:claude/root-constant-addresses` → `main` · +289 −50 · 9 files · 1 commits · closed without merging 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)
The ray-tracing builder passes buffer addresses as a pair of root
constants rather than as root views, so its programs failed with
"an address from a root parameter that is no address".

The tracker now takes a root constant as an address's low half when the
next dword of the same parameter is its high half, and records which
dword (`Address::dword`). The emitter binds such an address as a root CBV
or raw SRV, as it does for root descriptors, at a register that names the
parameter and the dword (`RootView`, `(dword + 1) << 8 | slot`); root
view registers are 16 bits now. The GPU side reads the address from the
two constants the title set and binds it as it does a root view.

The shader cache format is VSH2 (16-bit registers).

Root UAVs (#294) and the spill table (#302) are still needed for the
builder's programs to translate in the title; tested with synthetic
programs only (tracking, lowering, dxil.dll validation, pipeline
creation on an RTX 5080), no game data.

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

@⁠Marvisak on GitHub · 2026-11-25 00:27 UTC · original

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.

**@⁠Marvisak** on GitHub · 2026-11-25 00:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/667#issuecomment-7148523436) 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

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