Repository navigation
Description
On an RTX 4060 Ti under Wine + vkd3d-proton, a wave64 pixel shader on the direct translator leaves pixels unwritten in every 32-lane wave whose pixels all take the same side of an if / else: a synthetic shader of that shape left 896 of 4,096 pixels at the clear colour.
Setup: RTX 4060 Ti 16 GB, NVIDIA 615.71.09, Linux, Wine 11.21 Staging, vkd3d-proton master 71cae091 with local patches, release build for x86_64-pc-windows-gnu. The tree is main 493dbd3d with other unmerged pull requests; not run on main alone, on Windows, or on another card.
The shape. The console compiler's if / else on a per-pixel test: pixels inside a disc point-sample a texture in the first block, the others sample it in the second, and each block is skipped by s_cbranch_execz when no pixel of the wave takes it. Both blocks sample with implicit derivatives.
Measured
- A GPU test with a synthetic shader of that shape (64 x 64 target, disc of radius 20, clear colour -1): 896 pixels came back as
[-1.0, -1.0, -1.0, -1.0], the first at (20, 16), 1 run. With the skip over the second block not taken as a branch (the block runs with every lane masked), all 4,096 pixels were right, 1 run. - In a retail title, one pixel shader of this shape drew black blocks of 4 x 8 pixels over a centred ellipse, in 7 of 7 runs on the direct translator. Waves with pixels on both sides of the test drew right. The same shader on the HLSL path, which has the same skips, drew right (2 runs), and so did the direct path with the else-skip run through (1 run).
- The direct DXIL of that shader, dxil-spirv's SPIR-V of it and the HLSL path's form were read side by side and no difference was found at the skip: the wave-wide test is
dxil/lower.rson a mask fromballot_ps_quad(dxil/lanes.rs), andrecomp/emit.rson one fromballot_px_quad. Puttingballot_ps_quadback to fourWaveActiveBallotpasses (as before Recompiler: direct DXIL PS IR cuts (shared float decode, direct quad shuffles, predicate-derived lane masks) #3501) did not change the picture (1 run). So what goes wrong is after the DXIL: the driver's compiler is my guess, and vkd3d-proton's own SPIR-V was not looked at.
The test and a workaround are in one commit on a fork: Royalflamejlh/xcl-linux@68beb1b (gpu_direct_ps_waves_that_skip_a_branch_keep_the_other_branch_values; ps_masks::flat_skips runs a pixel shader straight through a forward s_cbranch_execz over a region with implicit-derivative samples when nothing after the region reads what it writes). The test uses a helper main does not have; I will carry both onto main as a draft pull request.
Not tested: native Windows, AMD, any other NVIDIA card or driver, main alone, the GPU time of the workaround (it applies to 3,475 of 66,582 such skips in one pack's pixel shaders).
AI use: Claude Code. Claude Opus 5.5 found the shader and the shape, wrote the test and the workaround; Claude Fable 5.2 ran the test on the card with and without the change and wrote this report.
Activity
Royalflamejlh commentedon Dec 1, 2026
A caution on the workaround linked above (ps_masks::flat_skips): it is too wide as written. In the same title, with it in, one other picture (a 2D artwork panel) comes out washed in green: found in the sampled frames of 2 runs with the change, and in none of 4 runs without it.Edited: that caution was wrong. The green-washed frames are not caused by the run-through. They are video frames whose chroma plane reads 0, and the same fault shows with the run-through switched off in every pixel shader (1 run, frames sampled every 3: one such frame; with it on: 4 and 13 frames in 2 runs). The shaders that draw those frames have no
s_cbranch_execz, so the change cannot touch their code. How often it shows varies from run to run, and my first comparison (1 of 76 sampled frames against none in 4 runs) read that variation as an effect. It is a separate fault, in how the decoded video planes reach the GPU here.Two things did come out of looking: the rule did not check that a loop inside the region still ends when it runs with EXEC 0 (a compare-based exit could spin); it now refuses a region with a backward branch. And following @imnicho's explicit-level result, the implicit-derivative condition is the wrong selector; a version without it, with the synthetic test drawing both forms, is being tested on a card here before I link it.
AI use: Claude Code. Claude Opus 5.5 found what the green frames are and made the two changes; Claude Fable 5.2 wrote the wrong caution and this correction.
imnicho commentedon Dec 1, 2026
RTX 5080 on native Windows 10: the same 896 of 4,096 pixels stay at the clear colour, and all are right with the skip run through. So it is not Wine or vkd3d-proton.
Setup: NVIDIA GeForce RTX 5080 16 GB, driver 610.47 (32.0.16.1047), Windows 10 22H2 (19045), native D3D12, no Wine. Your commit
68beb1bbas it is, plus one local line:ps_masks::flat_skipsreturns an empty set when an environment variable is set, so one test binary runs both ways. Nothing else is changed.cargo test -p xcl --lib -- --test-threads=1 --nocapture gpu_direct_ps_waves_that_skip_a_branchflat_skips1 passed, noSKIPPEDline896 pixels hold another branch's values, first [(20, 16, [-1.0, -1.0, -1.0, -1.0]), (21, 16, [-1.0, -1.0, -1.0, -1.0]), …The count and the first pixel are the ones you measured on the RTX 4060 Ti under Wine. So the unwritten waves come with NVIDIA's native D3D12 driver too, on another card generation and another driver branch (610.47 here, 615.71.09 on your Linux machine).
Not tested:
mainalone (the test needs your helper), a title with the workaround in, AMD or Intel, another driver.AI use: Claude Code with Claude Fable 5.2 built the commit, added the local switch, ran the test and wrote this.
🤖 Generated with Claude Code
imnicho commentedon Dec 1, 2026
Follow-up from the same card (RTX 5080, native Windows 10, driver 610.47): the unwritten waves do not need an implicit-derivative sample in the skipped block, so
flat_skipsas committed does not cover every case of it.The same tree as in my comment above (
68beb1bbplus local switches), with one change to the test's shader behind a switch: the second block'sIMAGE_SAMPLEbecomesIMAGE_SAMPLE_LZ. The texture has one level, so the values the test expects are the same. A second local switch drops the "has an implicit-derivative sample" condition fromflat_skips: every region that passes its other checks is run through.flat_skipsIMAGE_SAMPLE(as committed)IMAGE_SAMPLEIMAGE_SAMPLEIMAGE_SAMPLE_LZIMAGE_SAMPLE_LZIMAGE_SAMPLE_LZSo on this driver a wave whose pixels all skip the block comes out unwritten with an explicit level in the block too, and running the skip through cures both forms in this test. The first four rows include the six runs of my comment above.
Not tested: what the wider condition does in a title (your caution about the green panel is about the narrower one already), which other property of the region would be the right one to select by,
mainalone, AMD or Intel, another driver.AI use: Claude Code with Claude Fable 5.2 made the two local switches, ran the test and wrote this.
🤖 Generated with Claude Code
Recompiler: pixel shaders run through execz skips with EXEC 0 on NVIDIA
Recompiler: pixel shaders run through execz skips with EXEC 0
Recompiler: pixel shaders run through execz skips with EXEC 0 on NVIDIA
Recompiler: pixel shaders run through execz skips with EXEC 0