Skip to content

Commit 4ed219f

Browse files
Merge branch 'shadps4-emu:main' into main
2 parents 520c4a0 + 969955b commit 4ed219f

131 files changed

Lines changed: 8325 additions & 1507 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ on:
1414
- "documents/**"
1515
- "**/*.md"
1616

17+
workflow_dispatch:
18+
1719
concurrency:
1820
group: ci-${{ github.event_name }}-${{ github.ref }}
1921
cancel-in-progress: ${{ github.event_name == 'push' }}
@@ -65,6 +67,81 @@ jobs:
6567
echo "shorthash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
6668
echo "fullhash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
6769
70+
test:
71+
name: Run C++ Tests on ${{ matrix.os }}
72+
runs-on: ${{ matrix.os }}
73+
strategy:
74+
fail-fast: false
75+
matrix:
76+
os: [windows-latest, ubuntu-latest, macos-latest]
77+
include:
78+
- os: windows-latest
79+
compiler_cxx: clang-cl
80+
compiler_c: clang-cl
81+
- os: ubuntu-latest
82+
compiler_cxx: clang++
83+
compiler_c: clang
84+
- os: macos-latest
85+
compiler_cxx: clang++
86+
compiler_c: clang
87+
88+
steps:
89+
- name: Checkout repository
90+
uses: actions/checkout@v4
91+
with:
92+
submodules: recursive
93+
94+
- name: Setup CMake
95+
uses: lukka/get-cmake@latest
96+
97+
- name: Setup Visual Studio shell (Windows only)
98+
if: runner.os == 'Windows'
99+
uses: egor-tensin/vs-shell@v2
100+
with:
101+
arch: x64
102+
103+
- name: Install dependencies (Linux)
104+
if: runner.os == 'Linux'
105+
run: |
106+
sudo apt-get update
107+
sudo apt-get install -y ninja-build libx11-dev libxext-dev libwayland-dev libdecor-0-dev libxkbcommon-dev libxcursor-dev libxi-dev libxss-dev libxtst-dev libxrandr-dev libxfixes-dev libudev-dev uuid-dev uuid-dev
108+
109+
- name: Install dependencies (macOS)
110+
if: runner.os == 'macOS'
111+
run: |
112+
brew install ninja
113+
114+
- name: Configure CMake
115+
run: |
116+
cmake -B build -G Ninja \
117+
-DCMAKE_CXX_COMPILER="${{ matrix.compiler_cxx }}" \
118+
-DCMAKE_C_COMPILER="${{ matrix.compiler_c }}" \
119+
-DCMAKE_BUILD_TYPE=Debug \
120+
-DENABLE_TESTS=ON \
121+
${{ runner.os == 'macOS' && '-DCMAKE_OSX_ARCHITECTURES=x86_64' || '' }}
122+
shell: bash
123+
124+
- name: Create shadPS4 user data directory (Linux)
125+
if: runner.os == 'Linux'
126+
run: mkdir -p ~/.local/share/shadPS4
127+
128+
- name: Create shadPS4 user data directory (macOS)
129+
if: runner.os == 'macOS'
130+
run: mkdir -p ~/Library/Application\ Support/shadPS4
131+
132+
- name: Create shadPS4 user data directory (Windows)
133+
if: runner.os == 'Windows'
134+
run: mkdir -p "$APPDATA/shadPS4"
135+
shell: bash
136+
137+
- name: Build all tests
138+
run: cmake --build build
139+
shell: bash
140+
141+
- name: Run tests with CTest
142+
run: ctest --test-dir build --output-on-failure --progress
143+
shell: bash
144+
68145
windows-sdl:
69146
runs-on: windows-2025
70147
needs: get-info

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,3 +418,6 @@ FodyWeavers.xsd
418418
# JetBrains
419419
.idea
420420
cmake-build-*
421+
422+
# Nix Result symlink
423+
result

CMakeLists.txt

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ endif()
3333

3434
option(ENABLE_DISCORD_RPC "Enable the Discord RPC integration" ON)
3535
option(ENABLE_UPDATER "Enables the options to updater" ON)
36+
option(ENABLE_TESTS "Build unit tests (requires GTest)" OFF)
3637

