Skip to content

feat: run PS4 games on the AGC driver — Limbo (CUSA01664) in game (integration branch) - #6977

Draft
Get-fix wants to merge 48 commits into
boykopovar:mainfrom
Get-fix:ps4/limbo-gpu
Draft

Get-fix wants to merge 48 commits into
boykopovar:mainfrom
Get-fix:ps4/limbo-gpu

Conversation

@Get-fix

@Get-fix Get-fix commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What

Draft integration branch: PS4 titles on the AGC driver, with Limbo (CUSA01664) in game. This branch is main with the pull requests below merged, so they can be tested together. It isn't meant to merge itself: the members merge one by one, each with its own review, and the branch is rebased down as they land. Details, how to run and the bring-up story are in #6978.

Part Member What Depends on
A #9429 relinker: TLS relocations against the module's own section symbol merged
B #9430 shader: PS4 (GCN) shaders re-encoded to RDNA none
C #9431 AGC: PS4 targets, tiling and pattern fills #9430
D #9432 libSceGnmDriver and VideoOut #9431
E #9433 PS4 NpTrophy, save data v1, NpWebApi and Limbo's other imports merged
member #9225 (@YossiYad) sceNpSetContentRestriction, which Limbo calls at start merged

With A, E and #9225 in main, the branch is now main 7e2ba73 plus #9430 to #9432, taken in with a merge commit so the pull requests other contributors opened against it (Get-fix#1 to #21) keep their base. Those join the table once each is open upstream with its own review; @ntamas94's #9671 to #9676 already are, on top of #9430 to #9432.

Tested

