WIP: The Smurfs Dreams on Linux, first frames (stacked on #5) #12

Closed
Pacuka wants to merge 13 commits from upstream-pr/12 into main
Pacuka commented 2026-09-26 19:47:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Pacuka on 2026-09-26T19:47:17Z.


Status

Draft: this is stacked on #5 (Demons Souls boot) and is not meant to be merged on its own yet. This branch is based on #5 (yumlevi:feat/demons-souls-boot) because its AGC driver is much further along than main. It also includes #14 (libstdc++ ABI interposition on Linux). Until #5 lands, the diff below also contains all of #5. The commits new in this PR are the 13 on top of it, listed below. When #5 is merged I will rebase, strip the explanatory comments (docs/CONVENTIONS.md) and split this into small PRs.

The goal is running The Smurfs Dreams (Unreal Engine, FMOD) on Linux. How far it gets:

  • It boots through engine init, file/pak loading (AMPR/APR), networking/NP init (offline console) and FMOD module loading.
  • The Vulkan device comes up and compute dispatches and draws run. The title renders into a 2848x1600 target, scales it to 3840x2160 and presents 4 frames.
  • After the 4th frame the render thread stops submitting, and the window then goes "not responding". The cause: UE waits for frame fences that are resolved from GPU end-of-pipe interrupts, with a predicated INDIRECT_BUFFER (fast clear eliminate) in between. The last commit fixes several parts of that path (see below); the frame loop is not yet continuous.

Commits on top of #5

Linux fixes that are also on main (#7) but missing from #5:

  • fix(build): bundled SDL2 without static executable linking; guest library tests linked dynamically
  • fix(videoout): no __stdcall on the window procedure
  • fix(libc): calloc/realloc replacement slots; register the main guest image on Linux
  • fix(kernel): map SCE protections to readable host pages

New:

  • fix(kernel): sceKernelVirtualQuery fallback through /proc/self/maps (#5 only had VirtualQuery, so it did not build on Linux)
  • libc, host C++ exceptions on Linux: this branch first made the native __cxa_* aliases Windows-only. It now takes #14 instead, which fixes the same mixed-runtime problem the other way round (libc drives every host throw). With #14 Smurfs gets exactly as far (same 51 draws, 4 frames), and the GPU worker's catch now handles the VideoOut "window was closed" exception instead of terminating. The unhandled-throw log fix in Runtime.cpp stays.
  • libc: guest wchar_t is 16-bit. The wcs* functions in #5 call the host std::wcs*, which uses 32-bit wchar_t on Linux. This branch keeps a UTF-16 implementation.
  • AGC driver:
    • end-of-pipe interrupt delivery (sceAgcDriverAddEqEvent registry, per queue id: 0 = graphics, 0x20+ = compute); interrupt RELEASE_MEM stores its label synchronously before the event
    • a retired compute submission raises its queue's end-of-pipe event
    • SET_PREDICATION (BOOL64/BOOL32)
    • INDIRECT_BUFFER: targets are copied into the submission at submit time. Without CHAIN it is a call with a return stack, with CHAIN a jump.
    • null sampled texture descriptors (format 0) bound as a zero 1x1 texture
    • 3D textures in 64 KiB XOR modes (use the SW_64KB_S order, which is exact only at the block origin; tech debt)
    • DMA_DATA cache policy bits; DX_LINEAR_ATTR_CLIP_ENA; CMASK FAST_CLEAR colour targets
  • libSceAgc:
    • sceAgcDcbJump: mode 0 = call, mode 1 = chain
    • sceAgcJumpPatchSetTarget, SetPredication, SetPacketPredication, SetRangePredication
    • shader half fusion: GetFusedShaderSize / FuseShaderHalves (VS front + GS back into the GS-stage pair the #5 driver already draws)
    • the WRITE_DATA patch-address NID fPSCdQxgpSw
    • null placeholders for indirect register packets, plus Set*RegIndirectPatchSetNumRegisters
  • Runtime/libraries (from the Smurfs bring-up, merged with #5 per file; the other side's missing exports were carried over):
    • Net/Http/Http2/NP*/Json2/AppContent/PlayGo/SystemService/UserService/pthreads
    • APR submit-and-get-result
    • the AMPR kernel-event-queue command
    • sceKernelLoadStartModule for relinked resident modules
    • IME keyboard without a device
    • an ErrorDialog state machine
    • pad output no-ops and trigger-effect state

Notes for #5

The 16-bit wcs* functions, the /proc/self/maps fallback and the per-queue interrupt delivery are independent of Smurfs and probably worth picking into #5 directly.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4649270186 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12). Originally posted by [Pacuka](https://github.com/Pacuka) on 2026-09-26T19:47:17Z. --- ## Status **Draft: this is stacked on #5 (Demons Souls boot) and is not meant to be merged on its own yet.** This branch is based on #5 (`yumlevi:feat/demons-souls-boot`) because its AGC driver is much further along than `main`. It also includes #14 (libstdc++ ABI interposition on Linux). Until #5 lands, the diff below also contains all of #5. The commits new in this PR are the 13 on top of it, listed below. When #5 is merged I will rebase, strip the explanatory comments (docs/CONVENTIONS.md) and split this into small PRs. The goal is running **The Smurfs Dreams** (Unreal Engine, FMOD) on **Linux**. How far it gets: - It boots through engine init, file/pak loading (AMPR/APR), networking/NP init (offline console) and FMOD module loading. - The Vulkan device comes up and compute dispatches and draws run. The title renders into a 2848x1600 target, scales it to 3840x2160 and **presents 4 frames**. - After the 4th frame the render thread stops submitting, and the window then goes "not responding". The cause: UE waits for frame fences that are resolved from GPU end-of-pipe interrupts, with a predicated INDIRECT_BUFFER (fast clear eliminate) in between. The last commit fixes several parts of that path (see below); the frame loop is not yet continuous. ## Commits on top of #5 Linux fixes that are also on `main` (#7) but missing from #5: - `fix(build)`: bundled SDL2 without static executable linking; guest library tests linked dynamically - `fix(videoout)`: no `__stdcall` on the window procedure - `fix(libc)`: calloc/realloc replacement slots; register the main guest image on Linux - `fix(kernel)`: map SCE protections to readable host pages New: - `fix(kernel)`: `sceKernelVirtualQuery` fallback through `/proc/self/maps` (#5 only had `VirtualQuery`, so it did not build on Linux) - **libc, host C++ exceptions on Linux**: this branch first made the native `__cxa_*` aliases Windows-only. It now takes #14 instead, which fixes the same mixed-runtime problem the other way round (libc drives every host throw). With #14 Smurfs gets exactly as far (same 51 draws, 4 frames), and the GPU worker's `catch` now handles the VideoOut "window was closed" exception instead of terminating. The unhandled-throw log fix in `Runtime.cpp` stays. - **libc**: guest `wchar_t` is 16-bit. The `wcs*` functions in #5 call the host `std::wcs*`, which uses 32-bit `wchar_t` on Linux. This branch keeps a UTF-16 implementation. - **AGC driver**: - end-of-pipe interrupt delivery (`sceAgcDriverAddEqEvent` registry, per queue id: 0 = graphics, 0x20+ = compute); interrupt RELEASE_MEM stores its label synchronously before the event - a retired compute submission raises its queue's end-of-pipe event - `SET_PREDICATION` (BOOL64/BOOL32) - `INDIRECT_BUFFER`: targets are copied into the submission at submit time. Without CHAIN it is a call with a return stack, with CHAIN a jump. - null sampled texture descriptors (format 0) bound as a zero 1x1 texture - 3D textures in 64 KiB XOR modes (use the SW_64KB_S order, which is exact only at the block origin; tech debt) - DMA_DATA cache policy bits; `DX_LINEAR_ATTR_CLIP_ENA`; CMASK `FAST_CLEAR` colour targets - **libSceAgc**: - `sceAgcDcbJump`: mode 0 = call, mode 1 = chain - `sceAgcJumpPatchSetTarget`, `SetPredication`, `SetPacketPredication`, `SetRangePredication` - shader half fusion: `GetFusedShaderSize` / `FuseShaderHalves` (VS front + GS back into the GS-stage pair the #5 driver already draws) - the WRITE_DATA patch-address NID `fPSCdQxgpSw` - null placeholders for indirect register packets, plus `Set*RegIndirectPatchSetNumRegisters` - **Runtime/libraries** (from the Smurfs bring-up, merged with #5 per file; the other side's missing exports were carried over): - Net/Http/Http2/NP*/Json2/AppContent/PlayGo/SystemService/UserService/pthreads - APR submit-and-get-result - the AMPR kernel-event-queue command - `sceKernelLoadStartModule` for relinked resident modules - IME keyboard without a device - an ErrorDialog state machine - pad output no-ops and trigger-effect state ## Notes for #5 The 16-bit `wcs*` functions, the `/proc/self/maps` fallback and the per-queue interrupt delivery are independent of Smurfs and probably worth picking into #5 directly. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Pacuka commented 2026-09-28 20:46:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Pacuka on 2026-09-28T20:46:36Z.


Closing: #5 has been merged, and this draft's work now lives on a local branch rebased onto main. The parts that are still relevant will come as small, separate PRs (some already did: #39, #40, #42). Thanks!

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5878212274 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12#issuecomment-5878212274). Originally posted by [Pacuka](https://github.com/Pacuka) on 2026-09-28T20:46:36Z. --- Closing: #5 has been merged, and this draft's work now lives on a local branch rebased onto main. The parts that are still relevant will come as small, separate PRs (some already did: #39, #40, #42). Thanks!
boykopovar commented 2026-09-30 09:29:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by boykopovar on 2026-09-30T09:29:05Z.


Closing: #5 has been merged, and this draft's work now lives on a local branch rebased onto main. The parts that are still relevant will come as small, separate PRs (some already did: #39, #40, #42). Thanks!

Does The Smurfs Dreams work on Linux (on main)?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5908324174 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12#issuecomment-5908324174). Originally posted by [boykopovar](https://github.com/boykopovar) on 2026-09-30T09:29:05Z. --- > Closing: #5 has been merged, and this draft's work now lives on a local branch rebased onto main. The parts that are still relevant will come as small, separate PRs (some already did: #39, #40, #42). Thanks! Does The Smurfs Dreams work on Linux (on main)?
Pacuka commented 2026-10-06 15:36:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Pacuka on 2026-10-06T15:36:41Z.


Sorry for the late answer. Not on main yet. I checked today on main 5895ea72 (Linux 7.2, AMD): it doesn't load, because 23 imports have no export yet. The first one the loader hits is 3YQ1qY5ePUk (libSceAudioIn) from the bundled libfmod.prx. The others come from the eboot: libkernel (2), VideoOut (2), Net, NpManager, NpWebApi2, NpEntitlementAccess (4), Json2 (4), Http2, GameLiveStreaming (2), WebBrowserDialog (2), VoiceQoS and Acm.

On my local branch (an older main plus these exports and some AGC driver work that isn't upstream yet) it is playable but slow: the intro cinematic plays, the hub level loads and responds to the controller, at about 4–5 fps. The UI layers are never cleared, so they pile up on screen.

I'll send the missing exports as small PRs, one per library, after checking that no open PR already covers them, and then the driver parts one by one.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6019788372 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12#issuecomment-6019788372). Originally posted by [Pacuka](https://github.com/Pacuka) on 2026-10-06T15:36:41Z. --- Sorry for the late answer. Not on `main` yet. I checked today on `main` 5895ea72 (Linux 7.2, AMD): it doesn't load, because 23 imports have no export yet. The first one the loader hits is `3YQ1qY5ePUk` (libSceAudioIn) from the bundled `libfmod.prx`. The others come from the eboot: libkernel (2), VideoOut (2), Net, NpManager, NpWebApi2, NpEntitlementAccess (4), Json2 (4), Http2, GameLiveStreaming (2), WebBrowserDialog (2), VoiceQoS and Acm. On my local branch (an older `main` plus these exports and some AGC driver work that isn't upstream yet) it is playable but slow: the intro cinematic plays, the hub level loads and responds to the controller, at about 4–5 fps. The UI layers are never cleared, so they pile up on screen. I'll send the missing exports as small PRs, one per library, after checking that no open PR already covers them, and then the driver parts one by one.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!12
No description provided.