Skip to content

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

Closed
AlanQiang0418 wants to merge 1 commit into
Marvisak:mainfrom
AlanQiang0418:claude/root-constant-addresses
Closed

AlanQiang0418 wants to merge 1 commit into
Marvisak:mainfrom
AlanQiang0418:claude/root-constant-addresses

Conversation

@AlanQiang0418

Copy link
Copy Markdown
Contributor

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

Overlap

AI-assisted (Claude Code).

🤖 Generated with 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 (Marvisak#294) and the spill table (Marvisak#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 <noreply@anthropic.com>

@LAKSHYA-cmd-tech LAKSHYA-cmd-tech 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.

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 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.

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.

Kam471 pushed a commit to Kam471/VIctory that referenced this pull request Nov 24, 2026
Merged with the current 16-bit root view registers, Root UAVs, bounded
root SRV tables and relative-offset lowering. Root constant dword 0 is
still an offset, not a base; two different computed terms are represented
as a relative offset rather than refused.
nazmi pushed a commit to nazmi/VIctory that referenced this pull request Nov 24, 2026
Merged by hand across nine files; the PR's register widening lands on top of the newer structure rather than reverting it.

Kept from HEAD (the PR predates them): UserDataBind (the spilled-CBV enum from Marvisak#644) instead of the tuple the PR restores; root UAVs on stages; the SSA sum cache in resource.rs, extended with the PR's 'a root constant past a parameter's first dword is a low half' rule; and the rsrc2-taking test helpers. Taken from the PR: 16-bit root view registers (b<register>/t<register> instead of a parameter index), Address::dword, the VSH2 cache-version comment, and its new tests.

Also fixed while resolving: a nested #[test] inside another test (does not compile), four Address literals in the tracking test that predate the new dword field, and the add_stage/cbv/srv slot types widened to u16.

Verified: 613 passed / 12 ignored / 0 failed; both Clippy commands clean; fmt clean; policy 190 files.

Applied as the net diff of upstream PR Marvisak#667 (head 995f7f3), 2 commits.
@Marvisak

Copy link
Copy Markdown
Owner

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; 27c3dc9). 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 Marvisak closed this Nov 25, 2026
geiyiliyabumo pushed a commit to geiyiliyabumo/VIctory that referenced this pull request Nov 25, 2026
…tname-440-111a

HLE: allow local gethostname through offline resolvable() (Marvisak#440)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants