Skip to content

fix(agc): recheck packet flush reasons after pipeline drains - #19687

Open
JJenkx wants to merge 6 commits into
boykopovar:mainfrom
JJenkx:support/stale-packet-flush-d261-20261113
Open

JJenkx wants to merge 6 commits into
boykopovar:mainfrom
JJenkx:support/stale-packet-flush-d261-20261113

Conversation

@JJenkx

@JJenkx JJenkx commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What

A packet worker can decide to flush for an old batch's cap or pending-label deadline, then drain the draw pipeline before taking the GPU mutex. The committer can submit that batch during the drain. Main's final guard accepts any newly pending label, so it also submits the fresh, below-cap batch for the obsolete decision.

Recheck the live work count and pending-label deadline after drain/lock. Preserve the queued label's age before recording resets its pending timestamp, so an overdue queued label still forces submission. Keep cap/deadline defaults unchanged. No title unblock or FPS gain is claimed.

The CTest registration clears inherited label-mode switches for these cases while preserving Windows PATH handling.

The regression uses an actual queued callback and the existing drain-request counter to force this ordering, without new production hooks. Explicit idle verifies the GPU label bytes after retained work is submitted.

Tested

Default-invocation review fix (b3178f44678): the execution-test discovery loop also registers agc_driver_stale_packet_flush without arguments. The original suffix-only selector missed that invocation. It now runs stale-cap by default; the generic test receives the same cap/deadline/pipeline settings and inherited label-mode unsets as the explicit cases. Production PacketFlush.cpp is byte-identical to the qualified 68aee334 provider.

Using actual CMake registrations and ctest -R '^agc_driver_stale_packet_flush($|_)' -V, with all six label-mode switches deliberately set in the parent:

  • Original provider: default, stale-cap and stale-deadline fail with the expected extra submission; current-cap and queued-overdue pass.
  • Fixed provider: 5/5 pass, including the bare invocation. All ten executions select the physical RX 6650 XT and load validation 1.4.363; zero skips/VUIDs, unchanged frozen providers/fixtures.

Full logs, registrations, source patch and provider proofs, downloaded archive and all 18 members verified, SHA-256 93b35fa0505a01fcea6ddd8843f488a9b3cd512851f612590b06da877c4fbb25.

Linux 7.2.14, AMD Radeon RX 6650 XT, RADV Mesa 26.2.6, validation 1.4.363. Complete SDK/relinker builds pass on both arms. Same fixture on pure-main production d261fa6f5665 plus test-only commit c4a44dd2c777, versus correction 68aee334dd29:

New GPU case Main with same fixture Correction
stale cap after drain fails: 2 submissions, expected 1 passes
stale deadline after drain fails: 2 submissions, expected 1 passes
replacement still at cap passes passes
queued label already overdue passes passes

Matched 15-case gate: main 11 pass / 2 expected fail / 2 skip; correction 13 pass / 0 fail / 2 identical skip. All four new cases execute on the physical RX 6650 XT and individually log actual validation-layer insertion. The 13 non-skipped cases include seven physical-GPU cases and six CPU/order regressions. Existing copied_writer_label_order and _drain require storage-buffer alignment above 4; this device reports 4, so their forced-copy assertions are not claimed as coverage.

Both arms use ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer with verbose CTest, serialized through the host GPU FIFO. Zero VUIDs, no missing layer, no new skips; SDK and fixture hashes unchanged. Conventions, declaration audit (413 libraries / 34,519 unique reachable exports), and built-source registration checks pass.

Overlap: the official scan probed 1,524 open PRs and failed closed on #6186's shared file. Every merge base was checked manually: it changes only a profiling report line here; preserve that line independently. #18717 changes the default cap and #18809 changes HeldReads/HLE clear ordering; neither implements this recheck and this branch needs neither. Local merge-tree against main 135da47a9cb4 is clean.

Patch, full logs, per-case hardware/layer reviews, build proofs and checks — SHA-256 07c82d00bfae76b91016c306026ddc52cb59493431053376a8bc52a557c8ad29; downloaded archive and all 33 members verified.

Windows: the independent worker reports all four explicit cases passing three repetitions on head 89f8cac and fixed 68aee334, with the two expected baseline failures: Windows 11 Enterprise 22621, AMD RX 6700 XT / driver 26.10.1, GCC 15.2 UCRT Release, validation 1.4.363, own Windows FIFO, zero skips or validation IDs. The newer default-invocation fixture correction below has Linux qualification only so far. No native title or performance comparison is claimed for this fix.