3738
# First, determine whether to use CMAKE_OSX_ARCHITECTURES or CMAKE_SYSTEM_PROCESSOR.
3839
if (APPLE AND CMAKE_OSX_ARCHITECTURES)
@@ -244,7 +245,7 @@ find_package(VulkanMemoryAllocator 3.1.0 CONFIG)
244245
find_package(xbyak 7.07 CONFIG)
245246
find_package(xxHash 0.8.2 MODULE)
246247
find_package(ZLIB 1.3 MODULE)
247-
find_package(Zydis 5.0.0 CONFIG)
248+
find_package(Zydis 5.0.0 MODULE)
248249
find_package(pugixml 1.14 CONFIG)
249250
if (APPLE)
250251
find_package(date 3.0.1 CONFIG)
@@ -295,8 +296,15 @@ set(AUDIO_LIB src/core/libraries/audio/audioin.cpp
295296
src/core/libraries/audio/audioout_backend.h
296297
src/core/libraries/audio/audioout_error.h
297298
src/core/libraries/audio/sdl_audio_out.cpp
299+
src/core/libraries/audio/openal_audio_out.cpp
300+
src/core/libraries/audio/openal_manager.h
298301
src/core/libraries/ngs2/ngs2.cpp
299302
src/core/libraries/ngs2/ngs2.h
303+
src/core/libraries/audio3d/audio3d.cpp
304+
src/core/libraries/audio3d/audio3d_openal.cpp
305+
src/core/libraries/audio3d/audio3d_openal.h
306+
src/core/libraries/audio3d/audio3d.h
307+
src/core/libraries/audio3d/audio3d_error.h
300308
)
301309

