PlayStation 4 emulator for Windows, Linux and macOS written in C++
Find a file
Stephen Miller 6cdc52cdde
Core: More Memory Cleanup & Fixes (#2997)
* Only perform GPU memory mapping when GPU can access it

This better aligns with hardware observations, and should also speed up unmaps and decommits, since they don't need to be compared with the GPU max address anymore.

* Reserve fixes

ReserveVirtualRange seems to follow the 0x200000000 base address like MemoryPoolReserve does.
Both also need checks in their flags Fixed path to ensure we're mapping in-bounds. If we're not in mapping to our address space, we'll end up reserving and returning the wrong address, which could lead to weird memory issues in games.

I'll need to test on real hardware to verify if such changes are appropriate.

* Better sceKernelMmap

Handles errors where we would previously throw exceptions. Also moves the file logic to MapFile, since that way all the possible errors are in one place.
Also fixes some function parameters to align with our current standards.

* Major refactor

MapDirectMemory, MapFlexibleMemory, ReserveVirtualRange, and MemoryPoolReserve all internally use mmap to perform their mappings. Naturally, this means that all functions have similar behaviors, and a lot of duplicate code.
This add necessary conditional behavior to MapMemory so MemoryPoolReserve and ReserveVirtualRange can use it, without disrupting the behavior of MapDirectMemory or MapFlexibleMemory calls.

* Accurate phys_addr for non-direct mappings

* Properly handle GPU access rights

Since my first commit restricts GPU mappings to memory areas with GPU access permissions, we also need to be updating the GPU mappings appropriately during Protect calls too.

* Update memory.cpp

* Update memory.h

* Update memory.cpp

* Update memory.cpp

* Update memory.cpp

* Revert "Update memory.cpp"

This reverts commit 2c55d014c0.

* Coalesce dmem map

Aligns with hardware observations, hopefully shouldn't break anything since nothing should change hardware-wise when release dmem calls and unmap calls are performed?
Either that or Windows breaks because Windows, will need to test.

* Implement posix_mprotect

Unity calls this
Also fixes the names of sceKernelMprotect and sceKernelMtypeprotect, though that's more of a style change and can be reverted if requested.

* Fix sceKernelSetVirtualRangeName

Partially addresses a "regression" introduced when I fixed up some asserts.
As noted in the code, this implementation is still slightly inaccurate, as handling this properly could cause regressions on Windows.

* Unconditional assert in MapFile

* Remove protect warning

This is expected behavior, shouldn't need any logging.

* Respect alignment

Forgot to properly do this when updating ReserveVirtualRange and MemoryPoolReserve

* Fix Mprotect on free memory

On real hardware, this just does nothing. If something did get protected, there's no way to query that information.
Therefore, it seems pretty safe to just behave like munmap and return size here.

* Minor tidy-up

No functional difference, but looks better.
2025-05-29 18:56:03 +03: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 0.9.0 release 2025-05-22 18:52:44 +03:00
documents build: Target x86-64-v3 CPU architecture (#2934) 2025-05-14 10:37:16 -07:00
externals externals: Update MoltenVK (#2979) 2025-05-22 18:22:05 -07:00
LICENSES
scripts
src Core: More Memory Cleanup & Fixes (#2997) 2025-05-29 18:56:03 +03:00
.gitignore
.gitmodules externals: Remove winpthreads. (#2932) 2025-05-15 13:59:34 -07:00
CMakeLists.txt Libs: CompanionUtil (#2963) 2025-05-29 12:33:56 +03:00
CMakeSettings.json
CONTRIBUTING.md
crowdin.yml
LICENSE
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