Stephen Miller 65986d8a8a Kernel.Pthread: Various fixes (#4406)
* Fix for SignalTo behavior

Should run FindThread to make sure thread input is valid.

* Missing mutex-related exports

* Oops

* All missing cond exports

We have these implemented, so we might as well export them.
I also organized them a bit.

* Implement pthread_attr_getscope, pthread_attr_setcreatesuspend_np, pthread_attr_setscope

Also export all of our pthread_attr functions.

* Oops

* Fix SchedPolicy::Fifo definition

Some tricks FreeBSD source performs breaks with this incorrectly set.
Specifically, stuff like setting priorities breaks because we do array accesses with priority - 1 like FreeBSD, but Fifo being 0 makes that an oob read.

* Fix error checks in pthread_attr_setschedparam

* Fix and run thread destructors

_sceKernelSetThreadDtors receives the function itself, not a pointer to the function.

* Oops

* Rewrite pthread_rename_np for accuracy

There's a couple details the initial implementation missed that decomp shows. We weren't locking, we weren't doing the reference add or delete ops, and we were erroneously skipping null names when real hardware actually seems to allow it (the only thing real hardware skips for null name is naming the thread stack).

* Avoid changing common code by using the converted thread name instead

Slightly cleaner code

* Oops

* Flip priority defines

This better matches with FreeBSD's defines, and fixes the returns of sched_get_priority_min and sched_get_priority_max

* Fix args and return for sched_get_priority_max and sched_get_priority_min

Behavior is based on my own kernel decomp (though what I'm seeing matches what red_prig's done for fpPS4 too).

* Better comment

why not

* Fix error behavior of scePthreadGetPrio

Can error from invalid thread input, which the function hardcodes as an ORBIS_KERNEL_ERROR_ESRCH.

* Fix pthread_setprio

This should use the RefAdd and RefDelete functions on non-curthread threads, not FindThread.

* Remove pthread_set_name_np

Decomp shows it's identical to pthread_rename_np.

* Bring back pthread_set_name_np

What I didn't realize was that it was a void method. Behavior is the same as pthread_rename_np though, so call it instead of doing the direct common setname call.

* Move pthread_set_name_np

Needs to be under pthread_rename_np so I can actually call it.

* Better implementation of pthread_getname_np

* rwlock types

Some Sony extension to rwlocks, paired with a proper SDK check specific to rwlock init. I've implemented both pthread_rwlockattr_gettype_np and pthread_rwlockattr_settype_np, and added the relevant SDK check for rwlockattr type.

* Missing thread unlock in SignalTo

SignalTo specifically runs FindThread, then unlocks before running pretty much the same code as Signal.

* Fix comment
2026-05-13 20:50:37 -07:00
2025-02-18 15:55:13 +02:00
2026-04-24 17:50:49 +03:00
2025-10-31 10:28:39 +02:00
2026-03-17 09:22:22 +02:00
2026-05-13 20:50:37 -07:00
2026-04-19 00:57:05 +03:00
2026-05-11 20:14:57 -07:00
2022-10-24 12:48:38 +03:00
2025-11-08 19:08:18 -08:00



shadPS4

Bloodborne by From Software Hatsune Miku Project DIVA Future Tone by SEGA
Bloodborne screenshot Project DIVA screenshot
Yakuza 0 by SEGA DRIVECLUB™ by Evolution Studios
Yakuza screenshot DRIVECLUB screenshot

General information

shadPS4 is an early PlayStation 4 emulator for Windows, Linux and macOS written in C++.

Important

This is the emulator core, which does not include a GUI. If you just want to use the emulator as an end user, download the QtLauncher instead.

If you encounter problems or have doubts, do not hesitate to look at the Quickstart.
To verify that a game works, you can look at shadPS4 Game Compatibility.
To discuss shadPS4 development, suggest ideas or to ask for help, join our Discord server.
To get the latest news, go to our X (Twitter) or our website.
You can donate to the project via our Kofi page.

Status

Important

shadPS4 is early in development, don't expect a flawless experience.

Currently, the emulator can successfully run games like Bloodborne, Dark Souls Remastered, Red Dead Redemption, and many other games.

Why

This project began for fun. Given our limited free time, it may take some time before shadPS4 can run more complex games, but we're committed to making small, regular updates.

Building

Docker

For building shadPS4 in a containerized environment using Docker and VSCode, check the instructions here:
Docker Build Instructions

Windows

Check the build instructions for Windows.

Linux

Check the build instructions for Linux.

macOS

Check the build instructions for macOS.

Important

macOS users need at least macOS 15.4 to run shadPS4. Due to GPU issues there are currently heavy bugs on Intel Macs.

Usage examples

Important

For a user-friendly GUI, download the QtLauncher.

To get the list of all available commands and also a more detailed description of what each command does, please refer to the --help flag's output.

Below is a list of commonly used command patterns:

shadPS4 CUSA00001 # Searches for a game folder called CUSA00001 in the list of game install folders, and boots it.
shadPS4 --fullscreen true --config-clean CUSA00001    # the game argument is always the last one,
shadPS4 -g CUSA00001 --fullscreen true --config-clean # ...unless manually specified otherwise.
shadPS4 /path/to/game.elf # Boots a PS4 ELF file directly. Useful if you want to boot an executable that is not named eboot.bin.
shadPS4 CUSA00001 -- -flag1 -flag2 # Passes '-flag1' and '-flag2' to the game executable in argv.

Debugging and reporting issues

For more information on how to test, debug and report issues with the emulator or games, read the Debugging documentation.

Keyboard and Mouse Mappings

Note

Some keyboards may also require you to hold the Fn key to use the F* keys. Mac users should use the Command key instead of Control, and need to use Command+F11 for full screen to avoid conflicting with system key bindings.

Button Function
F10 FPS Counter
Ctrl+F10 Video Debug Info
F11 Fullscreen
F12 Trigger RenderDoc Capture (or game-only screenshot if RenderDoc is unavailable)
Alt+F12 Capture screenshot including HUD/dialog overlays

Note

Xbox and DualShock controllers work out of the box.

Controller button Keyboard equivalent
LEFT AXIS UP W
LEFT AXIS DOWN S
LEFT AXIS LEFT A
LEFT AXIS RIGHT D
RIGHT AXIS UP I
RIGHT AXIS DOWN K
RIGHT AXIS LEFT J
RIGHT AXIS RIGHT L
TRIANGLE Numpad 8 or C
CIRCLE Numpad 6 or B
CROSS Numpad 2 or N
SQUARE Numpad 4 or V
PAD UP UP
PAD DOWN DOWN
PAD LEFT LEFT
PAD RIGHT RIGHT
OPTIONS RETURN
BACK BUTTON / TOUCH PAD SPACE
L1 Q
R1 U
L2 E
R2 O
L3 X
R3 M

Keyboard and mouse inputs can be customized in the settings menu by clicking the Controller button, and further details and help on controls are also found there. Custom bindings are saved per-game. Inputs support up to three keys per binding, mouse buttons, mouse movement mapped to joystick input, and more.

Firmware files

shadPS4 can load some PlayStation 4 firmware files. The following firmware modules are supported and must be placed in shadPS4's sys_modules folder.

Modules Modules Modules Modules
libSceAudiodec.sprx libSceCesCs.sprx libSceFont.sprx libSceFontFt.sprx
libSceFreeTypeOt.sprx libSceJpegDec.sprx libSceJpegEnc.sprx libSceJson.sprx
libSceJson2.sprx libSceLibcInternal.sprx libSceNgs2.sprx libScePngEnc.sprx
libSceRtc.sprx libSceSystemGesture.sprx libSceUlt.sprx

Caution

The above modules are required to run the games properly and must be dumped from your legally owned PlayStation 4 console.

Main team

Logo is done by Xphalnos

Contributing

If you want to contribute, please read the CONTRIBUTING.md file.
Open a PR and we'll check it :)

Special Thanks

A few noteworthy teams/projects who've helped us along the way are:

  • Panda3DS: A multiplatform 3DS emulator from our co-author wheremyfoodat. They have been incredibly helpful in understanding and solving problems that came up from natively executing the x64 code of PS4 binaries

  • fpPS4: The fpPS4 team has assisted massively with understanding some of the more complex parts of the PS4 operating system and libraries, by helping with reverse engineering work and research.

  • yuzu: Our shader compiler has been designed with yuzu's Hades compiler as a blueprint. This allowed us to focus on the challenges of emulating a modern AMD GPU while having a high-quality optimizing shader compiler implementation as a base.

  • felix86: A new x86-64 → RISC-V Linux userspace emulator

  • emudev.org: A network of people interested in the documentation, emulation, simulation and re-implementation of hardware near extinction . Belongs to my friend skmp and me (shadow) also a member of it

License

S
Description
PlayStation 4 emulator for Windows, Linux and macOS written in C++
Readme GPL-2.0 142 MiB
Languages
C++ 98.1%
C 1.2%
CMake 0.4%
SourcePawn 0.2%