Shaders: in a pixel loop, a helper lane's v_readfirstlane_b32 reads its own value #224
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/224"
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?
Imported from DexNom/VIctory. Originally posted by murillojndem on 2026-11-29T10:23:14Z.
On the console, whole-quad mode puts a pixel shader's helper lanes in EXEC, so a loop over the lanes' values (read the first lane's with
v_readfirstlane_b32, run the lanes holding it, take them out of EXEC, as the console compiler's waterfall loops do) serves the helper lanes too, each in the pass that reads its value. The host's wave operations leave helper lanes out (DXIL withoutWaveOpsIncludeHelperLanes), and in the tests below the helpers of such a loop leave it with the values they held before it. Their quads then read those values after the loop: a DPP quad read here, and an implicit derivative reads the same lanes.Marvisak/VIctory@0601955 (by Vax; upstream PR 1733, for upstream issue 908) reports the effect in the title, with the loop limit then at 1<<20: draws of 0.3 to 1.3 s each until DEVICE_HUNG, about 200 s into the world. This tree cuts pixel loops at 128 passes, so the cost is bounded here; the wrong values after the loop remain.
Change: inside a loop of a pixel shader, a helper lane (
dx.op.isHelperLane) takes its own value asv_readfirstlane_b32's result. It matches in its first pass and leaves with the value it leaves with on the console. Lanes that are not helpers read the first lane's value as before. Two kinds of read are unchanged:resource::Waterfalldid not prove, which the translation then loads with one index for all lanes; a helper's own value would make that index differ between lanes.Waterfalls that
resource::Waterfallproves are already read per lane and do not reach this code.This restores
0601955for loops only. Upstream's form applies to every read, which in a test below gives the helpers of a triangle's edge quads their own value outside a loop, where the console gives them the first lane's.0601955is in this repository's history:570a941("Publish DexNom Runtime Radeon sources with upstream credits and build instructions") removed it, with no note on why. If that was deliberate for the Radeon runtime, this PR is not wanted. For traceability: #114, #115, #130 and #173 carry a commit (9fea743) with upstream's form applied to every first-lane read of a pixel shader, code-table addresses included, on unlessVICTORY_HELPER_OWN=0. This PR is the change alone, limited to loops, with tests.Tests, in
emit::helper_lane_tests. Each draws two triangles that share a diagonal into a 16x16 target, so the quads on the diagonal hold helper lanes, and runs on WARP and on the hardware adapter:helper_lanes_leave_a_first_lane_loop_with_their_own_key: a whole-quad pixel program runs a first-lane loop over a key unique to each pixel, then reads its quad's four keys.helpers_sharing_their_quads_key_leave_the_loop_with_it: the same with the quad's index as the key, which the quad's lanes share (a primitive's or a material's index in a title).drawn_lanes_take_their_turn_in_a_first_lane_loop: with a key a row shares, the triangle's own lanes still leave in different passes.a_first_lane_read_reaches_the_helper_lanes: outside a loop, every quad reads one first-lane value, edge quads included.emit::lower::tests::a_first_lane_read_feeding_a_scalar_load_is_found: a first-lane read shifted into a scalar load's offset is found, one only a compare reads is not.Results on
4ad8692, on WARP and an RX 7900 XT (driver 32.0.32015.7029):mainrecttests fail PSV0 validation with the SDK 10.0.22621dxil.dll, and threevalu_testsfail pipeline creation on WARP only. On the RX 7900 XT it gives 242 passed, 2 failed (therecttests), 4 ignored.cargo clippy -p victory-shader --all-targets --locked -- -D warningsis clean with and without--all-features,cargo xtask policypasses, and rustfmt reports nothing new.Limits:
mainalready gives such a body nothing from these helpers: in a test that counted passes inside the body (not in this PR), their count stayed 0 even when they shared their quad's key.s_ff1plusv_readlane_b32form of such a loop, and code-table addresses read throughv_readfirstlane_b32(code_smem).Claude (Anthropic) ported the change, wrote the tests, and ran them on WARP and on the RX 7900 XT under the adaptive GPU rules.
Generated with Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.