PlayStation 4 emulator for Windows, Linux and macOS written in C++
Find a file
Stephen Miller 6477dc4f1e
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
Core: Memory Fixes (#2872)
* Fix VirtualQuery behavior on low addresses.

* Fix VirtualQuery struct

Somewhere in our BitField and array use, the size of our VirtualQuery struct became larger than the struct used on real hardware.
Fixing this fixes some data corruption visible in the name parameter during my tests.

* Default name to anon

On real hardware, nameless mappings are given the name "anon:address" where address appears to be the address that made the memory call.
For simplicity sake, I'll stick to the name "anon" for now.

* Place an upper bound on returns from SearchFree

Right now, this upper bound is set based on the limitations of our GPU buffer cache and page table.
Someone with more experience in that area of code should probably fix that at some point.

* More anons

* Clang

* Fix name in sceKernelMapNamedDirectMemory

* strncpy instead of strcpy

Hardcoded the constant size for now, I need to review how real hardware behaves here to determine if anything else is necessary for this to be accurate.

* Fix name behavior

All memory naming functions restrict the name size to a 31 character limit, and return `ORBIS_KERNEL_ERROR_ENAMETOOLONG` if that limit is exceeded.
Since this value is constant for all functions involving names, I've defined it as a constant in kernel's memory.h, and used that in place of any hardcoded 32 character limits.

* Error logging

Hopefully this helps in catching the UFC regression?

* Increase address space upper bound

Probably needs heavy testing, especially on Mac/Windows.
This increases the address space, as needed to accommodate strange memory behaviors seen in UFC.

* VirtualQuery fix

Due to limitations of certain platforms, we initialize our vma_map with 3 separate free mappings.
As such, we need to use a while loop here to accurately query mappings with high addresses

* Fix mappings to high addresses

The PS4's GPU can only handle 40bit addresses. Our texture cache and buffer cache were designed around these limits, and mapping to higher addresses would cause segmentation faults and access violations.
To fix these crashes, only map to the GPU if the mapping is fully contained within the address space the GPU should access.
I'm open to suggestions on how to make this cleaner

* Revert "Increase address space upper bound"

This reverts commit 3d50eeeebb.

* Revert VirtualQuery while loop

Windows wasn't happy with this, again.
Will try to debug and properly fix this when I have a good chance.

* Fix asserts

FindVMA, due to the way it's programmed, never actually returns vma_map.end(), the furthest it ever returns is the last valid memory area. All those asserts we involving vma_map.end() never actually trigger due to this.
This commit removes redundant asserts, adds messages to asserts that were lacking them, and fixes all asserts designed to detect out of bounds memory accesses so they actually trigger.
I've also fixed some potential memory safety issues.

* Proper error behavior in QueryProtection

Might as well handle this properly while I'm here.

* Clang

* More information about ReserveVirtualRange results

Should help debug issues like the one in The Order: 1886 (CUSA00076)

* Fix assert message

* Update assert message

Extra space

* Fix my bug

Oh hey, finally something that's my fault.

* Fix rasterizer unmaps

Should use adjusted_size here, otherwise we could unmap too much.
Thanks to diegolix29 for spotting this.

* Fix edge case in MapMemory

Code comments explain everything.
This should fix some memory asserts.

* Fix fix

Avoid running the code path if it's unnecessary, since there are many additional edge cases to handle when the VMA map is small.

* Fix fix fix

Should prevent infinite loops, haven't tested properly yet though.

* Split logging for inputs and out_addr in ReserveVirtualRange

Addresses review comments.
2025-05-09 12:33:04 -07:00
.ci Bump to Clang 19 (#2434) 2025-02-18 15:55:13 +02:00
.github ci: Use mold linker for Linux builds (#2847) 2025-04-27 20:34:59 -07:00
cmake cmake: fix system libusb discovery (#2731) 2025-03-31 22:29:52 +03:00
dist tagged v0.8.0 release 2025-04-23 13:05:36 +03:00
documents renderer_vulkan: Improve handling of required vs optional extensions. (#2792) 2025-04-15 22:31:58 -07:00
externals Implement IMAGE_ATOMIC_FMIN and IMAGE_ATOMIC_FMAX for 32bit floats (#2820) 2025-04-30 11:42:08 -07:00
LICENSES audio: Accurate audio output timing. (#1986) 2024-12-31 12:38:52 +02:00
scripts Rewrite Save Data & Impl Save Data Dialog (#824) 2024-09-20 12:34:19 +03:00
src Core: Memory Fixes (#2872) 2025-05-09 12:33:04 -07:00
.gitignore misc: Add JetBrains build directories to gitignore. (#1573) 2024-11-22 17:36:31 +02:00
.gitmodules renderer_vulkan: Support loading Vulkan layers on macOS SDL build. (#2832) 2025-04-23 01:10:03 -07:00
CMakeLists.txt [Libs] Stubs sceSigninDialog (#2890) 2025-05-09 11:08:22 +03:00
CMakeSettings.json fix VS intellisense (#1104) 2024-09-27 09:03:42 +03:00
CONTRIBUTING.md Fix typo in CONTRIBUTING.md comment 2024-08-23 18:29:00 -07:00
crowdin.yml Update Crowdin configuration file 2025-02-13 14:50:02 +02:00
LICENSE Initial commit 2022-10-24 12:48:38 +03:00
README.md Discord logo fix on the README. (#2811) 2025-04-19 17:51:59 +03:00
REUSE.toml misc: Few small fixes. (#2780) 2025-04-13 12:10:24 -07:00
shell.nix Update linux build docs (#2474) 2025-02-19 13:29:31 +02:00



shadPS4

General information

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

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.
For those who'd like to donate to the project, we now have a 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 as a fun project. 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

Important

If you want to use shadPS4 to play your games, you don't have to follow the build instructions, you can simply download the emulator from either the release tab or the action tab.

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.

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

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, these must be dumped from your legally owned PlayStation 4 console.
The following firmware modules are supported and must be placed in shadPS4's user/sys_modules folder.

Modules Modules Modules Modules
libSceCesCs.sprx libSceFont.sprx libSceFontFt.sprx libSceFreeTypeOt.sprx
libSceJson.sprx libSceJson2.sprx libSceLibcInternal.sprx libSceNgs2.sprx
libSceRtc.sprx libSceUlt.sprx

Caution

The above modules are required to run the games properly and must be extracted from your PlayStation 4.
We do not provide any information or support on how to do this.

Main team

Logo is done by Xphalnos

Contributing

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

Translations

If you want to translate shadPS4 to your language we use Crowdin.

Contributors

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

License