fix(libSceGnmDriver): order compute-queue submissions against graphics submissions #21225
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/21225"
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 Gag21 on 2026-11-16T00:49:07Z.
What
Order PS4 Gnm compute-queue submissions (
sceGnmDingDong) and graphics submissions (sceGnmSubmitCommandBuffers) against each other underAPS5_GNM_ORDER_COMPUTE_GRAPHICSusing submission pacing (AgcDriverWaitSubmissionPaced_nid_postfix(5000)).Submissions through
sceGnmDingDongandsceGnmSubmitCommandBuffersrun on separate AGC worker queues (Queue 0 and Queue 0x20). Previously, compute-queue submissions were submitted to the AGC driver without waiting for earlier queued graphics or compute work, and graphics submissions did not wait for earlier compute work. When graphics passes and compute rings interact—such as sharing Global Data Share (GDS) counters, indirect draw arguments, or resource buffers—the lack of submission ordering allowed compute packets to execute concurrently or ahead of graphics packets. In Shadow of the Beast (CUSA01709), graphics clears GDS counter 0x40 viaDMA_DATAbefore running culling shaders (DS_APPEND), while a compute ring particle simulation consumes from GDS 0x40 (DS_CONSUME). Executing the compute ring ahead of graphics caused the counter to underflow (0 - 1 = 0xffffffff), resulting in indirect draw instance count corruption and GPU device loss.APS5_GNM_ORDER_COMPUTE_GRAPHICS, track queued work and compute submissions with atomic flags (g_workQueued,g_computeQueued).sceGnmDingDong, wait for earlier queued work viaAgcDriverWaitSubmissionPaced_nid_postfix(5000)before submitting lowered ACB packets to the compute queue, and record that compute work is queued. Every DingDong after another one also waits, serializing the queues with up to a 5-second wait while holding the ring lock.SubmitLocked, wait for earlier compute submissions viaAgcDriverWaitSubmissionPaced_nid_postfix(5000)before submitting graphics command buffers.APS5_GNM_ORDER_COMPUTE_GRAPHICSindocs/dev/ENVIRONMENT.mdunderlibSceGnmDriver.gnm_driver_compute_queue_orderedCTest target (--ordered) withENVIRONMENT "APS5_GNM_ORDER_COMPUTE_GRAPHICS=1"verifying bidirectional GDS counter ordering between graphicsDMA_DATAand compute ringDMA_DATAin an isolated process.sceGnmDingDongindocs/dev/debt/changes/fix-gnm-compute-queue-order-graphics.md.Tested
gnm_driver_compute_queue: passed (isolated fromorderComputestatic caching).gnm_driver_compute_queue_ordered: passed withAPS5_GNM_ORDER_COMPUTE_GRAPHICS=1. Confirmed that removing the wait insceGnmDingDongcauses the test to fail immediately withcompute queue did not observe GDS value written by graphics.gnm_driver_packets: passed.gnm_driver_submit_wait: passed (includingTestFrameBoundaryWaitandTestParkedComputeQueueWait).VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationandVK_LOADER_DEBUG=layerwithANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1: passed with 0VUID-validation errors.python tools/check_conventions.py --base HEAD~1passed with 0 errors.tools/fast_dup_check.pyandtools/offline_overlap.pyconfirmed 0 duplicates / overlaps across 1,588 open PRs.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)🤖 Generated with Claude Code
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T02:34:12Z.
Review: COMMENTED
Reviewed — comments
The review found a timeout path that can bypass the ordering this change is intended to enforce.
What I ran
Reviewed head
e9124aa516b899baf885200437c8d75d470ff4cbusing the prepared diff and targeted source reads throughrepo_read.py. No tests or other commands were run.Results
Findings
Blocking
None verified.
Non-blocking
WaitSubmissionPacedForreturnsfalsewhen its five-second deadline expires, but both Gnm call sites ignore that result and submit anyway. If earlier work has not reached the paced state within five seconds, the next compute or graphics submission can proceed without the ordering the change promises. Handle the timeout before submitting, or otherwise ensure the ordering is preserved. Changed lines:core/libs/prx/libSceGnmDriver/Export.cpp:383andcore/libs/prx/libSceGnmDriver/Export.cpp:746.Not verified
The full text of all changed files was included in the prepared review materials, but this review read targeted ranges from five changed files:
Lifecycle.cpp,Submission.cpp,Export.cpp,ComputeQueue.cpp, andSubmit.cpp. The remaining five changed files were not read: the two AGC driver headers,EntryPoints.cpp, and the two technical debt documents. Tests and the author-reported validation runs were not independently verified. No negative control was run.To get this to a good state
Nothing is required. Please consider handling the wait timeout before allowing the following submission to proceed.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T04:06:11Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the review covered all changed files listed in the manifest, but the reported checks were not rerun in this review.
What I ran
Reviewed head
f3962686d425192837714645d03c41113d3ce8eaagainst the prepared diff. Read all ten changed files and their added lines, along with targeted queue-worker and submission callers usingrepo_read.py. No tests or builds were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The author reports unit tests, Vulkan validation, conventions, debt-fold, and duplicate checks passed; these results were not independently verified. Console behavior and hardware-specific effects were not tested. No changed files were excluded;
files.jsonwas not available as a review-folder document.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T05:31:56Z.
Review: COMMENTED
Reviewed — no blocking findings
The reviewed head is
9e142fb3703aa585df8a89cafb3b06f4fb895f68; I found no verified blocking defect in the submission-ordering changes. The review is incomplete because repository files listed as reviewed were not all read, so approval is not justified.What I ran
Read the prepared description, commit list, manifest, and diff; inspected targeted source ranges using the pinned
repo_read.pyreader. No tests or build checks were run.Results
Findings
Blocking
None verified in the code inspected.
Non-blocking
None.
Not verified
The change adds submission pacing and compute/graphics ordering with atomic queued-work flags, a paced wait, a dedicated ordered test, and documentation. I read
core/libs/prx/libSceGnmDriver/Export.cppandcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Queues/Submission.cpptargeted ranges only. I did not read all changed files or all hunks. The manifest lists 11 changed files; the other 9, along with uninspected portions of the two files above, remain unverified. I could not inspectfiles.jsonthrough the available review-folder reader. Tests, Vulkan validation, conventions and duplicate checks in the PR description are author-reported and were not run by me.To get this to a good state
Nothing is required. Optional: complete the review of all changed files and run the relevant checks before deciding whether to approve.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-28T12:19:08Z.
Review: COMMENTED
Actionable comments posted: 3
d4c0b806-28e3-44db-b1ef-84d49c49a0cbReviewing files that changed from the base of the PR and between
f51f7fec91and1c049a2756.core/libs/prx/libSceAgcDriver/Execution/include/Driver.hppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/EntryPoints.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Lifecycle.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Queues/Submission.cppcore/libs/prx/libSceGnmDriver/CMakeLists.txtcore/libs/prx/libSceGnmDriver/Export.cppcore/libs/prx/libSceGnmDriver/tests/ComputeQueue.cppcore/libs/prx/libSceGnmDriver/tests/Submit.cppdocs/dev/ENVIRONMENT.mddocs/dev/debt/changes/fix-gnm-compute-queue-order-graphics.mddocs/dev/debt/changes/fix-gnm-submit-pacing-wait-settled.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T12:30:10Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the optional points below may improve the ordering coverage.
What I ran
Reviewed head
1c049a275660ca85b2d0924a920413b995e5ed89using the prepared diff and the pinnedrepo_read.pyreader. No tests or prechecks were run in this review; the test results in the description are author-reported.Results
Findings
Blocking
None.
Non-blocking
Not verified
The full text and added lines were read for all 12 changed files listed in the manifest. No files were excluded. Build, CTest, Vulkan validation, convention checks, duplicate checks, and physical-console behavior were not run or independently confirmed. The description reports the listed unit and validation checks passed on the author’s environment.
To get this to a good state
Nothing is required. The compute-to-graphics test gate is optional.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T17:41:24Z.
Review: COMMENTED
sceGnmDingDongsetsg_computeQueuedbefore it enqueues the compute packet, under the ring mutex. The graphics path takes a different mutex. It can consume the flag during that gap, see no compute work inWaitSubmissionPacedFor, and enqueue graphics ahead of the compute packet. Can the two paths serialize the wait and enqueue under a shared submission order, and publish the queued state only once the driver accepts the work? The ordered test exercises successive calls and misses this admission race.On Linux lavapipe,
agc_driver_gcn_scalar_buffer_base,gnm_driver_submit_wait, andgnm_driver_compute_queuepassed on both the pinned main and the merge with1c049a2756. The addedgnm_driver_compute_queue_orderedalso passed on the merge. All runs used required Vulkan, disabled shader cache, and verified insertion ofVK_LAYER_KHRONOS_validation1.4.369. The logs showed no missing-layer messages orVUID-errors. The concurrent-admission finding is from source inspection.AI-assisted: yes.