xshader: decide a loop's back edge for the whole wave too #396
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/396"
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 brcly/TuxBox. Originally posted by MathiewMay on 2026-11-28T12:56:55Z.
Summary
8724e8f("decide branches on EXEC and VCC for the whole wave") turned forward branches on EXEC and VCC intoWaveActiveAnyTruevotes where the mask ballots apply. The back edge of a structured loop kept each lane's own bit (tools/shader-compiler/src/hlsl/emitter/control_flow.rs):Before
8724e8fa lane outside EXEC skipped the loop by itself. Now it enters with its wave, its own VCC bit never sets, and it stays untiltb_guardruns out. The wave stays with it, and the lane has no iterations left for the loops after it.This takes the wave's decision for the back edge too, as
emitter/scalar.rsdoes for the forward branches. The latch above becomestb_c523 = (!WaveActiveAnyTrue((vcc_lo & 1u) != 0u));.The lines above are from ProjectScarlett's
CS_ScreenProbes_Inject, which the title dispatches over 14,400 groups in its first frames that trace rays. Three of three runs ona880dfdlost the device there: each time vkd3d-proton's breadcrumbs named that dispatch as the one command the GPU had started and not finished. With this change the same run passed that point and kept presenting until I stopped it three minutes later. That was only seven more frames: the title was down to a frame every 25 s by then, for a reason of its own that this does not touch. I ran those ona880dfdtogether with other changes of mine, not on this branch alone.Tested
Not a Lanes scenario: this is how one branch form is translated, which the translator's GPU checks cover with synthetic programs on the card, as 8724e8f's own tests do.
tools/check_mask_ballots_gpu.pygains alatchprogram in its 32-lane, 64-lane and paired forms: a loop that ends on VCC, entered by a wave that left lanes outside EXEC, then a loop every lane runs. Onmain8 of its cases fail on RADV, four inputs each in the 32-lane and 64-lane forms: the lanes left out get one turn of the second loop, not three. With the change all 665 cases pass.A unit test,
a_loop_ends_when_the_whole_wave_says_sointools/shader-compiler/src/tests/hlsl/mask_ballots.rs, checks the emitted latch for a whole wave and for a partial one. It fails onmain.GPU, driver and backend: AMD Radeon RX 9070 (1002:7550, RADV GFX1201), Mesa 26.2.7, Linux 7.3, GE-Proton11-14 (
--backend proton).Commands run and their results:
The GPU checks ran outside their Bubblewrap/
xvfb-runsandbox, which stalls on this machine (it has no Xvfb).Checks
No evidence JSON changes.
host_profiles.txtchanges in one line,waterfall any-host: the only recorded program whose translation changes.