Test-environment refresh 89f8cac67da6 changes only the CTest registration. Production and fixture C++ remain byte-identical to the qualified providers above. With all six label-mode switches deliberately set in the parent, the refreshed CMake-generated registrations retain both main negative failures and pass all four fixed-provider cases, with actual GPU/layer insertion and zero skips/VUIDs. The old registration reproduces the two negative-case failures on the fixed provider when label batching is disabled; the new registration isolates the intended policy. Controlled logs and equivalence proof, SHA-256 3a1b8291dc9eefc64f54ae821b8e1e2c55b196fc44f62247a1f139e1b20b255d. Existing SDK binaries were deliberately reused for this CMake-only refresh.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: AMD Radeon RX 6650 XT; RADV Mesa 26.2.6; Linux 7.2.14; Vulkan validation layer 1.4.363
  • AI-assisted: yes

Summary by CodeRabbit

  • Bug Fixes
    • Improved GPU work flushing when deferred labels are pending, helping ensure queued work is submitted when flush limits or deadlines are reached.
    • Avoided unnecessary submissions when no flush condition applies, improving consistency in how pending work is handled.

@tablefrogpillow

Copy link
Copy Markdown
Contributor

Heads-up from a Linux/RADV run at 68aee334dd (clean builds — rm -rf build on the RDNA boxes and ninja -t clean on Vega, so not a stale-object artifact; Mesa 26.2.6, validation layer 1.4.363, 0 VUID-). Two of the four new agc_driver_stale_packet_flush modes fail identically and deterministically on all three AMD generations:

mode Vega (VEGA10, GCN5) RDNA2 (RAPHAEL, gfx1036) RDNA3 (NAVI31, gfx1100)
stale-cap 0/3 0/3 0/3
stale-deadline 0/3 0/3 0/3
current-cap 3/3 3/3 3/3
queued-overdue 3/3 3/3 3/3

Both failures are the same assertion:

AGC graphics: stale packet flush: stale-cap submitted 2 batches, expected 1
AGC graphics: stale packet flush: stale-deadline submitted 2 batches, expected 1

i.e. on RADV these two paths submit 2 PM4 batches where the test expects the recheck to coalesce to 1; current-cap and queued-overdue behave as expected. I didn't want to guess whether RADV's submission/chaining just splits these two cases differently from the HW you validated on or whether the recheck needs to cover them — you know the flush logic. Happy to re-run any variant or dump the batch sequence if that helps.

AI-assisted: yes.

@JJenkx

JJenkx commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

@tablefrogpillow, I am checking this report. These assertions count host Recorder::SubmittedEpoch() transitions, not PM4 batches split by RADV, so I would like to isolate the host-side condition.

Please attach the exact CTest/binary commands and verbose logs, the loaded libSceAgcDriver path, and whether APS5_NO_LABEL_BATCHING, APS5_NO_LABEL_BATCH_SUBMIT, APS5_LABEL_OWN_LOCK, APS5_LABEL_TRY_EACH_PACKET or APS5_NO_QUEUED_LABELS are set. Only those relevant switches are needed, not a full environment dump.

The fixture currently inherits these switches; disabling label batching intentionally enables immediate packet submission and can invalidate its young-label expectation. I have queued a controlled default-versus-disabled-label-mode comparison on the same frozen 68aee334 provider before changing production code. The original complete verbose logs, fixture/provider hashes and source pins are in the linked evidence archive.

@tablefrogpillow

Copy link
Copy Markdown
Contributor

Thanks — the switch question is the useful part, so to answer it directly: none of APS5_NO_LABEL_BATCHING, APS5_NO_LABEL_BATCH_SUBMIT, APS5_LABEL_OWN_LOCK, APS5_LABEL_TRY_EACH_PACKET or APS5_NO_QUEUED_LABELS were set — env | grep -i APS5 is empty, and the env file I source (vulkan-validation/env.sh) sets only the validation-layer vars, no APS5_*. So the fixture ran on its inherited defaults with no override from my side; these are SubmittedEpoch() transitions under default label batching, not RADV PM4 splits (agreed — I only flagged the symptom).

Details you asked for, all at a clean build of 68aee334dd:

  • Build: rm -rf build && cmake -S . -B build -G Ninja && ninja -C build agc_driver_stale_packet_flush_tests (also reproduced with ninja -t clean on Vega — not a stale object).
  • Driver: build/core/libs/libs/unpatched/libSceAgcDriver.prx; test binary build/tests/agc_driver_stale_packet_flush_tests.
  • Run (per mode): ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ANYPS5_GPU=<VEGA10|RAPHAEL|NAVI31> ./build/tests/agc_driver_stale_packet_flush_tests stale-cap (and stale-deadline). Equivalently ctest -R '^agc_driver_stale_packet_flush_(stale_cap|stale_deadline)$' -V.
  • Output: the only app-level line before the abort is the assertion itself (… submitted 2 batches, expected 1); the test prints no per-submission/epoch trace at default verbosity. current-cap and queued-overdue pass 3/3 with the identical invocation on all three gens.