On main 7e2ba73 with #9430 to #9432, Windows 11, WinLibs GCC 15.2, NVIDIA GeForce RTX 5060 Ti (driver 610.88):

  • The full suite of 1,893 tests: 1,886 pass and 4 skip, the same 4 that skip on main. The 3 that fail also fail on main 7e2ba73 on this machine: agc_driver_sample_order and its --grid-reference and --recipe-depth-locations cases.
  • Validation layer, main against the branch with the same focused tests: the same 50 VUID- errors in the same 8 existing PS5 tests, none added (details in feat(libSceGnmDriver): build PS4 command buffers and submit them #9432).
  • Limbo (CUSA01664), converted with this build's relinker and its two bundled modules: a 60 s scripted run from start into gameplay with no errors and no not-implemented calls, on 22 Oct with the GPU otherwise idle.

Checklist

🤖 Generated with Claude Code

PS4 programs load system libraries with sceKernelLoadStartModule and
their console path. The OpenOrbis piglet sample loads
/<sandbox word>/common/lib/libScePigletv2VSH.sprx and
libScePrecompiledShaders.sprx, the sandboxed form of
/system/common/lib/ that sceKernelGetFsSandboxRandomWord names. The path
was opened as a guest file and the load failed with ENOENT.

A path in /system/common/lib/ or in the sandboxed /<word>/common/lib/
whose file name ends in .sprx now loads the host libs/<name>.prx, as
libSceSysmodule does for module IDs. Names with a directory part are
not mapped, so such a path cannot leave libs/.
PS4 titles ship sce_sys/param.sfo instead of param.json. When param.json
is absent, the application metadata now reads the title, title ID,
download data size and user defined parameters from param.sfo, and
/data and /download0 are mounted for it as for param.json. param.json
is still preferred when both files exist.
PS4 titles built with Sony's toolchain place a switch statement's jump
table in the code segment, after the last instruction of the function
that indexes it and inside the function's unwind range:

    lea    rcx, [rip + table]
    movsxd rax, dword ptr [rcx + rax*4]
    add    rax, rcx
    jmp    rax

Code analysis decodes each function range from start to end, so it read
the table as instructions; the syscall scan and the call-site resolver
sweep the whole segment and lost their instruction boundaries there.
Limbo (CUSA01664) stopped at "Unsupported Windows guest TLS instruction
(bytes: 65 f9)" and Bloodborne (CUSA00900) at "Instruction exceeds 15
bytes".

FindInlineJumpTables decodes a function range, follows the table
address of each RIP-relative lea through 64-bit register moves, and
records the address a movsxd with scale 4 indexes when it lies later
in the same function. When decoding reaches the first such address and
every dword from there to the end of the function is an offset, from
the nearest table before it, to code before the first table, the rest
of the function is taken as tables. Anything else is decoded as before.
Code analysis stops each function there and keeps the control-flow
pass out of the tables; the pipeline fills them with nops in the copies
the syscall scan and the call-site resolver read.
# Conflicts:
#	core/relinker/relinker/src/guest/GuestImageReader.cpp
# Conflicts:
#	docs/dev/debt/libkernel.md
# Conflicts:
#	docs/dev/debt/relinker.md
# Conflicts:
#	docs/dev/debt/libkernel.md
…ction symbol

Limbo's bundled libSceFios2.prx (CUSA01664) has DTPMOD64 relocations
against a local section symbol of value 0. As for a TLS relocation
without a symbol, the module and offset are the module's own TLS block,
so such a relocation is passed on without its symbol; a section symbol
with a value, or a module without PT_TLS, still fails.
Each GCN instruction is re-encoded to its RDNA form and decoded by the
existing RDNA decoder, so the PS4 path shares the recompiler. Covers the
legacy VS stage (program at the VS slot, user SGPRs from s0, vertex and
instance index in v0-v3), fetch shaders linked as user-data calls, MIMG
(image_sample and friends), PS4 buffer descriptors (GCN DATA_FORMAT /
NUM_FORMAT, 44-bit base) and T# image descriptors (GCN tiling in word 7).
The GCN switch is keyed into the shader disk cache. PS5 behaviour is
unchanged: every PS4-only rule is gated on GcnGuestShaders().
PS4 color and depth targets, buffer and image descriptors and the PS4
tile modes (1D/2D thin and display, depth with tile split, PRT, linear
general) on the AGC executor, with a GPU detiler for every mode. Textures
sampled over the padded corner of a render target are GPU block copies,
and the PS4 SDK pattern-fill compute kernel runs as a GPU fill (render
targets and HTILE are cleared without a CPU drain), so Limbo holds 60 fps.
Tests cover the tiling equations against addrlib formulas, the GPU
detiler for every mode and element size, descriptors and fills.
Real sceGnm shader, state and draw packet writers, submit and
submit-and-flip into the AGC executor, PS4 sync packets lowered to their
PS5 forms, constant engine buffers merged into the draw buffer and the
PS4 graphics EOP event. VideoOut accepts the PS4 10-bit display format.
NpTrophy reads the trophy count and icons from the title's trophy
package (names are encrypted and stay not implemented), PS4 v1 save data
calls wrap the native v2/v3 ones, NpWebApi library contexts, handles and
push event filters work offline (service filters fail without a
signed-in user), sceNpSetContentRestriction validates and stores.
libSceAjm is built from the libSceAjm.native sources for PS4 titles, and
Limbo's remaining imports are exported as not implemented.
@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Progress report (4777cac → 4562537)

📈 System libraries: 43.31% (+0.08%, +28 implemented, +18 declared functions)

✅ 28 implemented
Library Name
libSceGnmDriver sceGnmAreSubmitsAllowed
libSceGnmDriver sceGnmDeleteEqEvent
libSceGnmDriver sceGnmDispatchInitDefaultHardwareState
libSceGnmDriver sceGnmDrawInitDefaultHardwareState175
libSceGnmDriver sceGnmDriverCaptureInProgress
libSceGnmDriver sceGnmDriverTriggerCapture
libSceGnmDriver sceGnmFlushGarlic
libSceGnmDriver sceGnmGetEqEventType
libSceGnmDriver sceGnmInsertPopMarker
libSceGnmDriver sceGnmInsertPushColorMarker
libSceGnmDriver sceGnmInsertPushMarker
libSceGnmDriver sceGnmInsertSetMarker
libSceGnmDriver sceGnmInsertWaitFlipDone
libSceGnmDriver sceGnmIsUserPaEnabled
libSceGnmDriver sceGnmSetCsShader
libSceGnmDriver sceGnmSetEsShader
libSceGnmDriver sceGnmSetGsShader
libSceGnmDriver sceGnmSetHsShader
libSceGnmDriver sceGnmSetLsShader
libSceGnmDriver sceGnmSetPsShader
libSceGnmDriver sceGnmSetVsShader
libSceGnmDriver sceGnmSubmitDone
libSceGnmDriver sceGnmValidateCommandBuffers
libSceGnmDriver sceRazorCaptureCommandBuffersOnlyImmediate
libSceGnmDriver sceRazorCaptureCommandBuffersOnlySinceLastFlip
libSceGnmDriver sceRazorCaptureImmediate
libSceGnmDriver sceRazorCaptureSinceLastFlip
libSceGnmDriver sceRazorIsLoaded
⚪ 10 behaviourally empty (constant return or throw)
Library Name
libSceGnmDriver sceGnmAreSubmitsAllowed
libSceGnmDriver sceGnmDriverCaptureInProgress
libSceGnmDriver sceGnmDriverTriggerCapture
libSceGnmDriver sceGnmIsUserPaEnabled
libSceGnmDriver sceGnmValidateCommandBuffers
libSceGnmDriver sceRazorCaptureCommandBuffersOnlyImmediate
libSceGnmDriver sceRazorCaptureCommandBuffersOnlySinceLastFlip
libSceGnmDriver sceRazorCaptureImmediate
libSceGnmDriver sceRazorCaptureSinceLastFlip
libSceGnmDriver sceRazorIsLoaded
🆕 18 declared as stubs
Library Name
libSceGnmDriver sceGnmAddEqEvent
libSceGnmDriver sceGnmDebugHardwareStatus
libSceGnmDriver sceGnmDingDong
libSceGnmDriver sceGnmDisableMipStatsReport
libSceGnmDriver sceGnmGetEqTimeStamp
libSceGnmDriver sceGnmGetTheTessellationFactorRingBufferBaseAddress
libSceGnmDriver sceGnmInsertSetColorMarker
libSceGnmDriver sceGnmLogicalCuIndexToPhysicalCuIndex
libSceGnmDriver sceGnmLogicalCuMaskToPhysicalCuMask
libSceGnmDriver sceGnmMapComputeQueue
libSceGnmDriver sceGnmRequestFlipAndSubmitDone
libSceGnmDriver sceGnmRequestMipStatsReportAndReset
libSceGnmDriver sceGnmSetGsRingSizes
libSceGnmDriver sceGnmSetupMipStatsReport
libSceGnmDriver sceGnmSubmitAndFlipCommandBuffers
libSceGnmDriver sceGnmSubmitCommandBuffers
libSceGnmDriver sceGnmUnmapComputeQueue
libSceVideoOut sceVideoOutCursorSetHotSpot

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 17, 2026
@MarcZX10

Copy link
Copy Markdown
Contributor

The current conventions run for head d604ae745 fails on four exports that the description says are among the remaining imports that throw: sceGnmAreSubmitsAllowed, sceGnmIsUserPaEnabled, sceGnmDriverCaptureInProgress, and sceRazorIsLoaded. Please make each call NotImplemented_nid_no_patch(__func__) or list the intentionally silent stub in docs/dev/debt/libSceGnmDriver.md as the convention requires.

The same run flags the unchecked “One topic per PR” item. This PR currently combines relinker TLS relocation handling, GCN shader support, AGC target/tiling/fill behavior, GNM submission, and several library exports. CONTRIBUTING.md asks for one topic per branch and follow-up work in separate PRs; your proposed relinker → shader → AGC → GNM → libs order looks reviewable as a stack with explicit Depends on links. Could you decide the intended scope and update the PR/checklist accordingly? The current merge state is also DIRTY against main.

@github-actions github-actions Bot added already in main Merging would not change main; never closed automatically and removed already in main Merging would not change main; never closed automatically labels Nov 17, 2026
@github-actions github-actions Bot added already in main Merging would not change main; never closed automatically and removed already in main Merging would not change main; never closed automatically labels Nov 18, 2026
@github-actions github-actions Bot removed the already in main Merging would not change main; never closed automatically label Nov 19, 2026
@github-actions github-actions Bot added already in main Merging would not change main; never closed automatically and removed already in main Merging would not change main; never closed automatically labels Nov 19, 2026
@github-actions github-actions Bot added already in main Merging would not change main; never closed automatically and removed already in main Merging would not change main; never closed automatically labels Nov 23, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* already in main Merging would not change main; never closed automatically build docs libkernel prx relinker shader core/shader unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants