Repository navigation
feat(libSceAgcDriver): execute COND_WRITE - #977
Merged
oneandonlydean merged 1 commit intoOct 7, 2026
Merged
Conversation
COND_WRITE (opcode 0x45) with a memory poll and a memory destination is validated and executed: the driver drains the queue like WRITE_DATA, reads the poll dword through the range synchronization, compares it masked with the reference like a 32-bit WAIT_REG_MEM, and writes the data dword on a match. Register polls and register or scratch destinations are rejected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9 tasks done
Contributor
Author
|
Usage by titles: the packet comes from |
Collaborator
|
Thanks. The validation mirrors WAIT_REG_MEM and WRITE_DATA well, and it's good that the uncaught drain mutation is stated openly. Same question as on #975: which title submits COND_WRITE? Since the drain change only matters when labels are recorded on the GPU, a title that emits the packet is the only way to check that part. If you have one, please name it. |
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The AGC driver rejected COND_WRITE (opcode 0x45) as "not known in the reference". It now validates and executes it when the poll and the destination are both memory, the case
sceAgcCbCondWritewrites (#975):GuestMemory::Read(range synchronization, read siteWait), compares it withwaitCompares, and on a match writes the data dword throughGuestMemory::Write. Dwords 1-5 of COND_WRITE have the same layout as a 32-bit WAIT_REG_MEM: control, poll address, reference and mask.AccessesMemory. The drain records queued labels and waits for earlier GPU work, so the poll read sees values that earlier packets wrote on the GPU, and the write lands only after earlier GPU work that may read the destination.Pm4Opcodes.hpp.This PR does not depend on #975: the tests build the packets by hand.
Tested
Linux (Arch, GCC), Release with
BUILD_TESTING=ON, on currentmain. Inagc_driver_pm4_tests:testConditionalWrite:AccessesMemory;testConditionalWriteSubmission: throughsceAgcDriverSubmitDcb, a COND_WRITE sees the value an earlier WRITE_DATA of its queue stored, and a COND_WRITE whose comparison fails writes nothing.Mutations: inverted comparison, any write space accepted, 0x45 removed from
AccessesMemory, the mask written instead of the data, the reserved-bits check removed, and the poll read bypassing the synchronization each make the test fail.One mutation is not caught: removing 0x45 from the drain list. Without a Vulkan device, queued labels are written by the CPU between packets, so the order holds anyway in this test. The drain matters when labels are recorded on the GPU. I did not find a device-backed test that covers it; pointers are welcome.
Full
ctest: 362/362 passed. A simulated merge with every open PR shows no conflict; the new tests are placed apart from #898, which adds tests to the same file. Not tested with a title.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code