If a batch/epoch trace would help isolate it, point me at an env toggle or a one-line probe and I'll rerun on any/all three gens on the frozen 68aee334dd.

AI-assisted: yes.

@JJenkx

JJenkx commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

@tablefrogpillow, the controlled check reproduces your exact two assertions on the same fixed 68aee334 provider when APS5_NO_LABEL_BATCHING=1 is inherited; with default label mode that provider passes all four. That switch intentionally selects immediate per-packet submission, rather than the batching policy this fixture tests.

I refreshed the CTest registration in 89f8cac67da6 to unset the six relevant inherited label-mode switches, preserving the Windows PATH modification. No production C++ or fixture C++ changed. Using actual CMake-generated registrations and deliberately setting all six switches to 1 in the parent environment:

  • Original production provider with the same fixture: stale-cap/deadline fail with the expected extra submission; both positive controls pass.
  • Fixed provider: 4/4 pass, actual RX 6650 XT and validation 1.4.363 in every case, zero skips/VUIDs.

All sixteen controlled case executions, full logs and registration/provider-equivalence proof; downloaded archive and all 21 members verified, SHA-256 3a1b8291dc9eefc64f54ae821b8e1e2c55b196fc44f62247a1f139e1b20b255d.

This establishes an environment dependency in the original fixture; it does not establish which provider or environment your runs used. Please retry with ctest --test-dir build -R '^agc_driver_stale_packet_flush_' -V using the refreshed registration and attach the original commands/logs if this does not explain your result. A direct binary invocation also needs the case-specific APS5_BATCH_CAP=64 and APS5_LABEL_FLUSH_US settings from CTest (60000000, except stale-deadline uses 100000), as well as the equivalent label-mode switches.

@Doorriiaann

Copy link
Copy Markdown
Contributor

An NVIDIA run, next to the AMD runs: RTX 3070 (8 GB), NVIDIA 610.57.04, Ryzen 5 5600X, Debian 13, kernel 6.12.115, GCC 13.3.0 Release, validation layer 1.4.335, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ctest -R packet_flush -V, 3 runs.

On this head 68aee33 the four new mode tests (agc_driver_stale_packet_flush_stale_cap, _stale_deadline, _current_cap, _queued_overdue) pass 3/3, but a fifth test fails 3/3: agc_driver_stale_packet_flush, which runs agc_driver_stale_packet_flush_tests with no argument and stops at AGC graphics: stale packet flush: expected a test mode. It is not from agc_driver_stale_packet_flush_tests.cmake: the tests/execution/*.cpp loop in libSceAgcDriver/CMakeLists.txt registers every execution test once without arguments. Require(argc == 2, ...) in StalePacketFlush.cpp:141 runs before OpenVulkanTestDevice() at line 144, so it should fail on a machine without a device too. A plain ctest run picks it up.

Negative control, this PR's StalePacketFlush.cpp and agc_driver_stale_packet_flush_tests.cmake on the merge-base d261fa6, 3 runs: _stale_cap and _stale_deadline fail 3/3 with submitted 2 batches, expected 1, _current_cap and _queued_overdue pass, and the no-argument test fails the same way as on the head. No VUID- line.

So on this NVIDIA machine stale-cap and stale-deadline pass with the change and fail without it; the submitted 2 batches, expected 1 that tablefrogpillow sees on the head on RADV only shows here when the fix is reverted.

AI-assisted: yes

@JJenkx

JJenkx commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Windows check of head 89f8cac67d, its fix commit 68aee334dd, and the test-only parent c4a44dd2c7, all on main d261fa6f56. Setup: Windows 11 Enterprise 22621, AMD RX 6700 XT, AMD driver 26.10.1, MinGW-w64 GCC 15.2 UCRT, Release.

How it ran:

  • Each arm in its own lease of the shared Windows GPU FIFO.
  • ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (1.4.363) and VK_LOADER_DEBUG set.
  • ctest -R '^agc_driver_stale_packet_flush_' --repeat until-fail:3.
  • agc_driver_stale_packet_flush_tests and libs built in all three arms.
Test Test-only parent c4a44dd2c7 Fix 68aee334dd Head 89f8cac67d
agc_driver_stale_packet_flush_stale_cap fails: stale-cap submitted 2 batches, expected 1 passes, 3 of 3 passes, 3 of 3
agc_driver_stale_packet_flush_stale_deadline fails: stale-deadline submitted 2 batches, expected 1 passes, 3 of 3 passes, 3 of 3
agc_driver_stale_packet_flush_current_cap passes, 3 of 3 passes, 3 of 3 passes, 3 of 3
agc_driver_stale_packet_flush_queued_overdue passes, 3 of 3 passes, 3 of 3 passes, 3 of 3

Checks across all three arms:

  • Skips: none in any arm.
  • Validation: no VUID-, UNASSIGNED- or sync-hazard ID; the layer loaded in every arm.
  • Receipts: exit 0 and app_count=0 in all three.
  • Same test in both arms: the test executable is byte-identical between the parent and the fix (the fix changes only PacketFlush.cpp), and the candidate build recompiled that file into libSceAgcDriver.

The head's extra commit only adds ENVIRONMENT_MODIFICATION unsets for the label-mode variables to the test registration. It also passes all 4.

Conclusion: the parent fails exactly the two stale cases, with the extra fresh-batch submit, and this PR fixes both without changing the other two.

AI-assisted: yes.

@github-actions github-actions Bot added build agc libSceAgc* labels Nov 13, 2026
@JJenkx

JJenkx commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

@Doorriiaann, confirmed: the generic execution-test loop registers a fifth, no-argument invocation. My original suffix-only CTest selector missed it. I pushed b3178f44678: no argument now selects stale-cap, and the generic test gets the same setup and label-switch unsets as the explicit cases. Production code is unchanged.

The corrected broad selection is ctest --test-dir build -R '^agc_driver_stale_packet_flush($|_)' -V. With all six label-mode flags deliberately inherited in the parent, the original provider fails default/stale-cap/stale-deadline with the expected extra submission and passes both positive controls. The fixed provider passes all five. Every one of the ten case executions selected the actual RX 6650 XT and loaded validation 1.4.363; zero skips or VUIDs.

Patch, actual registrations, complete logs and frozen-provider proofs; archive and every member downloaded/verified, SHA-256 93b35fa0505a01fcea6ddd8843f488a9b3cd512851f612590b06da877c4fbb25.

The Windows worker has also posted its independent four-mode baseline/fix/head 89f8cac results. The new default-invocation correction is Linux-qualified so far. Your NVIDIA report is useful additional contributor coverage; this reply claims the device runs recorded in the linked artifacts.

@hamdanpor-ctrl

Copy link
Copy Markdown
Contributor

Test report, NVIDIA on Windows: the four new mode tests pass; the bare agc_driver_stale_packet_flush registration fails because it starts without a mode.

  • GPU: NVIDIA GeForce RTX 3050 Laptop GPU, driver 617.42, Windows 11 Pro (10.0.26300)
  • Build: WinLibs GCC 15.2.0 r7 UCRT, Release, all AGC execution tests built (-DANYPS5_AGC_EXECUTION_TESTS= empty)
  • Compared: main at 3f5bb8c, and the same commit with 89f8cac merged (git merge --no-ff, clean)
  • Environment: ANYPS5_GPU=NVIDIA, ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_DEBUG=layer (Vulkan SDK 1.4.363.0)
  • Command: ctest --test-dir build -V --parallel 4 -R "^agc_|^request_serializer|shader"
main main + this PR
Passed 1658 1662
Failed 0 1
VUID- lines 0 0
Validation messages 61 61, same IDs
  • agc_driver_stale_packet_flush_stale_cap, _stale_deadline, _current_cap and _queued_overdue pass.
  • agc_driver_stale_packet_flush fails in 0.14 s:
AGC graphics: stale packet flush: expected a test mode

StalePacketFlush.cpp lands in agcExecutionTestSources, so the agc_add_default_test loop in core/libs/prx/libSceAgcDriver/CMakeLists.txt also registers the bare agc_driver_stale_packet_flush, which runs the executable without an argument and hits Require(argc == 2, ...). CI builds only the three tests in ANYPS5_AGC_EXECUTION_TESTS, so it does not see this. A fix would be to add the target to the existing skip list there, as for the other mode-only tests:

if(agcTest STREQUAL "agc_driver_constant_store_tests" OR ... OR agcTest STREQUAL "agc_driver_rcp_hardware_tests" OR agcTest STREQUAL "agc_driver_stale_packet_flush_tests")

or to let main run one mode when no argument is given.

  • Every other test has the same result on both commits; the layer loads in both logs and neither reports it missing.

Single run each. AI-assisted (Claude Code).

@JJenkx

JJenkx commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

@hamdanpor-ctrl, your pinned 89f8cac67d predates the default-invocation fix in current head b3178f44678. The bare invocation now runs stale-cap, with the same cap/deadline/pipeline configuration and inherited label-mode unsets as the four explicit cases. Production PacketFlush.cpp is unchanged.

After updating and rebuilding agc_driver_stale_packet_flush_tests, select all five with:

ctest --test-dir build -R '^agc_driver_stale_packet_flush($|_)' -V

The complete selection passes 5/5 on the physical RX 6650 XT with validation 1.4.363 and zero skips/VUIDs. The original production provider fails default/stale-cap/stale-deadline and passes both positive controls. Patch, full logs, actual registrations and frozen-provider proofs are attached in the previous reply. Your Windows/NVIDIA report is useful additional coverage of the four explicit modes; the updated fifth invocation still needs a run on that setup.

@tablefrogpillow

Copy link
Copy Markdown
Contributor

Re-verified on the updated head b3178f4467 on additional RDNA hardware (Linux, RADV, Mesa 26.2.6, validation layer 1.4.363, 0 VUID-), running the full selection with the test's own environment (APS5_BATCH_CAP=64, APS5_LABEL_FLUSH_US=60000000 / 100000 for stale-deadline, APS5_DRAW_PIPELINE=1, APS5_PIPELINED_DRAWS=32, source-dir cwd, label switches unset — as agc_driver_stale_packet_flush_tests.cmake sets them):

RDNA2 (RAPHAEL, gfx1036) RDNA3 (NAVI31, gfx1100)
agc_driver_stale_packet_flush (default + stale-cap + stale-deadline + current-cap + queued-overdue) 5/5 5/5

So the default-invocation change and the recheck behave correctly across RDNA2 and RDNA3 as well, matching your RX 6650 XT run; 0 VUID- in every run. (For the record: my earlier 2/5 on these boxes was my own direct-binary invocation missing the batch-cap/flush-timing env above — not a hardware difference; with the proper environment they pass.)

AI-assisted: yes.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 28411 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketFlush.cpp L92-97

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6186 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketFlush.cpp
PR 22434 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketFlush.cpp
PR 22647 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketFlush.cpp
PR 28237 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketFlush.cpp

@JJenkx

JJenkx commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Update for the current head b3178f4467, plus a correction to my earlier result. Setup: Windows 11 Enterprise 22621, AMD RX 6700 XT, AMD driver 26.10.1, MinGW-w64 GCC 15.2 UCRT, Release, shared Windows GPU FIFO, ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, validation layer 1.4.363.

At this head, agc_driver_stale_packet_flush (the new default invocation), _stale_cap, _current_cap and _queued_overdue pass. No validation IDs and no skips.

agc_driver_stale_packet_flush_stale_deadline is intermittent on this machine. It fails with the base commit's message, stale-deadline submitted 2 batches, expected 1.

  • Timeline at the current head:
    • It failed on its first run.
    • It failed again on the first of 20 repeats.
    • Both of those ran while an unrelated 32-thread build was compiling.
    • It then passed once and failed once with the machine idle.
  • A/B in one GPU lease. The library is identical between 89f8cac67d and b3178f4467; only the test executable differs. So I swapped the two executables in, alternately, 10 runs each:
Test executable Passed Failed
b3178f4467 (this head) 8 2
89f8cac67d (previous head) 9 1

All three failures show the same submitted 2 batches, expected 1 message.

Correction: my earlier "passes, 3 of 3" for stale_deadline at 68aee334dd and 89f8cac67d held only for those runs. Over more runs it fails roughly 1 time in 10 at both heads, so this head's default-invocation change did not introduce it.

The other three cases still separate the fix cleanly: stale_cap fails 3 of 3 on the parent and passes on the fix. stale_deadline, with APS5_LABEL_FLUSH_US=100000, looks timing-sensitive on Windows: sometimes a second batch is submitted within the deadline window.

AI-assisted: yes.

@Doorriiaann

Copy link
Copy Markdown
Contributor

Rechecked b3178f4 on the RTX 3070, same setup as above, ctest -R '^agc_driver_stale_packet_flush($|_)' -V, 3 runs: all five pass 3/3, including the no-argument agc_driver_stale_packet_flush, with no VUID- line.

On the intermittent stale_deadline: here it passed 50/50 alone and 50/50 more with twelve busy loops on the 12 threads, so the second batch inside the 100 ms window has not shown on this Linux/NVIDIA machine in 103 runs at this head.

AI-assisted: yes

@oneandonlydean

Copy link
Copy Markdown
Collaborator

The fix reads right to me: flushBetweenPackets now recomputes the cap, deadline and packet reasons from the current pending label after the drain, and the counters follow the reason that applied. The exact head also has passing runs on RTX and RADV.

One thing blocks it: agc_driver_stale_packet_flush_stale_deadline is flaky, as your own Windows comment shows (8 of 10 at this head, 9 of 10 at the previous one, always stale-deadline submitted 2 batches, expected 1, and it also fails under load). A test that fails about one run in ten on a busy runner will turn main red. Please either make the case independent of timing (for example drive the clock or the deadline through a hook instead of relying on APS5_LABEL_FLUSH_US=100000 against real time) or show that the second batch in that window is expected and change the assertion to match. If the second batch is a real flush that the fix should have prevented, that is a code problem and I need to hear it.

… coming due

The stale-deadline case used a 100 ms label flush deadline so that its old
batch's label went stale during the 250 ms sleep, but its queued label was
stamped with the current time, so when the drain took longer than the
deadline that label came due as well and a second batch was submitted. The
queued label is now stamped in the future in every case but queued-overdue,
so only the old label's age decides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JJenkx

JJenkx commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, fixed in 111521419a1c; the second batch was not expected.

Cause. stale-deadline sets APS5_LABEL_FLUSH_US=100000 so that the old batch's label is stale after the 250 ms sleep. The test then queues a deferred label stamped steady_clock::now(), and after the pipeline drain flushBetweenPackets recomputes deferredDue = now - deferred.since >= labelFlushDeadline() (PacketFlush.cpp:83). When the drain plus the committer's work in the test (submitting the old batch, opening the replacement) took longer than 100 ms, the queued label came due too and submitted the replacement batch: submitted 2 batches, expected 1.

Reproduced deterministically. With a temporary 150 ms sleep at the start of the test's committer lambda (not committed), the previous head fails 5 of 5 with exactly that message.

Fix. The queued label is now stamped an hour in the future in every mode except queued-overdue (which still backdates it 120 s), so it is never due and only the old label's age, made stale by the sleep, decides. Nothing reads deferred.since except now - since >= deadline comparisons (PacketFlush.cpp lines 36, 67, 83), so a future stamp just reads as not due. The sleep side was already monotonic: a slower machine only makes the old label older.

Tested. Linux 7.2.14, RX 6650 XT, RADV, Release:

  • With the same temporary 150 ms committer sleep, the fixed test passes 10 of 10.
  • Without it, ctest -R "^agc_driver_stale_packet_flush" --repeat until-fail:20 (all four modes and the default invocation) passes, both idle and with 32 busy-loop threads on the 32 logical CPUs.

AI-assisted: yes

@JJenkx

JJenkx commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

A regression check on six titles at this head (111521419a1c), 70 s each, Cross every 15 s, against each title's earlier run on main 963137c40642:

Title main 963137c40642 this PR
PPSA02849 exit 0, 3,469 frames exit 0, 3,809 frames
PPSA03042 exit 0, 3,744 frames exit 0, 3,712 frames
PPSA03659 exit 0, 3,417 frames exit 0, 2,253 frames
PPSA04795 exit 0, 3,721 frames exit 0, 3,892 frames
PPSA05986 exit 0, 3,774 frames exit 0, 3,720 frames
PPSA06323 exit 0, 3,836 frames exit 0, 3,843 frames

No failure, refusal or stop. PPSA03659's lower count is a loading pause at about 32 s that lasted longer in that run. Alternating it with current main (718157584041), two runs each, shows the pause length varies on both sides: this PR resumed by about 42 s in both runs (3,295 and 3,254 frames at 66 s), and main resumed at about 66 s in one run and about 38 s in the other (1,863 and 3,548 frames). So I don't read a difference into it.

AI-assisted: yes

@domx4q

domx4q commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Ran the focused tests with the Khronos validation layer on Linux and an NVIDIA GPU, since CI runs the GPU tests only on lavapipe, and the earlier RTX 3070 Linux runs were of 68aee334dd and b3178f4467, before the queued-label change in 111521419a.

Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, NVIDIA GeForce RTX 4090 (vendor 0x10de, device 0x2684, Ada), proprietary driver 620.70.06, Vulkan 1.4.357, Khronos validation layer 1.4.363.1. Head 111521419a merged onto main fbaae8a79d with --no-ff (clean, as 5e00645a0b). Main baseline is a Release build of fbaae8a79d on the same machine.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer \
ctest --test-dir build -R '^agc_driver_stale_packet_flush($|_)|packet_flush' -V
main fbaae8a79d this PR
Result no matching tests (added by this PR) 5 of 5 passed
Insert instance layer "VK_LAYER_KHRONOS_validation" 0 5
was not found but was requested by env var VK_INSTANCE_LAYERS 0 0
VUID- none none

The five agc_driver_stale_packet_flush* tests are added by this PR, so the pattern selects nothing on main. On this head all five pass, every device selected the RTX 4090.

Repeat: ctest -R '^agc_driver_stale_packet_flush($|_)' --repeat until-fail:20 with the same environment (without -V, so results only): 100 of 100 runs pass, including 20 of agc_driver_stale_packet_flush_stale_deadline.

Negative control: with main's PacketFlush.cpp and this PR's tests, three fail and two pass (2 of 5): agc_driver_stale_packet_flush and _stale_cap with AGC graphics: stale packet flush: stale-cap submitted 2 batches, expected 1, and _stale_deadline with stale-deadline submitted 2 batches, expected 1; _current_cap and _queued_overdue pass. That matches the Tested section.

No new VUID- errors; all five new tests pass on Ada, 20 of 20 repeats each.

AI-assisted: yes (Claude Code)

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

The change at head 111521419a1c3c34216b5dedc870af46973eb21b rechecks current packet flush reasons after the pipeline drain and adds regression coverage for stale and current flush conditions.

What I ran

Read the prepared diff and all changed lines, then inspected the relevant label recording, pending-label snapshot, test registration, and CMake inclusion code. No local test command was run; test results in the PR description are author-reported.

Results

Check Result Note
Changed-line review passed All three changed files read
Targeted context passed Flush, label, recorder, and CMake paths checked
Local tests not run No test execution performed

Findings

Blocking

None.

Non-blocking

None.

Sources

Behavior claims are based on the pinned head 111521419a1c3c34216b5dedc870af46973eb21b, including PacketFlush.cpp, DeferredLabels.cpp, PacketMemory.cpp, and Recorder.cpp.

Not verified

No build, CTest, Windows run, or console behavior was verified locally. The PR description reports Linux GPU test runs and an independent Windows run; these were not reproduced here. files.json was not present in the review folder, so excluded-by-rule files could not be itemized; the prepared manifest lists three changed files, and all three were read.

To get this to a good state

Nothing is required.

@Jirka135

Copy link
Copy Markdown
Contributor

Windows runs of the current head 111521419a on an RTX 5090 (Blackwell) and on the RDNA2 iGPU, with and without the validation layer, plus the PR's tests on main's code.

Setup: Windows 11 Enterprise 10.0.26300, Ryzen 7 9800X3D, WinLibs GCC 15.2.0, Release. GPUs: NVIDIA GeForce RTX 5090 (10de:2b85), driver 617.42, and AMD Radeon(TM) Graphics (1002:13c0, gfx1036 iGPU), driver 32.0.21045.29003 (ANYPS5_GPU=AMD). Khronos validation layer 1.4.369. PR merged with --no-ff onto main 8b40357971. Red = this PR's StalePacketFlush.cpp and agc_driver_stale_packet_flush_tests.cmake on main's PacketFlush.cpp. Each cell is 3 runs with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer plus 3 runs without, a fresh ctest process each:
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ctest --test-dir build -R '^agc_driver_stale_packet_flush($|_)' -V

test red, RTX 5090 red, iGPU PR, RTX 5090 PR, iGPU
agc_driver_stale_packet_flush 0/6 0/6 6/6 6/6
agc_driver_stale_packet_flush_stale_cap 0/6 0/6 6/6 6/6
agc_driver_stale_packet_flush_stale_deadline 0/6 0/6 6/6 6/6
agc_driver_stale_packet_flush_current_cap 6/6 6/6 6/6 6/6
agc_driver_stale_packet_flush_queued_overdue 6/6 6/6 6/6 6/6

Red fails with stale-cap submitted 2 batches, expected 1 (default and stale-cap) and stale-deadline submitted 2 batches, expected 1. Because the deadline case is timing-sensitive, I also ran ctest -R '^agc_driver_stale_packet_flush_stale_deadline$' --repeat until-fail:50 without the layer: 50/50 on the RTX 5090 and 50/50 on the iGPU.

Every layered run logs Insert instance layer "VK_LAYER_KHRONOS_validation" for each of the 5 tests, none logs the layer as not found, and no run on either side has a VUID- line.

GPUs tested: NVIDIA GeForce RTX 5090, driver 617.42, Windows 11; AMD Radeon(TM) Graphics (gfx1036 iGPU), driver 32.0.21045.29003, Windows 11

AI-assisted: yes

@JJenkx

JJenkx commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Windows follow-up on the failing windows check (run 44118883715, 2026-11-17 15:50 UTC, head 111521419a): guest_libressl3_ec_parameters and guest_libressl3_asn1 aborted with 0xc0000409.

That run predates the fix: it started before #22388 merged at 16:47 UTC on 2026-11-17, reverting the LibreSSL 3 guest-pointer change that broke exactly these two tests on Windows.

They pass now:

  • this head merged onto current main bfb39f4f5a (6cd87a7dee, clean merge): both tests pass in each of 3 runs;
  • current main alone passes both, in a full non-device sweep at b5460b9e94 (4,576 of 4,576).

So the red windows status is stale pre-revert CI, not this PR. Re-running the check would refresh it.

Setup: Windows 11 Enterprise 22621, AMD Ryzen 9 5950X, WinLibs GCC 15.2 UCRT r7, Release.

AI-assisted: yes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JJenkx

JJenkx commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

Merged current main (69d574e9a2cc, no conflicts) in d78f37de32ab to refresh this PR's CI. The earlier Windows failure was only guest_libressl3_ec_parameters and guest_libressl3_asn1 crashing (0xc0000409) on the 2026-11-17 main. Both have been fixed on main since (#27459, #27500), and this PR doesn't touch them.

Linux/RADV, RX 6650 XT, Mesa 26.3.1, Release, merged head, with the Khronos validation layer inserted: all five agc_driver_stale_packet_flush* cases (base, stale_cap, stale_deadline, current_cap, queued_overdue) and agc_driver give 6 pass, 0 skipped, with 0 VUID- and 0 SYNC-HAZARD.

AI-assisted: yes

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Packet Flush Decision

Layer / File(s) Summary
Recheck packet flush conditions
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketFlush.cpp
The flush path refreshes deferred-label deadlines after acquiring the GPU lock. Before submission, it checks the batch cap, pending-label deadline, packet-flush condition, and recorded-label deadline. Counter classification now prioritizes packet flushes, then deadline flushes, then cap flushes.
Exercise stale packet flush scenarios
core/libs/prx/libSceAgcDriver/tests/execution/StalePacketFlush.cpp, core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_stale_packet_flush_tests.cmake
The execution test covers stale-cap, stale-deadline, current-cap, and queued-overdue modes. CMake registers the modes and configures their environments, including a distinct deadline value for stale-deadline.

Possibly related issues

  • boykopovar/AnyPS5 issue 27126: It concerns submission frequency caused by the pending-label flush deadline. This change updates deadline checks in the packet flush decision, but does not change the stated deadline policy or establish that the reported submission frequency is addressed.

Suggested reviewers: boykopovar

Change: Bug fix

Merge Risk: Minimal · up to d78f3

This change makes the packet flush path recheck live deadline and cap conditions after the pipeline drains, so stale flush decisions no longer cause extra or missed submissions. It adds regression tests for four scenarios with isolated test environments. No actionable merge-blocking risk was found.

Security architecture risk: Minimal · up to d78f3

The fix prevents an old flush decision from prematurely submitting a replacement GPU batch. It preserves submission for overdue queued labels and does not change who can submit work or what they can access. No material new risk was identified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The supported production exposure is a change in when an existing packet execution path submits recorded GPU work. The diff leaves the caller, device selection, queue argument, and submission operation in place.

Trust Boundaries and Controls

  • observed — The existing GPU mutex remains the serialization boundary for the final flush decision and submission. The PR revalidates the trigger inside that boundary rather than bypassing it or adding another submission path.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9ca35519-e18a-406c-a132-362fda4fde05
Commits

Reviewing files that changed from the base of the PR and between f51f7fe and d78f37d.

Files selected for processing: 3

  • core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketFlush.cpp
  • core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_stale_packet_flush_tests.cmake
  • core/libs/prx/libSceAgcDriver/tests/execution/StalePacketFlush.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@JJenkx

JJenkx commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Windows/AMD GPU run at this head (d78f37de32ab): agc_driver_stale_packet_flush, agc_driver_stale_packet_flush_stale_cap, agc_driver_stale_packet_flush_stale_deadline, agc_driver_stale_packet_flush_current_cap, agc_driver_stale_packet_flush_queued_overdue pass, 3/3 runs, on an RX 6700 XT. None were skipped. The Windows CI job has no GPU, so this covers what it cannot.

The test's three _WIN32 blocks are Win32 equivalents, not skips:

  • <windows.h>.
  • VirtualAlloc instead of aligned_alloc for the 64 KiB block.
  • VirtualFree instead of free.

Setup:

  • Windows 11 22621, Ryzen 9 5950X, MinGW-w64 GCC 15.2 UCRT r7, Release.
  • The exact PR head was built (not merged into main).
  • 3 runs through the shared FIFO.

AI-assisted: yes.

@Plyxen Plyxen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read the diff at d78f37de32. Windows 11, GCC 15.2, merged into main at c1593e4e1dd together with other open PRs (so not an isolated build), with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 and VK_LAYER_KHRONOS_validation on an RTX 5080 (621.24) and a Radeon iGPU (26.11.2).

  • the agc_driver_stale_packet_flush tests, with the other label and flush tests (90 in all): pass on both GPUs. The loader log shows the layer inserted and no "was not found" line, and neither run has a VUID- or SYNC-HAZARD line.
  • Control (the same tree with only this PR's source change taken out): three of the five fail, for example "stale packet flush: stale-cap submitted 2 batches, expected 1".

Not checked: the frame rate of a title.

AI-assisted: yes (Claude Code)

@ligmaSec ligmaSec left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested d78f37de32 against main at 9d362fb088 on Linux with Mesa lavapipe. agc_driver_gcn_scalar_buffer_base and agc_host_import_retirement passed on both revisions. On the change, all five agc_driver_stale_packet_flush* cases passed, covering the default invocation, stale cap, stale deadline, current cap, and overdue queued label. Every run required Vulkan and disabled the shader cache. The logs show the loader inserting Khronos validation 1.4.369, with no missing-layer warnings or VUID- messages. This comparison used software Vulkan.

AI-assisted: yes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants