Commit Graph

34 Commits

Author SHA1 Message Date
MarcZX100 cbd615bb42 fix(agc): return error for unsupported init versions 2026-10-12 23:15:39 +00:00
fdfawef324 f8257a112b feat(agc): return null from the workload builders for unregistered streams
sceAgcDcbSetWorkloadStreamInactive and the three ACB workload builders
(sceAgcAcbSetWorkloadsActive, sceAgcAcbSetWorkloadComplete,
sceAgcAcbSetWorkloadStreamInactive) threw for every call, and
sceAgcDcbSetWorkloadsActive read the workload ids before it checked the
stream.

The prosper console oracle (mattias800/prosper df074498,
prosper/tests/data/console_oracle/agcbuild.golden.tsv lines 48-56 and
196-204) measured all six calls on a PS5 with three argument patterns
and no workload stream registered: each returned null and wrote nothing.
Pattern b passes stream 1 with the workload ids at address 2, so the
console checks the stream before it reads the ids; here that call read
address 2 and crashed.

The four builders now return null for a null command buffer or a stream
that is not registered, and still throw for a registered stream: the
packet a registered stream gets is not measured, KytyPS5 has no body for
them, and its IT_NOP layout for the DCB calls differs from the
SET_UCONFIG_REG, WRITE_DATA and SET_WORKLOAD sequence OpenAGC
(3c7e8072, src/agc_workload_packet.c) derives from the driver. The
signatures are OpenAGC's DCB ones (src/game_compat.c), which says the
ACB calls use the same driver builders. sceAgcDcbSetWorkloadsActive now
checks the stream before the ids, as OpenAGC does. Recorded in
docs/dev/debt/libSceAgc.md.

agc_commands gains testWorkloadStreams: the three measured patterns for
all six calls (null, buffer untouched), an exhausted and a null buffer,
and a registered stream that throws without touching the buffer. On
upstream/main it fails with "sceAgcDcbSetWorkloadStreamInactive not
implemented", and the DCB active pattern b alone segfaults reading
0x2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 15:22:21 -04:00
Dean 2dfde65fa1
Merge pull request #3789 from xXPBSXx/fix/agc-workload-nop-packets
fix(libSceAgc): emit NOP packets for the DCB workload calls
2026-10-13 00:44:27 +13:00
Utku Halis 661f8e1e7c feat(libSceAgc): implement sceAgcAcbWaitUntilSafeForRendering 2026-10-12 08:26:47 +03:00
xXPBSXx 2a7b38ab75 fix(libSceAgc): write the KytyPS5 workload packets and return null for unregistered streams
sceAgcDcbSetWorkloadsActive writes an 18-dword IT_NOP packet (stream id, 64-bit workload mask) and sceAgcDcbSetWorkloadComplete a 12-dword one (stream id, workload id, 64-bit clear mask), following KytyPS5. Both return null for a null buffer, an unregistered or out-of-range stream, a workload id above 63, and for active a duplicate id or a count of 0 or above 63. sceAgcDriverRegisterWorkloadStream and sceAgcDriverUnregisterWorkloadStream now record the stream ids the DCB calls check.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-12 01:37:56 +02:00
xXPBSXx 45fcf734ab fix(libSceAgc): emit NOP packets for the DCB workload calls
sceAgcDcbSetWorkloadsActive and sceAgcDcbSetWorkloadComplete threw. They now write a plain two-dword NOP and keep no workload state.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-12 01:36:51 +02:00
Lorkydey 43783f725c feat(libSceAgc): build versioned ACB atomic GDS commands 2026-10-11 18:28:46 +02:00
David 9bec190733 feat(libSceAgc): implement sceAgcDebugRaiseException
sceAgcDebugRaiseException (NID T6xuVw0KUJo) now logs the exception id
with APS5_LOG_OUT and returns 0, as libkernel's
sceKernelDebugRaiseException does.

Palworld PPSA23126 (#2598) and 007 First Light PPSA11386 (#2523) import
it; neither is shown calling it.

OpenAGC 3c7e8072 (src/game_compat.c) returns 0 and says the function is
a no-op on retail hardware; the ud2 trap it describes for development
hardware is not reproduced. KytyPS5 6f0cddd4 (src/libs/agc.cpp) takes a
uint32 exception_id, logs it and returns 0. OpenAGC declares no
arguments, but a body that only traps reads none, so the uint32 is kept
and the conflict is recorded in TechnicalDebt. The aerolib name is from
zecoxao/sce_symbols 2883963a; ps5-payload-dev/sdk f5d40f02 has only an
untyped stub.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-11 07:47:33 -03:00
MathiasDevelopes 46d8c587c6 fix(agc): mask clear-state command to four bits 2026-10-11 12:11:03 +02:00
Cesar Rodriguez 8d96b44917 fix(libSceAgc): accept a null base in sceAgcDcbSetBaseIndirectArgs
The builder threw on a null indirect base, while the PM4 executor accepts
SET_BASE with address 0 (it only requires the alignment and address bits) and
an indirect draw that later reads the base is checked there. Titles clear the
base with 0, as with sceAgcDcbSetIndexBuffer, which already accepts 0 to
unbind. A non-null base is still checked for 8-byte alignment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 20:05:51 -07:00
Chad cbf86dfecf fix(agc): encode a one-dword NOP as the header-only form 2026-10-10 15:00:12 -05:00
Dean Galvin ea62569836 revert(agc): undo #1629's sceAgcDcbResetQueue packet sequence
#1629 makes sceAgcDcbResetQueue throw 'unsupported op bit 0x40' (and for
0x200/0x400). Dreaming Sarah and Astro Bot call it with op bit 0x40 at
start-up, so both abort before the first frame. Main with only #1629
reverted runs Dreaming Sarah normally again (59.9/59.9 fps, no skipped
draws, no flashes).
2026-10-10 20:57:15 +13:00
ahmedhamouda78 73eb8465d6 feat(agc): write the measured sceAgcDcbResetQueue packet sequence
Replace the CLEAR_STATE approximation with the envelope and per-op-bit packet groups measured on PS5 firmware 13.60. Emit groups for op bits 0x001, 0x002, 0x004, 0x008, 0x010, 0x020, 0x080, 0x100 and 0x800 in ascending order; throw for 0x040, 0x200 and 0x400 whose packets the driver rejects. state 2 sets the envelope flag and state 3 sets the 0x004 and 0x800 group payload dword.
2026-10-08 15:10:08 +00:00
Adrià ac951f8d09
Merge pull request #1215 from polysius/fix/agc-versioned-nid-names
refactor(libSceAgc): name exports after the versioned SDK names their NIDs hash to
2026-10-08 11:05:42 +02:00
ploysius f7424ea95d refactor(libSceAgc): name three more exports after their versioned NIDs
OpenAGC's include/agc_nids.h names three more of the raw-NID exports, and
each name hashes to its NID:

  gQkqkLttcpw  sceAgcAcb_gQkqkLttcpw               -> sceAgcAcbAtomicGds_0900
  dolOmWH+huQ  sceAgcUnknownGetFusedShaderSize     -> sceAgcGetFusedShaderSize_0080
  V++UgBtQhn0  sceAgcGetDataPacketPayloadAddressUnk -> sceAgcGetDataPacketPayloadAddress_0090

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 14:02:51 -04:00
ploysius 39191f905d refactor(libSceAgc): name exports after the versioned SDK names their NIDs hash to
Eight libSceAgc exports were published under a raw NID with a made-up
name. Each NID is the hash of a versioned SDK name (checked with
tools/nid_names.py compute_nid), so the functions now carry that name and
are exported from it directly:

  23LRUSvYu1M  sceAgcUnknownInitState          -> sceAgcInit_0090
  -KRzWekV120  sceAgcUnknown__MKRzWekV120      -> sceAgcDcbSetIndexSize_0600
  Ikfdt-rIqCE  sceAgcUnknown_Ikfdt_MrIqCE      -> sceAgcJumpPatchSetTarget_0300
  7Wa3aeJgeVU  sceAgcUnknown_7Wa3aeJgeVU       -> sceAgcBranchPatchSetThenTarget_0300
  rP5xLdOf26k  sceAgcUnknown_rP5xLdOf26k       -> sceAgcBranchPatchSetElseTarget_0300
  fd5Bp5tGTgo  sceAgcUnknownFuseShaderHalves   -> sceAgcFuseShaderHalves_0200
  qj7QZpgr9Uw  sceAgcDcbContextStateAnotherOp  -> sceAgcDcbContextStateOp_0100
  k0E7vkgqAuE  sceAgcCreateInterpolantMappingVsPs -> sceAgcUpdateInterpolantMapping_0100

The exported NIDs are unchanged; the extra exports under the hashes of the
made-up names are gone. Behaviour is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 13:55:45 -04:00
TideOPL 7fdfc9208b fix(libSceAgc): treat a null cursor_down as a buffer limited by its top
Every command writer checked bottom <= cursor_up <= cursor_down <= top.
PPSA16064 (Minecraft Dungeons II, Unreal Engine) builds small one-packet
buffers (8 dwords) with cursor_down left null, and the first
sceAgcDcbCopyData into one threw "invalid command buffer cursors".

