AGC: on an AMD RDNA 2 iGPU (Windows) every pixel of a killed BDA fault still lands one read-modify-write (agc_driver_pixel_interlock) #2009
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 boykopovar/AnyPS5. Originally posted by tezzgod74 on 2026-10-09T04:54:24Z.
agc_driver_pixel_interlockfails in its BDA fault draw on an AMD RDNA 2 iGPU, every run (5/5):With the checks in
DrawFaultturned into a log of every mismatch:x % 8 == 0(all 8 columns × 32 rows)The draw does report the unmapped read (
BDA access failed,reason=1), and every other pixel counts 64. The three normal passes and the pass after each fault draw pass in both wave sizes. On each faulting pixel, exactly one of the 64 overlapping fragments' increments lands.The RX 9060 XT (RDNA 4) in the same machine passes the whole test.
ANYPS5_GPURadeon(TM) GraphicsRX 9060The test arrived with #1130 (merged in
3069680b), and CI has no AMD device, so this may be its first run on RDNA 2. Not yet known whether the leaked increment comes from the recompiled shader or from the driver's handling of the killed invocation.Environment:
mainat79d23eb7, Release, MinGW-w64 GCC 15.2.0 (WinLibs r7), Windows 11 Pro 10.0.26300.Reproduce
Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-09T07:43:33Z.
Passes on RDNA 3.5: AMD Radeon 860M (0x1114), driver 32.0.13058.8001, Windows 11 10.0.26300,
mainf1451396, 5/5 runs (10 draws of 64 overlapping triangles over 2048 pixels, 2 of them with a killed BDA fault in every 8th column). So far only the RDNA 2 device fails; its driver branch (32.0.21045) also differs from both passing devices.Imported from boykopovar/AnyPS5. Originally posted by AcelezXYZ on 2026-10-09T07:45:03Z.
Thanks, that is a useful data point. With it the picture is:
Two things stand out:
To separate the two, the most informative runs would be:
Layers = 1fault draw from my previous comment on the failing iGPU. If a faulting pixel still counts 1 of 0 with no overlap, the increment does not depend on the interlock ordering.If the RDNA 2 failure follows the driver or the architecture and cannot be fixed on the user side, one thing could be tried in the generator without touching other hardware: in
StopBdaInvocationIf, set the pixel valid mask to 0 and branch to the common return so thatOpEndInvocationInterlockEXTis emitted once at the end andOpKillhappens after the critical section (that is whatEmitKillIfPixelValidMaskInactivealready does for the normal return). It is valid SPIR-V on every device, so it should not regress the two passing ones, but whether it changes behavior on RDNA 2 is unknown until someone runs it there.Imported from boykopovar/AnyPS5. Originally posted by danielradosa on 2026-10-09T17:32:49Z.
Reproduced on a second machine with the same iGPU and driver, plus the
Layers = 1run.Ryzen 5 7600 iGPU (RDNA 2,
0x164e), AMD driver 32.0.21045.5002, Vulkan 1.4.315, Windows 11 Pro 10.0.26300; RTX 4060 (0x2882, driver 616.92) in the same machine. MinGW-w64 GCC 15.2.0 (WinLibs r7), Release,BUILD_TESTING=ON,ANYPS5_ENABLE_SPIRV_TOOLS=ON,ANYPS5_REQUIRE_VULKAN=1. Tree:main0fdda7beplus #1748, which only touches libkernel.ANYPS5_GPURadeon(TM) Graphicsmain(64 layers)pixel interlock wave64 BDA fault: pixel 0 counted 1 of 0 overlapping read-modify-writesRadeon(TM) GraphicsLayers = 1RTX 4060mainWith one triangle per pixel there is no overlap and nothing to order, and the faulting invocation's read-modify-write still lands once. So the increment does not come from the interlock ordering; the counter load, add and store after the stopped BDA read run once for the invocation that
StopBdaInvocationIfkills. On this driver the architecture and the driver are still the same variable as before; this only rules out that the first machine was a one-off.I will try the
StopBdaInvocationIfchange you described on the same device and post the result.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by danielradosa on 2026-10-09T17:54:51Z.
Follow-up with the generator change, same machine (Radeon iGPU
0x164e, driver 32.0.21045.5002; RTX 4060 as control), same tree (main0fdda7be+ #1748).What the fault draw does on the Radeon, with temporary prints after the existing reason=1 check: every killed column pixel ends with guest = 1 and Counters = 0 in both wave64 and wave32, and every live pixel counts 64. So the killed lane's
buffer_storeis dropped, but its laterglobal_atomic_umax(anOpAtomicUMaxthrough the BDA pointer) still lands with 0 + 1 + 0 = 1, which is why it is 1 of 0 even with one layer. The RTX leaves those pixels at 0. That fits the lane running on past theOpKillthatStopBdaInvocationIfputs in a selection whose merge is the rest of the program; the logs show the effect, not how the driver lowersOpKill.Two changes each pass the test 5/5 on the Radeon and 3/3 on the RTX, with the fault still reported as reason=1 and the read-range check passing:
pixel_valid_mask_active = 0,OpEndInvocationInterlockEXT, the valid-mask kill,OpReturn. After the optimizer this isstore 0; End; if (!helper) OpKill; OpReturn, so a lane that survives the kill only reachesOpReturn.OpTerminateInvocationin place ofOpKill. The target is SPIR-V 1.3, so this also needsVK_KHR_shader_terminate_invocationenabled (both devices report it),SPV_KHR_terminate_invocationdeclared in the module and allowed inShaderValidation.cpp.agc_driver_graphics,agc_driver_bda_deviceandagc_driver_pixel_{helper_lanes,interlock,lds,lds_lane_slots,valid_mask,wave_reduction}pass on both GPUs with either change. Only the interlock test and the ordered-BDA check inagc_driver_graphicsreach the changed code, and that check's target does not list the terminate extension, so it does not exercise (b).Limits: (a) covers only ordered pixel shaders that have the valid-mask variable, and it relies on the kill staying in a selection whose merge is
OpReturn; if the!helpertest is folded away it is End +OpKillagain. (b) also changes non-ordered pixel shaders, whose BDA stops still use a plainOpKilland may leak the same way on this driver; I did not test that case.(a), without the temporary prints:
New pull requests from me are closed by the intake rule for now, so whoever picks this up is welcome to the patch; I can rerun anything on this device.
AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by tezzgod74 on 2026-10-10T03:35:20Z.
On the RDNA 2 iGPU, the faulting fragments are killed with
OpKillbut still carry out their guest write. WithOpTerminateInvocationthe test passes. All runs below are onmaind70b8998with local diagnostic changes only (no PR). Both GPUs are in the same machine. Results are wave64 and wave32 alike, 256 fault pixels and 1792 others per draw:OpEndInvocationInterlockEXTbefore the fault'sOpKill(critical section held through the kill)global_atomic_umax(dwords 22-23 ofFaultPixelCode, opcode 0x38) replaced bys_nopOpKillinStopBdaInvocationIfreplaced byOpTerminateInvocation(SPV_KHR_terminate_invocation, device extension andshaderTerminateInvocationenabled)global_atomic_umax): without that instruction, the fault pixels stay 0.OpTerminateInvocationthe invocations end and nothing is stored.So on this driver,
OpKilllooks like it behaves as a demote, and the demoted invocation's BDA atomic isn't masked. The RDNA 3.5 and RDNA 4 drivers terminate. Which part is the driver's fault (helper stores landing) depends on how strictlyOpKillis defined there.SPV_KHR_terminate_invocationwas added because implementations differed on it.On the generator side, two options:
OpTerminateInvocationwhere the device supportsVK_KHR_shader_terminate_invocation(core in Vulkan 1.3). Tested above: it passes on both devices. The otherOpKillsites (SpirvFlowEmitter.cpp:25,SpirvModuleEmitter.cpp:983) would have the same exposure for any store a discarded pixel makes after the kill on this driver. I haven't tested those.OpKill. @danielradosa ran it above and it passes on the same iGPU model; I haven't run it here.AI-assisted: yes
Edit: corrected the guest write to
global_atomic_umax(it was mislabelledglobal_store). This agrees with @danielradosa's runs above, which were posted first and also cover both generator changes.Imported from boykopovar/AnyPS5. Originally posted by poonasor on 2026-10-11T00:41:24Z.
Third RDNA 2 device, a discrete one, and option 1/(b) from above as a commit.
AMD Radeon RX 6700 XT (Navi 22, 0x73df), driver 32.0.21045.5002 (Adrenalin 25.10.45.05), Vulkan 1.4.315, Windows 11 Pro 23H2, WinLibs GCC 15.2.0 r7, Release. Same driver branch as the two iGPU reports. On
mainthe test faults inamdvlk64.dllfirst (#2944, fixed by #3173); with #3173 it fails as reported here:Commit
73969879onpoonasor:fix/shader-bda-stop-terminate-invocation(one commit onmain06da1176, 4 files, +31/-1):VulkanDevice.cpp: when the device hasVK_KHR_shader_terminate_invocationwithshaderTerminateInvocation, enables both and offersSPV_KHR_terminate_invocationto the recompiler.SpirvBdaFault.cpp:StopBdaInvocationIfin a pixel shader emitsOpTerminateInvocation(and declares the extension) when it is offered,OpKillotherwise.ShaderValidation.cpp: acceptsSPV_KHR_terminate_invocationin a fragment shader.SpirvSpecialization.cpp: listsOpTerminateInvocationnext toOpKill.Only the BDA stop changes. The pixel kill and valid-mask
OpKillsites (SpirvFlowEmitter.cpp,SpirvModuleEmitter.cpp) are left as they are: nobody has measured them on this driver, and terminating there would also end helper invocations that neighbouring derivatives may need.Measured on
main379d8b4e+ #3173 + #1463, with and without the change:agc_driver_pixel_interlockctest60609c45(same change)video_out), 0 failedDreaming Sarah (PPSA02929) relinked against that build runs at about 60 FPS as before.
Limits: the branch itself is a clean cherry-pick onto
06da1176and passestools/check_conventions.py, but I built and tested the change only on the379d8b4estack above. Not tested: a device without the extension (theOpKillfallback), NVIDIA, Intel, Linux.New pull requests from me are closed by the intake rule, so anyone with intake access is welcome to carry the commit; I can rerun anything on this GPU.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by tezzgod74 on 2026-10-11T01:45:09Z.
Tested @poonasor's
73969879on the RDNA 2 iGPU, cherry-picked ontomain9ba3d0d7(Windows 11 Pro 10.0.26300, MinGW-w64 GCC 15.2.0 r7, Release,-DANYPS5_ENABLE_SPIRV_TOOLS=ON):ANYPS5_GPUmainmain+73969879Radeon(TM) Graphicspixel_interlockfailsRX 9060Together with the earlier reports, three RDNA 2 devices on the 21045 branch fail on
main: two iGPUs (0x164e) and the RX 6700 XT. The fullctestshows no failure the commit introduces on either device;agc_driver_flat_aperturesfailed once on the RX 9060 XT in a parallel run and passed 5/5 alone.One review note on
ShaderValidation.cpp:SPV_KHR_terminate_invocationis accepted in any fragment shader without checking that the device enabledshaderTerminateInvocation, whileSPV_KHR_fragment_shader_barycentricnext to it requiresfragmentShaderBarycentric. The emitter only declares the extension when it is offered, so this doesn't change the result above.The 7950X iGPU on
main9ba3d0d7also shows #2944: 21agc_driver_*tests segfault on it in one full run (the set varies between runs), while the RX 9060 XT in the same machine has none.pixel_interlockisn't one of them, so it could be tested without #3173.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by abnergtz on 2026-10-11T04:02:04Z.
Fourth RDNA 2 device, and @poonasor's
73969879carried forward with @tezzgod74's validation note addressed, plus tests.AMD Radeon RX 6900 XT (Navi 21, 0x73af), driver 32.0.21045.5002, Vulkan 1.4.315, Windows 11 Pro 10.0.26220, WinLibs GCC 15.2.0, Release. Same driver branch as the other three reports;
mainfails as reported here:Branch
abnergtz:fix/agc-pixel-interlock-terminate-invocation(6 commits onmainaac0f1b8, 10 files, +150/-13):0ca06cf2fix(recompiler):StopBdaInvocationIfin a pixel shader emitsOpTerminateInvocation(and declaresSPV_KHR_terminate_invocation) when the target offers it,OpKillotherwise. Same as73969879, without theSpirvSpecialization.cppcase:OpTerminateInvocationhas no operands, so theVisitInputsdefault path already handles it identically.19486efafeat(agc):ShaderValidationaccepts the extension only in a fragment shader and only when the device enabledshaderTerminateInvocation, likeSPV_KHR_fragment_shader_barycentricnext to it (the review note above). The flag is part of the validation memo key inDraw.cpp.81f711d8feat(agc):VulkanDeviceenablesVK_KHR_shader_terminate_invocationand the feature when available;ShaderDeviceProfilerejects a target that advertises the SPIR-V extension without the enabled feature.4f16f09ffix(agc): validation also checksOpTerminateInvocationitself (fragment stage, enabled feature, extension declared), not only theOpExtension.a1f407b4test(agc): recompiler and validation tests for both paths (1 valid-maskOpKill+ 5 terminations with the extension, 6OpKillwithout; interlock end before every exit; no termination in non-pixel stages; non-interlocked pixel shader; specialization keeps the opcode and declaration; feature struct chained withVK_FALSEis rejected).f23c94cadocs(technical-debt): records the RDNA 2 measurements, that theOpKillfallback is still affected on a driver without the extension, and the twoOpKillsites left as they are.Measured with #3173 applied (
1d7f8bd3, not part of the branch) to remove the #2944 segfaults,-DANYPS5_ENABLE_SPIRV_TOOLS=ON:agc_driver_pixel_interlockctestmainaac0f1b8+ #3173The 7 failures are the same on both builds and none is in the changed code:
agc_driver_sdwa_float_selectors,agc_driver_sdwa_ldexp_f16(#1463),agc_driver_lds_mixed_width_atomics, threetls_function_coveragetimeouts that pass when run alone, andimport_audit(fails only in thegit worktreeused for the A/B; passes in a normal checkout). Noamdvlk64.dllsegfault in any of these runs.Limits: one machine and driver. Not tested: a device without the extension (the
OpKillfallback runs only in the recompiler tests), NVIDIA, Intel, Linux/lavapipe. The validation memo key change has no direct test:ValidationKeyandCachedFragmentOutputsare internal toDraw.cppand only reachable through a device-backed draw.I can't open pull requests under the intake rule either, so anyone with intake access is welcome to carry the branch; I can rerun anything on this GPU.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-11T08:46:21Z.
agc_driver_pixel_interlockon RDNA 4: no mismatch.AMD Radeon RX 9070 XT (Navi 48, gfx1201, device 0x7550, subgroup 64), RADV Mesa 26.2.4, CachyOS, kernel 7.2.9, GCC 16, Release,
mainabdad2a5. The wave64 and wave32 BDA-fault draws count 0 overlapping read-modify-writes (the expected value) and the test passes, standalone and inside a fullctestsweep (793 tests, 0 failures, 4 display-related skips).So the one-RMW-per-killed-pixel behaviour reported on the RDNA 2 iGPU does not reproduce on gfx1201 with Mesa 26.2.4.
Imported from boykopovar/AnyPS5. Originally posted by Lerrylore on 2026-10-13T17:42:52Z.
Additional Windows hardware result: the Ryzen 7 9800X3D iGPU reproduces the failure, and the public fix branch passes on this machine.
0x13c032.0.21045.90030x755032.0.31041.3013Built with MinGW-w64 GCC 15.2.0, RelWithDebInfo,
BUILD_TESTING=ON, andANYPS5_ENABLE_SPIRV_TOOLS=OFF.Results for
agc_driver_pixel_interlock, withAPS5_NO_PIPELINE_LTO=1in all runs below and each GPU selected explicitly throughANYPS5_GPU:5d50886ee4045dc2a081d8d93bf8e667f6d82325pixel interlock wave64 BDA fault: pixel 0 counted 1 of 0 overlapping read-modify-writesa1f407b49d435ef558f40ba2b79600aa4b4c3be7Without
APS5_NO_PIPELINE_LTO=1, the older fix branch crashes inamdvlk64.dllon the iGPU before reaching the assertion, consistent with the separate problem discussed in #2944. Disabling pipeline LTO alone does not fix the original mismatch on the main checkout.Limits: these builds have different base commits, so this is supporting hardware evidence rather than a same-base patch-only A/B comparison. The fix checkout was clean; the main checkout had an unrelated local CMake build adjustment in
libSceAudioIn. Only the pixel interlock test was evaluated here, not a full regression suite or a game.AI-assisted: Codex.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-16T23:53:46Z.
Fixed by #5804 (
65d56a297): pixel invocations stop withOpTerminateInvocationafter a BDA fault when the feature is available.agc_driver_pixel_interlockpasses on the RDNA 2 iGPU with the fix branch. Closing; reopen if it still fails on current main.