AGC event queue never wakes waiters (EVENT_TYPE vs eventId mismatch)
Emulator Version / Commit
d8397b0
Bug Description
i've been trying to get poppy playtime chapter 1 [ppsa20591] running (past the point in #3, which just silently closed near __cxa_guard_acquire). on current main it boots a lot further now — full engine thread bring-up, rhithread and the agc threads all get scheduled — but then it just hangs. left it running for over 9 minutes and nothing changed. (tested on commit d8397b0, .net 10 release build, windows, native cpu engine.)
traced it to the agc event queue code. the game submits a real command buffer with shaders and EVENT_WRITE completion packets, and it registers a couple of event listeners first:
agc.driver_add_eq_event eq=0x2 id=0x20 udata=0x0
agc.driver_add_eq_event eq=0x2 id=0x00 udata=0x0
but when the command buffer parser fires those events, nothing ever matches:
agc.dcb.event type=0x07 queues=0
agc.dcb.event type=0x10 queues=0
agc.dcb.event type=0x2E queues=0
agc.dcb.event type=0x2C queues=0
every one comes back queues=0. AgcInterruptThread sits in sceKernelWaitEqueue the whole time — its import count doesn't move between the first stall log and one taken 9 minutes later.
looking at the code, the two sides just aren't using the same id space. sceAgcDriverAddEqEvent (AgcExports.cs ~line 1946) registers the listener using the eventId the game passed in directly (0x20/0x00 here). the IT_EVENT_WRITE handler (AgcExports.cs ~line 2626) instead triggers using the raw pm4 EVENT_TYPE field off the packet (0x07/0x10/0x2E/0x2C) as the ident. those aren't the same numbering scheme, so they never match, and TriggerRegisteredEvents (KernelEventQueueCompatExports.cs:465) never has anything to wake up.
doesn't seem specific to this game — anything that waits on a gfx/compute completion event through sceAgcDriverAddEqEvent before continuing would hit the same hang.
i don't know the real ps4/ps5 mapping from EVENT_TYPE to that eventId though, so didn't want to just guess and hack something in. figured it's worth raising here first. couple options as i see it:
- someone knows the real mapping and we wire that up properly
- as a stopgap, treat any completion-style
EVENT_WRITEas satisfying any registered graphics event on that queue — probably unblocks most games even if it's not 100% accurate
happy to test anything against this build/game if it helps.
LOG - sharpemu-poppy-agc-trace.log
Log File
Fixed in commit via AGC event queue: IT_EVENT_WRITE now triggers by filter (KernelEventFilterGraphics) instead of raw EVENT_TYPE ident, since DriverAddEqEvent registers with a different eventId numbering. Added TriggerRegisteredEventsByFilter to KernelEventQueueCompatExports to match registrations by filter alone.
This looks already fixed — commit 1be009c ("[HLE] Trigger AGC graphics events by filter instead of exact ident (#173)", merged as part of #223 on 2026-07-15) adds TriggerRegisteredEventsByFilter in KernelEventQueueCompatExports.cs, matching exactly the stopgap Nabeelshar described and the reporter suggested (treat any completion-style EVENT_WRITE as satisfying any registered graphics event on the queue), with unit tests covering the mismatched ident/eventType case. Looks safe to close unless someone's still seeing this hang on current main.
Confirming zambasaurus's assessment: TriggerRegisteredEventsByFilter is present in current main (both AgcExports.cs and KernelEventQueueCompatExports.cs), matching the fix described. Looks safe to close from my read too.