Nothing in the library allocates downward, so cursor_down only bounds
the space above cursor_up. A null cursor_down now means that bound is
top. Non-null cursors are checked as before. TechnicalDebt records the
assumption.

agc_commands writes six dwords into such a buffer and checks that a
further allocation past top fails without moving the cursor.
2026-10-07 14:08:13 +01:00
Dean b62e84c8ca
Merge pull request #1035 from hugodearaujo/feat/agc-register-defaults-internal
feat(libSceAgc): implement sceAgcGetRegisterDefaultsInternal
2026-10-07 18:00:00 +13:00
Dean ed8dda83ec
Merge pull request #1030 from hugodearaujo/feat/agc-dcb-clear-state
feat(libSceAgc): implement sceAgcDcbClearState
2026-10-07 17:59:18 +13:00
hugodearaujo bdfd0287e1 feat(libSceAgc): implement sceAgcGetRegisterDefaultsInternal
Return the version 0 internal register defaults, the internal
counterpart of sceAgcGetRegisterDefaults.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 23:43:04 -03:00
hugodearaujo 425ed24795 feat(libSceAgc): implement sceAgcDcbClearState
Write the 2-dword CLEAR_STATE (0x12) packet with a 4-bit command, the
packet the driver already validates and executes by restoring the
initial context registers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 23:06:15 -03:00
hugodearaujo 54eeadb3a2 feat(libSceAgc): implement sceAgcWaitRegMemPatchMask
Patch the mask of a wait packet like sceAgcWaitRegMemPatchReference
patches its reference: a 32-bit value written to the low mask word of a
32- or 64-bit WAIT_REG_MEM, rejected above 32 bits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 22:34:29 -03:00
Dextroid17 ea68e850ff test(agc): fix the stale 32-bit WriteWait expectation and run the full suite
WriteWait has truncated the reference and mask of a 32-bit wait since
9c2a7560 ("relaxed checks for what titles send"), but testMemory still
expected a reference above 32 bits to throw, so agc_command_tests failed
when run without arguments. ctest only registers the "defaults" mode, so
the stale expectation was never noticed.

Update the expectation to the truncating behaviour (the packet keeps the low
halves) and register the full mode as agc_commands so the packet, marker,
flip, register and memory cases are checked again.

Closes #1005.
2026-10-06 18:58:45 -04:00
Nicolas Abosch e5191ebf13 fix(agc): reuse validated raw compute snapshots 2026-10-05 22:52:03 -03:00
Nicolas Abosch 41cd420cc6 feat(agc): support version initialization and raw compute programs 2026-10-05 22:47:38 -03:00
Michon 548162a203 fix(agc): grow a command buffer whose free space is below its reserved words
A command buffer with fewer free dwords than reserved_dw (an empty one whose
title allocates its storage in the callback, as Marvel's Wolverine does)
threw "reserved space exceeds command buffer capacity" before its callback ran.
Its available space is now 0, so the allocation goes to the callback with the
reserved words added, as for any other full buffer.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-01 00:02:31 +02:00
Dean Galvin 0c06382d89 feat(agc): ACB markers, index buffer unbinding and address in errors
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 19:47:33 +13:00
Pacuka 83f43d1004 feat(agc): emit indexed indirect draws
sceAgcDcbDrawIndexIndirect and sceAgcDcbDrawIndexIndirectMulti emit
DRAW_INDEX_INDIRECT (0x25) and DRAW_INDEX_INDIRECT_MULTI (0x38) like their
non-indexed counterparts, with 20-byte records.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 19:43:16 +02:00
boykopovar 2df58cf09c fix(kernel): support page-aligned mprotect for loaded images 2026-09-23 12:45:39 +03:00
boykopovar bf7e41bb8b feat(agc): add new context state op impl 2026-09-22 19:44:17 +03:00
boykopovar d31e35e1ab feat(agc): add flip presentation and suspend synchronization (wip) 2026-09-14 07:39:38 +03:00
boykopovar 87b52a99c8 feat(agc): add sceAgcGetDataPacketPayloadAddressUnk impl 2026-09-13 19:46:30 +03:00
boykopovar bed94ee90a fix(agc): add nullptr values handling for WriteRegisterRange 2026-09-13 19:41:29 +03:00
boykopovar bdff4874de feat(agc): add draw packets and register defaults with strict validation 2026-09-13 18:14:51 +03:00