fix(agc): order the stores of a label run against each other #17999
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17999"
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 kaiffeetasse on 2026-11-10T03:14:31Z.
What
Recorder::closeStoreRunrecords the stores of a batch's label run back to back and puts a transfer-to-transfer barrier between two of them only when the later one overlaps an earlier one in the same buffer. Two stores into different buffers therefore have no ordering between them, and a host that polls the later label and then reads the earlier one can see the earlier store missing —agc_driver_unregistered_label_on_gpufails that way (10 of 1000 runs on Windows, #17937; afterWaitIdlethe value is there, so it is late and not lost).Every store after the first of its group now takes that barrier, so a run's stores reach the host in program order. Following the review note below, that barrier also names
VK_PIPELINE_STAGE_HOST_BITandVK_ACCESS_HOST_READ_BITas its destination, which is the availability operation a polling host needs before it may read the earlier store while the batch is still running — the batch-end barrier only covers the host at submission end. The overlap case keeps its WAW barrier and itsstoreWawBarrierscounter; the new case counts inbarriersonly, which is whatCountBarriers(CommandClass::LabelRun, …)reports.docs/dev/debt/libSceAgcDriver.mdrecords that the run's own stores are now ordered and host-visible to each other, and that the batch-to-host ordering behind the batch's earlier writes still rests on driver behaviour.The cost is one barrier per store of a run beyond the first of its group, and it was not measured: the issue's local change (one barrier per later store, behind an environment variable) took the failing test from 5 of 500 to 0 of 500 on an RTX 5080, which is what this PR makes unconditional. Say if you would rather have the run split or flushed per label instead.
Tested
Linux, Ubuntu 24.04, GCC 13.3.0, Mesa 25.2.8
llvmpipe(CPU device — no hardware GPU on this machine),ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(layer 1.3.275, loaded: nowas not found but was requestedline, noVUID-line), on headba05419c80:agc_recorder_kept_bytes,agc_driver_recorder,agc_recorder_stored_bytes,agc_driver_unregistered_label_on_gpu: 4 of 4 passed.SeparateStoresOfOneRunAreOrdered: mock device recordsvkCmdUpdateBuffer/vkCmdPipelineBarrierin order; two stores of one run into different buffers must have a barrier between them, and that barrier's destination must name the host stage andHOST_READ. With the HOST bits removed from the two barriers again the test fails with both messages (… does not make the earlier store available to the host stage,… does not make the earlier store readable by the host); with them it passes. On a branch without the barrier at all it fails withthe stores of a run into different buffers are not separated by a barrier.agc_driver_unregistered_label_on_gpu: 300 runs without the fix, 300 runs with it, 0 failures —llvmpipedoes not lose the order the way the reporter's NVIDIA driver does, so the run count is not evidence either way here.python3 tools/check_conventions.py --base origin/main: all checks passed.tools/pr_overlap.py --branch …fails closed (exit 2) with 25 open PRs sharing these files; all 25 were compared by hand for the construct this PR changes: none adds, removes or renames a store-run barrier (only #13863 and #13920 callcloseStoreRun(true)from elsewhere).cf35cb8179merged ontomain017bd95f5f(clean merge): Windows 11 Enterprise 22621, WinLibs GCC 15.2.0 UCRT r7, Release, Vulkan hidden —agc_recorder_kept_bytespassed in 3 of 3 runs, none skipped.cf35cb8179merged intomain(Windows 10 22H2, RTX 5080, driver 621.14, WinLibs GCC 15.2.0, no validation layer):agc_driver_unregistered_label_on_gpufailed 1 of 500 and 6 of 2,000 runs onmain(all 7 with the message from #17937) and 0 of 2,500 with this PR. That is the reproduction the fix was written for.356ba02b5fand 0 on headcf35cb8179— the flake does not reproduce there, so those runs show the change does not disturb this test on that driver rather than confirming the fix. The HOST stage and access bits came from that review note.ba05419c80merged ontomainbab5bc6b98(Windows 11 Home 26300, i9-13900K, WinLibs GCC 15.2.0, RTX 4080, driver 32.0.16.2101,ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1):agc_driver_unregistered_label_on_gpufailed 2 of 500 runs onmain, both with the message from #17937, and 0 of 494 on the merge. The GPU set with the validation layer (tests whose names start withagc_,shader,video_outorguest_video,--parallel 4) was 1740/1740 onmainand 1739/1740 on the merge, with 0VUID-lines on both; the one failure,agc_driver_job_manager_compute_capacity, also fails onmainalone.ba05419c80merged ontomainaa5f2b541a(Windows 11 Pro 10.0.26300, i5-6600K, WinLibs GCC 16.2.0, RTX 3070, driver 621.01,ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1):agc_driver_unregistered_label_on_gpu0 failures of 1,000 onmainand 0 of 1,000 on the merge, andagc_recorder_kept_bytes,agc_driver_recorder,agc_recorder_stored_bytespass on both — the flake does not reproduce on that card, so this run neither confirms nor contradicts the fix; it does show the HOST-stage change builds and passes there, which had not been rerun. No validation layer on that machine, so noVUID-comparison from it.SharedOwnerCountsOncePerBatch()and adds their calls at the same place inmain(). Whichever of the two merges second needs a one-hunk rebase inRecorderKeptBytes.cpp; #16753 reworks the retained-owner API, not the store-run barrier, so they are not the same topic.Not tested: any hardware GPU on this machine, and whether the console orders two labels of one queue, which the test assumes. The two independent checks above cover Windows (RTX 5080, the reporter's machine) and Linux NVIDIA (RTX 4070 Ti); both are on
cf35cb8179, before the HOST bits were added.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)llvmpipe(Mesa 25.2.8, Ubuntu 24.04, CPU) here; independent runs by others on RTX 5080 (Windows), RTX 4080 (Windows) and RTX 4070 Ti (Linux NVIDIA) are quoted above