Shaders: scalar loads from a code table at the first lane's address #1276
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1276
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1276/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@mercuryVM on GitHub · 2026-11-24 17:02 UTC · original
mercuryVM:impl2/first-lane-code-address→main· +334 −8 · 4 files · 1 commits · closed without mergingWhat
The console compiler reads a constant array at an index it treats as uniform in a specific way. It builds a VGPR address (the
s_getpc_b64table base plus the scaled index), reads both dwords withv_readfirstlane_b32, and then issues ans_load_dword*at that address. The resource tracker refused these programs withan address not from a root parameter.resource.rs:Tracer::addressnow follows the two first-lane reads back to the VGPR address. If that address is a code-table base plus a per-lane term, it records the address with the lane's term and the read (Address::first_lane, new field). This only applies when the load is later in the same block and nothing in between writes EXEC. Otherwise the program is refused witha first-lane address read with other lanes. A root-parameter base in this form is refused with its own reason,a first-lane address from a root parameter, because the descriptor paths re-derive addresses from registers.emit/lower.rs: the three places that addAddress::dynamicnow share one helper,address_term. For a first-lane address it emitsWaveReadLaneFirstof the term inside thev_readfirstlane_b32's lane guard. It then broadcasts the result to every lane with an unsignedWaveActiveMaxover the guarded value and zeros.console_lanes, so they declare the console's wave size, like other code that reads other lanes.a descriptor built around a first-lane address). None was seen in the package.Measured
Package: the user's own Series 1.0.2.1
shaders.rpf.victory translate <shaders.rpf> --validate --list --jobs 4,origin/mainffe310evs this branch:an address not from a root parametera descriptor read only as data.shader does not translatewarnings): an exposure downsample pass (2 programs) and an irradiance SH integration (2 programs).s_or_b32from a descriptor's base address. They are inline ray tracing that reads the BVH (see #274), which is out of scope here.--pipelinesover the whole package did not finish within the 20 minutes I can hold the shared GPU, on either build, so I have no pipeline counts. The new GPU test creates the pipeline for its synthetic program.Tests
Windows 11 Pro, NVIDIA GeForce RTX 5070, AMD CPU. All fixtures are hand-written GFX10 words, with no game data.
resource::tests::a_first_lane_address_of_a_code_table_is_traced: the load is traced toCODEat the table's offset, withfirst_laneset.resource::tests::a_first_lane_address_read_with_other_lanes_is_refused: with EXEC restored between the reads and the load, it is refused with the new reason.emit::first_lane_tests::every_lane_loads_the_entry_the_first_lane_addresses: 32 lanes, withv_cmpxleaving lanes 6..31. Each lane addresses entry (lane + 3) & 7 and reads it from the first lane. Expected result: lanes 6..31 all store entry 1, lanes 0..5 store nothing. Passes on the RTX 5070. WARP is skipped because it creates noWaveSize(32)pipeline (the diff tests skip it the same way).Commands:
cargo test -p victory-shader --lib first_lane -- --test-threads=1: 11 passed.cargo test --workspace -- --test-threads=1: 345 passed, 0 failed, 6 ignored.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.rustfmt --edition 2024 --checkon the changed files: no diffs in changed lines. The remaining diffs inlower.rsandresource.rsare already on main.cargo xtask policy: 155 files ok.Not tested
--pipelinescounts (see above).v_readfirstlane_b32lowering does.Overlap
v_readfirstlane_b32in addresses, as part of a 2.2k-line change that currently conflicts with main. Its lowering emitsWaveReadLaneFirstwithout the lane guard, which the GPU test above shows reads the wrong lane underv_cmpx. This PR is the narrow code-table case only. If #645 lands first, the guard handling here still applies to it.v_readfirstlane_b32lowering has the same unguarded read. That is not changed here; it could follow.AI-assisted (Claude Code).
🤖 Generated with Claude Code
@MichaelSmithAI on GitHub · 2026-11-24 17:16 UTC · original
Independent code-table readback on
b95831ewith an RTX 4090 under Wine/GE 3.2. The synthetic table contained0x100 + index. With a 32-lane shader and EXEC restricted to lanes 10–31, the first active lane selected entry 2, and all active lanes stored0x102. A second shader initialized the index to 0, wrote 3 only on lanes ≥10, then restored EXEC before the first-lane read. Every lane stored0x100, as expected for the reconvergence case discussed on #1231. Wine returned the same hardware adapter for the WARP request.Both 64-lane versions were refused at pipeline creation on this 32-lane adapter. In a separate local merge with #439 at
bf0f951, those shaders ran. The divergent case returned entry 0 for all 54 active lanes, where lane 10 selected entry 2. The reconverged case returned entry 3 in the upper 32 lanes, where the console’s lane 0 selected entry 0. This is a concrete integration test for routing the address broadcast through #439’s console-wave exchange.For the four exposure/irradiance programs in the report, do you have the declared wave size for each hash? The cited world logs establish that these hashes hit translation refusals. Their wave sizes would help distinguish which ones need the cross-half path when checking pipeline creation after this change.
@pablogonz12 on GitHub · 2026-11-24 17:27 UTC · original
Setup: Linux, RX 9070 XT, RADV (Mesa 26.3.1), dxil-spirv master, spirv-val 1.3. Your head folded onto a base of origin/main
ffe310eplus #1017 (main's host build fails without it:E0425 host_resource), then the four-stage offline check over 768 programs (751-program world dump + 52-program BVH capture, 35 duplicate containers skipped).+2 programs translate and none is lost: "an address not from a root parameter" goes from 3 compute programs to 1, and no other reason moves. Same 10 SPIR-V validation failures as the base. (It clears the same two programs as #1225 and #1231 — the three reach the same class from different sides.)
Not tested: in-game.
@wwwwwwww3333333 on GitHub · 2026-11-24 19:16 UTC · original
Native Windows run on AMD RDNA2: RX 6750 XT (RDNA2, gfx1031), AMD driver 32.0.21045.29003, i5-13400F, Windows 11, Rust 1.98.1 MSVC. Head
b95831eon mainffe310e(clean merge).cargo test -p victory-shader --lib -- --test-threads=1: 123 passed, 0 failed, 1 ignored (main alone: 120). The new tests pass:first_lane_tests::every_lane_loads_the_entry_the_first_lane_addresses,resource::tests::a_first_lane_address_of_a_code_table_is_tracedandresource::tests::a_first_lane_address_read_with_other_lanes_is_refused. The description lists AMD hosts as untested; this is AMD's native D3D12 driver. (Output was captured, so I can't say from this run whether WARP took its skip path.)Synthetic tests only, no game files. AI-assisted (Claude picked the PRs and wrote the batch script; I ran it on my machine).
@mercuryVM on GitHub · 2026-11-24 19:18 UTC · original
Thanks for the runs.
@MichaelSmithAI, wave sizes. I read the
wave64flag of each program on the package.So 3 of the 4 are wave64. This PR makes a program with a per-lane first-lane address declare the console's wave size (
console_lanes). On a 32-lane host, those 3 then translate and validate but fail pipeline creation until wave64 emulation (#233 / #439) lands. On a 32-lane host this PR only changes the outcome for the wave32 one. Your #439 result (entry 0 for all lanes where lane 10 picked entry 2) suggests the broadcast has to go through #439's console-wave exchange there. I'll note that in the body.Overlap with #1225 / #1231. Both are older than this PR, and I missed them when I searched. #1225 handles the uniform case without any wave op: when every lane holds the same index, it reads the source directly. That is better for wave64 programs on 32-lane hosts, since no wave size is declared. pablogonz12 reports that #1225 and #1231 clear the same programs as this PR in their dump. This PR adds the non-uniform case (first-lane semantics under the read's lane guard). That case is only needed where the uniformity proof fails.
I'd suggest landing #1225 / #1231 first. I'll then restack this PR on them, so the wave op is used only for addresses they cannot prove uniform. If nothing in the title needs that case, I'll close this PR.
@catminou4.
first_lane_testsran on Windows 11 with an RTX 5070 (passes). WARP is skipped because it creates noWaveSize(32)pipeline. The details are in the body.@Marvisak on GitHub · 2026-11-25 00:36 UTC · original
Automated triage for the maintainers. Closing because this change is already in
main, ormainhas since replaced the code it patches.Scalar loads from a code table at a first-lane address. Main traces these since commit
27c3dc9d(resource.rs:816-865, reaches_pc follows v_readfirstlane_b32 back to s_getpc_b64); the world list has no program left with 'an address not from a root parameter'. Same topic as #1225.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