Repository navigation
rdna2spirv: a pixel lane off at the last color export is not written; without vm, EXEC at the color export decides (measured on RDNA2) - #3988
Conversation
… without vm, EXEC at the color export decides Measured on RDNA2 (gfx1036) with the pixel-shader oracle of ItsNotRexed#3061: a pixel is written when its lane was on in EXEC at the last vm export (if the path has one) and at the last export to the color target. The translator discarded by EXEC at the end on a path without vm, and kept an older export's value for a lane off at the last color export. The latches are only emitted where EXEC can change after an export. GPU fixture ps_exp_color_mask, semantic tests, design.md EXEC row. AI-assisted.
jeremygold02
left a comment
There was a problem hiding this comment.
Verified partial writes on the translated Vulkan path at b3d34afc6c047cc31bbe3b46f1592866ebecf47a. With independent color-export and validity masks, the 64 pixels in their intersection received B and all other 192 retained the framebuffer clear value. At parent aa2988cc555bad7ecd508b48a702adbb32fe7c95, the 64 top-right pixels showed the earlier color A. I compared all four RGBA32F words at every position.
| Revision | EXEC at last MRT0 export | EXEC at final vm export |
B = 2 | Earlier A = 1 | Clear = −1 |
|---|---|---|---|---|---|
| Head | left half | top half | 64 | 0 | 192 |
| Head | left half | all | 128 | 0 | 128 |
| Head | all | top half | 128 | 0 | 128 |
| Head | all | all | 256 | 0 | 0 |
| Parent | left half | top half | 64 | 64 | 128 |
To reproduce, draw the synthetic vs_ids fullscreen triangle into a 16×16 target with vk_harness's −1 clear. The handwritten PS saves incoming EXEC, exports A = (1,1,1,1) to MRT0 from every lane, then exports B = (2,2,2,2) to the same target with EXEC restricted to u < 0.5. Restore incoming EXEC, restrict it to v < 0.5, issue exp null off, off, off, off done vm, then restore EXEC again. Use s_waitcnt expcnt(0) after each export. Omitting the first or second restriction independently gives the control rows above. The final restore ensures the result distinguishes the sampled export masks from end-of-shader EXEC.
Five draws ran on NVIDIA GeForce RTX 5070, driver 621.01 (32.0.16.2101), subgroup 32, with Intel Core Ultra 7 265K on Windows 11 Home 25H2 build 26200.9974. Built the harness from the PR head and translated the same synthetic assembly on each revision. All modules passed Vulkan 1.2 SPIR-V validation. This covers one MRT on the translated path. The PR author's separate native RDNA2 measurements provide the hardware reference.
AI-assisted by GPT-6.2 Astra.
|
Independent mixed-mask pixel run at |
|
Automated test:
Same machine and setup as my earlier manual reports. AI-assisted (Claude Code). |
|
Tested
AI-assisted (Claude Code). |
Requested by Lucas · project thread
Claimed in the coordination issue as: EGEN-PS-EXPORT-MASK, #3918 (comment) (finding with the full table: #3918 (comment))
What and why
#1640 made a pixel shader discard by EXEC at its last
vmexport, from the ISA guide, and said it was not measured. I measured it on RDNA2 with the pixel-shader oracle of #3061 (hand-written ISA as the pixel shader of a real draw, gfx1036, wave64 stage, 8x8 target, EXEC cut to half of the target withv_cmpxon an interpolated coordinate,s_waitcnt expcnt(0)after every export). 18 programs; one rule fits all of them:a pixel is written when its lane was on in EXEC at the last
vmexport the path executed (if any) and at the last export to the color target.The
vmhalf is what #1640 implemented, and it holds. The color half is new: an export sends data only for the lanes that are on, a later export to the same target replaces the earlier one for the whole wave, and a lane with no data from the last one is not written, even when a laterexp null done vmmarks it valid. Six of the 18 programs differed from the translator:exp mrt0 done(no vm); EXEC R afterwardsexp mrt0 done(no vm); EXEC restoredexp mrt0; restored;exp null done vmexp mrt0 A; EXEC R;exp mrt0 B; restored;exp null done vmexp mrt0 A vm; EXEC R;exp mrt0 B done(no vm); restoredexp mrt0 vm; restored; top half only;exp null done vmThe change:
exportalso keeps EXEC at each color export (%col_mask_mrtN), and the PS epilogue keeps the pixel when(no vm export ran or EXEC was on at the last one) and (EXEC was on at the last color export); a path with no export at all still goes by EXEC at the end. As before, the latches are only emitted when some path can write EXEC after avmexport, now also after a color export; in every other shader EXEC at the end is the same mask and the SPIR-V is unchanged (the 81 other semantic fixtures translate to byte-identical text).Limits, also in the design row: with several color targets a pixel stays when any target got an export from its lane (Vulkan cannot skip one attachment per pixel, and the oracle's pipeline has one target, so this is not measured);
mrtzis not part of the color mask (not measured). Whether any corpus shader writes EXEC between a color export and the end was not counted (no corpus here); compiled code normally exports last.A trap for anyone measuring exports, now in
docs/design.md: they are asynchronous. Withouts_waitcnt expcnt(0)the hardware takes the data and the EXEC of a later moment, which looks exactly like "EXEC at the end decides".Tested
tests/semantic/test_export_valid_mask.py: 21 tests. Two of Translator: a pixel shader discards by EXEC at its last vm export, not at the end #1640's expectations for paths withoutvmare turned around to what the hardware does, a classColorExportMaskhas the table's rows, and the new GPU fixture runs there too. Againstmain's translator 7 fail; with the change all pass.runtime/test/shaders/ps_exp_color_mask.asm(the first row:exp mrt0 donefrom every lane, wait, EXEC off):run_gpu_tests.py --filter ps_exp_color_mask4096/4096 pixels exact on the AMD Radeon RDNA2 iGPU (driver 26.10.1) and on the RTX 5080 (driver 616.92). The same body run natively through the oracle gives the same words on every pixel. Withmain's translator the test fails on both GPUs (every pixel still the clear value).python -m unittest discover -s tests/semantic: 7461 tests, 7 failures and 3 errors, the same ten as onmainaa2988c without this change on this machine (test_loop_ballot_barrier3 + 2 errors,test_cmp_class_f642,test_mutations2,test_vcmp16_opsel1 error; checked by running those four modules on a clean export ofmain). None is in the export tests.regen_fixtures.py --checkclean;tests/test_shader_checks.pyandtests/test_docs_*.pyOK.run_gpu_tests.py --filter ps_on the Radeon with the change: 86/94 passed, 8 skipped, none failed.Depends on nothing; #3061 is only the tool the measurement used.
Checklist
docs/design.md, with how it was confirmed.AI-assisted.