Repository navigation
Shaders: an address in two root constants is a root view (#614) - #667
AlanQiang0418 wants to merge 1 commit into
Conversation
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
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.
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.
|
Automated triage for the maintainers. Closing because this change is already in 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. |
…tname-440-111a HLE: allow local gethostname through offline resolvable() (Marvisak#440)
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
resource.rs): a root constant is an address's low half when the next dword of the same parameter is its high half.Address::dwordsays which dword. Halves split over two parameters stay refused.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.draw.rs,pipeline/host.rs): the address is read from the two constants the title set, then bound through the existingroot_viewpath (alignment, scratch copy).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 passesdxil.dllvalidation, andHost::compute_pipelineaccepts 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, andcargo xtask policypasses.Not covered
a root UAV or typed root view. The spill table (Shaders: read root arguments the console spills to memory #302) is also needed before any of this runs in the title.Overlap
VSH2and widens root views, so whichever lands second needs a rebase.Tracer::address/suminresource.rsand stops treating root constants as a base. This PR gives constant-pair addresses their own path inaddress().AI-assisted (Claude Code).
🤖 Generated with Claude Code