Repository navigation
feat(agc): emit the remaining workload packets for registered streams - #6128
Closed
fdfawef324 wants to merge 1 commit into
Closed
fdfawef324 wants to merge 1 commit into
fdfawef324 wants to merge 1 commit into
Conversation
sceAgcAcbSetWorkloadsActive, sceAgcAcbSetWorkloadComplete, sceAgcAcbSetWorkloadStreamInactive and sceAgcDcbSetWorkloadStreamInactive threw NotImplemented for a registered workload stream. boykopovar#4709 kept that throw because the console packet is not measured and KytyPS5 and OpenAGC disagree on the layout. The DCB active and complete encoders move into Agc::Workload, and the ACB calls use them, so the ACB writes the 18- and 12-dword IT_NOP packets the DCB already writes (KytyPS5's layout). The stream inactive calls write a 9-dword IT_NOP with the stream id and zeros. Each IT_NOP has the size of the console sequence OpenAGC's agc_workload_packet.c derives, and its effect is argued per sequence: - Stream inactive is SET_UCONFIG_REG (4 dwords) and WRITE_DATA (5) to registers 0xc342 and 0xc343, SQ_THREAD_TRACE_USERDATA_2 and _3 in Mesa's gfx10 and gfx103 register maps. They only feed SQ thread traces, which are not emulated, so the NOP has the same effect otherwise. - Active (4 + 5 + 9 dwords) and complete (3 + 9) add SET_WORKLOAD (0x1e), which writes the mask to the stream's slot in a driver table that OpenAGC carves from SceGnmGpuInfo at 0x3a000, not title memory. That write is dropped and unverified, as it already is for the DCB on main. - On the console the ACB sequence differs from the DCB one by a control flag (header bit 2, SET_WORKLOAD control bit 30); the IT_NOP form does not carry it. Validation does not change: a null buffer, an unregistered or out-of-range stream and the existing workload id, id array and count checks return null without writing. The AGC driver needs no change. Pm4::Validate accepts a plain NOP that is not predicated on graphics and compute queues, and Pm4::Execute skips it. A predicated one throws, as every IT_NOP libSceAgc writes does; the debt entry records it. testRegisteredWorkloadStreams in agc_commands registers a stream and checks that the ACB and DCB IT_NOP packets are equal byte for byte. It pins the inactive packet, runs all six packets through Pm4::Validate and Pm4::Execute on queue 0 and compute queue 0x20, and checks the ACB rejections. Without the change it fails with "sceAgcAcbSetWorkloadsActive not implemented". The DCB wrappers' arguments are renamed to camelCase, and the workload debt entries are merged into one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Closing this myself to respect the queue policy in #4826: no title has been shown to stop here on AI-assisted: yes |
12 tasks done
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
sceAgcAcbSetWorkloadsActive,sceAgcAcbSetWorkloadComplete,sceAgcAcbSetWorkloadStreamInactiveandsceAgcDcbSetWorkloadStreamInactivethrewNotImplementedfor a registered workload stream.Relation to #4709
#4709 made these four return null for a null buffer or an unregistered stream. It kept the registered case throwing because the console packet is not measured, and KytyPS5 (
IT_NOP) and OpenAGC (SET_UCONFIG_REG, WRITE_DATA, SET_WORKLOAD) disagree on the layout. This PR does not claim to know the console packet either. It writes anIT_NOPof the console sequence's size, and for each sequence it says what the console packet does and what is dropped here. The sequences are from OpenAGCagc_workload_packet.c, with exact bytes in its test.0xcc000000 | streamIdand 0 to 0x342 and 0x343. WRITE_DATA (5): 0 to register 0xc343. No SET_WORKLOAD, no slot addressIT_NOP: stream id, seven zero dwords0xcc000000 | streamIdand the low mask to 0x342 and 0x343. WRITE_DATA (5): the high mask to 0xc343. SET_WORKLOAD (0x1e, 9): control word, stream slot address, maskIT_NOP: stream id, 64-bit mask (KytyPS5, onmainfor the DCB since #3789)0xcd000000 | workloadId << 5 | streamIdto 0x342. SET_WORKLOAD (9): control word, slot address, clear mask. No WRITE_DATAIT_NOP: stream id, workload id, 64-bit clear mask (KytyPS5, onmainfor the DCB since #3789)SQ_THREAD_TRACE_USERDATA_2and_3, at 0x30D08 and 0x30D0C in Mesa's gfx10.json and gfx103.json. RADV writes its RGP markers to them two dwords at a time (radv_sqtt.c). They only feed SQ thread traces, which are not emulated. The AGC driver already drops libSceAgc's predicated tag writes to 0x342 as carrying no register state (IsTagMarkerinPm4.cpp). Stream inactive writes nothing else, so its 9-dword NOP has the console's effect apart from the thread trace.SceGnmGpuInforegion at offset 0x3A000 (driver_prospero.c). It publishes the region as theSce.Debug:Gnmprocess property, namedSceGnmDumpArea(L925-L940). It is driver memory, not title memory. This write is dropped here, and its effect is not verified. OpenAGC keeps its own use of the sequence disabled on firmware 11.60 after its submissions stalled (L1736-L1742). The DCB active and complete calls onmainhave dropped this write since fix(libSceAgc): emit NOP packets for the DCB workload calls #3789; this PR does the same for the ACB.0xc0027904becomes0xc0027900) and bit 30 of the SET_WORKLOAD control word. TheIT_NOPform carries neither, so here the ACB and DCB calls write identical packets.So the case against #4709's throw is that the dropped effect is limited to the thread trace and a driver-owned table, that the debt entry records both, and that
mainhas used the same stand-in for the DCB since #3789. Keeping the throw remains the alternative if that is not enough.Changes
DcbState/src/Workload.cpp: the DCB active and complete encoders move intoAgc::Workload::WriteActiveandWriteComplete, and a newWriteStreamInactiveis added. The DCB exports call them; their arguments are renamed to camelCase. The ACB exports inAcb/src/Control.cppcall the same functions.Pm4::Validateaccepts a plain NOP (custom field 0) on graphics and compute queues when it is not predicated. Its only check, against0x6875xxxxflip markers, cannot match a stream id of 1 to 31.Pm4::Executereturns at once for it.Pm4::Validatethrows on a NOP with the predicate bit set. So a workload packet predicated bysceAgcSetRangePredicationorsceAgcSetPacketPredicationthrows at submission. EveryIT_NOPlibSceAgc writes already behaves this way, including markers and the DCB workload packets onmain. Accepting a predicated plain NOP inValidateis a separate change.docs/dev/debt/libSceAgc.md: the two workload entries are merged into one. It describes each sequence separately, the effect argument above, the dropped SET_WORKLOAD write, the ACB control flag and the predication gap. The KytyPS5 link is pinned to 6f0cddd, whoseagc.cppis identical to KytyPS5maintoday.Title IDs: none in
core/. No title was run. No title is shown calling these functions on a registered stream, so nothing is claimed to be unblocked.Tested
Windows Server 2025 (10.0.26100), AMD Ryzen 9 5900X, WinLibs MinGW-w64 GCC 15.2.0, Ninja, Release,
BUILD_TESTING=ON. Rebased onmaineea428c.testRegisteredWorkloadStreamsinagc_commands:0xdeadbeef.0x00000001,0x80000002). Checks the inactive packet (headerHeader(0x10, 9, 0), stream id, seven zero dwords) and that nothing was written past it.IT_NOPstand-in. It is not console parity: the console ACB and DCB sequences differ by the control flag above.AgcDriver::Pm4::Validate/Executeon queue 0, and each ACB packet on compute queue 0x20.testWorkloadStreamsthat expected the registered calls to throw.main'sWorkload.hpp,Workload.cppandControl.cpp,agc_commandsfails withsceAgcAcbSetWorkloadsActive not implemented.agc_commandspasses (0.24 s).agc_initialization,agc_commands,agc_platform_tests,agc_semaphore_tests,agc_packet_info_tests,agc_register_command_tests,agc_cb_cond_write_tests,agc_payload_range_tests,agc_end_of_shader_action_size_tests,agc_branch_patch_tests,agc_predication_tests,agc_shader_fusion,agc_context_state_size_tests,agc_interpolant_mapping,guest_shader_link,agc_gs_oversubscription_tests,agc_gs_prim_payload_tests,agc_dma_data_tests,agc_write_data_patch_tests,agc_prime_utcl2_tests,agc_cond_exec_patch_tests,agc_shader_helpers,agc_driver_pm4,agc_driver_pm4_failureandguest_agc_driver_resources.tools/check_conventions.pyfrommaineea428c, with--titleand--body: passes.Not tested: Linux, macOS, titles, Vulkan rendering. No test here does GPU work; the driver check is PM4 validation and execution on the CPU.
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)Pm4::Validate/Executeon the CPU, no GPU work)🤖 Generated with Claude Code