Shaders: quad reads in a pixel program's lane branch see the lanes outside EXEC #244
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/244"
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-30T16:37:39Z.
The translator turns a region that the console runs with EXEC narrowed into a per-lane branch on the host (
structure.rs,LaneExit::Branch), so a lane outside EXEC is not there inside it. A DPP ords_swizzle_b32quad read in such a region that names one of those lanes is undefined in DXIL. On the RX 7900 XT it gave the value the branch would have computed in that lane; on WARP it gave 0 or garbage. The console reads the lane's register when the DPP fetches inactive lanes (FI), and without FI treats the lane as disabled (0 with bound_ctrl, no write without).A pixel program with such a read is now translated a second time, with the EXEC branches around the read taken by whole quads through
structure::structure_wide, as compute programs already are (widen). Inwave_widea pixel quad decides by quad reads of its lanes' conditions (quad_vote), which include helper lanes; the wave operations of SM 6.6 leave helpers out. The four lanes of the quad stay together, and the lanes outside EXEC run the region under their guards, as on the console.The first translation stays whenever the second does not translate. That covers:
v_interp_p1/v_interp_p2pair reads the first half's result and could not keep the register of a lane outside EXEC. This refusal stops the second translation at once.VICTORY_QUAD_WIDE=0keeps the old translation, and the switch is part of the shader cache key. The line "shaders from the cache and translated so far" also counts the pixel programs translated this way (quad_wide), in runs that translate them rather than take them from the cache.Without FI the read is exact only together with #232, which treats a source lane outside EXEC by its guard; this change is what makes that lane present inside a lane branch.
The case was found through LloydNicholson/VIctory-Linux commit 933d51d6, which reports star flares in the bloom (
PS_BreakableGlassNoCrack) and purple speckles on glossy surfaces from such reads on RADV, and replaces the read with the lane's own value. That symptom is not reproduced here; the tests below are synthetic.Tests:
emit::dpp_lane_branch_tests::pixel_dpp_fetching_a_lane_outside_exec_in_a_lane_branch_reads_its_register: a pixel program narrows EXEC to the lanes of even x withs_and_saveexec_b32ands_cbranch_execz, changes v2 inside the branch, and moves the odd-x neighbour's v2 withv_mov_b32_dpp quad_perm:[1,0,3,2] fi:1. It is drawn as one triangle over the target and as two triangles sharing the diagonal (quads with helper lanes), on WARP and the RX 7900 XT. On main, and withVICTORY_QUAD_WIDE=0, 128 of 256 pixels are wrong on both (the card gives x + 5 where the console gives x + 1); with this change it passes on both.VICTORY_QUAD_WIDE=0they all fail.emit::rect::tests(rectangles_are_drawn_whole,the_rectangle_stage_is_a_geometry_shader), which fail on main too. On this revision a game was opened during the card run, so the suite ran on WARP only: 235 passed, 5 failed, 4 ignored; the failures are the same two rect tests and threevalu_teststhat ask for the hardware device and fail the same way on main in that mode (compute_pipeline failed). The new test ran on the card on this revision, before the game was opened.-D warnings, with and without--all-features, for victory-shader, victory-gpu and victory, andcargo xtask policypass. rustfmt reports the same differences as on main. It merges without conflicts with my open PRs and test branches.Limits:
s_cbranch_execzands_cbranch_execnzbranches are taken by quads; a quad read under a VCC or SCC branch keeps the old translation.quad_widecount in the log shows it in a run that translates them.Generated with Claude Code
Imported from DexNom/VIctory. Originally posted by Zippp69 on 2026-11-30T16:44:44Z.
Require at least one D3D12 readback in the regression test. Both backends can be skipped by
Host::new, leavingfailuresempty. In that case the new test passes without drawing either triangle arrangement. Track whether a backend actually ran and require one readback, or report an explicit skip when the environment has no SM 6.6 device. This is a static test-coverage finding. TestImported from DexNom/VIctory. Originally posted by murillojndem on 2026-11-30T18:44:14Z.
Thanks, applied in
52332ea.left_lane_failuresnow counts the devices that drew and asserts that at least one did, the same checkrun_cases_onmakes invalu_tests, so the test cannot pass without a readback.With
Host::newmade to fail for both devices the test now fails with "no SM 6.6 device to draw on". Unchanged, it passes on WARP and on an RX 7900 XT, drawing on both. On the CI runner WARP opens: main'srun_cases_onwould otherwise fail its ownran > 0check there, so the new assertion holds on CI too.pixel_quad_broadcast_reads_helper_coordinates_at_shared_triangle_edgein main'shelper_lane_tests.rshas the same loop without the count. This PR leaves it as main has it.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.