302310
set(GNM_LIB src/core/libraries/gnmdriver/gnmdriver.cpp
@@ -871,6 +879,12 @@ set(CORE src/core/aerolib/stubs.cpp
871879
src/core/tls.h
872880
src/core/emulator_state.cpp
873881
src/core/emulator_state.h
882+
src/core/emulator_settings.cpp
883+
src/core/emulator_settings.h
884+
src/core/user_manager.cpp
885+
src/core/user_manager.h
886+
src/core/user_settings.cpp
887+
src/core/user_settings.h
874888
)
875889

876890
if (ARCHITECTURE STREQUAL "x86_64")
@@ -1077,6 +1091,8 @@ set(IMGUI src/imgui/imgui_config.h
10771091
src/imgui/imgui_layer.h
10781092
src/imgui/imgui_std.h
10791093
src/imgui/imgui_texture.h
1094+
src/imgui/imgui_translations.cpp
1095+
src/imgui/imgui_translations.h
10801096
src/imgui/renderer/imgui_core.cpp
10811097
src/imgui/renderer/imgui_core.h
10821098
src/imgui/renderer/imgui_impl_sdl3.cpp
@@ -1101,6 +1117,8 @@ set(EMULATOR src/emulator.cpp
11011117
src/sdl_window.cpp
11021118
)
11031119

1120+
if(NOT ENABLE_TESTS)
1121+
11041122
add_executable(shadps4
11051123
${AUDIO_CORE}
11061124
${IMGUI}
@@ -1121,7 +1139,14 @@ create_target_directory_groups(shadps4)
11211139

11221140
target_link_libraries(shadps4 PRIVATE magic_enum::magic_enum fmt::fmt toml11::toml11 tsl::robin_map xbyak::xbyak Tracy::TracyClient RenderDoc::API FFmpeg::ffmpeg Dear_ImGui gcn half::half ZLIB::ZLIB PNG::PNG)
11231141
target_link_libraries(shadps4 PRIVATE Boost::headers GPUOpen::VulkanMemoryAllocator LibAtrac9 sirit Vulkan::Headers xxHash::xxhash Zydis::Zydis glslang::glslang SDL3::SDL3 SDL3_mixer::SDL3_mixer pugixml::pugixml)
1124-
target_link_libraries(shadps4 PRIVATE stb::headers libusb::usb lfreist-hwinfo::hwinfo nlohmann_json::nlohmann_json miniz::miniz fdk-aac CLI11::CLI11 OpenAL::OpenAL Cpp_Httplib)
1142+
target_link_libraries(shadps4 PRIVATE stb::headers lfreist-hwinfo::hwinfo nlohmann_json::nlohmann_json miniz::miniz fdk-aac CLI11::CLI11 OpenAL::OpenAL Cpp_Httplib)
1143+
1144+
if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
1145+
target_link_libraries(shadps4 PRIVATE "/usr/lib/libusb.so")
1146+
target_link_libraries(shadps4 PRIVATE "/usr/local/lib/libuuid.so")
1147+
else()
1148+
target_link_libraries(shadps4 PRIVATE libusb::usb)
1149+
endif()
11251150

11261151
target_compile_definitions(shadps4 PRIVATE IMGUI_USER_CONFIG="imgui/imgui_config.h")
11271152
target_compile_definitions(Dear_ImGui PRIVATE IMGUI_USER_CONFIG="${PROJECT_SOURCE_DIR}/src/imgui/imgui_config.h")
@@ -1167,6 +1192,8 @@ if (APPLE)
11671192

11681193
# Replacement for std::chrono::time_zone
11691194
target_link_libraries(shadps4 PRIVATE date::date-tz epoll-shim)
1195+
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
1196+
target_link_libraries(shadps4 PRIVATE date::date-tz epoll-shim)
11701197
endif()
11711198

11721199
if (WIN32)
@@ -1254,3 +1281,8 @@ endif()
12541281

12551282
# Install rules
12561283
install(TARGETS shadps4 BUNDLE DESTINATION .)
1284+
1285+
else()
1286+
enable_testing()
1287+
add_subdirectory(tests)
1288+
endif()

REUSE.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ path = [
2222
"documents/Screenshots/Linux/*",
2323
"documents/Screenshots/Windows/*",
2424
"externals/MoltenVK/MoltenVK_icd.json",
25+
"flake.lock",
2526
"scripts/ps4_names.txt",
2627
"src/images/bronze.png",
2728
"src/images/gold.png",
@@ -130,4 +131,4 @@ SPDX-License-Identifier = "MIT"
130131
[[annotations]]
131132
path = "src/video_core/host_shaders/fsr/*"
132133
SPDX-FileCopyrightText = "Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved."
133-
SPDX-License-Identifier = "MIT"
134+
SPDX-License-Identifier = "MIT"

documents/building-linux.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,23 @@ sudo zypper install clang git cmake libasound2 libpulse-devel \
5353
nix-shell shell.nix
5454
```
5555

56+
#### Nix Flake Development Shell
57+
```bash
58+
nix develop
59+
cmake -S . -B build/ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
60+
ln -s ./build/compile_commands.json .
61+
```
62+
63+
#### Nix Flake Build
64+
```bash
65+
nix build .?submodules=1#linux.debug
66+
```
67+
```bash
68+
nix build .?submodules=1#linux.release
69+
```
70+
```bash
71+
nix build .?submodules=1#linux.releaseWithDebugInfo
72+
```
5673
#### Other Linux distributions
5774

5875
You can try one of two methods:

externals/CMakeLists.txt

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,15 @@ endif()
210210

211211
# libusb
212212
if (NOT TARGET libusb::usb)
213-
add_subdirectory(ext-libusb)
214-
add_library(libusb::usb ALIAS usb-1.0)
213+
if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
214+
# YOU MUST USE NATIVE LIBUSB
215+
# using anything else will crash instantly, also freebsd will NOT like it
216+
# no you cant vendor this libusb, its builtin on freebsd
217+
find_package(libusb)
218+
else()
219+
add_subdirectory(ext-libusb)
220+
add_library(libusb::usb ALIAS usb-1.0)
221+
endif()
215222
endif()
216223

217224
# Discord RPC
@@ -233,25 +240,26 @@ endif()
233240
set(HWINFO_STATIC ON)
234241
add_subdirectory(hwinfo)
235242

236-
# Apple-only dependencies
237-
if (APPLE)
243+
if (APPLE OR ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
238244
# date
239245
if (NOT TARGET date::date-tz)
240246
option(BUILD_TZ_LIB "" ON)
241247
option(USE_SYSTEM_TZ_DB "" ON)
242248
add_subdirectory(date)
243249
endif()
250+
if (NOT TARGET epoll-shim)
251+
add_subdirectory(epoll-shim)
252+
endif()
253+
endif()
244254

255+
# Apple-only dependencies
256+
if (APPLE)
245257
# MoltenVK
246258
if (NOT TARGET MoltenVK)
247259
set(MVK_EXCLUDE_SPIRV_TOOLS ON)
248260
set(MVK_USE_METAL_PRIVATE_API ON)
249261
add_subdirectory(MoltenVK)
250262
endif()
251-
252-
if (NOT TARGET epoll-shim)
253-
add_subdirectory(epoll-shim)
254-
endif()
255263
endif()
256264

257265
#windows only

flake.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)