Compare commits
3 Commits
main
...
cpu-detili
Author | SHA1 | Date |
---|---|---|
raphaelthegreat | c7bf29cbac | |
raphaelthegreat | f291674790 | |
raphaelthegreat | 6cec16225d |
|
@ -19,12 +19,8 @@ chmod a+x linuxdeploy-x86_64.AppImage
|
||||||
chmod a+x linuxdeploy-plugin-qt-x86_64.AppImage
|
chmod a+x linuxdeploy-plugin-qt-x86_64.AppImage
|
||||||
chmod a+x linuxdeploy-plugin-checkrt-x86_64.sh
|
chmod a+x linuxdeploy-plugin-checkrt-x86_64.sh
|
||||||
|
|
||||||
|
|
||||||
# Build AppImage
|
# Build AppImage
|
||||||
./linuxdeploy-x86_64.AppImage --appdir AppDir
|
./linuxdeploy-x86_64.AppImage --appdir AppDir
|
||||||
./linuxdeploy-plugin-checkrt-x86_64.sh --appdir AppDir
|
./linuxdeploy-plugin-checkrt-x86_64.sh --appdir AppDir
|
||||||
|
|
||||||
cp -a "$GITHUB_WORKSPACE/build/translations" AppDir/usr/bin
|
|
||||||
|
|
||||||
./linuxdeploy-x86_64.AppImage --appdir AppDir -d "$GITHUB_WORKSPACE"/.github/shadps4.desktop -e "$GITHUB_WORKSPACE"/build/shadps4 -i "$GITHUB_WORKSPACE"/.github/shadps4.png --plugin qt --output appimage
|
./linuxdeploy-x86_64.AppImage --appdir AppDir -d "$GITHUB_WORKSPACE"/.github/shadps4.desktop -e "$GITHUB_WORKSPACE"/build/shadps4 -i "$GITHUB_WORKSPACE"/.github/shadps4.png --plugin qt --output appimage
|
||||||
mv Shadps4-x86_64.AppImage Shadps4-qt.AppImage
|
mv Shadps4-x86_64.AppImage Shadps4-qt.AppImage
|
||||||
|
|
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 197 KiB |
|
@ -14,4 +14,4 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: fsfe/reuse-action@v4
|
- uses: fsfe/reuse-action@v3
|
|
@ -10,6 +10,7 @@ on:
|
||||||
branches: [ "main" ]
|
branches: [ "main" ]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||||
BUILD_TYPE: Release
|
BUILD_TYPE: Release
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
@ -18,12 +19,12 @@ jobs:
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
- name: Fetch submodules
|
||||||
submodules: recursive
|
run: git submodule update --init --recursive
|
||||||
|
|
||||||
- name: Install misc packages
|
- name: Install misc packages
|
||||||
run: >
|
run: >
|
||||||
sudo apt-get update && sudo apt install libx11-dev libxext-dev libwayland-dev libfuse2 clang build-essential qt6-base-dev qt6-tools-dev
|
sudo apt-get update && sudo apt install libx11-dev libxext-dev libwayland-dev libfuse2 clang build-essential qt6-base-dev
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DENABLE_QT_GUI=ON
|
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DENABLE_QT_GUI=ON
|
||||||
|
|
|
@ -8,8 +8,10 @@ on:
|
||||||
branches: [ "main" ]
|
branches: [ "main" ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "main" ]
|
branches: [ "main" ]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||||
BUILD_TYPE: Release
|
BUILD_TYPE: Release
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
@ -37,6 +39,7 @@ jobs:
|
||||||
name: shadps4-ubuntu64
|
name: shadps4-ubuntu64
|
||||||
path: |
|
path: |
|
||||||
${{github.workspace}}/build/shadps4
|
${{github.workspace}}/build/shadps4
|
||||||
|
${{github.workspace}}/build/libSDL3.so.0.0.0
|
||||||
|
|
||||||
- name: Run AppImage packaging script
|
- name: Run AppImage packaging script
|
||||||
run: ./.github/linux-appimage-sdl.sh
|
run: ./.github/linux-appimage-sdl.sh
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
# SPDX-FileCopyrightText: 2024 shadPS4 Emulator Project
|
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
name: macOS-Qt
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ "main" ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ "main" ]
|
|
||||||
|
|
||||||
env:
|
|
||||||
BUILD_TYPE: Release
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: macos-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
|
|
||||||
- name: Setup latest Xcode
|
|
||||||
uses: maxim-lobanov/setup-xcode@v1
|
|
||||||
with:
|
|
||||||
xcode-version: latest
|
|
||||||
|
|
||||||
- name: Install MoltenVK
|
|
||||||
run: |
|
|
||||||
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
|
||||||
arch -x86_64 /usr/local/bin/brew install molten-vk
|
|
||||||
|
|
||||||
- name: Setup Qt
|
|
||||||
uses: jurplel/install-qt-action@v4
|
|
||||||
with:
|
|
||||||
version: 6.7.2
|
|
||||||
host: mac
|
|
||||||
target: desktop
|
|
||||||
arch: clang_64
|
|
||||||
archives: qtbase qttools
|
|
||||||
|
|
||||||
- name: Configure CMake
|
|
||||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_OSX_ARCHITECTURES=x86_64 -DENABLE_QT_GUI=ON
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel $(sysctl -n hw.ncpu)
|
|
||||||
|
|
||||||
- name: Package
|
|
||||||
run: |
|
|
||||||
mkdir upload
|
|
||||||
mv ${{github.workspace}}/build/shadps4.app upload
|
|
||||||
mv ${{github.workspace}}/build/translations upload
|
|
||||||
macdeployqt upload/shadps4.app
|
|
||||||
tar cf shadps4-macos-qt.tar.gz -C upload .
|
|
||||||
|
|
||||||
- name: Upload executable
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: shadps4-macos-qt
|
|
||||||
path: shadps4-macos-qt.tar.gz
|
|
|
@ -1,52 +0,0 @@
|
||||||
# SPDX-FileCopyrightText: 2024 shadPS4 Emulator Project
|
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
name: macOS
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ "main" ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ "main" ]
|
|
||||||
|
|
||||||
env:
|
|
||||||
BUILD_TYPE: Release
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: macos-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
|
|
||||||
- name: Setup latest Xcode
|
|
||||||
uses: maxim-lobanov/setup-xcode@v1
|
|
||||||
with:
|
|
||||||
xcode-version: latest
|
|
||||||
|
|
||||||
- name: Install MoltenVK
|
|
||||||
run: |
|
|
||||||
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
|
||||||
arch -x86_64 /usr/local/bin/brew install molten-vk
|
|
||||||
|
|
||||||
- name: Configure CMake
|
|
||||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_OSX_ARCHITECTURES=x86_64
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel $(sysctl -n hw.ncpu)
|
|
||||||
|
|
||||||
- name: Package
|
|
||||||
run: |
|
|
||||||
mkdir upload
|
|
||||||
mv ${{github.workspace}}/build/shadps4 upload
|
|
||||||
cp $(arch -x86_64 /usr/local/bin/brew --prefix)/opt/molten-vk/lib/libMoltenVK.dylib upload
|
|
||||||
install_name_tool -add_rpath "@loader_path" upload/shadps4
|
|
||||||
tar cf shadps4-macos-sdl.tar.gz -C upload .
|
|
||||||
|
|
||||||
- name: Upload executable
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: shadps4-macos-sdl
|
|
||||||
path: shadps4-macos-sdl.tar.gz
|
|
|
@ -10,8 +10,12 @@ on:
|
||||||
branches: [ "main" ]
|
branches: [ "main" ]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||||
BUILD_TYPE: Release
|
BUILD_TYPE: Release
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
@ -24,23 +28,23 @@ jobs:
|
||||||
- name: Setup Qt
|
- name: Setup Qt
|
||||||
uses: jurplel/install-qt-action@v4
|
uses: jurplel/install-qt-action@v4
|
||||||
with:
|
with:
|
||||||
version: 6.7.2
|
|
||||||
host: windows
|
|
||||||
target: desktop
|
|
||||||
arch: win64_msvc2019_64
|
arch: win64_msvc2019_64
|
||||||
archives: qtbase qttools
|
version: 6.7.1
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
|
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
||||||
|
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
|
||||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -T ClangCL -DENABLE_QT_GUI=ON
|
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -T ClangCL -DENABLE_QT_GUI=ON
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
|
# Build your program with the given configuration
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel
|
||||||
|
|
||||||
- name: Deploy
|
- name: Deploy
|
||||||
run: |
|
run: |
|
||||||
mkdir upload
|
mkdir upload
|
||||||
move build/Release/shadPS4.exe upload
|
move build/Release/shadPS4.exe upload
|
||||||
move build/translations upload
|
move build/Release/zlib-ng2.dll upload
|
||||||
windeployqt --dir upload upload/shadPS4.exe
|
windeployqt --dir upload upload/shadPS4.exe
|
||||||
|
|
||||||
- name: Upload executable
|
- name: Upload executable
|
||||||
|
|
|
@ -10,8 +10,12 @@ on:
|
||||||
branches: [ "main" ]
|
branches: [ "main" ]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||||
BUILD_TYPE: Release
|
BUILD_TYPE: Release
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
@ -19,16 +23,18 @@ jobs:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
|
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
||||||
|
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
|
||||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -T ClangCL
|
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -T ClangCL
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
|
# Build your program with the given configuration
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel
|
||||||
|
- name: Upload a Build Artifact
|
||||||
- name: Upload executable
|
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: shadps4-win64-sdl
|
name: shadps4-win64
|
||||||
|
# A file, directory or wildcard pattern that describes what to upload
|
||||||
path: |
|
path: |
|
||||||
${{github.workspace}}/build/Release/shadPS4.exe
|
${{github.workspace}}/build/Release/shadPS4.exe
|
||||||
|
${{github.workspace}}/build/Release/SDL3.dll
|
|
@ -408,4 +408,3 @@ FodyWeavers.xsd
|
||||||
/emulator/eboot.bin
|
/emulator/eboot.bin
|
||||||
/out/*
|
/out/*
|
||||||
/third-party/out/*
|
/third-party/out/*
|
||||||
/src/common/scm_rev.cpp
|
|
||||||
|
|
|
@ -1,87 +1,57 @@
|
||||||
|
[submodule "externals/discord-rpc"]
|
||||||
|
path = externals/discord-rpc
|
||||||
|
url = https://github.com/shadps4-emu/ext-discord-rpc.git
|
||||||
[submodule "externals/cryptopp-cmake"]
|
[submodule "externals/cryptopp-cmake"]
|
||||||
path = externals/cryptopp-cmake
|
path = externals/cryptopp-cmake
|
||||||
url = https://github.com/shadps4-emu/ext-cryptopp-cmake.git
|
url = https://github.com/shadps4-emu/ext-cryptopp-cmake.git
|
||||||
shallow = true
|
|
||||||
[submodule "externals/cryptopp"]
|
[submodule "externals/cryptopp"]
|
||||||
path = externals/cryptopp
|
path = externals/cryptopp
|
||||||
url = https://github.com/shadps4-emu/ext-cryptopp.git
|
url = https://github.com/shadps4-emu/ext-cryptopp.git
|
||||||
shallow = true
|
|
||||||
[submodule "externals/cryptoppwin"]
|
[submodule "externals/cryptoppwin"]
|
||||||
path = externals/cryptoppwin
|
path = externals/cryptoppwin
|
||||||
url = https://github.com/shadps4-emu/ext-cryptoppwin.git
|
url = https://github.com/shadps4-emu/ext-cryptoppwin.git
|
||||||
shallow = true
|
|
||||||
[submodule "externals/zlib-ng"]
|
[submodule "externals/zlib-ng"]
|
||||||
path = externals/zlib-ng
|
path = externals/zlib-ng
|
||||||
url = https://github.com/shadps4-emu/ext-zlib-ng.git
|
url = https://github.com/shadps4-emu/ext-zlib-ng.git
|
||||||
shallow = true
|
|
||||||
[submodule "externals/sdl3"]
|
[submodule "externals/sdl3"]
|
||||||
path = externals/sdl3
|
path = externals/sdl3
|
||||||
url = https://github.com/shadps4-emu/ext-SDL.git
|
url = https://github.com/shadps4-emu/ext-SDL.git
|
||||||
shallow = true
|
|
||||||
[submodule "externals/fmt"]
|
[submodule "externals/fmt"]
|
||||||
path = externals/fmt
|
path = externals/fmt
|
||||||
url = https://github.com/shadps4-emu/ext-fmt.git
|
url = https://github.com/shadps4-emu/ext-fmt.git
|
||||||
shallow = true
|
|
||||||
[submodule "externals/vulkan-headers"]
|
[submodule "externals/vulkan-headers"]
|
||||||
path = externals/vulkan-headers
|
path = externals/vulkan-headers
|
||||||
url = https://github.com/KhronosGroup/Vulkan-Headers.git
|
url = https://github.com/KhronosGroup/Vulkan-Headers.git
|
||||||
shallow = true
|
|
||||||
[submodule "externals/vma"]
|
[submodule "externals/vma"]
|
||||||
path = externals/vma
|
path = externals/vma
|
||||||
url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
|
url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
|
||||||
shallow = true
|
|
||||||
[submodule "externals/glslang"]
|
[submodule "externals/glslang"]
|
||||||
path = externals/glslang
|
path = externals/glslang
|
||||||
url = https://github.com/KhronosGroup/glslang.git
|
url = https://github.com/KhronosGroup/glslang.git
|
||||||
shallow = true
|
|
||||||
[submodule "externals/robin-map"]
|
[submodule "externals/robin-map"]
|
||||||
path = externals/robin-map
|
path = externals/robin-map
|
||||||
url = https://github.com/Tessil/robin-map.git
|
url = https://github.com/Tessil/robin-map.git
|
||||||
shallow = true
|
[submodule "externals/boost"]
|
||||||
|
path = externals/boost
|
||||||
|
url = https://github.com/raphaelthegreat/ext-boost.git
|
||||||
[submodule "externals/xbyak"]
|
[submodule "externals/xbyak"]
|
||||||
path = externals/xbyak
|
path = externals/xbyak
|
||||||
url = https://github.com/herumi/xbyak.git
|
url = https://github.com/herumi/xbyak.git
|
||||||
shallow = true
|
|
||||||
[submodule "externals/winpthreads"]
|
[submodule "externals/winpthreads"]
|
||||||
path = externals/winpthreads
|
path = externals/winpthreads
|
||||||
url = https://github.com/shadps4-emu/winpthreads.git
|
url = https://github.com/shadps4-emu/winpthreads.git
|
||||||
shallow = true
|
|
||||||
[submodule "externals/magic_enum"]
|
[submodule "externals/magic_enum"]
|
||||||
path = externals/magic_enum
|
path = externals/magic_enum
|
||||||
url = https://github.com/Neargye/magic_enum.git
|
url = https://github.com/Neargye/magic_enum.git
|
||||||
shallow = true
|
|
||||||
[submodule "externals/toml11"]
|
[submodule "externals/toml11"]
|
||||||
path = externals/toml11
|
path = externals/toml11
|
||||||
url = https://github.com/ToruNiina/toml11.git
|
url = https://github.com/ToruNiina/toml11.git
|
||||||
shallow = true
|
|
||||||
[submodule "externals/zydis"]
|
[submodule "externals/zydis"]
|
||||||
path = externals/zydis
|
path = externals/zydis
|
||||||
url = https://github.com/zyantific/zydis.git
|
url = https://github.com/zyantific/zydis.git
|
||||||
shallow = true
|
|
||||||
[submodule "externals/sirit"]
|
[submodule "externals/sirit"]
|
||||||
path = externals/sirit
|
path = externals/sirit
|
||||||
url = https://github.com/shadps4-emu/sirit.git
|
url = https://github.com/raphaelthegreat/sirit
|
||||||
shallow = true
|
|
||||||
[submodule "externals/xxhash"]
|
[submodule "externals/xxhash"]
|
||||||
path = externals/xxhash
|
path = externals/xxhash
|
||||||
url = https://github.com/Cyan4973/xxHash.git
|
url = https://github.com/Cyan4973/xxHash.git
|
||||||
shallow = true
|
|
||||||
[submodule "externals/tracy"]
|
|
||||||
path = externals/tracy
|
|
||||||
url = https://github.com/shadps4-emu/tracy.git
|
|
||||||
shallow = true
|
|
||||||
[submodule "externals/ext-boost"]
|
|
||||||
path = externals/ext-boost
|
|
||||||
url = https://github.com/shadps4-emu/ext-boost.git
|
|
||||||
shallow = true
|
|
||||||
[submodule "externals/date"]
|
|
||||||
path = externals/date
|
|
||||||
url = https://github.com/HowardHinnant/date.git
|
|
||||||
shallow = true
|
|
||||||
[submodule "externals/ffmpeg-core"]
|
|
||||||
path = externals/ffmpeg-core
|
|
||||||
url = https://github.com/shadps4-emu/ext-ffmpeg-core.git
|
|
||||||
shallow = true
|
|
||||||
[submodule "externals/half"]
|
|
||||||
path = externals/half
|
|
||||||
url = https://github.com/ROCm/half.git
|
|
||||||
|
|
42
.reuse/dep5
|
@ -3,28 +3,17 @@ Comment: It is best to use this file to record copyright information about
|
||||||
generated, binary and third party files
|
generated, binary and third party files
|
||||||
|
|
||||||
Files: CMakeSettings.json
|
Files: CMakeSettings.json
|
||||||
|
scripts/ps4_names.txt
|
||||||
|
documents/changelog.txt
|
||||||
|
documents/readme.txt
|
||||||
.github/shadps4.desktop
|
.github/shadps4.desktop
|
||||||
.github/shadps4.png
|
.github/shadps4.png
|
||||||
.gitmodules
|
.gitmodules
|
||||||
documents/changelog.txt
|
documents/Screenshots/screenshot.png
|
||||||
documents/readme.txt
|
src/images/shadps4.ico
|
||||||
documents/Quickstart/1.png
|
|
||||||
documents/Quickstart/2.png
|
|
||||||
documents/Screenshots/Bloodborne.png
|
|
||||||
documents/Screenshots/Sonic Mania.png
|
|
||||||
documents/Screenshots/Undertale.png
|
|
||||||
documents/Screenshots/We are DOOMED.png
|
|
||||||
scripts/ps4_names.txt
|
|
||||||
src/images/about_icon.png
|
|
||||||
src/images/controller_icon.png
|
src/images/controller_icon.png
|
||||||
src/images/exit_icon.png
|
src/images/exit_icon.png
|
||||||
src/images/file_icon.png
|
src/images/file_icon.png
|
||||||
src/images/flag_china.png
|
|
||||||
src/images/flag_eu.png
|
|
||||||
src/images/flag_jp.png
|
|
||||||
src/images/flag_unk.png
|
|
||||||
src/images/flag_us.png
|
|
||||||
src/images/flag_world.png
|
|
||||||
src/images/folder_icon.png
|
src/images/folder_icon.png
|
||||||
src/images/grid_icon.png
|
src/images/grid_icon.png
|
||||||
src/images/iconsize_icon.png
|
src/images/iconsize_icon.png
|
||||||
|
@ -35,26 +24,9 @@ Files: CMakeSettings.json
|
||||||
src/images/refresh_icon.png
|
src/images/refresh_icon.png
|
||||||
src/images/settings_icon.png
|
src/images/settings_icon.png
|
||||||
src/images/stop_icon.png
|
src/images/stop_icon.png
|
||||||
src/images/shadPS4.icns
|
|
||||||
src/images/shadps4.ico
|
|
||||||
src/images/themes_icon.png
|
src/images/themes_icon.png
|
||||||
src/shadps4.qrc
|
|
||||||
src/shadps4.rc
|
src/shadps4.rc
|
||||||
|
src/shadps4.qrc
|
||||||
|
externals/stb_image.h
|
||||||
Copyright: shadPS4 Emulator Project
|
Copyright: shadPS4 Emulator Project
|
||||||
License: GPL-2.0-or-later
|
License: GPL-2.0-or-later
|
||||||
|
|
||||||
Files: externals/cmake-modules/*
|
|
||||||
Copyright: 2009-2010 Iowa State University
|
|
||||||
License: BSL-1.0
|
|
||||||
|
|
||||||
Files: externals/renderdoc/*
|
|
||||||
Copyright: 2019-2024 Baldur Karlsson
|
|
||||||
License: MIT
|
|
||||||
|
|
||||||
Files: externals/stb_image.h
|
|
||||||
Copyright: 2017 Sean Barrett
|
|
||||||
License: MIT
|
|
||||||
|
|
||||||
Files: externals/tracy/*
|
|
||||||
Copyright: 2017-2024 Bartosz Taudul <wolf@nereid.pl>
|
|
||||||
License: BSD-3-Clause
|
|
||||||
|
|
362
CMakeLists.txt
|
@ -6,24 +6,20 @@ cmake_minimum_required(VERSION 3.16.3)
|
||||||
set(CMAKE_CXX_STANDARD 23)
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||||
|
|
||||||
if(APPLE)
|
|
||||||
enable_language(OBJC)
|
|
||||||
set(CMAKE_OSX_DEPLOYMENT_TARGET 11)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (NOT CMAKE_BUILD_TYPE)
|
if (NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE Release)
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(shadPS4)
|
project(shadps4)
|
||||||
|
|
||||||
option(ENABLE_QT_GUI "Enable the Qt GUI. If not selected then the emulator uses a minimal SDL-based UI instead" OFF)
|
option(ENABLE_QT_GUI "Enable the Qt GUI. If not selected then the emulator uses a minimal SDL-based UI instead" OFF)
|
||||||
|
|
||||||
# This function should be passed a list of all files in a target. It will automatically generate file groups
|
# This function should be passed a list of all files in a target. It will automatically generate
|
||||||
# following the directory hierarchy, so that the layout of the files in IDEs matches the one in the filesystem.
|
# file groups following the directory hierarchy, so that the layout of the files in IDEs matches the
|
||||||
|
# one in the filesystem.
|
||||||
function(create_target_directory_groups target_name)
|
function(create_target_directory_groups target_name)
|
||||||
|
# Place any files that aren't in the source list in a separate group so that they don't get in
|
||||||
# Place any files that aren't in the source list in a separate group so that they don't get in the way.
|
# the way.
|
||||||
source_group("Other Files" REGULAR_EXPRESSION ".")
|
source_group("Other Files" REGULAR_EXPRESSION ".")
|
||||||
|
|
||||||
get_target_property(target_sources "${target_name}" SOURCES)
|
get_target_property(target_sources "${target_name}" SOURCES)
|
||||||
|
@ -36,8 +32,35 @@ function(create_target_directory_groups target_name)
|
||||||
endforeach()
|
endforeach()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
# Setup a custom clang-format target (if clang-format can be found) that will run
|
# Setup a custom clang-format target (if clang-format can be found) that will run
|
||||||
# against all the src files. This should be used before making a pull request.
|
# against all the src files. This should be used before making a pull request.
|
||||||
|
# =======================================================================
|
||||||
|
|
||||||
|
set(CLANG_FORMAT_POSTFIX "-17")
|
||||||
|
find_program(CLANG_FORMAT
|
||||||
|
NAMES clang-format${CLANG_FORMAT_POSTFIX}
|
||||||
|
clang-format
|
||||||
|
PATHS ${PROJECT_BINARY_DIR}/externals)
|
||||||
|
# if find_program doesn't find it, try to download from externals
|
||||||
|
if (NOT CLANG_FORMAT)
|
||||||
|
if (WIN32)
|
||||||
|
message(STATUS "Clang format not found! Downloading...")
|
||||||
|
set(CLANG_FORMAT "${PROJECT_BINARY_DIR}/externals/clang-format${CLANG_FORMAT_POSTFIX}.exe")
|
||||||
|
file(DOWNLOAD
|
||||||
|
https://github.com/citra-emu/ext-windows-bin/raw/master/clang-format${CLANG_FORMAT_POSTFIX}.exe
|
||||||
|
"${CLANG_FORMAT}" SHOW_PROGRESS
|
||||||
|
STATUS DOWNLOAD_SUCCESS)
|
||||||
|
if (NOT DOWNLOAD_SUCCESS EQUAL 0)
|
||||||
|
message(WARNING "Could not download clang format! Disabling the clang format target")
|
||||||
|
file(REMOVE ${CLANG_FORMAT})
|
||||||
|
unset(CLANG_FORMAT)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(WARNING "Clang format not found! Disabling the clang format target")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if (CLANG_FORMAT)
|
if (CLANG_FORMAT)
|
||||||
set(SRCS ${PROJECT_SOURCE_DIR}/src)
|
set(SRCS ${PROJECT_SOURCE_DIR}/src)
|
||||||
set(CCOMMENT "Running clang format against all the .h and .cpp files in src/")
|
set(CCOMMENT "Running clang format against all the .h and .cpp files in src/")
|
||||||
|
@ -54,82 +77,13 @@ if (CLANG_FORMAT)
|
||||||
unset(CCOMMENT)
|
unset(CCOMMENT)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
|
||||||
|
|
||||||
# generate git revision information
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules/")
|
|
||||||
include(GetGitRevisionDescription)
|
|
||||||
get_git_head_revision(GIT_REF_SPEC GIT_REV)
|
|
||||||
git_describe(GIT_DESC --always --long --dirty)
|
|
||||||
git_branch_name(GIT_BRANCH)
|
|
||||||
|
|
||||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/common/scm_rev.cpp.in" "${CMAKE_CURRENT_SOURCE_DIR}/src/common/scm_rev.cpp" @ONLY)
|
|
||||||
|
|
||||||
find_package(Boost 1.84.0 CONFIG)
|
|
||||||
find_package(FFmpeg 5.1.2 MODULE)
|
|
||||||
find_package(fmt 10.2.0 CONFIG)
|
|
||||||
find_package(glslang 14.2.0 CONFIG)
|
|
||||||
find_package(magic_enum 0.9.6 CONFIG)
|
|
||||||
find_package(RenderDoc 1.6.0 MODULE)
|
|
||||||
find_package(SDL3 3.1.2 CONFIG)
|
|
||||||
find_package(toml11 4.2.0 CONFIG)
|
|
||||||
find_package(tsl-robin-map 1.3.0 CONFIG)
|
|
||||||
find_package(VulkanHeaders 1.3.289 CONFIG)
|
|
||||||
find_package(VulkanMemoryAllocator 3.1.0 CONFIG)
|
|
||||||
find_package(xbyak 7.07 CONFIG)
|
|
||||||
find_package(xxHash 0.8.2 MODULE)
|
|
||||||
find_package(zlib-ng 2.1.7 MODULE)
|
|
||||||
find_package(Zydis 5.0.0 CONFIG)
|
|
||||||
|
|
||||||
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR NOT MSVC)
|
|
||||||
find_package(cryptopp 8.9.0 MODULE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (APPLE)
|
|
||||||
find_package(date 3.0.1 CONFIG)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Note: Windows always has these functions through winpthreads
|
|
||||||
include(CheckSymbolExists)
|
|
||||||
check_symbol_exists(pthread_mutex_timedlock "pthread.h" HAVE_PTHREAD_MUTEX_TIMEDLOCK)
|
|
||||||
if(HAVE_PTHREAD_MUTEX_TIMEDLOCK OR WIN32)
|
|
||||||
add_compile_options(-DHAVE_PTHREAD_MUTEX_TIMEDLOCK)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
|
||||||
# libc++ requires -fexperimental-library to enable std::jthread and std::stop_token support.
|
|
||||||
include(CheckCXXSymbolExists)
|
|
||||||
check_cxx_symbol_exists(_LIBCPP_VERSION version LIBCPP)
|
|
||||||
if(LIBCPP)
|
|
||||||
add_compile_options(-fexperimental-library)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_subdirectory(externals)
|
add_subdirectory(externals)
|
||||||
include_directories(src)
|
include_directories(src)
|
||||||
|
|
||||||
if(ENABLE_QT_GUI)
|
if(ENABLE_QT_GUI)
|
||||||
find_package(Qt6 REQUIRED COMPONENTS Widgets Concurrent LinguistTools Network)
|
find_package(Qt6 REQUIRED COMPONENTS Widgets Concurrent)
|
||||||
qt_standard_project_setup()
|
qt_standard_project_setup()
|
||||||
set(CMAKE_AUTORCC ON)
|
set(CMAKE_AUTORCC ON)
|
||||||
set(CMAKE_AUTOMOC ON)
|
|
||||||
set(CMAKE_AUTOUIC ON)
|
|
||||||
|
|
||||||
set(QT_TRANSLATIONS "${PROJECT_SOURCE_DIR}/src/qt_gui/translations")
|
|
||||||
file(GLOB_RECURSE TRANSLATIONS_TS ${QT_TRANSLATIONS}/*.ts)
|
|
||||||
|
|
||||||
set_source_files_properties(${TRANSLATIONS_TS} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/translations")
|
|
||||||
qt_add_translation(TRANSLATIONS_QM ${TRANSLATIONS_TS})
|
|
||||||
|
|
||||||
set(TRANSLATIONS_QRC ${CMAKE_CURRENT_BINARY_DIR}/translations/translations.qrc)
|
|
||||||
file(WRITE ${TRANSLATIONS_QRC} "<RCC><qresource prefix=\"translations\">\n")
|
|
||||||
foreach (QM ${TRANSLATIONS_QM})
|
|
||||||
get_filename_component(QM_FILE ${QM} NAME)
|
|
||||||
file(APPEND ${TRANSLATIONS_QRC} "<file>${QM_FILE}</file>\n")
|
|
||||||
endforeach (QM)
|
|
||||||
file(APPEND ${TRANSLATIONS_QRC} "</qresource></RCC>")
|
|
||||||
|
|
||||||
qt_add_resources(TRANSLATIONS ${TRANSLATIONS_QRC})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(AUDIO_CORE src/audio_core/sdl_audio.cpp
|
set(AUDIO_CORE src/audio_core/sdl_audio.cpp
|
||||||
|
@ -140,15 +94,10 @@ set(AUDIO_LIB src/core/libraries/audio/audioin.cpp
|
||||||
src/core/libraries/audio/audioin.h
|
src/core/libraries/audio/audioin.h
|
||||||
src/core/libraries/audio/audioout.cpp
|
src/core/libraries/audio/audioout.cpp
|
||||||
src/core/libraries/audio/audioout.h
|
src/core/libraries/audio/audioout.h
|
||||||
src/core/libraries/ajm/ajm.cpp
|
|
||||||
src/core/libraries/ajm/ajm.h
|
|
||||||
src/core/libraries/ngs2/ngs2.cpp
|
|
||||||
src/core/libraries/ngs2/ngs2.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(GNM_LIB src/core/libraries/gnmdriver/gnmdriver.cpp
|
set(GNM_LIB src/core/libraries/gnmdriver/gnmdriver.cpp
|
||||||
src/core/libraries/gnmdriver/gnmdriver.h
|
src/core/libraries/gnmdriver/gnmdriver.h
|
||||||
src/core/libraries/gnmdriver/gnm_error.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(KERNEL_LIB
|
set(KERNEL_LIB
|
||||||
|
@ -156,10 +105,6 @@ set(KERNEL_LIB
|
||||||
src/core/libraries/kernel/event_flag/event_flag.h
|
src/core/libraries/kernel/event_flag/event_flag.h
|
||||||
src/core/libraries/kernel/event_flag/event_flag_obj.cpp
|
src/core/libraries/kernel/event_flag/event_flag_obj.cpp
|
||||||
src/core/libraries/kernel/event_flag/event_flag_obj.h
|
src/core/libraries/kernel/event_flag/event_flag_obj.h
|
||||||
src/core/libraries/kernel/threads/rwlock.cpp
|
|
||||||
src/core/libraries/kernel/threads/semaphore.cpp
|
|
||||||
src/core/libraries/kernel/threads/keys.cpp
|
|
||||||
src/core/libraries/kernel/threads/threads.h
|
|
||||||
src/core/libraries/kernel/cpu_management.cpp
|
src/core/libraries/kernel/cpu_management.cpp
|
||||||
src/core/libraries/kernel/cpu_management.h
|
src/core/libraries/kernel/cpu_management.h
|
||||||
src/core/libraries/kernel/event_queue.cpp
|
src/core/libraries/kernel/event_queue.cpp
|
||||||
|
@ -172,6 +117,8 @@ set(KERNEL_LIB
|
||||||
src/core/libraries/kernel/libkernel.h
|
src/core/libraries/kernel/libkernel.h
|
||||||
src/core/libraries/kernel/memory_management.cpp
|
src/core/libraries/kernel/memory_management.cpp
|
||||||
src/core/libraries/kernel/memory_management.h
|
src/core/libraries/kernel/memory_management.h
|
||||||
|
src/core/libraries/kernel/physical_memory.cpp
|
||||||
|
src/core/libraries/kernel/physical_memory.h
|
||||||
src/core/libraries/kernel/thread_management.cpp
|
src/core/libraries/kernel/thread_management.cpp
|
||||||
src/core/libraries/kernel/thread_management.h
|
src/core/libraries/kernel/thread_management.h
|
||||||
src/core/libraries/kernel/time_management.cpp
|
src/core/libraries/kernel/time_management.cpp
|
||||||
|
@ -207,30 +154,6 @@ set(SYSTEM_LIBS src/core/libraries/system/commondialog.cpp
|
||||||
src/core/libraries/system/userservice.h
|
src/core/libraries/system/userservice.h
|
||||||
src/core/libraries/app_content/app_content.cpp
|
src/core/libraries/app_content/app_content.cpp
|
||||||
src/core/libraries/app_content/app_content.h
|
src/core/libraries/app_content/app_content.h
|
||||||
src/core/libraries/rtc/rtc.cpp
|
|
||||||
src/core/libraries/rtc/rtc.h
|
|
||||||
src/core/libraries/rtc/rtc_error.h
|
|
||||||
src/core/libraries/disc_map/disc_map.cpp
|
|
||||||
src/core/libraries/disc_map/disc_map.h
|
|
||||||
src/core/libraries/disc_map/disc_map_codes.h
|
|
||||||
src/core/libraries/avplayer/avplayer_common.cpp
|
|
||||||
src/core/libraries/avplayer/avplayer_common.h
|
|
||||||
src/core/libraries/avplayer/avplayer_file_streamer.cpp
|
|
||||||
src/core/libraries/avplayer/avplayer_file_streamer.h
|
|
||||||
src/core/libraries/avplayer/avplayer_impl.cpp
|
|
||||||
src/core/libraries/avplayer/avplayer_impl.h
|
|
||||||
src/core/libraries/avplayer/avplayer_source.cpp
|
|
||||||
src/core/libraries/avplayer/avplayer_source.h
|
|
||||||
src/core/libraries/avplayer/avplayer_state.cpp
|
|
||||||
src/core/libraries/avplayer/avplayer_state.h
|
|
||||||
src/core/libraries/avplayer/avplayer.cpp
|
|
||||||
src/core/libraries/avplayer/avplayer.h
|
|
||||||
src/core/libraries/ngs2/ngs2.cpp
|
|
||||||
src/core/libraries/ngs2/ngs2.h
|
|
||||||
src/core/libraries/ngs2/ngs2_error.h
|
|
||||||
src/core/libraries/ngs2/ngs2_impl.cpp
|
|
||||||
src/core/libraries/ngs2/ngs2_impl.h
|
|
||||||
src/core/libraries/ajm/ajm_error.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(VIDEOOUT_LIB src/core/libraries/videoout/buffer.h
|
set(VIDEOOUT_LIB src/core/libraries/videoout/buffer.h
|
||||||
|
@ -240,39 +163,28 @@ set(VIDEOOUT_LIB src/core/libraries/videoout/buffer.h
|
||||||
src/core/libraries/videoout/video_out.h
|
src/core/libraries/videoout/video_out.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(LIBC_SOURCES src/core/libraries/libc_internal/libc_internal.cpp
|
set(LIBC_SOURCES src/core/libraries/libc/libc.cpp
|
||||||
|
src/core/libraries/libc/libc.h
|
||||||
|
src/core/libraries/libc/printf.h
|
||||||
|
src/core/libraries/libc/va_ctx.h
|
||||||
|
src/core/libraries/libc/libc_cxa.cpp
|
||||||
|
src/core/libraries/libc/libc_cxa.h
|
||||||
|
src/core/libraries/libc/libc_stdio.cpp
|
||||||
|
src/core/libraries/libc/libc_stdio.h
|
||||||
|
src/core/libraries/libc/libc_math.cpp
|
||||||
|
src/core/libraries/libc/libc_math.h
|
||||||
|
src/core/libraries/libc/libc_string.cpp
|
||||||
|
src/core/libraries/libc/libc_string.h
|
||||||
|
src/core/libraries/libc/libc_stdlib.cpp
|
||||||
|
src/core/libraries/libc/libc_stdlib.h
|
||||||
|
src/core/libraries/libc_internal/libc_internal.cpp
|
||||||
src/core/libraries/libc_internal/libc_internal.h
|
src/core/libraries/libc_internal/libc_internal.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(DIALOGS_LIB src/core/libraries/dialogs/error_dialog.cpp
|
|
||||||
src/core/libraries/dialogs/error_dialog.h
|
|
||||||
src/core/libraries/dialogs/ime_dialog.cpp
|
|
||||||
src/core/libraries/dialogs/ime_dialog.h
|
|
||||||
src/core/libraries/dialogs/error_codes.h
|
|
||||||
)
|
|
||||||
|
|
||||||
set(PAD_LIB src/core/libraries/pad/pad.cpp
|
set(PAD_LIB src/core/libraries/pad/pad.cpp
|
||||||
src/core/libraries/pad/pad.h
|
src/core/libraries/pad/pad.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(PNG_LIB src/core/libraries/libpng/pngdec.cpp
|
|
||||||
src/core/libraries/libpng/pngdec.h
|
|
||||||
)
|
|
||||||
|
|
||||||
set(PLAYGO_LIB src/core/libraries/playgo/playgo.cpp
|
|
||||||
src/core/libraries/playgo/playgo.h
|
|
||||||
src/core/libraries/playgo/playgo_types.h
|
|
||||||
)
|
|
||||||
|
|
||||||
set(RANDOM_LIB src/core/libraries/random/random.cpp
|
|
||||||
src/core/libraries/random/random.h
|
|
||||||
src/core/libraries/random/random_error.h
|
|
||||||
)
|
|
||||||
|
|
||||||
set(USBD_LIB src/core/libraries/usbd/usbd.cpp
|
|
||||||
src/core/libraries/usbd/usbd.h
|
|
||||||
)
|
|
||||||
|
|
||||||
set(NP_LIBS src/core/libraries/np_manager/np_manager.cpp
|
set(NP_LIBS src/core/libraries/np_manager/np_manager.cpp
|
||||||
src/core/libraries/np_manager/np_manager.h
|
src/core/libraries/np_manager/np_manager.h
|
||||||
src/core/libraries/np_score/np_score.cpp
|
src/core/libraries/np_score/np_score.cpp
|
||||||
|
@ -280,7 +192,6 @@ set(NP_LIBS src/core/libraries/np_manager/np_manager.cpp
|
||||||
src/core/libraries/np_trophy/np_trophy.cpp
|
src/core/libraries/np_trophy/np_trophy.cpp
|
||||||
src/core/libraries/np_trophy/np_trophy.h
|
src/core/libraries/np_trophy/np_trophy.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(MISC_LIBS src/core/libraries/screenshot/screenshot.cpp
|
set(MISC_LIBS src/core/libraries/screenshot/screenshot.cpp
|
||||||
src/core/libraries/screenshot/screenshot.h
|
src/core/libraries/screenshot/screenshot.h
|
||||||
)
|
)
|
||||||
|
@ -306,6 +217,8 @@ set(COMMON src/common/logging/backend.cpp
|
||||||
src/common/debug.h
|
src/common/debug.h
|
||||||
src/common/disassembler.cpp
|
src/common/disassembler.cpp
|
||||||
src/common/disassembler.h
|
src/common/disassembler.h
|
||||||
|
src/common/discord.cpp
|
||||||
|
src/common/discord.h
|
||||||
src/common/endian.h
|
src/common/endian.h
|
||||||
src/common/enum.h
|
src/common/enum.h
|
||||||
src/common/io_file.cpp
|
src/common/io_file.cpp
|
||||||
|
@ -318,24 +231,17 @@ set(COMMON src/common/logging/backend.cpp
|
||||||
src/common/native_clock.h
|
src/common/native_clock.h
|
||||||
src/common/path_util.cpp
|
src/common/path_util.cpp
|
||||||
src/common/path_util.h
|
src/common/path_util.h
|
||||||
src/common/object_pool.h
|
|
||||||
src/common/polyfill_thread.h
|
src/common/polyfill_thread.h
|
||||||
src/common/rdtsc.cpp
|
src/common/rdtsc.cpp
|
||||||
src/common/rdtsc.h
|
src/common/rdtsc.h
|
||||||
src/common/singleton.h
|
src/common/singleton.h
|
||||||
src/common/slot_vector.h
|
|
||||||
src/common/string_util.cpp
|
src/common/string_util.cpp
|
||||||
src/common/string_util.h
|
src/common/string_util.h
|
||||||
src/common/thread.cpp
|
src/common/thread.cpp
|
||||||
src/common/thread.h
|
src/common/thread.h
|
||||||
src/common/types.h
|
src/common/types.h
|
||||||
src/common/uint128.h
|
src/common/uint128.h
|
||||||
src/common/unique_function.h
|
|
||||||
src/common/version.h
|
src/common/version.h
|
||||||
src/common/ntapi.h
|
|
||||||
src/common/ntapi.cpp
|
|
||||||
src/common/scm_rev.cpp
|
|
||||||
src/common/scm_rev.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(CORE src/core/aerolib/stubs.cpp
|
set(CORE src/core/aerolib/stubs.cpp
|
||||||
|
@ -344,8 +250,6 @@ set(CORE src/core/aerolib/stubs.cpp
|
||||||
src/core/aerolib/aerolib.h
|
src/core/aerolib/aerolib.h
|
||||||
src/core/address_space.cpp
|
src/core/address_space.cpp
|
||||||
src/core/address_space.h
|
src/core/address_space.h
|
||||||
src/core/cpu_patches.cpp
|
|
||||||
src/core/cpu_patches.h
|
|
||||||
src/core/crypto/crypto.cpp
|
src/core/crypto/crypto.cpp
|
||||||
src/core/crypto/crypto.h
|
src/core/crypto/crypto.h
|
||||||
src/core/crypto/keys.h
|
src/core/crypto/keys.h
|
||||||
|
@ -356,18 +260,12 @@ set(CORE src/core/aerolib/stubs.cpp
|
||||||
src/core/file_format/pkg_type.h
|
src/core/file_format/pkg_type.h
|
||||||
src/core/file_format/psf.cpp
|
src/core/file_format/psf.cpp
|
||||||
src/core/file_format/psf.h
|
src/core/file_format/psf.h
|
||||||
src/core/file_format/playgo_chunk.cpp
|
|
||||||
src/core/file_format/playgo_chunk.h
|
|
||||||
src/core/file_format/trp.cpp
|
|
||||||
src/core/file_format/trp.h
|
|
||||||
src/core/file_format/splash.h
|
src/core/file_format/splash.h
|
||||||
src/core/file_format/splash.cpp
|
src/core/file_format/splash.cpp
|
||||||
src/core/file_sys/fs.cpp
|
src/core/file_sys/fs.cpp
|
||||||
src/core/file_sys/fs.h
|
src/core/file_sys/fs.h
|
||||||
src/core/loader.cpp
|
src/core/loader.cpp
|
||||||
src/core/loader.h
|
src/core/loader.h
|
||||||
src/core/loader/dwarf.cpp
|
|
||||||
src/core/loader/dwarf.h
|
|
||||||
src/core/loader/elf.cpp
|
src/core/loader/elf.cpp
|
||||||
src/core/loader/elf.h
|
src/core/loader/elf.h
|
||||||
src/core/loader/symbols_resolver.h
|
src/core/loader/symbols_resolver.h
|
||||||
|
@ -384,12 +282,7 @@ set(CORE src/core/aerolib/stubs.cpp
|
||||||
${PAD_LIB}
|
${PAD_LIB}
|
||||||
${VIDEOOUT_LIB}
|
${VIDEOOUT_LIB}
|
||||||
${NP_LIBS}
|
${NP_LIBS}
|
||||||
${PNG_LIB}
|
|
||||||
${PLAYGO_LIB}
|
|
||||||
${RANDOM_LIB}
|
|
||||||
${USBD_LIB}
|
|
||||||
${MISC_LIBS}
|
${MISC_LIBS}
|
||||||
${DIALOGS_LIB}
|
|
||||||
src/core/linker.cpp
|
src/core/linker.cpp
|
||||||
src/core/linker.h
|
src/core/linker.h
|
||||||
src/core/memory.cpp
|
src/core/memory.cpp
|
||||||
|
@ -404,14 +297,13 @@ set(CORE src/core/aerolib/stubs.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(SHADER_RECOMPILER src/shader_recompiler/exception.h
|
set(SHADER_RECOMPILER src/shader_recompiler/exception.h
|
||||||
|
src/shader_recompiler/object_pool.h
|
||||||
src/shader_recompiler/profile.h
|
src/shader_recompiler/profile.h
|
||||||
src/shader_recompiler/recompiler.cpp
|
src/shader_recompiler/recompiler.cpp
|
||||||
src/shader_recompiler/recompiler.h
|
src/shader_recompiler/recompiler.h
|
||||||
src/shader_recompiler/runtime_info.h
|
src/shader_recompiler/runtime_info.h
|
||||||
src/shader_recompiler/backend/spirv/emit_spirv.cpp
|
src/shader_recompiler/backend/spirv/emit_spirv.cpp
|
||||||
src/shader_recompiler/backend/spirv/emit_spirv.h
|
src/shader_recompiler/backend/spirv/emit_spirv.h
|
||||||
src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp
|
|
||||||
src/shader_recompiler/backend/spirv/emit_spirv_barriers.cpp
|
|
||||||
src/shader_recompiler/backend/spirv/emit_spirv_bitwise_conversion.cpp
|
src/shader_recompiler/backend/spirv/emit_spirv_bitwise_conversion.cpp
|
||||||
src/shader_recompiler/backend/spirv/emit_spirv_composite.cpp
|
src/shader_recompiler/backend/spirv/emit_spirv_composite.cpp
|
||||||
src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp
|
src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp
|
||||||
|
@ -422,14 +314,13 @@ set(SHADER_RECOMPILER src/shader_recompiler/exception.h
|
||||||
src/shader_recompiler/backend/spirv/emit_spirv_integer.cpp
|
src/shader_recompiler/backend/spirv/emit_spirv_integer.cpp
|
||||||
src/shader_recompiler/backend/spirv/emit_spirv_logical.cpp
|
src/shader_recompiler/backend/spirv/emit_spirv_logical.cpp
|
||||||
src/shader_recompiler/backend/spirv/emit_spirv_select.cpp
|
src/shader_recompiler/backend/spirv/emit_spirv_select.cpp
|
||||||
src/shader_recompiler/backend/spirv/emit_spirv_shared_memory.cpp
|
|
||||||
src/shader_recompiler/backend/spirv/emit_spirv_special.cpp
|
src/shader_recompiler/backend/spirv/emit_spirv_special.cpp
|
||||||
src/shader_recompiler/backend/spirv/emit_spirv_undefined.cpp
|
src/shader_recompiler/backend/spirv/emit_spirv_undefined.cpp
|
||||||
src/shader_recompiler/backend/spirv/emit_spirv_warp.cpp
|
|
||||||
src/shader_recompiler/backend/spirv/spirv_emit_context.cpp
|
src/shader_recompiler/backend/spirv/spirv_emit_context.cpp
|
||||||
src/shader_recompiler/backend/spirv/spirv_emit_context.h
|
src/shader_recompiler/backend/spirv/spirv_emit_context.h
|
||||||
src/shader_recompiler/frontend/translate/data_share.cpp
|
src/shader_recompiler/frontend/translate/data_share.cpp
|
||||||
src/shader_recompiler/frontend/translate/export.cpp
|
src/shader_recompiler/frontend/translate/export.cpp
|
||||||
|
src/shader_recompiler/frontend/translate/flat_memory.cpp
|
||||||
src/shader_recompiler/frontend/translate/scalar_alu.cpp
|
src/shader_recompiler/frontend/translate/scalar_alu.cpp
|
||||||
src/shader_recompiler/frontend/translate/scalar_memory.cpp
|
src/shader_recompiler/frontend/translate/scalar_memory.cpp
|
||||||
src/shader_recompiler/frontend/translate/translate.cpp
|
src/shader_recompiler/frontend/translate/translate.cpp
|
||||||
|
@ -449,11 +340,10 @@ set(SHADER_RECOMPILER src/shader_recompiler/exception.h
|
||||||
src/shader_recompiler/frontend/opcodes.h
|
src/shader_recompiler/frontend/opcodes.h
|
||||||
src/shader_recompiler/frontend/structured_control_flow.cpp
|
src/shader_recompiler/frontend/structured_control_flow.cpp
|
||||||
src/shader_recompiler/frontend/structured_control_flow.h
|
src/shader_recompiler/frontend/structured_control_flow.h
|
||||||
src/shader_recompiler/ir/passes/constant_propagation_pass.cpp
|
src/shader_recompiler/ir/passes/constant_propogation_pass.cpp
|
||||||
src/shader_recompiler/ir/passes/dead_code_elimination_pass.cpp
|
src/shader_recompiler/ir/passes/dead_code_elimination_pass.cpp
|
||||||
src/shader_recompiler/ir/passes/identity_removal_pass.cpp
|
src/shader_recompiler/ir/passes/identity_removal_pass.cpp
|
||||||
src/shader_recompiler/ir/passes/ir_passes.h
|
src/shader_recompiler/ir/passes/ir_passes.h
|
||||||
src/shader_recompiler/ir/passes/lower_shared_mem_to_registers.cpp
|
|
||||||
src/shader_recompiler/ir/passes/resource_tracking_pass.cpp
|
src/shader_recompiler/ir/passes/resource_tracking_pass.cpp
|
||||||
src/shader_recompiler/ir/passes/shader_info_collection_pass.cpp
|
src/shader_recompiler/ir/passes/shader_info_collection_pass.cpp
|
||||||
src/shader_recompiler/ir/passes/ssa_rewrite_pass.cpp
|
src/shader_recompiler/ir/passes/ssa_rewrite_pass.cpp
|
||||||
|
@ -487,14 +377,18 @@ set(VIDEO_CORE src/video_core/amdgpu/liverpool.cpp
|
||||||
src/video_core/amdgpu/pm4_cmds.h
|
src/video_core/amdgpu/pm4_cmds.h
|
||||||
src/video_core/amdgpu/pm4_opcodes.h
|
src/video_core/amdgpu/pm4_opcodes.h
|
||||||
src/video_core/amdgpu/resource.h
|
src/video_core/amdgpu/resource.h
|
||||||
src/video_core/amdgpu/default_context.cpp
|
src/video_core/amdgpu/gpuaddr/dataformat.cpp
|
||||||
src/video_core/buffer_cache/buffer.cpp
|
src/video_core/amdgpu/gpuaddr/dataformat.h
|
||||||
src/video_core/buffer_cache/buffer.h
|
src/video_core/amdgpu/gpuaddr/element.cpp
|
||||||
src/video_core/buffer_cache/buffer_cache.cpp
|
src/video_core/amdgpu/gpuaddr/error.cpp
|
||||||
src/video_core/buffer_cache/buffer_cache.h
|
src/video_core/amdgpu/gpuaddr/error.h
|
||||||
src/video_core/buffer_cache/memory_tracker_base.h
|
src/video_core/amdgpu/gpuaddr/gpuaddr.h
|
||||||
src/video_core/buffer_cache/range_set.h
|
src/video_core/amdgpu/gpuaddr/gpuaddr_private.h
|
||||||
src/video_core/buffer_cache/word_manager.h
|
src/video_core/amdgpu/gpuaddr/surface.cpp
|
||||||
|
src/video_core/amdgpu/gpuaddr/surfgen.cpp
|
||||||
|
src/video_core/amdgpu/gpuaddr/tilemodes.cpp
|
||||||
|
src/video_core/amdgpu/gpuaddr/tiler.cpp
|
||||||
|
src/video_core/amdgpu/gpuaddr/types.h
|
||||||
src/video_core/renderer_vulkan/liverpool_to_vk.cpp
|
src/video_core/renderer_vulkan/liverpool_to_vk.cpp
|
||||||
src/video_core/renderer_vulkan/liverpool_to_vk.h
|
src/video_core/renderer_vulkan/liverpool_to_vk.h
|
||||||
src/video_core/renderer_vulkan/renderer_vulkan.cpp
|
src/video_core/renderer_vulkan/renderer_vulkan.cpp
|
||||||
|
@ -521,57 +415,42 @@ set(VIDEO_CORE src/video_core/amdgpu/liverpool.cpp
|
||||||
src/video_core/renderer_vulkan/vk_resource_pool.h
|
src/video_core/renderer_vulkan/vk_resource_pool.h
|
||||||
src/video_core/renderer_vulkan/vk_scheduler.cpp
|
src/video_core/renderer_vulkan/vk_scheduler.cpp
|
||||||
src/video_core/renderer_vulkan/vk_scheduler.h
|
src/video_core/renderer_vulkan/vk_scheduler.h
|
||||||
src/video_core/renderer_vulkan/vk_shader_cache.cpp
|
|
||||||
src/video_core/renderer_vulkan/vk_shader_cache.h
|
|
||||||
src/video_core/renderer_vulkan/vk_shader_util.cpp
|
src/video_core/renderer_vulkan/vk_shader_util.cpp
|
||||||
src/video_core/renderer_vulkan/vk_shader_util.h
|
src/video_core/renderer_vulkan/vk_shader_util.h
|
||||||
|
src/video_core/renderer_vulkan/vk_stream_buffer.cpp
|
||||||
|
src/video_core/renderer_vulkan/vk_stream_buffer.h
|
||||||
src/video_core/renderer_vulkan/vk_swapchain.cpp
|
src/video_core/renderer_vulkan/vk_swapchain.cpp
|
||||||
src/video_core/renderer_vulkan/vk_swapchain.h
|
src/video_core/renderer_vulkan/vk_swapchain.h
|
||||||
src/video_core/texture_cache/image.cpp
|
src/video_core/texture_cache/image.cpp
|
||||||
src/video_core/texture_cache/image.h
|
src/video_core/texture_cache/image.h
|
||||||
src/video_core/texture_cache/image_info.cpp
|
|
||||||
src/video_core/texture_cache/image_info.h
|
|
||||||
src/video_core/texture_cache/image_view.cpp
|
src/video_core/texture_cache/image_view.cpp
|
||||||
src/video_core/texture_cache/image_view.h
|
src/video_core/texture_cache/image_view.h
|
||||||
src/video_core/texture_cache/sampler.cpp
|
src/video_core/texture_cache/sampler.cpp
|
||||||
src/video_core/texture_cache/sampler.h
|
src/video_core/texture_cache/sampler.h
|
||||||
|
src/video_core/texture_cache/slot_vector.h
|
||||||
src/video_core/texture_cache/texture_cache.cpp
|
src/video_core/texture_cache/texture_cache.cpp
|
||||||
src/video_core/texture_cache/texture_cache.h
|
src/video_core/texture_cache/texture_cache.h
|
||||||
src/video_core/texture_cache/tile_manager.cpp
|
src/video_core/texture_cache/tile_manager.cpp
|
||||||
src/video_core/texture_cache/tile_manager.h
|
src/video_core/texture_cache/tile_manager.h
|
||||||
src/video_core/texture_cache/types.h
|
src/video_core/texture_cache/types.h
|
||||||
src/video_core/page_manager.cpp
|
|
||||||
src/video_core/page_manager.h
|
|
||||||
src/video_core/multi_level_page_table.h
|
|
||||||
src/video_core/renderdoc.cpp
|
|
||||||
src/video_core/renderdoc.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(INPUT src/input/controller.cpp
|
set(INPUT src/input/controller.cpp
|
||||||
src/input/controller.h
|
src/input/controller.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(EMULATOR src/emulator.cpp
|
# the above is shared in sdl and qt version (TODO share them all)
|
||||||
src/emulator.h
|
|
||||||
src/sdl_window.h
|
|
||||||
src/sdl_window.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
# The above is shared in SDL and Qt version (TODO share them all)
|
|
||||||
|
|
||||||
if(ENABLE_QT_GUI)
|
if(ENABLE_QT_GUI)
|
||||||
qt_add_resources(RESOURCE_FILES src/shadps4.qrc)
|
qt_add_resources(RESOURCE_FILES src/shadps4.qrc)
|
||||||
|
|
||||||
set(QT_GUI src/qt_gui/about_dialog.cpp
|
set(QT_GUI
|
||||||
src/qt_gui/about_dialog.h
|
|
||||||
src/qt_gui/about_dialog.ui
|
|
||||||
src/qt_gui/cheats_patches.cpp
|
|
||||||
src/qt_gui/cheats_patches.h
|
|
||||||
src/qt_gui/memory_patcher.cpp
|
|
||||||
src/qt_gui/memory_patcher.h
|
|
||||||
src/qt_gui/main_window_ui.h
|
src/qt_gui/main_window_ui.h
|
||||||
src/qt_gui/main_window.cpp
|
src/qt_gui/main_window.cpp
|
||||||
src/qt_gui/main_window.h
|
src/qt_gui/main_window.h
|
||||||
|
src/qt_gui/gui_settings.cpp
|
||||||
|
src/qt_gui/gui_settings.h
|
||||||
|
src/qt_gui/gui_save.h
|
||||||
src/qt_gui/gui_context_menus.h
|
src/qt_gui/gui_context_menus.h
|
||||||
src/qt_gui/game_list_utils.h
|
src/qt_gui/game_list_utils.h
|
||||||
src/qt_gui/game_info.cpp
|
src/qt_gui/game_info.cpp
|
||||||
|
@ -584,19 +463,12 @@ set(QT_GUI src/qt_gui/about_dialog.cpp
|
||||||
src/qt_gui/game_install_dialog.h
|
src/qt_gui/game_install_dialog.h
|
||||||
src/qt_gui/pkg_viewer.cpp
|
src/qt_gui/pkg_viewer.cpp
|
||||||
src/qt_gui/pkg_viewer.h
|
src/qt_gui/pkg_viewer.h
|
||||||
src/qt_gui/trophy_viewer.cpp
|
src/qt_gui/settings.cpp
|
||||||
src/qt_gui/trophy_viewer.h
|
src/qt_gui/settings.h
|
||||||
src/qt_gui/elf_viewer.cpp
|
|
||||||
src/qt_gui/elf_viewer.h
|
|
||||||
src/qt_gui/main_window_themes.cpp
|
src/qt_gui/main_window_themes.cpp
|
||||||
src/qt_gui/main_window_themes.h
|
src/qt_gui/main_window_themes.h
|
||||||
src/qt_gui/settings_dialog.cpp
|
|
||||||
src/qt_gui/settings_dialog.h
|
|
||||||
src/qt_gui/settings_dialog.ui
|
|
||||||
src/qt_gui/main.cpp
|
src/qt_gui/main.cpp
|
||||||
${EMULATOR}
|
|
||||||
${RESOURCE_FILES}
|
${RESOURCE_FILES}
|
||||||
${TRANSLATIONS}
|
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -609,8 +481,8 @@ if (ENABLE_QT_GUI)
|
||||||
${CORE}
|
${CORE}
|
||||||
${SHADER_RECOMPILER}
|
${SHADER_RECOMPILER}
|
||||||
${VIDEO_CORE}
|
${VIDEO_CORE}
|
||||||
${EMULATOR}
|
src/sdl_window.h
|
||||||
src/images/shadPS4.icns
|
src/sdl_window.cpp
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
add_executable(shadps4
|
add_executable(shadps4
|
||||||
|
@ -620,10 +492,7 @@ else()
|
||||||
${CORE}
|
${CORE}
|
||||||
${SHADER_RECOMPILER}
|
${SHADER_RECOMPILER}
|
||||||
${VIDEO_CORE}
|
${VIDEO_CORE}
|
||||||
${EMULATOR}
|
|
||||||
src/main.cpp
|
src/main.cpp
|
||||||
src/emulator.cpp
|
|
||||||
src/emulator.h
|
|
||||||
src/sdl_window.h
|
src/sdl_window.h
|
||||||
src/sdl_window.cpp
|
src/sdl_window.cpp
|
||||||
)
|
)
|
||||||
|
@ -631,82 +500,47 @@ endif()
|
||||||
|
|
||||||
create_target_directory_groups(shadps4)
|
create_target_directory_groups(shadps4)
|
||||||
|
|
||||||
target_link_libraries(shadps4 PRIVATE magic_enum::magic_enum fmt::fmt toml11::toml11 tsl::robin_map xbyak::xbyak Tracy::TracyClient RenderDoc::API FFmpeg::ffmpeg)
|
target_link_libraries(shadps4 PRIVATE magic_enum::magic_enum fmt::fmt toml11::toml11 tsl::robin_map xbyak)
|
||||||
target_link_libraries(shadps4 PRIVATE Boost::headers GPUOpen::VulkanMemoryAllocator sirit Vulkan::Headers xxHash::xxhash Zydis::Zydis glslang::SPIRV glslang::glslang SDL3::SDL3)
|
target_link_libraries(shadps4 PRIVATE discord-rpc boost vma sirit vulkan-headers xxhash Zydis SPIRV glslang SDL3-shared)
|
||||||
|
|
||||||
if (APPLE)
|
|
||||||
# Reserve system-managed memory space.
|
|
||||||
target_link_options(shadps4 PRIVATE -Wl,-no_pie,-no_fixup_chains,-no_huge,-pagezero_size,0x400000,-segaddr,GUEST_SYSTEM,0x400000,-image_base,0x10000000000)
|
|
||||||
|
|
||||||
# Link MoltenVK for Vulkan support
|
|
||||||
find_library(MOLTENVK MoltenVK REQUIRED)
|
|
||||||
target_link_libraries(shadps4 PRIVATE ${MOLTENVK})
|
|
||||||
|
|
||||||
# Replacement for std::chrono::time_zone
|
|
||||||
target_link_libraries(shadps4 PRIVATE date::date-tz)
|
|
||||||
|
|
||||||
# Half float conversions for F16C patches
|
|
||||||
target_link_libraries(shadps4 PRIVATE half)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (NOT ENABLE_QT_GUI)
|
if (NOT ENABLE_QT_GUI)
|
||||||
target_link_libraries(shadps4 PRIVATE SDL3::SDL3)
|
target_link_libraries(shadps4 PRIVATE SDL3-shared)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND MSVC)
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND MSVC)
|
||||||
target_link_libraries(shadps4 PRIVATE cryptoppwin zlib-ng::zlib)
|
target_link_libraries(shadps4 PRIVATE cryptoppwin zlib)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(shadps4 PRIVATE cryptopp::cryptopp zlib-ng::zlib)
|
target_link_libraries(shadps4 PRIVATE cryptopp::cryptopp zlib)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ENABLE_QT_GUI)
|
if (ENABLE_QT_GUI)
|
||||||
target_link_libraries(shadps4 PRIVATE Qt6::Widgets Qt6::Concurrent Qt6::Network)
|
target_link_libraries(shadps4 PRIVATE Qt6::Widgets Qt6::Concurrent)
|
||||||
add_definitions(-DENABLE_QT_GUI)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_link_libraries(shadps4 PRIVATE mincore winpthreads)
|
target_link_libraries(shadps4 PRIVATE mincore winpthreads clang_rt.builtins-x86_64.lib)
|
||||||
|
|
||||||
if (MSVC)
|
|
||||||
# MSVC likes putting opinions on what people can use, disable:
|
|
||||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
|
||||||
endif()
|
|
||||||
|
|
||||||
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN)
|
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN)
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
# Needed for conflicts with time.h of windows.h
|
# Needed for conflicts with time.h of windows.h
|
||||||
add_definitions(-D_TIMESPEC_DEFINED)
|
add_definitions(-D_TIMESPEC_DEFINED)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Target Windows 10 RS5
|
# Target Windows 10 RS5
|
||||||
add_definitions(-DNTDDI_VERSION=0x0A000006 -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00)
|
add_definitions(-DNTDDI_VERSION=0x0A000006 -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00)
|
||||||
|
# Increase stack commit area
|
||||||
if (MSVC)
|
target_link_options(shadps4 PRIVATE /STACK:0x200000,0x200000)
|
||||||
target_link_libraries(shadps4 PRIVATE clang_rt.builtins-x86_64.lib)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Disable ASLR so we can reserve the user area
|
# Disable ASLR so we can reserve the user area
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
target_link_options(shadps4 PRIVATE /DYNAMICBASE:NO)
|
target_link_options(shadps4 PRIVATE /DYNAMICBASE:NO)
|
||||||
else()
|
else()
|
||||||
target_link_options(shadps4 PRIVATE -Wl,--disable-dynamicbase)
|
target_link_options(shadps4 PRIVATE -Wl,--disable-dynamicbase)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Increase stack commit area (Needed, otherwise there are crashes)
|
|
||||||
if (MSVC)
|
|
||||||
target_link_options(shadps4 PRIVATE /STACK:0x200000,0x200000)
|
|
||||||
else()
|
|
||||||
target_link_options(shadps4 PRIVATE -Wl,--stack,2097152)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_sources(shadps4 PRIVATE src/shadps4.rc)
|
target_sources(shadps4 PRIVATE src/shadps4.rc)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_definitions(-DBOOST_ASIO_STANDALONE)
|
|
||||||
|
|
||||||
target_include_directories(shadps4 PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
target_include_directories(shadps4 PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
# Shaders sources
|
# Shaders sources
|
||||||
|
@ -718,10 +552,16 @@ target_include_directories(shadps4 PRIVATE ${HOST_SHADERS_INCLUDE})
|
||||||
|
|
||||||
if (ENABLE_QT_GUI)
|
if (ENABLE_QT_GUI)
|
||||||
set_target_properties(shadps4 PROPERTIES
|
set_target_properties(shadps4 PROPERTIES
|
||||||
# WIN32_EXECUTABLE ON
|
WIN32_EXECUTABLE ON
|
||||||
MACOSX_BUNDLE ON
|
MACOSX_BUNDLE ON)
|
||||||
MACOSX_BUNDLE_ICON_FILE shadPS4.icns)
|
|
||||||
|
|
||||||
set_source_files_properties(src/images/shadPS4.icns PROPERTIES
|
|
||||||
MACOSX_PACKAGE_LOCATION Resources)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
add_custom_command(TARGET shadps4 POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
|
$<TARGET_FILE:zlib>
|
||||||
|
$<TARGET_FILE_DIR:shadps4>)
|
||||||
|
|
||||||
|
add_custom_command(TARGET shadps4 POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
|
$<TARGET_FILE:SDL3-shared>
|
||||||
|
$<TARGET_FILE_DIR:shadps4>)
|
||||||
|
|
|
@ -1,33 +1,22 @@
|
||||||
{
|
{
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
|
||||||
"name": "x64-Clang-Release",
|
|
||||||
"generator": "Ninja",
|
|
||||||
"configurationType": "Release",
|
|
||||||
"buildRoot": "${projectDir}\\Build\\${name}",
|
|
||||||
"installRoot": "${projectDir}\\Install\\${name}",
|
|
||||||
"cmakeCommandArgs": "",
|
|
||||||
"buildCommandArgs": "",
|
|
||||||
"ctestCommandArgs": "",
|
|
||||||
"inheritEnvironments": [ "clang_cl_x64_x64" ]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "x64-Clang-Debug",
|
"name": "x64-Clang-Debug",
|
||||||
"generator": "Ninja",
|
"generator": "Ninja",
|
||||||
"configurationType": "Debug",
|
"configurationType": "Debug",
|
||||||
"buildRoot": "${projectDir}\\Build\\${name}",
|
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||||
"installRoot": "${projectDir}\\Install\\${name}",
|
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||||
"cmakeCommandArgs": "",
|
"cmakeCommandArgs": "",
|
||||||
"buildCommandArgs": "",
|
"buildCommandArgs": "",
|
||||||
"ctestCommandArgs": "",
|
"ctestCommandArgs": "",
|
||||||
"inheritEnvironments": [ "clang_cl_x64_x64" ]
|
"inheritEnvironments": [ "clang_cl_x64_x64" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "x64-Clang-RelWithDebInfo",
|
"name": "x64-Clang-Release",
|
||||||
"generator": "Ninja",
|
"generator": "Ninja",
|
||||||
"configurationType": "RelWithDebInfo",
|
"configurationType": "RelWithDebInfo",
|
||||||
"buildRoot": "${projectDir}\\Build\\${name}",
|
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||||
"installRoot": "${projectDir}\\Install\\${name}",
|
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||||
"cmakeCommandArgs": "",
|
"cmakeCommandArgs": "",
|
||||||
"buildCommandArgs": "",
|
"buildCommandArgs": "",
|
||||||
"ctestCommandArgs": "",
|
"ctestCommandArgs": "",
|
||||||
|
|
|
@ -31,7 +31,7 @@ Follow the indentation/whitespace style shown below. Do not use tabs, use 4-spac
|
||||||
* For doc-comments (Doxygen comments), use /// if it's a single line, else use the /** */ style featured in the example. Start the text on the second line, not the first containing /**.
|
* For doc-comments (Doxygen comments), use /// if it's a single line, else use the /** */ style featured in the example. Start the text on the second line, not the first containing /**.
|
||||||
* For items that are both defined and declared in two separate files, put the doc-comment only next to the associated declaration. (In a header file, usually.) Otherwise, put it next to the implementation. Never duplicate doc-comments in both places.
|
* For items that are both defined and declared in two separate files, put the doc-comment only next to the associated declaration. (In a header file, usually.) Otherwise, put it next to the implementation. Never duplicate doc-comments in both places.
|
||||||
|
|
||||||
```c++
|
```
|
||||||
// Includes should be sorted lexicographically
|
// Includes should be sorted lexicographically
|
||||||
// STD includes first
|
// STD includes first
|
||||||
#include <array>
|
#include <array>
|
||||||
|
@ -69,7 +69,7 @@ enum class SomeEnum {
|
||||||
* Note that the asterisks are indented by one space to align to the first line.
|
* Note that the asterisks are indented by one space to align to the first line.
|
||||||
*/
|
*/
|
||||||
struct Position {
|
struct Position {
|
||||||
// Always initialize member variables!
|
// Always intitialize member variables!
|
||||||
int x{};
|
int x{};
|
||||||
int y{};
|
int y{};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
Boost Software License - Version 1.0 - August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
153
README.md
|
@ -9,155 +9,96 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
<br>
|
<br>
|
||||||
<b>shadPS4</b>
|
<b>shadPS4</b>
|
||||||
<br>
|
<br>
|
||||||
</h1>
|
|
||||||
|
|
||||||
<h1 align="center">
|
|
||||||
<a href="https://discord.gg/MyZRaBngxA">
|
|
||||||
<img src="https://img.shields.io/discord/1080089157554155590?color=5865F2&label=shadPS4 Discord&logo=Discord&logoColor=white" width="240">
|
|
||||||
<a href="https://github.com/shadps4-emu/shadPS4/releases/latest">
|
|
||||||
<img src="https://img.shields.io/github/downloads/shadps4-emu/shadPS4/total.svg" width="140">
|
|
||||||
<a href="https://shadps4.net/">
|
|
||||||
<img src="https://img.shields.io/badge/shadPS4-website-8A2BE2" width="150">
|
|
||||||
<a href="https://x.com/shadps4">
|
|
||||||
<img src="https://img.shields.io/badge/-Join%20us-black?logo=X&logoColor=white" width="100">
|
|
||||||
<a href="https://github.com/shadps4-emu/shadPS4/stargazers">
|
|
||||||
<img src="https://img.shields.io/github/stars/shadps4-emu/shadPS4" width="120">
|
|
||||||
</h1>
|
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
|
|
||||||
|
<a href="https://discord.gg/MyZRaBngxA">
|
||||||
|
<img src="https://img.shields.io/discord/1080089157554155590?color=5865F2&label=shadPS4 Discord&logo=Discord&logoColor=white" width="240">
|
||||||
|
|
||||||
|
<a href="https://github.com/shadps4-emu/shadPS4/releases/latest">
|
||||||
|
<img src="https://img.shields.io/github/downloads/shadps4-emu/shadPS4/total.svg" width="140">
|
||||||
|
|
||||||
<a href="https://shadps4.net/">
|
<a href="https://shadps4.net/">
|
||||||
<img src="https://github.com/shadps4-emu/shadPS4/blob/main/documents/Screenshots/Sonic Mania.png" width="400">
|
<img src="https://img.shields.io/badge/shadPS4-website-8A2BE2" width="150">
|
||||||
<img src="https://github.com/shadps4-emu/shadPS4/blob/main/documents/Screenshots/Bloodborne.png" width="400">
|
|
||||||
<img src="https://github.com/shadps4-emu/shadPS4/blob/main/documents/Screenshots/Undertale.png" width="400">
|
|
||||||
<img src="https://github.com/shadps4-emu/shadPS4/blob/main/documents/Screenshots/We are DOOMED.png" width="400">
|
|
||||||
</p>
|
|
||||||
|
|
||||||
# General information
|
<a href="https://x.com/shadps4">
|
||||||
|
<img src="https://img.shields.io/badge/-Join%20us-black?logo=X&logoColor=white" width="100">
|
||||||
|
|
||||||
shadPS4 is an early **PlayStation 4** emulator for **Windows**, **Linux** and **macOS** written in C++.
|
<a href="https://github.com/shadps4-emu/shadPS4/stargazers">
|
||||||
|
<img src="https://img.shields.io/github/stars/shadps4-emu/shadPS4" width="120">
|
||||||
|
|
||||||
If you encounter problems or have doubts, do not hesitate to look at the [**Quickstart**](https://github.com/shadps4-emu/shadPS4/blob/main/documents/Quickstart/Quickstart.md).
|
<h1 align="center">
|
||||||
|
<br>
|
||||||
|
<a href="https://shadps4.net/"><img src="https://github.com/shadps4-emu/shadPS4/blob/main/documents/Screenshots/screenshot.png" width="550"></a>
|
||||||
|
<br>
|
||||||
|
|
||||||
To verify that a game works, you can look at [**shadPS4 Game Compatibility**](https://github.com/shadps4-emu/shadps4-game-compatibility).
|
# shadPS4
|
||||||
|
|
||||||
To discuss shadPS4 development, suggest ideas or to ask for help, join our [**Discord server**](https://discord.gg/MyZRaBngxA).
|
shadPS4 is an early PS4 emulator for Windows and Linux written in C++
|
||||||
|
|
||||||
To get the latest news, go to our [**X (Twitter)**](https://x.com/shadps4) or our [**website**](https://shadps4.net/).
|
To discuss shadPS4 development or suggest ideas, join the [Discord server](https://discord.gg/MyZRaBngxA)
|
||||||
|
|
||||||
|
Check us on [X (twitter)](https://x.com/shadps4) or on our [website](https://shadps4.net/).
|
||||||
|
|
||||||
# Status
|
# Status
|
||||||
|
|
||||||
> [!IMPORTANT]
|
In development, 2D games are working like [Sonic Mania](https://www.youtube.com/watch?v=AAHoNzhHyCU), Undertale, Momodora and others...
|
||||||
> shadPS4 is early in developement, don't expect a flawless experience.
|
|
||||||
|
|
||||||
Currently, the emulator successfully runs small games like [**Sonic Mania**](https://www.youtube.com/watch?v=AAHoNzhHyCU), [**Undertale**](https://youtu.be/5zIvdy65Ro4) and it can even *somewhat* run [**Bloodborne**](https://www.youtube.com/watch?v=wC6s0avpQRE).
|
# Why?
|
||||||
|
|
||||||
# Why
|
The project started as a fun project. Due to limited free time, it will probably take a while before shadPS4 is able to run anything decent, but we're trying to make small, regular commits.
|
||||||
|
|
||||||
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.
|
# Build
|
||||||
|
|
||||||
# Building
|
|
||||||
|
|
||||||
## Windows
|
## Windows
|
||||||
|
|
||||||
Check the build instructions for [**Windows**](https://github.com/shadps4-emu/shadPS4/blob/main/documents/building-windows.md).
|
Check the build instructions for [Windows](https://github.com/shadps4-emu/shadPS4/blob/main/documents/building-windows.md).
|
||||||
|
|
||||||
## Linux
|
## Linux
|
||||||
|
|
||||||
Check the build instructions for [**Linux**](https://github.com/shadps4-emu/shadPS4/blob/main/documents/building-linux.md).
|
Check the build instructions for [Linux](https://github.com/shadps4-emu/shadPS4/blob/main/documents/linux_building.md).
|
||||||
|
|
||||||
## Building status
|
## Build status
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary><b>Windows</b></summary>
|
|
||||||
|
|
||||||
|Windows|Build status|
|
|Windows|Build status|
|
||||||
|--------|--------|
|
|--------|------------|
|
||||||
|Windows SDL Build|[![Windows-sdl](https://github.com/shadps4-emu/shadPS4/actions/workflows/windows.yml/badge.svg)](https://github.com/shadps4-emu/shadPS4/actions/workflows/windows.yml)
|
|Windows SDL Build|[![Windows-sdl](https://github.com/shadps4-emu/shadPS4/actions/workflows/windows.yml/badge.svg)](https://github.com/shadps4-emu/shadPS4/actions/workflows/windows.yml)
|
||||||
|Windows Qt Build|[![Windows-qt](https://github.com/shadps4-emu/shadPS4/actions/workflows/windows-qt.yml/badge.svg)](https://github.com/shadps4-emu/shadPS4/actions/workflows/windows-qt.yml)
|
|Windows Qt Build|[![Windows-qt](https://github.com/shadps4-emu/shadPS4/actions/workflows/windows-qt.yml/badge.svg)](https://github.com/shadps4-emu/shadPS4/actions/workflows/windows-qt.yml)
|
||||||
</details>
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary><b>Linux</b></summary>
|
|
||||||
|
|
||||||
|Linux|Build status|
|
|Linux|Build status|
|
||||||
|--------|--------|
|
|--------|------------|
|
||||||
|Linux SDL Build|[![Linux-sdl](https://github.com/shadps4-emu/shadPS4/actions/workflows/linux.yml/badge.svg)](https://github.com/shadps4-emu/shadPS4/actions/workflows/linux.yml)
|
|Linux SDL Build|[![Linux-sdl](https://github.com/shadps4-emu/shadPS4/actions/workflows/linux.yml/badge.svg)](https://github.com/shadps4-emu/shadPS4/actions/workflows/linux.yml)
|
||||||
|Linux Qt Build|[![Linux-qt](https://github.com/shadps4-emu/shadPS4/actions/workflows/linux-qt.yml/badge.svg)](https://github.com/shadps4-emu/shadPS4/actions/workflows/linux-qt.yml)
|
|Linux Qt Build|[![Linux-qt](https://github.com/shadps4-emu/shadPS4/actions/workflows/linux-qt.yml/badge.svg)](https://github.com/shadps4-emu/shadPS4/actions/workflows/linux-qt.yml)
|
||||||
</details>
|
|
||||||
|
|
||||||
<details>
|
# Executing a program
|
||||||
<summary><b>macOS</b></summary>
|
|
||||||
|
|
||||||
| macOS | Build status |
|
You can copy and paste the path to the CMD or drag the executable file to the application.
|
||||||
|--------|--------|
|
```
|
||||||
|macOS SDL Build|[![macOS-sdl](https://github.com/shadps4-emu/shadPS4/actions/workflows/macos.yml/badge.svg)](https://github.com/shadps4-emu/shadPS4/actions/workflows/macos.yml)
|
C:\Users\******\shadPS4.exe C:\******\game_eboot.bin
|
||||||
|macOS Qt Build|[![macOS-qt](https://github.com/shadps4-emu/shadPS4/actions/workflows/macos-qt.yml/badge.svg)](https://github.com/shadps4-emu/shadPS4/actions/workflows/macos-qt.yml)
|
```
|
||||||
</details>
|
|
||||||
|
|
||||||
# Debugging and reporting issues
|
|
||||||
|
|
||||||
For more information on how to test, debug and report issues with the emulator or games, read the [Debugging documentation](https://github.com/shadps4-emu/shadPS4/blob/main/documents/Debugging/Debugging.md).
|
|
||||||
|
|
||||||
# Keyboard mapping
|
|
||||||
|
|
||||||
> [!NOTE]
|
|
||||||
> Xbox and DualShock controllers work out of the box.
|
|
||||||
|
|
||||||
| Controller button | Keyboard equivelant |
|
|
||||||
|-------------|-------------|
|
|
||||||
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 |
|
|
||||||
CIRCLE | Numpad 6 |
|
|
||||||
CROSS | Numpad 2 |
|
|
||||||
SQUARE | Numpad 4 |
|
|
||||||
PAD UP | UP |
|
|
||||||
PAD DOWN | DOWN |
|
|
||||||
PAD LEFT | LEFT |
|
|
||||||
PAD RIGHT | RIGHT |
|
|
||||||
OPTIONS | RETURN |
|
|
||||||
TOUCH PAD | SPACE |
|
|
||||||
L1 | Q |
|
|
||||||
R1 | U |
|
|
||||||
L2 | E |
|
|
||||||
R2 | O |
|
|
||||||
L3 | X |
|
|
||||||
R3 | M |
|
|
||||||
|
|
||||||
# Main team
|
# Main team
|
||||||
|
|
||||||
- [**georgemoralis**](https://github.com/georgemoralis)
|
- [georgemoralis](https://github.com/georgemoralis)
|
||||||
- [**raphaelthegreat**](https://github.com/raphaelthegreat)
|
- [raphaelthegreat](https://github.com/raphaelthegreat)
|
||||||
- [**psucien**](https://github.com/psucien)
|
- [psucien](https://github.com/psucien)
|
||||||
- [**skmp**](https://github.com/skmp)
|
- [skmp](https://github.com/skmp)
|
||||||
- [**wheremyfoodat**](https://github.com/wheremyfoodat)
|
- [wheremyfoodat](https://github.com/wheremyfoodat)
|
||||||
- [**raziel1000**](https://github.com/raziel1000)
|
- [raziel1000](https://github.com/raziel1000)
|
||||||
|
|
||||||
Logo is done by [**Xphalnos**](https://github.com/Xphalnos)
|
Logo is done by [Xphalnos](https://github.com/Xphalnos)
|
||||||
|
|
||||||
# Contributing
|
# Contribution
|
||||||
|
|
||||||
If you want to contribute, please look the [**CONTRIBUTING.md**](https://github.com/shadps4-emu/shadPS4/blob/main/CONTRIBUTING.md) file.
|
We currently accept any contribution, just open a PR and we will check it :)
|
||||||
|
|
||||||
Open a PR and we'll check it :)
|
|
||||||
|
|
||||||
# Contributors
|
# Contributors
|
||||||
|
|
||||||
<a href="https://github.com/shadps4-emu/shadPS4/graphs/contributors">
|
<a href="https://github.com/shadps4-emu/shadPS4/graphs/contributors">
|
||||||
<img src="https://contrib.rocks/image?repo=shadps4-emu/shadPS4&max=15">
|
<img src="https://contrib.rocks/image?repo=shadps4-emu/shadPS4&max=15" />
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
# Sister Projects
|
# Sister Projects
|
||||||
|
|
||||||
- [**Panda3DS**](https://github.com/wheremyfoodat/Panda3DS): A multiplatform 3DS emulator from our co-author wheremyfoodat.
|
- [Panda3DS](https://github.com/wheremyfoodat/Panda3DS): A multiplatform 3DS emulator from our co-author wheremyfoodat.
|
||||||
- [**hydra**](https://github.com/hydra-emu/hydra): A multisystem, multiplatform emulator (chip-8, GB, NES, N64) from Paris.
|
- [hydra](https://github.com/hydra-emu/hydra): A multisystem, multiplatform emulator (chip-8, GB, NES, N64) from Paris.
|
||||||
|
|
||||||
# License
|
|
||||||
|
|
||||||
- [**GPL-2.0 license**](https://github.com/shadps4-emu/shadPS4/blob/main/LICENSE)
|
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
# SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
find_package(PkgConfig QUIET)
|
|
||||||
pkg_check_modules(FFMPEG QUIET IMPORTED_TARGET libavcodec libavfilter libavformat libavutil libswresample libswscale)
|
|
||||||
|
|
||||||
find_file(FFMPEG_VERSION_FILE libavutil/ffversion.h HINTS "${FFMPEG_libavutil_INCLUDEDIR}")
|
|
||||||
if (FFMPEG_VERSION_FILE)
|
|
||||||
file(STRINGS "${FFMPEG_VERSION_FILE}" FFMPEG_VERSION_LINE REGEX "FFMPEG_VERSION")
|
|
||||||
string(REGEX MATCH "[0-9.]+" FFMPEG_VERSION "${FFMPEG_VERSION_LINE}")
|
|
||||||
unset(FFMPEG_VERSION_LINE)
|
|
||||||
unset(FFMPEG_VERSION_FILE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
find_package_handle_standard_args(FFmpeg
|
|
||||||
REQUIRED_VARS FFMPEG_LINK_LIBRARIES
|
|
||||||
VERSION_VAR FFMPEG_VERSION
|
|
||||||
)
|
|
||||||
|
|
||||||
if (FFmpeg_FOUND AND NOT TARGET FFmpeg::ffmpeg)
|
|
||||||
add_library(FFmpeg::ffmpeg ALIAS PkgConfig::FFMPEG)
|
|
||||||
endif()
|
|
|
@ -1,25 +0,0 @@
|
||||||
# SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
find_path(RENDERDOC_INCLUDE_DIR renderdoc_app.h)
|
|
||||||
|
|
||||||
if (RENDERDOC_INCLUDE_DIR AND EXISTS "${RENDERDOC_INCLUDE_DIR}/renderdoc_app.h")
|
|
||||||
file(STRINGS "${RENDERDOC_INCLUDE_DIR}/renderdoc_app.h" RENDERDOC_VERSION_LINE REGEX "typedef struct RENDERDOC_API")
|
|
||||||
string(REGEX REPLACE ".*typedef struct RENDERDOC_API_([0-9]+)_([0-9]+)_([0-9]+).*" "\\1.\\2.\\3" RENDERDOC_VERSION "${RENDERDOC_VERSION_LINE}")
|
|
||||||
unset(RENDERDOC_VERSION_LINE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
find_package_handle_standard_args(RenderDoc
|
|
||||||
REQUIRED_VARS RENDERDOC_INCLUDE_DIR
|
|
||||||
VERSION_VAR RENDERDOC_VERSION
|
|
||||||
)
|
|
||||||
|
|
||||||
if (RenderDoc_FOUND AND NOT TARGET RenderDoc::API)
|
|
||||||
add_library(RenderDoc::API INTERFACE IMPORTED)
|
|
||||||
set_target_properties(RenderDoc::API PROPERTIES
|
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${RENDERDOC_INCLUDE_DIR}"
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
mark_as_advanced(RENDERDOC_INCLUDE_DIR)
|
|
|
@ -1,15 +0,0 @@
|
||||||
# SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
find_package(PkgConfig QUIET)
|
|
||||||
pkg_search_module(CRYPTOPP QUIET IMPORTED_TARGET libcryptopp)
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
find_package_handle_standard_args(cryptopp
|
|
||||||
REQUIRED_VARS CRYPTOPP_LINK_LIBRARIES
|
|
||||||
VERSION_VAR CRYPTOPP_VERSION
|
|
||||||
)
|
|
||||||
|
|
||||||
if (cryptopp_FOUND AND NOT TARGET cryptopp::cryptopp)
|
|
||||||
add_library(cryptopp::cryptopp ALIAS PkgConfig::CRYPTOPP)
|
|
||||||
endif()
|
|
|
@ -1,15 +0,0 @@
|
||||||
# SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
find_package(PkgConfig QUIET)
|
|
||||||
pkg_search_module(XXHASH QUIET IMPORTED_TARGET libxxhash)
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
find_package_handle_standard_args(xxHash
|
|
||||||
REQUIRED_VARS XXHASH_LINK_LIBRARIES
|
|
||||||
VERSION_VAR XXHASH_VERSION
|
|
||||||
)
|
|
||||||
|
|
||||||
if (xxHash_FOUND AND NOT TARGET xxHash::xxhash)
|
|
||||||
add_library(xxHash::xxhash ALIAS PkgConfig::XXHASH)
|
|
||||||
endif()
|
|
|
@ -1,15 +0,0 @@
|
||||||
# SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
find_package(PkgConfig QUIET)
|
|
||||||
pkg_search_module(ZLIB_NG QUIET IMPORTED_TARGET zlib-ng)
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
find_package_handle_standard_args(zlib-ng
|
|
||||||
REQUIRED_VARS ZLIB_NG_LINK_LIBRARIES
|
|
||||||
VERSION_VAR ZLIB_NG_VERSION
|
|
||||||
)
|
|
||||||
|
|
||||||
if (zlib-ng_FOUND AND NOT TARGET zlib-ng::zlib)
|
|
||||||
add_library(zlib-ng::zlib ALIAS PkgConfig::ZLIB_NG)
|
|
||||||
endif()
|
|
|
@ -1,156 +0,0 @@
|
||||||
<!--
|
|
||||||
SPDX-FileCopyrightText: 2024 shadPS4 Emulator Project
|
|
||||||
SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
-->
|
|
||||||
|
|
||||||
# Debugging and reporting issues about shadPS4 and games
|
|
||||||
|
|
||||||
This document covers information about debugging, troubleshooting and reporting developer-side issues related to shadPS4 and games.
|
|
||||||
|
|
||||||
## Setup
|
|
||||||
|
|
||||||
This section will guide you through setting up tools for debugging the emulator. This list will likely expand as more tools and platforms receive consistent setups.
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Windows and Visual Studio</summary>
|
|
||||||
|
|
||||||
Make sure you have the project set up for building on Windows with Visual Studio and CMake: [Build shadPS4 for Windows
|
|
||||||
](https://github.com/shadps4-emu/shadPS4/blob/main/documents/building-windows.md)
|
|
||||||
|
|
||||||
1. Open the project folder in Visual Studio **as a folder**. _Do not run `cmake ..` or other commands that set up the project._
|
|
||||||
|
|
||||||
2. In the Solution Explorer, click the **Switch between solutions and available views** button.\
|
|
||||||
![image](https://github.com/user-attachments/assets/4e2be2b1-ba5a-4451-9ab2-f4ecf246213d)
|
|
||||||
|
|
||||||
3. Double-click on **CMake Targets View**.\
|
|
||||||
![image](https://github.com/user-attachments/assets/5ce7cf90-cd61-4cfa-bef5-645909827290)
|
|
||||||
|
|
||||||
4. Under **shadPS4 Project**, right-click on the **shadps4 (executable)** solution and click **Set as Startup Item**. This will let you start and debug shadPS4 using the VS debug buttons, as well as the default F5 shortcut.\
|
|
||||||
![image](https://github.com/user-attachments/assets/34c7c047-28a3-499f-be8f-df781134d104)
|
|
||||||
|
|
||||||
5. Right-click the **shadps4 (executable)** solution once more and click **Add debug configuration**.
|
|
||||||
|
|
||||||
6. Add an `"args: []"` section into the first `configurations` entry.\
|
|
||||||
List your game path as an argument, as if you were launching the non-GUI emulator from the command line.
|
|
||||||
![image](https://github.com/user-attachments/assets/8c7c3e69-f38f-4d6b-bdfd-4f1c41c50be7)
|
|
||||||
|
|
||||||
7. Set the appropriate CMake configuration for debugging or testing.
|
|
||||||
- For debugging the emulator and games within it, select `x64-Clang-Debug`.
|
|
||||||
- For testing the emulator with compiler optimizations as a release build, it is recommended to select `x64-Clang-RelWithDebInfo`,
|
|
||||||
as debug symbols will still be generated in case you encounter release configuration-exclusive bugs/errors.
|
|
||||||
![image](https://github.com/user-attachments/assets/0d975f7a-7bea-4f89-87ef-5d685bea4381)
|
|
||||||
|
|
||||||
Launch and debug the emulator through **Debug > Start Debugging** (F5 by default), or **Debug > Start Without Debugging** (Ctrl+F5 by default) when testing games for performance.
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
## Configuration
|
|
||||||
|
|
||||||
You can configure the emulator by editing the `config.toml` file found in the `user` folder created after starting the application.
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Some configuration entries worth changing</summary>
|
|
||||||
|
|
||||||
- `[General]`
|
|
||||||
|
|
||||||
- `logType`: Configures logging synchronization (`sync`/`async`)
|
|
||||||
- By default, the emulator logs messages asynchronously for better performance. Some log messages may end up being received out-of-order.
|
|
||||||
- It can be beneficial to set this to `sync` in order for the log to accurately maintain message order, at the cost of performance.
|
|
||||||
- When communicating about issues with games and the log messages aren't clear due to potentially confusing order, set this to `sync` and send that log as well.
|
|
||||||
- `logFilter`: Sets the logging category for various logging classes.
|
|
||||||
- Format: `<class>:<level> ...`
|
|
||||||
- Multiple classes can be set by separating them with a space. (example: `Render:Warning Debug:Critical Lib.Pad:Error`)
|
|
||||||
- Sub-classes can be specified in the same format as seen in the console/log (such as `Core.Linker`).
|
|
||||||
- All classes and sub-classes can be set by specifying a `*` symbol. (example: `Kernel.*:Critical`)
|
|
||||||
- Valid log levels: `Trace, Debug, Info, Warning, Error, Critical` - in this order, setting a level silences all levels preceding it and logs every level after it.
|
|
||||||
- Examples:
|
|
||||||
- If the log is being spammed with messages coming from Lib.Pad, you can use `Lib.Pad:Critical` to only log critical-level messages.
|
|
||||||
- If you'd like to mute everything, but still want to receive messages from Vulkan rendering: `*:Critical Render.Vulkan:Info`
|
|
||||||
|
|
||||||
- `Fullscreen`: Display the game in a full screen borderless window.
|
|
||||||
|
|
||||||
- `[GPU]`
|
|
||||||
- `dumpShaders`: Dump shaders that are loaded by the emulator. Dump path: `../user/shader/dumps`
|
|
||||||
- `nullGpu`: Disables rendering.
|
|
||||||
- `screenWidth` and `screenHeight`: Configures the game window width and height.
|
|
||||||
|
|
||||||
- `[Vulkan]`
|
|
||||||
- `validation`-related settings: Use when debugging Vulkan.
|
|
||||||
- `rdocEnable`: Automatically hook RenderDoc when installed. Useful for debugging shaders and game rendering.
|
|
||||||
- `rdocMarkersEnable`: Enable automatic RenderDoc event annotation
|
|
||||||
|
|
||||||
- `[LLE]`
|
|
||||||
- `libc`: Use LLE with `libc`.
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
## Quick analysis
|
|
||||||
|
|
||||||
This section will provide some preliminary steps to take and tips on what to do when you encounter scenarios that require debugging.
|
|
||||||
|
|
||||||
<details open>
|
|
||||||
<summary>When a game crashes and breaks in the debugger</summary>
|
|
||||||
|
|
||||||
1. Analyze the log
|
|
||||||
- A console will open by default when you launch the emulator. It shows the same log messages that go into the log file found at `<emulator executable>/user/log/shad_log.txt`.
|
|
||||||
|
|
||||||
- It is recommended that you start analyzing the log bottom-up first:
|
|
||||||
- Are there any critical or error-level messages at the end of the log that would point to a reason for the game crashing?
|
|
||||||
- Do any of the last few messages contain information about the game loading files?
|
|
||||||
- Did the game window draw anything on-screen?
|
|
||||||
|
|
||||||
- Continue analyzing the log from the start to see other errors (such as with initialization, memory mapping, linker errors etc.)
|
|
||||||
|
|
||||||
2. Analyze the stack trace
|
|
||||||
- When the emulator is launched through a debugger, it will **break** when an exception or violation is encountered.\
|
|
||||||
_(**breaking** in this context means pausing execution of the program before it continues or stops altogether.
|
|
||||||
Breaks can be intentional as well - these are set with various kinds of **breakpoints**.)_
|
|
||||||
|
|
||||||
- Default setups of most debuggers include a **Stack trace** window/panel that lists the functions the program has called before breaking.
|
|
||||||
|
|
||||||
- The stack trace entries can be navigated to and will show the relevant function, as well as switch to the state that the program was in at the time of execution.\
|
|
||||||
Use the **Locals** and **Watch** windows to investigate variables and other code in these contexts.
|
|
||||||
|
|
||||||
3. Identify the reason for the crash
|
|
||||||
- **Logs aren't always accurate in determining the reason for a crash.**\
|
|
||||||
Some log entries are reported as errors but may not be fatal for the execution to stop. `Critical` entries are most likely to be the cause for crashes.
|
|
||||||
|
|
||||||
- Pinpoint the area of the emulator where the crash occured\
|
|
||||||
If the stack trace ends with functions that are relevant to rendering, it is safe to assume that the issue is with **rendering**.\
|
|
||||||
Similarly, if a crash is in a library responsible for playing videos, your issue can be narrowed down to the scope of video playback in the emulator.
|
|
||||||
|
|
||||||
- **⚠ Some crashes are intentional**
|
|
||||||
- If you identify **Access violations for writing operations** where the function is (or in cases of game libraries, _looks like_ it is) copying memory,
|
|
||||||
it most likely is an **intentional exception** meant to catch game data being written by the game.
|
|
||||||
This is used by the emulator developers to identify procedures that have to do with game data changing.
|
|
||||||
- Debugging tools usually include an option to not break on certain types of exceptions. **Exclude access violations and other intentional exceptions when debugging to skip these exceptions.**
|
|
||||||
- You can also identify such cases if the game works in Release builds of the emulator. These intentional exceptions are development-time only.
|
|
||||||
- Attempt to **Continue** and observe whether the stack trace and/or variables and registers change when you encounter exceptions.
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
## Reporting and communicating about issues
|
|
||||||
|
|
||||||
When communicating with the project about game-specific issues, specify an **uniquely identifable game name** along with its `CUSA-xxxxx` code that is specific to the region/variant of the game you're testing.\
|
|
||||||
The version number is also important to add at least in the description, especially if you can verify that the game behaves differently across versions.\
|
|
||||||
Accurately identifying games will help other developers that own that game recognize your issue by its title and jump in to help test and debug it.
|
|
||||||
|
|
||||||
- Examples of good naming schemes:
|
|
||||||
- Amplitude (2016) `CUSA02480`
|
|
||||||
- Rock Band 4 (`CUSA02084`) v1.0
|
|
||||||
- inFamous: Second Son \[`CUSA-00004`\]
|
|
||||||
- Examples of unideal naming schemes:
|
|
||||||
- _The Witness_
|
|
||||||
- _GTA 5_
|
|
||||||
- _Watch Dogs_
|
|
||||||
|
|
||||||
- If your issue is small or you aren't sure whether you have properly identified something, [join the Discord server](https://discord.gg/MyZRaBngxA) and use the #development channel
|
|
||||||
to concisely explain the issue, as well as any findings you currently have.
|
|
||||||
|
|
||||||
- It is recommended that you check the [game compatibility issue tracker](https://github.com/shadps4-emu/shadps4-game-compatibility/issues) and post very short summaries of progress changes there,
|
|
||||||
(such as the game now booting into the menu or getting in-game) for organizational and status update purposes.
|
|
||||||
|
|
||||||
- ⚠ **Do not post theoretical, unproven game-specific issues in the emulator issue tracker that you cannot verify and locate in the emulator source code as being a bug.**\
|
|
||||||
Do, however, add information about the game you experienced the issue in, so that it can be tested in a reproducible environment.
|
|
||||||
- Good example: "_Crash in `Shader::Gcn::CFG::EmitBlocks()`, out of bounds list access_" -> _issue description shares stack trace, points to code in the repository and provides relevant information_
|
|
||||||
- Bad example: "_Amplitude crashes on boot, access violation_" -> _issue description reiterates title, focuses on the game instead of the emulator and refuses to elaborate_
|
|
Before Width: | Height: | Size: 658 KiB |
|
@ -1,81 +0,0 @@
|
||||||
<!--
|
|
||||||
SPDX-FileCopyrightText: 2024 shadPS4 Emulator Project
|
|
||||||
SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
-->
|
|
||||||
|
|
||||||
# shadPS4 Quickstart
|
|
||||||
|
|
||||||
## Summary
|
|
||||||
|
|
||||||
- [PC Requirements](#pc-requirements)
|
|
||||||
- [CPU](#cpu)
|
|
||||||
- [GPU](#gpu)
|
|
||||||
- [RAM](#ram)
|
|
||||||
- [OS](#os)
|
|
||||||
- [Have the latest WIP version](#have-the-latest-wip-version)
|
|
||||||
- [Install PKG files (Games and Updates)](#install-pkg-files)
|
|
||||||
- [Configure the emulator](#configure-the-emulator)
|
|
||||||
|
|
||||||
## PC Requirements
|
|
||||||
|
|
||||||
### CPU
|
|
||||||
|
|
||||||
- A processor with at least 4 cores and 6 threads
|
|
||||||
- Above 2.5 GHz frequency
|
|
||||||
|
|
||||||
### GPU
|
|
||||||
|
|
||||||
- A graphics card with at least 1GB of VRAM
|
|
||||||
- Keep your graphics drivers up to date
|
|
||||||
- Vulkan 1.3 support (required)
|
|
||||||
|
|
||||||
### RAM
|
|
||||||
|
|
||||||
- 8GB of RAM or more
|
|
||||||
|
|
||||||
### OS
|
|
||||||
|
|
||||||
- Windows 10 or Ubuntu 22.04
|
|
||||||
|
|
||||||
## How to run the latest Work-in-Progress builds of ShadPS4
|
|
||||||
|
|
||||||
1. Go to <https://github.com/shadps4-emu/shadPS4/actions> and make sure you are logged into your GitHub account (important!)
|
|
||||||
2. On the left side of the page, select your operating system of choice (the "**qt**" versions have a user interface, which is probably the one you want. The others are SDL versions, which can only be run via command line). ![image](https://github.com/user-attachments/assets/43f01bbf-236c-4d6d-98ac-f5a5badd4ce8)
|
|
||||||
|
|
||||||
3. In the workflow list, select the latest entry with a green :white_check_mark: icon in front of it. (or the latest entry for whatever pull request you wish to test). ![image](https://github.com/user-attachments/assets/6365f407-867c-44ae-bf00-944f8d84a349)
|
|
||||||
|
|
||||||
4. On the bottom of this page, select the name of the file, and it should start downloading. (If there is no file here, double check that you are indeed logged into a GitHub account, and that there is a green :white_check_mark: icon. ![image](https://github.com/user-attachments/assets/97924500-3911-4f90-ab63-ffae7e52700b)
|
|
||||||
|
|
||||||
5. Once downloaded, extract to its own folder, and run ShadPS4's executable from the extracted folder.
|
|
||||||
|
|
||||||
6. Upon first launch, ShadPS4 will prompt you to select a folder to store your installed games in. Select "Browse" and then select a folder that ShadPS4 can use to install your PKG files to.
|
|
||||||
|
|
||||||
## Install PKG files
|
|
||||||
|
|
||||||
To install PKG files (game and updates), you will need the Qt application (with UI). You will have to go to "File" then to "Install Packages (PKG)", a window will open then you will have to select the files. You can install multiple PKG files at once. Once finished, the game should appear in the application.
|
|
||||||
|
|
||||||
<img src="https://github.com/shadps4-emu/shadPS4/blob/main/documents/Quickstart/2.png" width="800"></a>
|
|
||||||
|
|
||||||
## Configure the emulator
|
|
||||||
|
|
||||||
You can configure the emulator by editing the `config.toml` file found in the `user` folder created after starting the application.\
|
|
||||||
Some settings may be related to more technical development and debugging. For more information on those, see [Debugging](https://github.com/shadps4-emu/shadPS4/blob/main/documents/Debugging/Debugging.md#configuration).
|
|
||||||
|
|
||||||
Here's a list of configuration entries that are worth changing:
|
|
||||||
|
|
||||||
- `[General]`
|
|
||||||
|
|
||||||
- `Fullscreen`: Display the game in a full screen borderless window.
|
|
||||||
|
|
||||||
- `logType`: Configures logging synchronization (`sync`/`async`)
|
|
||||||
- It can be beneficial to set this to `sync` in order for the log to accurately maintain message order, at the cost of performance.
|
|
||||||
- Use when sending logs to developers. See more about [reporting issues](https://github.com/shadps4-emu/shadPS4/blob/main/documents/Debugging/Debugging.md#reporting-and-communicating-about-issues).
|
|
||||||
- `logFilter`: Sets the logging category for various logging classes.
|
|
||||||
- Format: `<class>:<level> ...`, `<class.*>:<level> <*:level> ...`
|
|
||||||
- Valid log levels: `Trace, Debug, Info, Warning, Error, Critical` - in this order, setting a level silences all levels preceding it and logs every level after it.
|
|
||||||
- Examples:
|
|
||||||
- If the log is being spammed with messages coming from Lib.Pad, you can use `Lib.Pad:Critical` to only log critical-level messages.
|
|
||||||
- If you'd like to mute everything, but still want to receive messages from Vulkan rendering: `*:Error Render.Vulkan:Info`
|
|
||||||
|
|
||||||
- `[GPU]`
|
|
||||||
- `screenWidth` and `screenHeight`: Configures the game window width and height.
|
|
Before Width: | Height: | Size: 350 KiB |
Before Width: | Height: | Size: 850 KiB |
Before Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 175 KiB |
After Width: | Height: | Size: 843 KiB |
|
@ -1,56 +0,0 @@
|
||||||
<!--
|
|
||||||
SPDX-FileCopyrightText: 2024 shadPS4 Emulator Project
|
|
||||||
SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
-->
|
|
||||||
|
|
||||||
## Build shadPS4 for Linux
|
|
||||||
|
|
||||||
### Install the necessary tools to build shadPS4:
|
|
||||||
|
|
||||||
#### Debian & Ubuntu
|
|
||||||
```
|
|
||||||
sudo apt-get install build-essential libasound2-dev libpulse-dev libopenal-dev zlib1g-dev libedit-dev libvulkan-dev libudev-dev git libevdev-dev libsdl2-2.0 libsdl2-dev libjack-dev libsndio-dev
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Fedora
|
|
||||||
```
|
|
||||||
sudo dnf install alsa-lib-devel cmake libatomic libevdev-devel libudev-devel openal-devel qt6-qtbase-devel qt6-qtbase-private-devel vulkan-devel pipewire-jack-audio-connection-kit-devel qt6-qtmultimedia-devel qt6-qtsvg-devel
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Arch Linux
|
|
||||||
```
|
|
||||||
sudo pacman -S openal cmake vulkan-validation-layers qt6-base qt6-declarative qt6-multimedia sdl2 sndio jack2 base-devel
|
|
||||||
```
|
|
||||||
|
|
||||||
#### OpenSUSE
|
|
||||||
```
|
|
||||||
sudo zypper install git cmake libasound2 libpulse-devel openal-soft-devel zlib-devel libedit-devel vulkan-devel libudev-devel libqt6-qtbase-devel libqt6-qtmultimedia-devel libqt6-qtsvg-devel libQt6Gui-private-headers-devel libevdev-devel libsndio7_1 libjack-devel
|
|
||||||
```
|
|
||||||
### Cloning and compiling:
|
|
||||||
|
|
||||||
Clone the repository recursively:
|
|
||||||
```
|
|
||||||
git clone --recursive https://github.com/shadps4-emu/shadPS4.git
|
|
||||||
cd shadPS4
|
|
||||||
```
|
|
||||||
|
|
||||||
Generate the build directory in the shadPS4 directory:
|
|
||||||
```
|
|
||||||
cmake -S . -B build/
|
|
||||||
```
|
|
||||||
|
|
||||||
Enter the directory:
|
|
||||||
```
|
|
||||||
cd build/
|
|
||||||
```
|
|
||||||
|
|
||||||
Use make to build the project:
|
|
||||||
```
|
|
||||||
cmake --build . --parallel$(nproc)
|
|
||||||
```
|
|
||||||
|
|
||||||
Now run the emulator:
|
|
||||||
|
|
||||||
```
|
|
||||||
./shadps4 /"PATH"/"TO"/"GAME"/"FOLDER"/eboot.bin
|
|
||||||
```
|
|
|
@ -3,98 +3,23 @@ SPDX-FileCopyrightText: 2024 shadPS4 Emulator Project
|
||||||
SPDX-License-Identifier: GPL-2.0-or-later
|
SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
-->
|
-->
|
||||||
|
|
||||||
# Build shadPS4 for Windows
|
# Build shadps4 for Windows
|
||||||
|
|
||||||
This tutorial reads as if you have none of the prerequisites already installed. If you do, just ignore the steps regarding installation.
|
## Download Visual Studio Community 2022 17.9.6
|
||||||
If you are building to contribute to the project, please omit `--depth 1` from the git invokations.
|
|
||||||
|
|
||||||
Note: **ARM64 is not supported!** As of writing, it will not build nor run. The instructions with respect to ARM64 are for developers only.
|
Download link: [Visual Studio 2022](https://visualstudio.microsoft.com/vs/)
|
||||||
|
|
||||||
## Option 1: Visual Studio 2022
|
## Requirements
|
||||||
|
|
||||||
### (Prerequisite) Download the Community edition from [**Visual Studio 2022**](https://visualstudio.microsoft.com/vs/)
|
### From Visual Studio Community
|
||||||
|
|
||||||
Once you are within the installer:
|
- Desktop development with C++
|
||||||
1. Select `Desktop development with C++`
|
|
||||||
2. Go to "Individual Components" tab
|
|
||||||
3. Search and select `C++ Clang Compiler for Windows` and `MSBuild support for LLVM`
|
|
||||||
4. Continue the installation
|
|
||||||
|
|
||||||
### (Prerequisite) Download [**Qt**](https://doc.qt.io/qt-6/get-and-install-qt.html)
|
### From individual components tab install
|
||||||
|
|
||||||
Beware, this requires you to create a Qt account. If you do not want to do this, please follow the MSYS2/MinGW compilation method instead.
|
- C++ Clang Compiler for Windows (17.0.3)
|
||||||
|
- MSBuild support for LLVM (Clang-cl) toolset
|
||||||
|
|
||||||
1. Under the current, non beta version of Qt (at the time of writing 6.7.2), select the option `MSVC 2019 64-bit` or similar.
|
- ## Compiling
|
||||||
If you are on Windows on ARM / Qualcomm Snapdragon Elite X, select `MSVC 2019 ARM64` instead.
|
|
||||||
|
|
||||||
Go through the installation normally. If you know what you are doing, you may unselect individual components that eat up too much disk space.
|
- Open Visual Studio and select the Clang-debug or Clang-release. It should compile just fine.
|
||||||
|
|
||||||
2. Download and install [Qt Visual Studio Tools](https://marketplace.visualstudio.com/items?itemName=TheQtCompany.QtVisualStudioTools2022)
|
|
||||||
|
|
||||||
Once you are finished, you will have to configure Qt within Visual Studio:
|
|
||||||
1. Tools -> Options -> Qt -> Versions
|
|
||||||
2. Add a new Qt version and navigate it to the correct folder. Should look like so: `C:\Qt\6.7.2\msvc2019_64`
|
|
||||||
3. Enable the default checkmark on the new version you just created.
|
|
||||||
|
|
||||||
### (Prerequisite) Download [**Git for Windows**](https://git-scm.com/download/win)
|
|
||||||
|
|
||||||
Go through the Git for Windows installation as normal
|
|
||||||
|
|
||||||
### Cloning the source code
|
|
||||||
|
|
||||||
1. Open Git for Windows, navigate to a place where you want to store the shadPS4 source code folder
|
|
||||||
2. Clone the repository by running
|
|
||||||
`git clone --depth 1 --recursive https://github.com/shadps4-emu/shadPS4`
|
|
||||||
|
|
||||||
### Compiling with Visual Studio GUI
|
|
||||||
|
|
||||||
1. Open up Visual Studio, select `Open a local folder` and select the folder with the shadPS4 source code. The folder should contain `CMakeLists.txt`
|
|
||||||
2. Change x64-Clang-Debug to x64-Clang-Release if you want a regular, non-debug build.
|
|
||||||
3. If you want to build shadPS4 with the Qt Gui:
|
|
||||||
1. Click x64-Clang-Release and select "Manage Configurations"
|
|
||||||
2. Look for "CMake command arguments" and add to the text field
|
|
||||||
`-DENABLE_QT_GUI=ON -DCMAKE_PREFIX_PATH=C:\Qt\6.7.2\msvc2019_64`
|
|
||||||
(Change Qt path if you've installed it to non-default path)
|
|
||||||
3. Press CTRL+S to save and wait a moment for CMake generation
|
|
||||||
4. Change the project to build to shadps4.exe
|
|
||||||
5. Build -> Build All
|
|
||||||
|
|
||||||
Your shadps4.exe will be in `c:\path\to\source\Build\x64-Clang-Release\`
|
|
||||||
|
|
||||||
To automatically populate the necessary files to run shadPS4.exe, run in a command prompt or terminal:
|
|
||||||
`C:\Qt\6.7.2\msvc2019_64\bin\windeployqt.exe c:\path\to\shadps4.exe`
|
|
||||||
(Change Qt path if you've installed it to non-default path)
|
|
||||||
|
|
||||||
## Option 2: MSYS2/MinGW
|
|
||||||
|
|
||||||
### (Prerequisite) Download [**MSYS2**](https://www.msys2.org/)
|
|
||||||
|
|
||||||
Go through the MSYS2 installation as normal
|
|
||||||
|
|
||||||
If you are building to distribute, please omit `-DCMAKE_CXX_FLAGS="-O2 -march=native"` within the build configuration step.
|
|
||||||
|
|
||||||
Normal x86-based computers, follow:
|
|
||||||
1. Open "MSYS2 MINGW64" from your new applications
|
|
||||||
2. Run `pacman -Syu`, let it complete;
|
|
||||||
3. Run `pacman -S --needed git mingw-w64-x86_64-binutils mingw-w64-x86_64-clang mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-qt6-base`
|
|
||||||
4. Run `git clone --depth 1 --recursive https://github.com/shadps4-emu/shadPS4`
|
|
||||||
5. Run `cd shadPS4`
|
|
||||||
6. Run `cmake -S . -B build -DCMAKE_CXX_COMPILER="clang++.exe" -DCMAKE_C_COMPILER="clang.exe" -DCMAKE_CXX_FLAGS="-O2 -march=native"`
|
|
||||||
7. Run `cmake --build build`
|
|
||||||
8. To run the finished product, run `./build/shadPS4.exe`
|
|
||||||
|
|
||||||
ARM64-based computers, follow:
|
|
||||||
1. Open "MSYS2 CLANGARM64" from your new applications
|
|
||||||
2. Run `pacman -Syu`, let it complete;
|
|
||||||
3. Run `pacman -S --needed git mingw-w64-clang-aarch64-binutils mingw-w64-clang-aarch64-clang mingw-w64-clang-aarch64-cmake mingw-w64-clang-aarch64-ninja mingw-w64-clang-aarch64-qt6-base`
|
|
||||||
4. Run `git clone --depth 1 --recursive https://github.com/shadps4-emu/shadPS4`
|
|
||||||
5. Run `cd shadPS4`
|
|
||||||
6. Run `cmake -S . -B build -DCMAKE_CXX_COMPILER="clang++.exe" -DCMAKE_C_COMPILER="clang.exe" -DCMAKE_CXX_FLAGS="-O2 -march=native"`
|
|
||||||
7. Run `cmake --build build`
|
|
||||||
8. To run the finished product, run `./build/shadPS4.exe`
|
|
||||||
|
|
||||||
## Note on MSYS2 builds
|
|
||||||
|
|
||||||
These builds may not be easily copyable to people who do not also have a MSYS2 installation.
|
|
||||||
If you want to distribute these builds, you need to copy over the correct DLLs into a distribution folder.
|
|
||||||
In order to run them, you must be within the MSYS2 shell environment.
|
|
||||||
|
|
|
@ -1,15 +1,3 @@
|
||||||
v0.2.0 15/08/2024 - codename validptr
|
|
||||||
=================
|
|
||||||
- Adding macOS support
|
|
||||||
- Big shader recompiler improvements
|
|
||||||
- Core improvements
|
|
||||||
- GUI improvements
|
|
||||||
|
|
||||||
v0.1.0 01/07/2024 - codename madturtle
|
|
||||||
=================
|
|
||||||
- Added a shader recompiler, with this we have a lot of games that starts to work
|
|
||||||
- Rewrote a big part of core
|
|
||||||
|
|
||||||
v0.0.3 23/03/2024 - codename salad
|
v0.0.3 23/03/2024 - codename salad
|
||||||
=================
|
=================
|
||||||
-Switching to std::thread
|
-Switching to std::thread
|
||||||
|
@ -24,21 +12,21 @@ v0.0.3 23/03/2024 - codename salad
|
||||||
-Initial TLS work
|
-Initial TLS work
|
||||||
-New logging implementation
|
-New logging implementation
|
||||||
-Some functions implemented for userService,systemService
|
-Some functions implemented for userService,systemService
|
||||||
- Added sceAudioOut module and output using SDL audio
|
-Added sceAudioOut module and output using sdl audio
|
||||||
|
|
||||||
v0.0.2 21/10/2023
|
v0.0.2 21/10/2023
|
||||||
=================
|
=================
|
||||||
- Using cstdint header in variable types
|
-using cstdint header in variable types
|
||||||
-run_main_entry: Rewrite in asm for stack setup
|
-run_main_entry: Rewrite in asm for stack setup
|
||||||
- Printf libc implementation for work with sysv_abi
|
-printf libc implementation for work with sysv_abi
|
||||||
- Initial pad emulation (only digital pad atm)
|
-initial pad emulation (only digital pad atm)
|
||||||
-Implemented sceVideoOutIsFlipPending
|
-Implemented sceVideoOutIsFlipPending
|
||||||
-Added auto stubs , now unsupported hle function will resolve as empty stubs
|
-Added auto stubs , now unsupported hle function will resolve as empty stubs
|
||||||
-Rewrote libc_cxa functions
|
-Rewrote libc_cxa functions
|
||||||
-Libc implementations ( _ZdlPv,_Znwm,rand,_Fsin,qsort,free,strncpy,memmove,atan2f,pow,_Sin)
|
-Libc implementations ( _ZdlPv,_Znwm,rand,_Fsin,qsort,free,strncpy,memmove,atan2f,pow,_Sin)
|
||||||
- ET_SCE_DYNAMIC behaves as valid for execution now
|
-ET_SCE_DYNAMIC behaves as valid for execution now.
|
||||||
- Initial FileSystem work (not yet usable)
|
-Initial FileSystem work (not yet usable).
|
||||||
|
|
||||||
v0.0.1 29/09/2023
|
v0.0.1 29/09/2023
|
||||||
=================
|
=================
|
||||||
First public release. Everything is new.
|
First public release . Everything is new
|
|
@ -0,0 +1,21 @@
|
||||||
|
<!--
|
||||||
|
SPDX-FileCopyrightText: 2024 shadPS4 Emulator Project
|
||||||
|
SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
-->
|
||||||
|
|
||||||
|
## Build shadPS4 for Linux
|
||||||
|
|
||||||
|
Generate the build directory in the shadPS4 directory:
|
||||||
|
```
|
||||||
|
cmake -S . -B build/
|
||||||
|
```
|
||||||
|
|
||||||
|
Enter the directory:
|
||||||
|
```
|
||||||
|
cd build/
|
||||||
|
```
|
||||||
|
|
||||||
|
Use make to build the project:
|
||||||
|
```
|
||||||
|
make -j$(nproc)
|
||||||
|
```
|
|
@ -0,0 +1,35 @@
|
||||||
|
shadPS4 - A PS4 emulator
|
||||||
|
=========================
|
||||||
|
|
||||||
|
1. Intro
|
||||||
|
2. Current status
|
||||||
|
3. Contributors
|
||||||
|
4. Greetings
|
||||||
|
|
||||||
|
1.Intro
|
||||||
|
=======
|
||||||
|
shadPS4 is a Play Station 4 emulator for Windows and Linux. Although atm it can't run a lot of stuff, we are working torwards to make it more compatible.
|
||||||
|
|
||||||
|
2.Current status
|
||||||
|
================
|
||||||
|
shadPS4 is a HLE emulator. Currently on a small amount of functions is emulated, which is one of the reasons compatibility is low.
|
||||||
|
|
||||||
|
3.Contributors
|
||||||
|
==============
|
||||||
|
- georgemoralis
|
||||||
|
- raphaelthegreat
|
||||||
|
- skmp
|
||||||
|
- wheremyfoodat
|
||||||
|
|
||||||
|
4.Greetings
|
||||||
|
===========
|
||||||
|
I would like to thank the following people for helping me so far, with coding or moral support.
|
||||||
|
|
||||||
|
- wheremyfoodat - or @rodakinos for believed me
|
||||||
|
- paris - or OFFTKP for not believing me and that made me a better coder :D
|
||||||
|
- skmp - or kornilios for being good old friend
|
||||||
|
- PandaBad - our beloved stalker
|
||||||
|
- emufan4568 - for advices
|
||||||
|
- velocity - for talking 1-2 times per year on discord server. We miss you velocity
|
||||||
|
|
||||||
|
- probably more, will include in the next readme :D
|
|
@ -1,89 +1,57 @@
|
||||||
# SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
# SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
set(BUILD_SHARED_LIBS OFF)
|
|
||||||
set(BUILD_TESTING OFF)
|
|
||||||
set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL ON)
|
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
# Silence "deprecation" warnings
|
# Silence "deprecation" warnings
|
||||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Boost
|
# Boost
|
||||||
if (NOT TARGET Boost::headers)
|
set(BOOST_ROOT "${CMAKE_SOURCE_DIR}/externals/boost" CACHE STRING "")
|
||||||
set(BOOST_ROOT "${CMAKE_SOURCE_DIR}/externals/ext-boost" CACHE STRING "")
|
set(Boost_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/externals/boost" CACHE STRING "")
|
||||||
set(Boost_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/externals/ext-boost" CACHE STRING "")
|
|
||||||
set(Boost_NO_SYSTEM_PATHS ON CACHE BOOL "")
|
set(Boost_NO_SYSTEM_PATHS ON CACHE BOOL "")
|
||||||
add_library(boost INTERFACE)
|
add_library(boost INTERFACE)
|
||||||
target_include_directories(boost SYSTEM INTERFACE ${Boost_INCLUDE_DIR})
|
target_include_directories(boost SYSTEM INTERFACE ${Boost_INCLUDE_DIR})
|
||||||
add_library(Boost::headers ALIAS boost)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# fmtlib
|
# fmtlib
|
||||||
if (NOT TARGET fmt::fmt)
|
add_subdirectory(fmt EXCLUDE_FROM_ALL)
|
||||||
add_subdirectory(fmt)
|
|
||||||
endif()
|
# Discord-RPC
|
||||||
|
set(BUILD_EXAMPLES OFF CACHE BOOL "")
|
||||||
|
add_subdirectory(discord-rpc EXCLUDE_FROM_ALL)
|
||||||
|
target_include_directories(discord-rpc INTERFACE ./discord-rpc/include)
|
||||||
|
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND MSVC)
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND MSVC)
|
||||||
# If it is clang and MSVC we will add a static lib
|
# If it is clang and MSVC we will add a static lib
|
||||||
# CryptoPP
|
# CryptoPP
|
||||||
add_subdirectory(cryptoppwin)
|
add_subdirectory(cryptoppwin EXCLUDE_FROM_ALL)
|
||||||
target_include_directories(cryptoppwin INTERFACE cryptoppwin/include)
|
target_include_directories(cryptoppwin INTERFACE cryptoppwin/include)
|
||||||
else()
|
else()
|
||||||
# CryptoPP
|
# CryptoPP
|
||||||
if (NOT TARGET cryptopp::cryptopp)
|
|
||||||
set(CRYPTOPP_INSTALL OFF)
|
|
||||||
set(CRYPTOPP_BUILD_TESTING OFF)
|
set(CRYPTOPP_BUILD_TESTING OFF)
|
||||||
set(CRYPTOPP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/)
|
set(CRYPTOPP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/)
|
||||||
add_subdirectory(cryptopp-cmake)
|
add_subdirectory(cryptopp-cmake EXCLUDE_FROM_ALL)
|
||||||
file(COPY cryptopp DESTINATION cryptopp FILES_MATCHING PATTERN "*.h")
|
|
||||||
target_include_directories(cryptopp INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/cryptopp")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (NOT TARGET FFmpeg::ffmpeg)
|
|
||||||
set(ARCHITECTURE "x86_64")
|
|
||||||
add_subdirectory(ffmpeg-core)
|
|
||||||
add_library(FFmpeg::ffmpeg ALIAS ffmpeg)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Zlib-Ng
|
# Zlib-Ng
|
||||||
if (NOT TARGET zlib-ng::zlib)
|
|
||||||
set(ZLIB_ENABLE_TESTS OFF)
|
set(ZLIB_ENABLE_TESTS OFF)
|
||||||
set(WITH_GTEST OFF)
|
set(WITH_GTEST OFF)
|
||||||
set(WITH_NEW_STRATEGIES ON)
|
set(WITH_NEW_STRATEGIES ON)
|
||||||
set(WITH_NATIVE_INSTRUCTIONS ON)
|
set(WITH_NATIVE_INSTRUCTIONS ON)
|
||||||
add_subdirectory(zlib-ng)
|
add_subdirectory(zlib-ng)
|
||||||
add_library(zlib-ng::zlib ALIAS zlib)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# SDL3
|
# SDL3
|
||||||
if (NOT TARGET SDL3::SDL3)
|
add_subdirectory(sdl3 EXCLUDE_FROM_ALL)
|
||||||
set(SDL_PIPEWIRE OFF)
|
|
||||||
add_subdirectory(sdl3)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# vulkan-headers
|
# vulkan-headers
|
||||||
if (NOT TARGET Vulkan::Headers)
|
add_library(vulkan-headers INTERFACE)
|
||||||
set(VULKAN_HEADERS_ENABLE_MODULE OFF)
|
target_include_directories(vulkan-headers SYSTEM INTERFACE ./vulkan-headers/include)
|
||||||
add_subdirectory(vulkan-headers)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# VMA
|
# VMA
|
||||||
if (NOT TARGET GPUOpen::VulkanMemoryAllocator)
|
add_library(vma INTERFACE)
|
||||||
add_subdirectory(vma)
|
target_include_directories(vma SYSTEM INTERFACE ./vma/include)
|
||||||
endif()
|
|
||||||
|
|
||||||
# RenderDoc
|
|
||||||
if (NOT TARGET RenderDoc::API)
|
|
||||||
add_library(renderdoc INTERFACE)
|
|
||||||
target_include_directories(renderdoc SYSTEM INTERFACE ./renderdoc)
|
|
||||||
add_library(RenderDoc::API ALIAS renderdoc)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# glslang
|
# glslang
|
||||||
if (NOT TARGET glslang::glslang)
|
|
||||||
set(SKIP_GLSLANG_INSTALL ON CACHE BOOL "")
|
set(SKIP_GLSLANG_INSTALL ON CACHE BOOL "")
|
||||||
set(ENABLE_GLSLANG_BINARIES OFF CACHE BOOL "")
|
set(ENABLE_GLSLANG_BINARIES OFF CACHE BOOL "")
|
||||||
set(ENABLE_SPVREMAPPER OFF CACHE BOOL "")
|
set(ENABLE_SPVREMAPPER OFF CACHE BOOL "")
|
||||||
|
@ -92,79 +60,36 @@ if (NOT TARGET glslang::glslang)
|
||||||
set(BUILD_EXTERNAL OFF CACHE BOOL "")
|
set(BUILD_EXTERNAL OFF CACHE BOOL "")
|
||||||
set(ENABLE_OPT OFF CACHE BOOL "")
|
set(ENABLE_OPT OFF CACHE BOOL "")
|
||||||
add_subdirectory(glslang)
|
add_subdirectory(glslang)
|
||||||
file(COPY glslang/SPIRV DESTINATION glslang/glslang FILES_MATCHING PATTERN "*.h")
|
|
||||||
target_include_directories(SPIRV INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/glslang")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Robin-map
|
# Robin-map
|
||||||
if (NOT TARGET tsl::robin_map)
|
add_subdirectory(robin-map EXCLUDE_FROM_ALL)
|
||||||
add_subdirectory(robin-map)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Xbyak
|
# Xbyak
|
||||||
if (NOT TARGET xbyak::xbyak)
|
add_subdirectory(xbyak EXCLUDE_FROM_ALL)
|
||||||
add_subdirectory(xbyak)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# MagicEnum
|
# MagicEnum
|
||||||
if (NOT TARGET magic_enum::magic_enum)
|
add_subdirectory(magic_enum EXCLUDE_FROM_ALL)
|
||||||
add_subdirectory(magic_enum)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Toml11
|
# Toml11
|
||||||
if (NOT TARGET toml11::toml11)
|
add_subdirectory(toml11 EXCLUDE_FROM_ALL)
|
||||||
add_subdirectory(toml11)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# xxHash
|
# xxHash
|
||||||
if (NOT TARGET xxHash::xxhash)
|
|
||||||
add_library(xxhash xxhash/xxhash.h xxhash/xxhash.c)
|
add_library(xxhash xxhash/xxhash.h xxhash/xxhash.c)
|
||||||
target_include_directories(xxhash PUBLIC xxhash)
|
target_include_directories(xxhash PUBLIC xxhash)
|
||||||
add_library(xxHash::xxhash ALIAS xxhash)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Zydis
|
# Zydis
|
||||||
if (NOT TARGET Zydis::Zydis)
|
|
||||||
option(ZYDIS_BUILD_TOOLS "" OFF)
|
option(ZYDIS_BUILD_TOOLS "" OFF)
|
||||||
option(ZYDIS_BUILD_EXAMPLES "" OFF)
|
option(ZYDIS_BUILD_EXAMPLES "" OFF)
|
||||||
add_subdirectory(zydis)
|
add_subdirectory(zydis EXCLUDE_FROM_ALL)
|
||||||
endif()
|
|
||||||
|
|
||||||
# Winpthreads
|
# Winpthreads
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
add_subdirectory(winpthreads)
|
add_subdirectory(winpthreads EXCLUDE_FROM_ALL)
|
||||||
target_include_directories(winpthreads INTERFACE winpthreads/include)
|
target_include_directories(winpthreads INTERFACE winpthreads/include)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# sirit
|
# sirit
|
||||||
add_subdirectory(sirit)
|
add_subdirectory(sirit EXCLUDE_FROM_ALL)
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_compile_options(sirit PUBLIC "-Wno-error=unused-command-line-argument")
|
target_compile_options(sirit PUBLIC "-Wno-error=unused-command-line-argument")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (APPLE)
|
|
||||||
# half
|
|
||||||
add_library(half INTERFACE)
|
|
||||||
target_include_directories(half INTERFACE half/include)
|
|
||||||
|
|
||||||
# date
|
|
||||||
if (NOT TARGET date::date-tz)
|
|
||||||
option(BUILD_TZ_LIB "" ON)
|
|
||||||
option(USE_SYSTEM_TZ_DB "" ON)
|
|
||||||
add_subdirectory(date)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Tracy
|
|
||||||
option(TRACY_ENABLE "" ON)
|
|
||||||
option(TRACY_NO_CRASH_HANDLER "" ON) # Otherwise texture cache exceptions will be treaten as a crash
|
|
||||||
option(TRACY_ON_DEMAND "" ON)
|
|
||||||
option(TRACY_NO_FRAME_IMAGE "" ON)
|
|
||||||
option(TRACY_FIBERS "" ON) # For AmdGpu frontend profiling
|
|
||||||
option(TRACY_NO_SYSTEM_TRACING "" ON)
|
|
||||||
option(TRACY_NO_CALLSTACK "" ON)
|
|
||||||
option(TRACY_NO_CODE_TRANSFER "" ON)
|
|
||||||
option(TRACY_NO_SAMPLING "" ON)
|
|
||||||
option(TRACY_ONLY_LOCALHOST "" ON)
|
|
||||||
option(TRACY_NO_CONTEXT_SWITCH "" ON)
|
|
||||||
add_subdirectory(tracy)
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 87b7817119982e8ad6068855fae31b11590514be
|
|
@ -1,158 +0,0 @@
|
||||||
# - Returns a version string from Git
|
|
||||||
#
|
|
||||||
# These functions force a re-configure on each git commit so that you can
|
|
||||||
# trust the values of the variables in your build system.
|
|
||||||
#
|
|
||||||
# get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...])
|
|
||||||
#
|
|
||||||
# Returns the refspec and sha hash of the current head revision
|
|
||||||
#
|
|
||||||
# git_describe(<var> [<additional arguments to git describe> ...])
|
|
||||||
#
|
|
||||||
# Returns the results of git describe on the source tree, and adjusting
|
|
||||||
# the output so that it tests false if an error occurs.
|
|
||||||
#
|
|
||||||
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
|
|
||||||
#
|
|
||||||
# Returns the results of git describe --exact-match on the source tree,
|
|
||||||
# and adjusting the output so that it tests false if there was no exact
|
|
||||||
# matching tag.
|
|
||||||
#
|
|
||||||
# Requires CMake 2.6 or newer (uses the 'function' command)
|
|
||||||
#
|
|
||||||
# Original Author:
|
|
||||||
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
|
||||||
# http://academic.cleardefinition.com
|
|
||||||
# Iowa State University HCI Graduate Program/VRAC
|
|
||||||
#
|
|
||||||
# Copyright Iowa State University 2009-2010.
|
|
||||||
# Distributed under the Boost Software License, Version 1.0.
|
|
||||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
# http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
|
|
||||||
if(__get_git_revision_description)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
set(__get_git_revision_description YES)
|
|
||||||
|
|
||||||
# We must run the following at "include" time, not at function call time,
|
|
||||||
# to find the path to this module rather than the path to a calling list file
|
|
||||||
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
|
|
||||||
|
|
||||||
function(get_git_head_revision _refspecvar _hashvar)
|
|
||||||
set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
||||||
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
|
|
||||||
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
|
|
||||||
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
|
|
||||||
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
|
|
||||||
if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
|
|
||||||
# We have reached the root directory, we are not in git
|
|
||||||
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
|
|
||||||
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
|
|
||||||
endwhile()
|
|
||||||
# check if this is a submodule
|
|
||||||
if(NOT IS_DIRECTORY ${GIT_DIR})
|
|
||||||
file(READ ${GIT_DIR} submodule)
|
|
||||||
string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule})
|
|
||||||
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
|
|
||||||
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
|
|
||||||
endif()
|
|
||||||
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
|
|
||||||
if(NOT EXISTS "${GIT_DATA}")
|
|
||||||
file(MAKE_DIRECTORY "${GIT_DATA}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT EXISTS "${GIT_DIR}/HEAD")
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
set(HEAD_FILE "${GIT_DATA}/HEAD")
|
|
||||||
configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
|
|
||||||
|
|
||||||
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
|
|
||||||
"${GIT_DATA}/grabRef.cmake"
|
|
||||||
@ONLY)
|
|
||||||
include("${GIT_DATA}/grabRef.cmake")
|
|
||||||
|
|
||||||
set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE)
|
|
||||||
set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE)
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
function(git_branch_name _var)
|
|
||||||
if(NOT GIT_FOUND)
|
|
||||||
find_package(Git QUIET)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT GIT_FOUND)
|
|
||||||
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
execute_process(COMMAND
|
|
||||||
"${GIT_EXECUTABLE}"
|
|
||||||
rev-parse --abbrev-ref HEAD
|
|
||||||
WORKING_DIRECTORY
|
|
||||||
"${CMAKE_SOURCE_DIR}"
|
|
||||||
RESULT_VARIABLE
|
|
||||||
res
|
|
||||||
OUTPUT_VARIABLE
|
|
||||||
out
|
|
||||||
ERROR_QUIET
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
||||||
if(NOT res EQUAL 0)
|
|
||||||
set(out "${out}-${res}-NOTFOUND")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(${_var} "${out}" PARENT_SCOPE)
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
function(git_describe _var)
|
|
||||||
if(NOT GIT_FOUND)
|
|
||||||
find_package(Git QUIET)
|
|
||||||
endif()
|
|
||||||
#get_git_head_revision(refspec hash)
|
|
||||||
if(NOT GIT_FOUND)
|
|
||||||
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
#if(NOT hash)
|
|
||||||
# set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
|
|
||||||
# return()
|
|
||||||
#endif()
|
|
||||||
|
|
||||||
# TODO sanitize
|
|
||||||
#if((${ARGN}" MATCHES "&&") OR
|
|
||||||
# (ARGN MATCHES "||") OR
|
|
||||||
# (ARGN MATCHES "\\;"))
|
|
||||||
# message("Please report the following error to the project!")
|
|
||||||
# message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
|
|
||||||
#endif()
|
|
||||||
|
|
||||||
#message(STATUS "Arguments to execute_process: ${ARGN}")
|
|
||||||
|
|
||||||
execute_process(COMMAND
|
|
||||||
"${GIT_EXECUTABLE}"
|
|
||||||
describe
|
|
||||||
${hash}
|
|
||||||
${ARGN}
|
|
||||||
WORKING_DIRECTORY
|
|
||||||
"${CMAKE_SOURCE_DIR}"
|
|
||||||
RESULT_VARIABLE
|
|
||||||
res
|
|
||||||
OUTPUT_VARIABLE
|
|
||||||
out
|
|
||||||
ERROR_QUIET
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
||||||
if(NOT res EQUAL 0)
|
|
||||||
set(out "${out}-${res}-NOTFOUND")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(${_var} "${out}" PARENT_SCOPE)
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
function(git_get_exact_tag _var)
|
|
||||||
git_describe(out --exact-match ${ARGN})
|
|
||||||
set(${_var} "${out}" PARENT_SCOPE)
|
|
||||||
endfunction()
|
|
|
@ -1,42 +0,0 @@
|
||||||
#
|
|
||||||
# Internal file for GetGitRevisionDescription.cmake
|
|
||||||
#
|
|
||||||
# Requires CMake 2.6 or newer (uses the 'function' command)
|
|
||||||
#
|
|
||||||
# Original Author:
|
|
||||||
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
|
||||||
# http://academic.cleardefinition.com
|
|
||||||
# Iowa State University HCI Graduate Program/VRAC
|
|
||||||
#
|
|
||||||
# Copyright Iowa State University 2009-2010.
|
|
||||||
# Distributed under the Boost Software License, Version 1.0.
|
|
||||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
# http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
|
|
||||||
set(HEAD_HASH)
|
|
||||||
|
|
||||||
file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
|
|
||||||
|
|
||||||
string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
|
|
||||||
if(HEAD_CONTENTS MATCHES "ref")
|
|
||||||
# named branch
|
|
||||||
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
|
|
||||||
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
|
|
||||||
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
|
|
||||||
elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}")
|
|
||||||
configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
|
|
||||||
set(HEAD_HASH "${HEAD_REF}")
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
# detached HEAD
|
|
||||||
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT HEAD_HASH)
|
|
||||||
if(EXISTS "@GIT_DATA@/head-ref")
|
|
||||||
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
|
|
||||||
string(STRIP "${HEAD_HASH}" HEAD_HASH)
|
|
||||||
else()
|
|
||||||
set(HEAD_HASH "Unknown")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 60f81a77e0c9a0e7ffc1ca1bc438ddfa2e43b78e
|
Subproject commit 782057f5f18fbdad2bd2b291fb1ec558a8ab8225
|
|
@ -1 +1 @@
|
||||||
Subproject commit 2c384c28265a93358a2455e610e76393358794df
|
Subproject commit 19cd13af5f7fa4904b174b81e98852283dbe8c1f
|
|
@ -1 +1 @@
|
||||||
Subproject commit bc3441dd2d6a9728e747dc0180bc8b9065a2923c
|
Subproject commit 0dd224c6812cd038e9f4691d2f869dd57b547ff1
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 1ead6715dec030d340a316c927c877a3c4e5a00c
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 4ec218155d73bcb8022f8f7ca72305d801f84beb
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit a04136add1e469f46d8ae8d3e8307779240a5c53
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit e30b7d7fe228bfb3f6e41ce1040b44a15eb7d5e0
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit c98518351efd5a46f5d448e947e0b7242d197d07
|
Subproject commit d2473b7b73c0af2a3ed34c99e50ace0a1040581a
|
|
@ -1 +1 @@
|
||||||
Subproject commit 12cbda959b6df2af119a76a73ff906c2bed36884
|
Subproject commit 2b19bf7e1bc0b60cf2fe9d33e5ba6b37dfc1cc83
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 1ddada225144cac0de8f6b5c0dd9acffd99a2e68
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit dae6bbf16c363e9ead4e628a47fdb02956a634f3
|
Subproject commit db0b726c051f2d631b85793038677caf467a7cfe
|
|
@ -1,741 +0,0 @@
|
||||||
/******************************************************************************
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2019-2024 Baldur Karlsson
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Documentation for the API is available at https://renderdoc.org/docs/in_application_api.html
|
|
||||||
//
|
|
||||||
|
|
||||||
#if !defined(RENDERDOC_NO_STDINT)
|
|
||||||
#include <stdint.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER)
|
|
||||||
#define RENDERDOC_CC __cdecl
|
|
||||||
#elif defined(__linux__) || defined(__FreeBSD__)
|
|
||||||
#define RENDERDOC_CC
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
#define RENDERDOC_CC
|
|
||||||
#else
|
|
||||||
#error "Unknown platform"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Constants not used directly in below API
|
|
||||||
|
|
||||||
// This is a GUID/magic value used for when applications pass a path where shader debug
|
|
||||||
// information can be found to match up with a stripped shader.
|
|
||||||
// the define can be used like so: const GUID RENDERDOC_ShaderDebugMagicValue =
|
|
||||||
// RENDERDOC_ShaderDebugMagicValue_value
|
|
||||||
#define RENDERDOC_ShaderDebugMagicValue_struct \
|
|
||||||
{ \
|
|
||||||
0xeab25520, 0x6670, 0x4865, 0x84, 0x29, 0x6c, 0x8, 0x51, 0x54, 0x00, 0xff \
|
|
||||||
}
|
|
||||||
|
|
||||||
// as an alternative when you want a byte array (assuming x86 endianness):
|
|
||||||
#define RENDERDOC_ShaderDebugMagicValue_bytearray \
|
|
||||||
{ \
|
|
||||||
0x20, 0x55, 0xb2, 0xea, 0x70, 0x66, 0x65, 0x48, 0x84, 0x29, 0x6c, 0x8, 0x51, 0x54, 0x00, 0xff \
|
|
||||||
}
|
|
||||||
|
|
||||||
// truncated version when only a uint64_t is available (e.g. Vulkan tags):
|
|
||||||
#define RENDERDOC_ShaderDebugMagicValue_truncated 0x48656670eab25520ULL
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// RenderDoc capture options
|
|
||||||
//
|
|
||||||
|
|
||||||
typedef enum RENDERDOC_CaptureOption
|
|
||||||
{
|
|
||||||
// Allow the application to enable vsync
|
|
||||||
//
|
|
||||||
// Default - enabled
|
|
||||||
//
|
|
||||||
// 1 - The application can enable or disable vsync at will
|
|
||||||
// 0 - vsync is force disabled
|
|
||||||
eRENDERDOC_Option_AllowVSync = 0,
|
|
||||||
|
|
||||||
// Allow the application to enable fullscreen
|
|
||||||
//
|
|
||||||
// Default - enabled
|
|
||||||
//
|
|
||||||
// 1 - The application can enable or disable fullscreen at will
|
|
||||||
// 0 - fullscreen is force disabled
|
|
||||||
eRENDERDOC_Option_AllowFullscreen = 1,
|
|
||||||
|
|
||||||
// Record API debugging events and messages
|
|
||||||
//
|
|
||||||
// Default - disabled
|
|
||||||
//
|
|
||||||
// 1 - Enable built-in API debugging features and records the results into
|
|
||||||
// the capture, which is matched up with events on replay
|
|
||||||
// 0 - no API debugging is forcibly enabled
|
|
||||||
eRENDERDOC_Option_APIValidation = 2,
|
|
||||||
eRENDERDOC_Option_DebugDeviceMode = 2, // deprecated name of this enum
|
|
||||||
|
|
||||||
// Capture CPU callstacks for API events
|
|
||||||
//
|
|
||||||
// Default - disabled
|
|
||||||
//
|
|
||||||
// 1 - Enables capturing of callstacks
|
|
||||||
// 0 - no callstacks are captured
|
|
||||||
eRENDERDOC_Option_CaptureCallstacks = 3,
|
|
||||||
|
|
||||||
// When capturing CPU callstacks, only capture them from actions.
|
|
||||||
// This option does nothing without the above option being enabled
|
|
||||||
//
|
|
||||||
// Default - disabled
|
|
||||||
//
|
|
||||||
// 1 - Only captures callstacks for actions.
|
|
||||||
// Ignored if CaptureCallstacks is disabled
|
|
||||||
// 0 - Callstacks, if enabled, are captured for every event.
|
|
||||||
eRENDERDOC_Option_CaptureCallstacksOnlyDraws = 4,
|
|
||||||
eRENDERDOC_Option_CaptureCallstacksOnlyActions = 4,
|
|
||||||
|
|
||||||
// Specify a delay in seconds to wait for a debugger to attach, after
|
|
||||||
// creating or injecting into a process, before continuing to allow it to run.
|
|
||||||
//
|
|
||||||
// 0 indicates no delay, and the process will run immediately after injection
|
|
||||||
//
|
|
||||||
// Default - 0 seconds
|
|
||||||
//
|
|
||||||
eRENDERDOC_Option_DelayForDebugger = 5,
|
|
||||||
|
|
||||||
// Verify buffer access. This includes checking the memory returned by a Map() call to
|
|
||||||
// detect any out-of-bounds modification, as well as initialising buffers with undefined contents
|
|
||||||
// to a marker value to catch use of uninitialised memory.
|
|
||||||
//
|
|
||||||
// NOTE: This option is only valid for OpenGL and D3D11. Explicit APIs such as D3D12 and Vulkan do
|
|
||||||
// not do the same kind of interception & checking and undefined contents are really undefined.
|
|
||||||
//
|
|
||||||
// Default - disabled
|
|
||||||
//
|
|
||||||
// 1 - Verify buffer access
|
|
||||||
// 0 - No verification is performed, and overwriting bounds may cause crashes or corruption in
|
|
||||||
// RenderDoc.
|
|
||||||
eRENDERDOC_Option_VerifyBufferAccess = 6,
|
|
||||||
|
|
||||||
// The old name for eRENDERDOC_Option_VerifyBufferAccess was eRENDERDOC_Option_VerifyMapWrites.
|
|
||||||
// This option now controls the filling of uninitialised buffers with 0xdddddddd which was
|
|
||||||
// previously always enabled
|
|
||||||
eRENDERDOC_Option_VerifyMapWrites = eRENDERDOC_Option_VerifyBufferAccess,
|
|
||||||
|
|
||||||
// Hooks any system API calls that create child processes, and injects
|
|
||||||
// RenderDoc into them recursively with the same options.
|
|
||||||
//
|
|
||||||
// Default - disabled
|
|
||||||
//
|
|
||||||
// 1 - Hooks into spawned child processes
|
|
||||||
// 0 - Child processes are not hooked by RenderDoc
|
|
||||||
eRENDERDOC_Option_HookIntoChildren = 7,
|
|
||||||
|
|
||||||
// By default RenderDoc only includes resources in the final capture necessary
|
|
||||||
// for that frame, this allows you to override that behaviour.
|
|
||||||
//
|
|
||||||
// Default - disabled
|
|
||||||
//
|
|
||||||
// 1 - all live resources at the time of capture are included in the capture
|
|
||||||
// and available for inspection
|
|
||||||
// 0 - only the resources referenced by the captured frame are included
|
|
||||||
eRENDERDOC_Option_RefAllResources = 8,
|
|
||||||
|
|
||||||
// **NOTE**: As of RenderDoc v1.1 this option has been deprecated. Setting or
|
|
||||||
// getting it will be ignored, to allow compatibility with older versions.
|
|
||||||
// In v1.1 the option acts as if it's always enabled.
|
|
||||||
//
|
|
||||||
// By default RenderDoc skips saving initial states for resources where the
|
|
||||||
// previous contents don't appear to be used, assuming that writes before
|
|
||||||
// reads indicate previous contents aren't used.
|
|
||||||
//
|
|
||||||
// Default - disabled
|
|
||||||
//
|
|
||||||
// 1 - initial contents at the start of each captured frame are saved, even if
|
|
||||||
// they are later overwritten or cleared before being used.
|
|
||||||
// 0 - unless a read is detected, initial contents will not be saved and will
|
|
||||||
// appear as black or empty data.
|
|
||||||
eRENDERDOC_Option_SaveAllInitials = 9,
|
|
||||||
|
|
||||||
// In APIs that allow for the recording of command lists to be replayed later,
|
|
||||||
// RenderDoc may choose to not capture command lists before a frame capture is
|
|
||||||
// triggered, to reduce overheads. This means any command lists recorded once
|
|
||||||
// and replayed many times will not be available and may cause a failure to
|
|
||||||
// capture.
|
|
||||||
//
|
|
||||||
// NOTE: This is only true for APIs where multithreading is difficult or
|
|
||||||
// discouraged. Newer APIs like Vulkan and D3D12 will ignore this option
|
|
||||||
// and always capture all command lists since the API is heavily oriented
|
|
||||||
// around it and the overheads have been reduced by API design.
|
|
||||||
//
|
|
||||||
// 1 - All command lists are captured from the start of the application
|
|
||||||
// 0 - Command lists are only captured if their recording begins during
|
|
||||||
// the period when a frame capture is in progress.
|
|
||||||
eRENDERDOC_Option_CaptureAllCmdLists = 10,
|
|
||||||
|
|
||||||
// Mute API debugging output when the API validation mode option is enabled
|
|
||||||
//
|
|
||||||
// Default - enabled
|
|
||||||
//
|
|
||||||
// 1 - Mute any API debug messages from being displayed or passed through
|
|
||||||
// 0 - API debugging is displayed as normal
|
|
||||||
eRENDERDOC_Option_DebugOutputMute = 11,
|
|
||||||
|
|
||||||
// Option to allow vendor extensions to be used even when they may be
|
|
||||||
// incompatible with RenderDoc and cause corrupted replays or crashes.
|
|
||||||
//
|
|
||||||
// Default - inactive
|
|
||||||
//
|
|
||||||
// No values are documented, this option should only be used when absolutely
|
|
||||||
// necessary as directed by a RenderDoc developer.
|
|
||||||
eRENDERDOC_Option_AllowUnsupportedVendorExtensions = 12,
|
|
||||||
|
|
||||||
// Define a soft memory limit which some APIs may aim to keep overhead under where
|
|
||||||
// possible. Anything above this limit will where possible be saved directly to disk during
|
|
||||||
// capture.
|
|
||||||
// This will cause increased disk space use (which may cause a capture to fail if disk space is
|
|
||||||
// exhausted) as well as slower capture times.
|
|
||||||
//
|
|
||||||
// Not all memory allocations may be deferred like this so it is not a guarantee of a memory
|
|
||||||
// limit.
|
|
||||||
//
|
|
||||||
// Units are in MBs, suggested values would range from 200MB to 1000MB.
|
|
||||||
//
|
|
||||||
// Default - 0 Megabytes
|
|
||||||
eRENDERDOC_Option_SoftMemoryLimit = 13,
|
|
||||||
} RENDERDOC_CaptureOption;
|
|
||||||
|
|
||||||
// Sets an option that controls how RenderDoc behaves on capture.
|
|
||||||
//
|
|
||||||
// Returns 1 if the option and value are valid
|
|
||||||
// Returns 0 if either is invalid and the option is unchanged
|
|
||||||
typedef int(RENDERDOC_CC *pRENDERDOC_SetCaptureOptionU32)(RENDERDOC_CaptureOption opt, uint32_t val);
|
|
||||||
typedef int(RENDERDOC_CC *pRENDERDOC_SetCaptureOptionF32)(RENDERDOC_CaptureOption opt, float val);
|
|
||||||
|
|
||||||
// Gets the current value of an option as a uint32_t
|
|
||||||
//
|
|
||||||
// If the option is invalid, 0xffffffff is returned
|
|
||||||
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetCaptureOptionU32)(RENDERDOC_CaptureOption opt);
|
|
||||||
|
|
||||||
// Gets the current value of an option as a float
|
|
||||||
//
|
|
||||||
// If the option is invalid, -FLT_MAX is returned
|
|
||||||
typedef float(RENDERDOC_CC *pRENDERDOC_GetCaptureOptionF32)(RENDERDOC_CaptureOption opt);
|
|
||||||
|
|
||||||
typedef enum RENDERDOC_InputButton
|
|
||||||
{
|
|
||||||
// '0' - '9' matches ASCII values
|
|
||||||
eRENDERDOC_Key_0 = 0x30,
|
|
||||||
eRENDERDOC_Key_1 = 0x31,
|
|
||||||
eRENDERDOC_Key_2 = 0x32,
|
|
||||||
eRENDERDOC_Key_3 = 0x33,
|
|
||||||
eRENDERDOC_Key_4 = 0x34,
|
|
||||||
eRENDERDOC_Key_5 = 0x35,
|
|
||||||
eRENDERDOC_Key_6 = 0x36,
|
|
||||||
eRENDERDOC_Key_7 = 0x37,
|
|
||||||
eRENDERDOC_Key_8 = 0x38,
|
|
||||||
eRENDERDOC_Key_9 = 0x39,
|
|
||||||
|
|
||||||
// 'A' - 'Z' matches ASCII values
|
|
||||||
eRENDERDOC_Key_A = 0x41,
|
|
||||||
eRENDERDOC_Key_B = 0x42,
|
|
||||||
eRENDERDOC_Key_C = 0x43,
|
|
||||||
eRENDERDOC_Key_D = 0x44,
|
|
||||||
eRENDERDOC_Key_E = 0x45,
|
|
||||||
eRENDERDOC_Key_F = 0x46,
|
|
||||||
eRENDERDOC_Key_G = 0x47,
|
|
||||||
eRENDERDOC_Key_H = 0x48,
|
|
||||||
eRENDERDOC_Key_I = 0x49,
|
|
||||||
eRENDERDOC_Key_J = 0x4A,
|
|
||||||
eRENDERDOC_Key_K = 0x4B,
|
|
||||||
eRENDERDOC_Key_L = 0x4C,
|
|
||||||
eRENDERDOC_Key_M = 0x4D,
|
|
||||||
eRENDERDOC_Key_N = 0x4E,
|
|
||||||
eRENDERDOC_Key_O = 0x4F,
|
|
||||||
eRENDERDOC_Key_P = 0x50,
|
|
||||||
eRENDERDOC_Key_Q = 0x51,
|
|
||||||
eRENDERDOC_Key_R = 0x52,
|
|
||||||
eRENDERDOC_Key_S = 0x53,
|
|
||||||
eRENDERDOC_Key_T = 0x54,
|
|
||||||
eRENDERDOC_Key_U = 0x55,
|
|
||||||
eRENDERDOC_Key_V = 0x56,
|
|
||||||
eRENDERDOC_Key_W = 0x57,
|
|
||||||
eRENDERDOC_Key_X = 0x58,
|
|
||||||
eRENDERDOC_Key_Y = 0x59,
|
|
||||||
eRENDERDOC_Key_Z = 0x5A,
|
|
||||||
|
|
||||||
// leave the rest of the ASCII range free
|
|
||||||
// in case we want to use it later
|
|
||||||
eRENDERDOC_Key_NonPrintable = 0x100,
|
|
||||||
|
|
||||||
eRENDERDOC_Key_Divide,
|
|
||||||
eRENDERDOC_Key_Multiply,
|
|
||||||
eRENDERDOC_Key_Subtract,
|
|
||||||
eRENDERDOC_Key_Plus,
|
|
||||||
|
|
||||||
eRENDERDOC_Key_F1,
|
|
||||||
eRENDERDOC_Key_F2,
|
|
||||||
eRENDERDOC_Key_F3,
|
|
||||||
eRENDERDOC_Key_F4,
|
|
||||||
eRENDERDOC_Key_F5,
|
|
||||||
eRENDERDOC_Key_F6,
|
|
||||||
eRENDERDOC_Key_F7,
|
|
||||||
eRENDERDOC_Key_F8,
|
|
||||||
eRENDERDOC_Key_F9,
|
|
||||||
eRENDERDOC_Key_F10,
|
|
||||||
eRENDERDOC_Key_F11,
|
|
||||||
eRENDERDOC_Key_F12,
|
|
||||||
|
|
||||||
eRENDERDOC_Key_Home,
|
|
||||||
eRENDERDOC_Key_End,
|
|
||||||
eRENDERDOC_Key_Insert,
|
|
||||||
eRENDERDOC_Key_Delete,
|
|
||||||
eRENDERDOC_Key_PageUp,
|
|
||||||
eRENDERDOC_Key_PageDn,
|
|
||||||
|
|
||||||
eRENDERDOC_Key_Backspace,
|
|
||||||
eRENDERDOC_Key_Tab,
|
|
||||||
eRENDERDOC_Key_PrtScrn,
|
|
||||||
eRENDERDOC_Key_Pause,
|
|
||||||
|
|
||||||
eRENDERDOC_Key_Max,
|
|
||||||
} RENDERDOC_InputButton;
|
|
||||||
|
|
||||||
// Sets which key or keys can be used to toggle focus between multiple windows
|
|
||||||
//
|
|
||||||
// If keys is NULL or num is 0, toggle keys will be disabled
|
|
||||||
typedef void(RENDERDOC_CC *pRENDERDOC_SetFocusToggleKeys)(RENDERDOC_InputButton *keys, int num);
|
|
||||||
|
|
||||||
// Sets which key or keys can be used to capture the next frame
|
|
||||||
//
|
|
||||||
// If keys is NULL or num is 0, captures keys will be disabled
|
|
||||||
typedef void(RENDERDOC_CC *pRENDERDOC_SetCaptureKeys)(RENDERDOC_InputButton *keys, int num);
|
|
||||||
|
|
||||||
typedef enum RENDERDOC_OverlayBits
|
|
||||||
{
|
|
||||||
// This single bit controls whether the overlay is enabled or disabled globally
|
|
||||||
eRENDERDOC_Overlay_Enabled = 0x1,
|
|
||||||
|
|
||||||
// Show the average framerate over several seconds as well as min/max
|
|
||||||
eRENDERDOC_Overlay_FrameRate = 0x2,
|
|
||||||
|
|
||||||
// Show the current frame number
|
|
||||||
eRENDERDOC_Overlay_FrameNumber = 0x4,
|
|
||||||
|
|
||||||
// Show a list of recent captures, and how many captures have been made
|
|
||||||
eRENDERDOC_Overlay_CaptureList = 0x8,
|
|
||||||
|
|
||||||
// Default values for the overlay mask
|
|
||||||
eRENDERDOC_Overlay_Default = (eRENDERDOC_Overlay_Enabled | eRENDERDOC_Overlay_FrameRate |
|
|
||||||
eRENDERDOC_Overlay_FrameNumber | eRENDERDOC_Overlay_CaptureList),
|
|
||||||
|
|
||||||
// Enable all bits
|
|
||||||
eRENDERDOC_Overlay_All = ~0U,
|
|
||||||
|
|
||||||
// Disable all bits
|
|
||||||
eRENDERDOC_Overlay_None = 0,
|
|
||||||
} RENDERDOC_OverlayBits;
|
|
||||||
|
|
||||||
// returns the overlay bits that have been set
|
|
||||||
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetOverlayBits)();
|
|
||||||
// sets the overlay bits with an and & or mask
|
|
||||||
typedef void(RENDERDOC_CC *pRENDERDOC_MaskOverlayBits)(uint32_t And, uint32_t Or);
|
|
||||||
|
|
||||||
// this function will attempt to remove RenderDoc's hooks in the application.
|
|
||||||
//
|
|
||||||
// Note: that this can only work correctly if done immediately after
|
|
||||||
// the module is loaded, before any API work happens. RenderDoc will remove its
|
|
||||||
// injected hooks and shut down. Behaviour is undefined if this is called
|
|
||||||
// after any API functions have been called, and there is still no guarantee of
|
|
||||||
// success.
|
|
||||||
typedef void(RENDERDOC_CC *pRENDERDOC_RemoveHooks)();
|
|
||||||
|
|
||||||
// DEPRECATED: compatibility for code compiled against pre-1.4.1 headers.
|
|
||||||
typedef pRENDERDOC_RemoveHooks pRENDERDOC_Shutdown;
|
|
||||||
|
|
||||||
// This function will unload RenderDoc's crash handler.
|
|
||||||
//
|
|
||||||
// If you use your own crash handler and don't want RenderDoc's handler to
|
|
||||||
// intercede, you can call this function to unload it and any unhandled
|
|
||||||
// exceptions will pass to the next handler.
|
|
||||||
typedef void(RENDERDOC_CC *pRENDERDOC_UnloadCrashHandler)();
|
|
||||||
|
|
||||||
// Sets the capture file path template
|
|
||||||
//
|
|
||||||
// pathtemplate is a UTF-8 string that gives a template for how captures will be named
|
|
||||||
// and where they will be saved.
|
|
||||||
//
|
|
||||||
// Any extension is stripped off the path, and captures are saved in the directory
|
|
||||||
// specified, and named with the filename and the frame number appended. If the
|
|
||||||
// directory does not exist it will be created, including any parent directories.
|
|
||||||
//
|
|
||||||
// If pathtemplate is NULL, the template will remain unchanged
|
|
||||||
//
|
|
||||||
// Example:
|
|
||||||
//
|
|
||||||
// SetCaptureFilePathTemplate("my_captures/example");
|
|
||||||
//
|
|
||||||
// Capture #1 -> my_captures/example_frame123.rdc
|
|
||||||
// Capture #2 -> my_captures/example_frame456.rdc
|
|
||||||
typedef void(RENDERDOC_CC *pRENDERDOC_SetCaptureFilePathTemplate)(const char *pathtemplate);
|
|
||||||
|
|
||||||
// returns the current capture path template, see SetCaptureFileTemplate above, as a UTF-8 string
|
|
||||||
typedef const char *(RENDERDOC_CC *pRENDERDOC_GetCaptureFilePathTemplate)();
|
|
||||||
|
|
||||||
// DEPRECATED: compatibility for code compiled against pre-1.1.2 headers.
|
|
||||||
typedef pRENDERDOC_SetCaptureFilePathTemplate pRENDERDOC_SetLogFilePathTemplate;
|
|
||||||
typedef pRENDERDOC_GetCaptureFilePathTemplate pRENDERDOC_GetLogFilePathTemplate;
|
|
||||||
|
|
||||||
// returns the number of captures that have been made
|
|
||||||
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetNumCaptures)();
|
|
||||||
|
|
||||||
// This function returns the details of a capture, by index. New captures are added
|
|
||||||
// to the end of the list.
|
|
||||||
//
|
|
||||||
// filename will be filled with the absolute path to the capture file, as a UTF-8 string
|
|
||||||
// pathlength will be written with the length in bytes of the filename string
|
|
||||||
// timestamp will be written with the time of the capture, in seconds since the Unix epoch
|
|
||||||
//
|
|
||||||
// Any of the parameters can be NULL and they'll be skipped.
|
|
||||||
//
|
|
||||||
// The function will return 1 if the capture index is valid, or 0 if the index is invalid
|
|
||||||
// If the index is invalid, the values will be unchanged
|
|
||||||
//
|
|
||||||
// Note: when captures are deleted in the UI they will remain in this list, so the
|
|
||||||
// capture path may not exist anymore.
|
|
||||||
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetCapture)(uint32_t idx, char *filename,
|
|
||||||
uint32_t *pathlength, uint64_t *timestamp);
|
|
||||||
|
|
||||||
// Sets the comments associated with a capture file. These comments are displayed in the
|
|
||||||
// UI program when opening.
|
|
||||||
//
|
|
||||||
// filePath should be a path to the capture file to add comments to. If set to NULL or ""
|
|
||||||
// the most recent capture file created made will be used instead.
|
|
||||||
// comments should be a NULL-terminated UTF-8 string to add as comments.
|
|
||||||
//
|
|
||||||
// Any existing comments will be overwritten.
|
|
||||||
typedef void(RENDERDOC_CC *pRENDERDOC_SetCaptureFileComments)(const char *filePath,
|
|
||||||
const char *comments);
|
|
||||||
|
|
||||||
// returns 1 if the RenderDoc UI is connected to this application, 0 otherwise
|
|
||||||
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_IsTargetControlConnected)();
|
|
||||||
|
|
||||||
// DEPRECATED: compatibility for code compiled against pre-1.1.1 headers.
|
|
||||||
// This was renamed to IsTargetControlConnected in API 1.1.1, the old typedef is kept here for
|
|
||||||
// backwards compatibility with old code, it is castable either way since it's ABI compatible
|
|
||||||
// as the same function pointer type.
|
|
||||||
typedef pRENDERDOC_IsTargetControlConnected pRENDERDOC_IsRemoteAccessConnected;
|
|
||||||
|
|
||||||
// This function will launch the Replay UI associated with the RenderDoc library injected
|
|
||||||
// into the running application.
|
|
||||||
//
|
|
||||||
// if connectTargetControl is 1, the Replay UI will be launched with a command line parameter
|
|
||||||
// to connect to this application
|
|
||||||
// cmdline is the rest of the command line, as a UTF-8 string. E.g. a captures to open
|
|
||||||
// if cmdline is NULL, the command line will be empty.
|
|
||||||
//
|
|
||||||
// returns the PID of the replay UI if successful, 0 if not successful.
|
|
||||||
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_LaunchReplayUI)(uint32_t connectTargetControl,
|
|
||||||
const char *cmdline);
|
|
||||||
|
|
||||||
// RenderDoc can return a higher version than requested if it's backwards compatible,
|
|
||||||
// this function returns the actual version returned. If a parameter is NULL, it will be
|
|
||||||
// ignored and the others will be filled out.
|
|
||||||
typedef void(RENDERDOC_CC *pRENDERDOC_GetAPIVersion)(int *major, int *minor, int *patch);
|
|
||||||
|
|
||||||
// Requests that the replay UI show itself (if hidden or not the current top window). This can be
|
|
||||||
// used in conjunction with IsTargetControlConnected and LaunchReplayUI to intelligently handle
|
|
||||||
// showing the UI after making a capture.
|
|
||||||
//
|
|
||||||
// This will return 1 if the request was successfully passed on, though it's not guaranteed that
|
|
||||||
// the UI will be on top in all cases depending on OS rules. It will return 0 if there is no current
|
|
||||||
// target control connection to make such a request, or if there was another error
|
|
||||||
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_ShowReplayUI)();
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
// Capturing functions
|
|
||||||
//
|
|
||||||
|
|
||||||
// A device pointer is a pointer to the API's root handle.
|
|
||||||
//
|
|
||||||
// This would be an ID3D11Device, HGLRC/GLXContext, ID3D12Device, etc
|
|
||||||
typedef void *RENDERDOC_DevicePointer;
|
|
||||||
|
|
||||||
// A window handle is the OS's native window handle
|
|
||||||
//
|
|
||||||
// This would be an HWND, GLXDrawable, etc
|
|
||||||
typedef void *RENDERDOC_WindowHandle;
|
|
||||||
|
|
||||||
// A helper macro for Vulkan, where the device handle cannot be used directly.
|
|
||||||
//
|
|
||||||
// Passing the VkInstance to this macro will return the RENDERDOC_DevicePointer to use.
|
|
||||||
//
|
|
||||||
// Specifically, the value needed is the dispatch table pointer, which sits as the first
|
|
||||||
// pointer-sized object in the memory pointed to by the VkInstance. Thus we cast to a void** and
|
|
||||||
// indirect once.
|
|
||||||
#define RENDERDOC_DEVICEPOINTER_FROM_VKINSTANCE(inst) (*((void **)(inst)))
|
|
||||||
|
|
||||||
// This sets the RenderDoc in-app overlay in the API/window pair as 'active' and it will
|
|
||||||
// respond to keypresses. Neither parameter can be NULL
|
|
||||||
typedef void(RENDERDOC_CC *pRENDERDOC_SetActiveWindow)(RENDERDOC_DevicePointer device,
|
|
||||||
RENDERDOC_WindowHandle wndHandle);
|
|
||||||
|
|
||||||
// capture the next frame on whichever window and API is currently considered active
|
|
||||||
typedef void(RENDERDOC_CC *pRENDERDOC_TriggerCapture)();
|
|
||||||
|
|
||||||
// capture the next N frames on whichever window and API is currently considered active
|
|
||||||
typedef void(RENDERDOC_CC *pRENDERDOC_TriggerMultiFrameCapture)(uint32_t numFrames);
|
|
||||||
|
|
||||||
// When choosing either a device pointer or a window handle to capture, you can pass NULL.
|
|
||||||
// Passing NULL specifies a 'wildcard' match against anything. This allows you to specify
|
|
||||||
// any API rendering to a specific window, or a specific API instance rendering to any window,
|
|
||||||
// or in the simplest case of one window and one API, you can just pass NULL for both.
|
|
||||||
//
|
|
||||||
// In either case, if there are two or more possible matching (device,window) pairs it
|
|
||||||
// is undefined which one will be captured.
|
|
||||||
//
|
|
||||||
// Note: for headless rendering you can pass NULL for the window handle and either specify
|
|
||||||
// a device pointer or leave it NULL as above.
|
|
||||||
|
|
||||||
// Immediately starts capturing API calls on the specified device pointer and window handle.
|
|
||||||
//
|
|
||||||
// If there is no matching thing to capture (e.g. no supported API has been initialised),
|
|
||||||
// this will do nothing.
|
|
||||||
//
|
|
||||||
// The results are undefined (including crashes) if two captures are started overlapping,
|
|
||||||
// even on separate devices and/oror windows.
|
|
||||||
typedef void(RENDERDOC_CC *pRENDERDOC_StartFrameCapture)(RENDERDOC_DevicePointer device,
|
|
||||||
RENDERDOC_WindowHandle wndHandle);
|
|
||||||
|
|
||||||
// Returns whether or not a frame capture is currently ongoing anywhere.
|
|
||||||
//
|
|
||||||
// This will return 1 if a capture is ongoing, and 0 if there is no capture running
|
|
||||||
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_IsFrameCapturing)();
|
|
||||||
|
|
||||||
// Ends capturing immediately.
|
|
||||||
//
|
|
||||||
// This will return 1 if the capture succeeded, and 0 if there was an error capturing.
|
|
||||||
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_EndFrameCapture)(RENDERDOC_DevicePointer device,
|
|
||||||
RENDERDOC_WindowHandle wndHandle);
|
|
||||||
|
|
||||||
// Ends capturing immediately and discard any data stored without saving to disk.
|
|
||||||
//
|
|
||||||
// This will return 1 if the capture was discarded, and 0 if there was an error or no capture
|
|
||||||
// was in progress
|
|
||||||
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_DiscardFrameCapture)(RENDERDOC_DevicePointer device,
|
|
||||||
RENDERDOC_WindowHandle wndHandle);
|
|
||||||
|
|
||||||
// Only valid to be called between a call to StartFrameCapture and EndFrameCapture. Gives a custom
|
|
||||||
// title to the capture produced which will be displayed in the UI.
|
|
||||||
//
|
|
||||||
// If multiple captures are ongoing, this title will be applied to the first capture to end after
|
|
||||||
// this call. The second capture to end will have no title, unless this function is called again.
|
|
||||||
//
|
|
||||||
// Calling this function has no effect if no capture is currently running, and if it is called
|
|
||||||
// multiple times only the last title will be used.
|
|
||||||
typedef void(RENDERDOC_CC *pRENDERDOC_SetCaptureTitle)(const char *title);
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// RenderDoc API versions
|
|
||||||
//
|
|
||||||
|
|
||||||
// RenderDoc uses semantic versioning (http://semver.org/).
|
|
||||||
//
|
|
||||||
// MAJOR version is incremented when incompatible API changes happen.
|
|
||||||
// MINOR version is incremented when functionality is added in a backwards-compatible manner.
|
|
||||||
// PATCH version is incremented when backwards-compatible bug fixes happen.
|
|
||||||
//
|
|
||||||
// Note that this means the API returned can be higher than the one you might have requested.
|
|
||||||
// e.g. if you are running against a newer RenderDoc that supports 1.0.1, it will be returned
|
|
||||||
// instead of 1.0.0. You can check this with the GetAPIVersion entry point
|
|
||||||
typedef enum RENDERDOC_Version
|
|
||||||
{
|
|
||||||
eRENDERDOC_API_Version_1_0_0 = 10000, // RENDERDOC_API_1_0_0 = 1 00 00
|
|
||||||
eRENDERDOC_API_Version_1_0_1 = 10001, // RENDERDOC_API_1_0_1 = 1 00 01
|
|
||||||
eRENDERDOC_API_Version_1_0_2 = 10002, // RENDERDOC_API_1_0_2 = 1 00 02
|
|
||||||
eRENDERDOC_API_Version_1_1_0 = 10100, // RENDERDOC_API_1_1_0 = 1 01 00
|
|
||||||
eRENDERDOC_API_Version_1_1_1 = 10101, // RENDERDOC_API_1_1_1 = 1 01 01
|
|
||||||
eRENDERDOC_API_Version_1_1_2 = 10102, // RENDERDOC_API_1_1_2 = 1 01 02
|
|
||||||
eRENDERDOC_API_Version_1_2_0 = 10200, // RENDERDOC_API_1_2_0 = 1 02 00
|
|
||||||
eRENDERDOC_API_Version_1_3_0 = 10300, // RENDERDOC_API_1_3_0 = 1 03 00
|
|
||||||
eRENDERDOC_API_Version_1_4_0 = 10400, // RENDERDOC_API_1_4_0 = 1 04 00
|
|
||||||
eRENDERDOC_API_Version_1_4_1 = 10401, // RENDERDOC_API_1_4_1 = 1 04 01
|
|
||||||
eRENDERDOC_API_Version_1_4_2 = 10402, // RENDERDOC_API_1_4_2 = 1 04 02
|
|
||||||
eRENDERDOC_API_Version_1_5_0 = 10500, // RENDERDOC_API_1_5_0 = 1 05 00
|
|
||||||
eRENDERDOC_API_Version_1_6_0 = 10600, // RENDERDOC_API_1_6_0 = 1 06 00
|
|
||||||
} RENDERDOC_Version;
|
|
||||||
|
|
||||||
// API version changelog:
|
|
||||||
//
|
|
||||||
// 1.0.0 - initial release
|
|
||||||
// 1.0.1 - Bugfix: IsFrameCapturing() was returning false for captures that were triggered
|
|
||||||
// by keypress or TriggerCapture, instead of Start/EndFrameCapture.
|
|
||||||
// 1.0.2 - Refactor: Renamed eRENDERDOC_Option_DebugDeviceMode to eRENDERDOC_Option_APIValidation
|
|
||||||
// 1.1.0 - Add feature: TriggerMultiFrameCapture(). Backwards compatible with 1.0.x since the new
|
|
||||||
// function pointer is added to the end of the struct, the original layout is identical
|
|
||||||
// 1.1.1 - Refactor: Renamed remote access to target control (to better disambiguate from remote
|
|
||||||
// replay/remote server concept in replay UI)
|
|
||||||
// 1.1.2 - Refactor: Renamed "log file" in function names to just capture, to clarify that these
|
|
||||||
// are captures and not debug logging files. This is the first API version in the v1.0
|
|
||||||
// branch.
|
|
||||||
// 1.2.0 - Added feature: SetCaptureFileComments() to add comments to a capture file that will be
|
|
||||||
// displayed in the UI program on load.
|
|
||||||
// 1.3.0 - Added feature: New capture option eRENDERDOC_Option_AllowUnsupportedVendorExtensions
|
|
||||||
// which allows users to opt-in to allowing unsupported vendor extensions to function.
|
|
||||||
// Should be used at the user's own risk.
|
|
||||||
// Refactor: Renamed eRENDERDOC_Option_VerifyMapWrites to
|
|
||||||
// eRENDERDOC_Option_VerifyBufferAccess, which now also controls initialisation to
|
|
||||||
// 0xdddddddd of uninitialised buffer contents.
|
|
||||||
// 1.4.0 - Added feature: DiscardFrameCapture() to discard a frame capture in progress and stop
|
|
||||||
// capturing without saving anything to disk.
|
|
||||||
// 1.4.1 - Refactor: Renamed Shutdown to RemoveHooks to better clarify what is happening
|
|
||||||
// 1.4.2 - Refactor: Renamed 'draws' to 'actions' in callstack capture option.
|
|
||||||
// 1.5.0 - Added feature: ShowReplayUI() to request that the replay UI show itself if connected
|
|
||||||
// 1.6.0 - Added feature: SetCaptureTitle() which can be used to set a title for a
|
|
||||||
// capture made with StartFrameCapture() or EndFrameCapture()
|
|
||||||
|
|
||||||
typedef struct RENDERDOC_API_1_6_0
|
|
||||||
{
|
|
||||||
pRENDERDOC_GetAPIVersion GetAPIVersion;
|
|
||||||
|
|
||||||
pRENDERDOC_SetCaptureOptionU32 SetCaptureOptionU32;
|
|
||||||
pRENDERDOC_SetCaptureOptionF32 SetCaptureOptionF32;
|
|
||||||
|
|
||||||
pRENDERDOC_GetCaptureOptionU32 GetCaptureOptionU32;
|
|
||||||
pRENDERDOC_GetCaptureOptionF32 GetCaptureOptionF32;
|
|
||||||
|
|
||||||
pRENDERDOC_SetFocusToggleKeys SetFocusToggleKeys;
|
|
||||||
pRENDERDOC_SetCaptureKeys SetCaptureKeys;
|
|
||||||
|
|
||||||
pRENDERDOC_GetOverlayBits GetOverlayBits;
|
|
||||||
pRENDERDOC_MaskOverlayBits MaskOverlayBits;
|
|
||||||
|
|
||||||
// Shutdown was renamed to RemoveHooks in 1.4.1.
|
|
||||||
// These unions allow old code to continue compiling without changes
|
|
||||||
union
|
|
||||||
{
|
|
||||||
pRENDERDOC_Shutdown Shutdown;
|
|
||||||
pRENDERDOC_RemoveHooks RemoveHooks;
|
|
||||||
};
|
|
||||||
pRENDERDOC_UnloadCrashHandler UnloadCrashHandler;
|
|
||||||
|
|
||||||
// Get/SetLogFilePathTemplate was renamed to Get/SetCaptureFilePathTemplate in 1.1.2.
|
|
||||||
// These unions allow old code to continue compiling without changes
|
|
||||||
union
|
|
||||||
{
|
|
||||||
// deprecated name
|
|
||||||
pRENDERDOC_SetLogFilePathTemplate SetLogFilePathTemplate;
|
|
||||||
// current name
|
|
||||||
pRENDERDOC_SetCaptureFilePathTemplate SetCaptureFilePathTemplate;
|
|
||||||
};
|
|
||||||
union
|
|
||||||
{
|
|
||||||
// deprecated name
|
|
||||||
pRENDERDOC_GetLogFilePathTemplate GetLogFilePathTemplate;
|
|
||||||
// current name
|
|
||||||
pRENDERDOC_GetCaptureFilePathTemplate GetCaptureFilePathTemplate;
|
|
||||||
};
|
|
||||||
|
|
||||||
pRENDERDOC_GetNumCaptures GetNumCaptures;
|
|
||||||
pRENDERDOC_GetCapture GetCapture;
|
|
||||||
|
|
||||||
pRENDERDOC_TriggerCapture TriggerCapture;
|
|
||||||
|
|
||||||
// IsRemoteAccessConnected was renamed to IsTargetControlConnected in 1.1.1.
|
|
||||||
// This union allows old code to continue compiling without changes
|
|
||||||
union
|
|
||||||
{
|
|
||||||
// deprecated name
|
|
||||||
pRENDERDOC_IsRemoteAccessConnected IsRemoteAccessConnected;
|
|
||||||
// current name
|
|
||||||
pRENDERDOC_IsTargetControlConnected IsTargetControlConnected;
|
|
||||||
};
|
|
||||||
pRENDERDOC_LaunchReplayUI LaunchReplayUI;
|
|
||||||
|
|
||||||
pRENDERDOC_SetActiveWindow SetActiveWindow;
|
|
||||||
|
|
||||||
pRENDERDOC_StartFrameCapture StartFrameCapture;
|
|
||||||
pRENDERDOC_IsFrameCapturing IsFrameCapturing;
|
|
||||||
pRENDERDOC_EndFrameCapture EndFrameCapture;
|
|
||||||
|
|
||||||
// new function in 1.1.0
|
|
||||||
pRENDERDOC_TriggerMultiFrameCapture TriggerMultiFrameCapture;
|
|
||||||
|
|
||||||
// new function in 1.2.0
|
|
||||||
pRENDERDOC_SetCaptureFileComments SetCaptureFileComments;
|
|
||||||
|
|
||||||
// new function in 1.4.0
|
|
||||||
pRENDERDOC_DiscardFrameCapture DiscardFrameCapture;
|
|
||||||
|
|
||||||
// new function in 1.5.0
|
|
||||||
pRENDERDOC_ShowReplayUI ShowReplayUI;
|
|
||||||
|
|
||||||
// new function in 1.6.0
|
|
||||||
pRENDERDOC_SetCaptureTitle SetCaptureTitle;
|
|
||||||
} RENDERDOC_API_1_6_0;
|
|
||||||
|
|
||||||
typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_0_0;
|
|
||||||
typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_0_1;
|
|
||||||
typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_0_2;
|
|
||||||
typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_1_0;
|
|
||||||
typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_1_1;
|
|
||||||
typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_1_2;
|
|
||||||
typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_2_0;
|
|
||||||
typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_3_0;
|
|
||||||
typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_4_0;
|
|
||||||
typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_4_1;
|
|
||||||
typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_4_2;
|
|
||||||
typedef RENDERDOC_API_1_6_0 RENDERDOC_API_1_5_0;
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// RenderDoc API entry point
|
|
||||||
//
|
|
||||||
// This entry point can be obtained via GetProcAddress/dlsym if RenderDoc is available.
|
|
||||||
//
|
|
||||||
// The name is the same as the typedef - "RENDERDOC_GetAPI"
|
|
||||||
//
|
|
||||||
// This function is not thread safe, and should not be called on multiple threads at once.
|
|
||||||
// Ideally, call this once as early as possible in your application's startup, before doing
|
|
||||||
// any API work, since some configuration functionality etc has to be done also before
|
|
||||||
// initialising any APIs.
|
|
||||||
//
|
|
||||||
// Parameters:
|
|
||||||
// version is a single value from the RENDERDOC_Version above.
|
|
||||||
//
|
|
||||||
// outAPIPointers will be filled out with a pointer to the corresponding struct of function
|
|
||||||
// pointers.
|
|
||||||
//
|
|
||||||
// Returns:
|
|
||||||
// 1 - if the outAPIPointers has been filled with a pointer to the API struct requested
|
|
||||||
// 0 - if the requested version is not supported or the arguments are invalid.
|
|
||||||
//
|
|
||||||
typedef int(RENDERDOC_CC *pRENDERDOC_GetAPI)(RENDERDOC_Version version, void **outAPIPointers);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
} // extern "C"
|
|
||||||
#endif
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 2c48a1a50203bbaf1e3d0d64c5d726d56f8d3bb3
|
Subproject commit 1115dad3ffa0994e3f43b693d9b9cc99944c64c1
|
|
@ -1 +1 @@
|
||||||
Subproject commit 4cc3410dce50cefce98d3cf3cf1bc8eca83b862a
|
Subproject commit bcbf09acdef71b550e837c8aaca67b08b6a38f0f
|
|
@ -1 +1 @@
|
||||||
Subproject commit 37090c74cc6e680f2bc334cac8fd182f7634a1f6
|
Subproject commit 8c281cc0b7cd638d3853a5aa2fc35b969fcbb599
|
|
@ -1,4 +1,4 @@
|
||||||
/* stb_image - v2.30 - public domain image loader - http://nothings.org/stb
|
/* stb_image - v2.29 - public domain image loader - http://nothings.org/stb
|
||||||
no warranty implied; use at your own risk
|
no warranty implied; use at your own risk
|
||||||
|
|
||||||
Do this:
|
Do this:
|
||||||
|
@ -48,7 +48,6 @@ LICENSE
|
||||||
|
|
||||||
RECENT REVISION HISTORY:
|
RECENT REVISION HISTORY:
|
||||||
|
|
||||||
2.30 (2024-05-31) avoid erroneous gcc warning
|
|
||||||
2.29 (2023-05-xx) optimizations
|
2.29 (2023-05-xx) optimizations
|
||||||
2.28 (2023-01-29) many error fixes, security errors, just tons of stuff
|
2.28 (2023-01-29) many error fixes, security errors, just tons of stuff
|
||||||
2.27 (2021-07-11) document stbi_info better, 16-bit PNM support, bug fixes
|
2.27 (2021-07-11) document stbi_info better, 16-bit PNM support, bug fixes
|
||||||
|
@ -5160,11 +5159,9 @@ static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp)
|
||||||
// non-paletted with tRNS = constant alpha. if header-scanning, we can stop now.
|
// non-paletted with tRNS = constant alpha. if header-scanning, we can stop now.
|
||||||
if (scan == STBI__SCAN_header) { ++s->img_n; return 1; }
|
if (scan == STBI__SCAN_header) { ++s->img_n; return 1; }
|
||||||
if (z->depth == 16) {
|
if (z->depth == 16) {
|
||||||
for (k = 0; k < s->img_n && k < 3; ++k) // extra loop test to suppress false GCC warning
|
for (k = 0; k < s->img_n; ++k) tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is
|
||||||
tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is
|
|
||||||
} else {
|
} else {
|
||||||
for (k = 0; k < s->img_n && k < 3; ++k)
|
for (k = 0; k < s->img_n; ++k) tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger
|
||||||
tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 4b740127230472779c4a4d71e1a75aaa3a367a2d
|
Subproject commit 85faca9cbe8d76324ff38c1801be44c63e12d5be
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit b8061982cad0210b649541016c88ff5faa90733c
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit e1bdbca9baf4d682fb6066b380f4aa4a7bdbb58a
|
Subproject commit eaf8fc27eeadf6f21b11183651b829e897f01957
|
|
@ -1 +1 @@
|
||||||
Subproject commit d205aff40b4e15d4c568523ee6a26f85138126d9
|
Subproject commit 192d051db3382e213f8bd9d8048fc9eaa78ed6ab
|
|
@ -1 +1 @@
|
||||||
Subproject commit f00c973a6ab2a23573708568b8ef4acc20a9d36b
|
Subproject commit d937b60055aaea313422672ebd5cc8bfa87a1682
|
|
@ -1 +1 @@
|
||||||
Subproject commit ccdf68421bc8eb85693f573080fc0a5faad862db
|
Subproject commit 80477f635345e8f13efc512d84b01b94cad92cd9
|
|
@ -1 +1 @@
|
||||||
Subproject commit dbea33e47e7c0fe0b7c8592cd931c7430c1f130d
|
Subproject commit ac3a25da3d957d9ef3e4114d9f8332d34ce83a46
|
|
@ -1 +1 @@
|
||||||
Subproject commit d54e3769be0c522015b784eca2af258b1c026107
|
Subproject commit 1007e7a9c74148fe915384d7cc44921559500241
|
|
@ -1 +1 @@
|
||||||
Subproject commit bd73bc03b0aacaa89c9c203b9b43cd08f1b1843b
|
Subproject commit fd3e9a6cc8bdcc617b531feda186699e51664f76
|
|
@ -114108,7 +114108,7 @@ STUB(
|
||||||
_ZN3sce2Np9CppWebApi6Common12IntrusivePtrINS1_7Matches2V124RequestCompetitiveResultEE7add_refEv)
|
_ZN3sce2Np9CppWebApi6Common12IntrusivePtrINS1_7Matches2V124RequestCompetitiveResultEE7add_refEv)
|
||||||
STUB("efPahl2FufA",
|
STUB("efPahl2FufA",
|
||||||
_ZN3sce2Np9CppWebApi30CommunicationRestrictionStatus2V35Error8fromJsonERKNS_4Json5ValueE)
|
_ZN3sce2Np9CppWebApi30CommunicationRestrictionStatus2V35Error8fromJsonERKNS_4Json5ValueE)
|
||||||
STUB("efX3lrPwdKA", sceAppContentAddcontMountByEntitlementId)
|
STUB("efX3lrPwdKA", sceAppContentAddcontMountByEntitlemetId)
|
||||||
STUB("efXnxYFN5oE", _ZNSt11range_errorD0Ev)
|
STUB("efXnxYFN5oE", _ZNSt11range_errorD0Ev)
|
||||||
STUB("efcwuDLsAM0", _ZThn120_NK7WebCore16HTMLMediaElement5mutedEv)
|
STUB("efcwuDLsAM0", _ZThn120_NK7WebCore16HTMLMediaElement5mutedEv)
|
||||||
STUB("efhGArzWdxE", _ZN7bmalloc6IsoTLS15s_didInitializeE)
|
STUB("efhGArzWdxE", _ZN7bmalloc6IsoTLS15s_didInitializeE)
|
||||||
|
@ -129493,7 +129493,7 @@ STUB(
|
||||||
STUB("kJlYH5uMAWI", sceNetResolverDestroy)
|
STUB("kJlYH5uMAWI", sceNetResolverDestroy)
|
||||||
STUB("kJmdxo4uM+8",
|
STUB("kJmdxo4uM+8",
|
||||||
_ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE5_InitERKSt8_Locinfo)
|
_ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE5_InitERKSt8_Locinfo)
|
||||||
STUB("kJmjt81mXKQ", sceAppContentAddcontEnqueueDownloadByEntitlementId)
|
STUB("kJmjt81mXKQ", sceAppContentAddcontEnqueueDownloadByEntitlemetId)
|
||||||
STUB(
|
STUB(
|
||||||
"kJoY9lMIFzY",
|
"kJoY9lMIFzY",
|
||||||
_ZN3sce2Np9CppWebApi6Common8IteratorINS2_12IntrusivePtrINS1_21AdvancedPlayerProfile2V138MatchCompletionRateDisconnectedMetricsEEEEmmEi)
|
_ZN3sce2Np9CppWebApi6Common8IteratorINS2_12IntrusivePtrINS1_21AdvancedPlayerProfile2V138MatchCompletionRateDisconnectedMetricsEEEEmmEi)
|
||||||
|
|
|
@ -80897,10 +80897,10 @@ sceAppCheckerExecute
|
||||||
sceAppCheckerExecuteEx
|
sceAppCheckerExecuteEx
|
||||||
sceAppContentAddcontDelete
|
sceAppContentAddcontDelete
|
||||||
sceAppContentAddcontEnqueueDownload
|
sceAppContentAddcontEnqueueDownload
|
||||||
sceAppContentAddcontEnqueueDownloadByEntitlementId
|
sceAppContentAddcontEnqueueDownloadByEntitlemetId
|
||||||
sceAppContentAddcontEnqueueDownloadSp
|
sceAppContentAddcontEnqueueDownloadSp
|
||||||
sceAppContentAddcontMount
|
sceAppContentAddcontMount
|
||||||
sceAppContentAddcontMountByEntitlementId
|
sceAppContentAddcontMountByEntitlemetId
|
||||||
sceAppContentAddcontShrink
|
sceAppContentAddcontShrink
|
||||||
sceAppContentAddcontUnmount
|
sceAppContentAddcontUnmount
|
||||||
sceAppContentAppParamGetInt
|
sceAppContentAppParamGetInt
|
||||||
|
|
|
@ -1,23 +1,20 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include <common/assert.h>
|
||||||
|
#include <core/libraries/error_codes.h>
|
||||||
#include "sdl_audio.h"
|
#include "sdl_audio.h"
|
||||||
|
|
||||||
#include "common/assert.h"
|
|
||||||
#include "core/libraries/error_codes.h"
|
|
||||||
|
|
||||||
#include <SDL3/SDL_audio.h>
|
|
||||||
#include <SDL3/SDL_init.h>
|
|
||||||
#include <SDL3/SDL_timer.h>
|
|
||||||
|
|
||||||
#include <mutex> // std::unique_lock
|
|
||||||
|
|
||||||
namespace Audio {
|
namespace Audio {
|
||||||
|
|
||||||
|
int SDLAudio::AudioInit() {
|
||||||
|
return SDL_InitSubSystem(SDL_INIT_AUDIO);
|
||||||
|
}
|
||||||
|
|
||||||
int SDLAudio::AudioOutOpen(int type, u32 samples_num, u32 freq,
|
int SDLAudio::AudioOutOpen(int type, u32 samples_num, u32 freq,
|
||||||
Libraries::AudioOut::OrbisAudioOutParamFormat format) {
|
Libraries::AudioOut::OrbisAudioOutParam format) {
|
||||||
using Libraries::AudioOut::OrbisAudioOutParamFormat;
|
using Libraries::AudioOut::OrbisAudioOutParam;
|
||||||
std::unique_lock lock{m_mutex};
|
std::scoped_lock lock{m_mutex};
|
||||||
for (int id = 0; id < portsOut.size(); id++) {
|
for (int id = 0; id < portsOut.size(); id++) {
|
||||||
auto& port = portsOut[id];
|
auto& port = portsOut[id];
|
||||||
if (!port.isOpen) {
|
if (!port.isOpen) {
|
||||||
|
@ -28,42 +25,42 @@ int SDLAudio::AudioOutOpen(int type, u32 samples_num, u32 freq,
|
||||||
port.format = format;
|
port.format = format;
|
||||||
SDL_AudioFormat sampleFormat;
|
SDL_AudioFormat sampleFormat;
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_MONO:
|
case OrbisAudioOutParam::ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_MONO:
|
||||||
sampleFormat = SDL_AUDIO_S16;
|
sampleFormat = SDL_AUDIO_S16;
|
||||||
port.channels_num = 1;
|
port.channels_num = 1;
|
||||||
port.sample_size = 2;
|
port.sample_size = 2;
|
||||||
break;
|
break;
|
||||||
case OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_MONO:
|
case OrbisAudioOutParam::ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_MONO:
|
||||||
sampleFormat = SDL_AUDIO_F32;
|
sampleFormat = SDL_AUDIO_F32;
|
||||||
port.channels_num = 1;
|
port.channels_num = 1;
|
||||||
port.sample_size = 4;
|
port.sample_size = 4;
|
||||||
break;
|
break;
|
||||||
case OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_STEREO:
|
case OrbisAudioOutParam::ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_STEREO:
|
||||||
sampleFormat = SDL_AUDIO_S16;
|
sampleFormat = SDL_AUDIO_S16;
|
||||||
port.channels_num = 2;
|
port.channels_num = 2;
|
||||||
port.sample_size = 2;
|
port.sample_size = 2;
|
||||||
break;
|
break;
|
||||||
case OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_STEREO:
|
case OrbisAudioOutParam::ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_STEREO:
|
||||||
sampleFormat = SDL_AUDIO_F32;
|
sampleFormat = SDL_AUDIO_F32;
|
||||||
port.channels_num = 2;
|
port.channels_num = 2;
|
||||||
port.sample_size = 4;
|
port.sample_size = 4;
|
||||||
break;
|
break;
|
||||||
case OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_8CH:
|
case OrbisAudioOutParam::ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_8CH:
|
||||||
sampleFormat = SDL_AUDIO_S16;
|
sampleFormat = SDL_AUDIO_S16;
|
||||||
port.channels_num = 8;
|
port.channels_num = 8;
|
||||||
port.sample_size = 2;
|
port.sample_size = 2;
|
||||||
break;
|
break;
|
||||||
case OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_8CH:
|
case OrbisAudioOutParam::ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_8CH:
|
||||||
sampleFormat = SDL_AUDIO_F32;
|
sampleFormat = SDL_AUDIO_F32;
|
||||||
port.channels_num = 8;
|
port.channels_num = 8;
|
||||||
port.sample_size = 4;
|
port.sample_size = 4;
|
||||||
break;
|
break;
|
||||||
case OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_8CH_STD:
|
case OrbisAudioOutParam::ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_8CH_STD:
|
||||||
sampleFormat = SDL_AUDIO_S16;
|
sampleFormat = SDL_AUDIO_S16;
|
||||||
port.channels_num = 8;
|
port.channels_num = 8;
|
||||||
port.sample_size = 2;
|
port.sample_size = 2;
|
||||||
break;
|
break;
|
||||||
case OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_8CH_STD:
|
case OrbisAudioOutParam::ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_8CH_STD:
|
||||||
sampleFormat = SDL_AUDIO_F32;
|
sampleFormat = SDL_AUDIO_F32;
|
||||||
port.channels_num = 8;
|
port.channels_num = 8;
|
||||||
port.sample_size = 4;
|
port.sample_size = 4;
|
||||||
|
@ -82,7 +79,7 @@ int SDLAudio::AudioOutOpen(int type, u32 samples_num, u32 freq,
|
||||||
fmt.channels = port.channels_num;
|
fmt.channels = port.channels_num;
|
||||||
fmt.freq = 48000;
|
fmt.freq = 48000;
|
||||||
port.stream =
|
port.stream =
|
||||||
SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &fmt, NULL, NULL);
|
SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_OUTPUT, &fmt, NULL, NULL);
|
||||||
SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(port.stream));
|
SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(port.stream));
|
||||||
return id + 1;
|
return id + 1;
|
||||||
}
|
}
|
||||||
|
@ -92,7 +89,7 @@ int SDLAudio::AudioOutOpen(int type, u32 samples_num, u32 freq,
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 SDLAudio::AudioOutOutput(s32 handle, const void* ptr) {
|
s32 SDLAudio::AudioOutOutput(s32 handle, const void* ptr) {
|
||||||
std::shared_lock lock{m_mutex};
|
std::scoped_lock lock{m_mutex};
|
||||||
auto& port = portsOut[handle - 1];
|
auto& port = portsOut[handle - 1];
|
||||||
if (!port.isOpen) {
|
if (!port.isOpen) {
|
||||||
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
|
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
|
||||||
|
@ -104,7 +101,7 @@ s32 SDLAudio::AudioOutOutput(s32 handle, const void* ptr) {
|
||||||
int result = SDL_PutAudioStreamData(port.stream, ptr,
|
int result = SDL_PutAudioStreamData(port.stream, ptr,
|
||||||
port.samples_num * port.sample_size * port.channels_num);
|
port.samples_num * port.sample_size * port.channels_num);
|
||||||
// TODO find a correct value 8192 is estimated
|
// TODO find a correct value 8192 is estimated
|
||||||
while (SDL_GetAudioStreamAvailable(port.stream) > 65536) {
|
while (SDL_GetAudioStreamAvailable(port.stream) > 8192) {
|
||||||
SDL_Delay(0);
|
SDL_Delay(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,8 +109,8 @@ s32 SDLAudio::AudioOutOutput(s32 handle, const void* ptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDLAudio::AudioOutSetVolume(s32 handle, s32 bitflag, s32* volume) {
|
bool SDLAudio::AudioOutSetVolume(s32 handle, s32 bitflag, s32* volume) {
|
||||||
using Libraries::AudioOut::OrbisAudioOutParamFormat;
|
using Libraries::AudioOut::OrbisAudioOutParam;
|
||||||
std::shared_lock lock{m_mutex};
|
std::scoped_lock lock{m_mutex};
|
||||||
auto& port = portsOut[handle - 1];
|
auto& port = portsOut[handle - 1];
|
||||||
if (!port.isOpen) {
|
if (!port.isOpen) {
|
||||||
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
|
return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT;
|
||||||
|
@ -123,9 +120,8 @@ bool SDLAudio::AudioOutSetVolume(s32 handle, s32 bitflag, s32* volume) {
|
||||||
|
|
||||||
if (bit == 1) {
|
if (bit == 1) {
|
||||||
int src_index = i;
|
int src_index = i;
|
||||||
if (port.format ==
|
if (port.format == OrbisAudioOutParam::ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_8CH_STD ||
|
||||||
OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_FLOAT_8CH_STD ||
|
port.format == OrbisAudioOutParam::ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_8CH_STD) {
|
||||||
port.format == OrbisAudioOutParamFormat::ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_8CH_STD) {
|
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 4:
|
case 4:
|
||||||
src_index = 6;
|
src_index = 6;
|
||||||
|
@ -150,13 +146,4 @@ bool SDLAudio::AudioOutSetVolume(s32 handle, s32 bitflag, s32* volume) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDLAudio::AudioOutGetStatus(s32 handle, int* type, int* channels_num) {
|
|
||||||
std::shared_lock lock{m_mutex};
|
|
||||||
auto& port = portsOut[handle - 1];
|
|
||||||
*type = port.type;
|
|
||||||
*channels_num = port.channels_num;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Audio
|
} // namespace Audio
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <shared_mutex>
|
#include <mutex>
|
||||||
#include <SDL3/SDL_audio.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
#include "core/libraries/audio/audioout.h"
|
#include "core/libraries/audio/audioout.h"
|
||||||
|
|
||||||
namespace Audio {
|
namespace Audio {
|
||||||
|
@ -14,25 +15,25 @@ public:
|
||||||
SDLAudio() = default;
|
SDLAudio() = default;
|
||||||
virtual ~SDLAudio() = default;
|
virtual ~SDLAudio() = default;
|
||||||
|
|
||||||
|
int AudioInit();
|
||||||
int AudioOutOpen(int type, u32 samples_num, u32 freq,
|
int AudioOutOpen(int type, u32 samples_num, u32 freq,
|
||||||
Libraries::AudioOut::OrbisAudioOutParamFormat format);
|
Libraries::AudioOut::OrbisAudioOutParam format);
|
||||||
s32 AudioOutOutput(s32 handle, const void* ptr);
|
s32 AudioOutOutput(s32 handle, const void* ptr);
|
||||||
bool AudioOutSetVolume(s32 handle, s32 bitflag, s32* volume);
|
bool AudioOutSetVolume(s32 handle, s32 bitflag, s32* volume);
|
||||||
bool AudioOutGetStatus(s32 handle, int* type, int* channels_num);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct PortOut {
|
struct PortOut {
|
||||||
SDL_AudioStream* stream = nullptr;
|
bool isOpen = false;
|
||||||
|
int type = 0;
|
||||||
u32 samples_num = 0;
|
u32 samples_num = 0;
|
||||||
|
u8 sample_size = 0;
|
||||||
u32 freq = 0;
|
u32 freq = 0;
|
||||||
u32 format = -1;
|
u32 format = -1;
|
||||||
int type = 0;
|
|
||||||
int channels_num = 0;
|
int channels_num = 0;
|
||||||
int volume[8] = {};
|
int volume[8] = {};
|
||||||
u8 sample_size = 0;
|
SDL_AudioStream* stream = nullptr;
|
||||||
bool isOpen = false;
|
|
||||||
};
|
};
|
||||||
std::shared_mutex m_mutex;
|
std::mutex m_mutex;
|
||||||
std::array<PortOut, 22> portsOut; // main up to 8 ports , BGM 1 port , voice up to 4 ports ,
|
std::array<PortOut, 22> portsOut; // main up to 8 ports , BGM 1 port , voice up to 4 ports ,
|
||||||
// personal up to 4 ports , padspk up to 5 ports , aux 1 port
|
// personal up to 4 ports , padspk up to 5 ports , aux 1 port
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,56 +10,25 @@
|
||||||
namespace Config {
|
namespace Config {
|
||||||
|
|
||||||
static bool isNeo = false;
|
static bool isNeo = false;
|
||||||
static bool isFullscreen = false;
|
|
||||||
static u32 screenWidth = 1280;
|
static u32 screenWidth = 1280;
|
||||||
static u32 screenHeight = 720;
|
static u32 screenHeight = 720;
|
||||||
static s32 gpuId = -1; // Vulkan physical device index. Set to negative for auto select
|
static s32 gpuId = -1; // Vulkan physical device index. Set to negative for auto select
|
||||||
static std::string logFilter;
|
static std::string logFilter;
|
||||||
static std::string logType = "async";
|
static std::string logType = "sync";
|
||||||
static std::string userName = "shadPS4";
|
|
||||||
static bool useSpecialPad = false;
|
|
||||||
static int specialPadClass = 1;
|
|
||||||
static bool isDebugDump = false;
|
static bool isDebugDump = false;
|
||||||
|
static bool isLibc = true;
|
||||||
static bool isShowSplash = false;
|
static bool isShowSplash = false;
|
||||||
static bool isNullGpu = false;
|
static bool isNullGpu = false;
|
||||||
static bool shouldCopyGPUBuffers = false;
|
|
||||||
static bool shouldDumpShaders = false;
|
static bool shouldDumpShaders = false;
|
||||||
static bool shouldDumpPM4 = false;
|
static bool shouldDumpPM4 = false;
|
||||||
static u32 vblankDivider = 1;
|
|
||||||
static bool vkValidation = false;
|
|
||||||
static bool vkValidationSync = false;
|
|
||||||
static bool vkValidationGpu = false;
|
|
||||||
static bool rdocEnable = false;
|
|
||||||
static bool rdocMarkersEnable = false;
|
|
||||||
// Gui
|
|
||||||
std::string settings_install_dir = "";
|
|
||||||
u32 main_window_geometry_x = 400;
|
|
||||||
u32 main_window_geometry_y = 400;
|
|
||||||
u32 main_window_geometry_w = 1280;
|
|
||||||
u32 main_window_geometry_h = 720;
|
|
||||||
u32 mw_themes = 0;
|
|
||||||
u32 m_icon_size = 36;
|
|
||||||
u32 m_icon_size_grid = 69;
|
|
||||||
u32 m_slider_pos = 0;
|
|
||||||
u32 m_slider_pos_grid = 0;
|
|
||||||
u32 m_table_mode = 0;
|
|
||||||
u32 m_window_size_W = 1280;
|
|
||||||
u32 m_window_size_H = 720;
|
|
||||||
std::vector<std::string> m_pkg_viewer;
|
|
||||||
std::vector<std::string> m_elf_viewer;
|
|
||||||
std::vector<std::string> m_recent_files;
|
|
||||||
std::string emulator_language = "en";
|
|
||||||
// Settings
|
|
||||||
u32 m_language = 1; // english
|
|
||||||
|
|
||||||
|
bool isLleLibc() {
|
||||||
|
return isLibc;
|
||||||
|
}
|
||||||
bool isNeoMode() {
|
bool isNeoMode() {
|
||||||
return isNeo;
|
return isNeo;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isFullscreenMode() {
|
|
||||||
return isFullscreen;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 getScreenWidth() {
|
u32 getScreenWidth() {
|
||||||
return screenWidth;
|
return screenWidth;
|
||||||
}
|
}
|
||||||
|
@ -80,18 +49,6 @@ std::string getLogType() {
|
||||||
return logType;
|
return logType;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getUserName() {
|
|
||||||
return userName;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool getUseSpecialPad() {
|
|
||||||
return useSpecialPad;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getSpecialPadClass() {
|
|
||||||
return specialPadClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool debugDump() {
|
bool debugDump() {
|
||||||
return isDebugDump;
|
return isDebugDump;
|
||||||
}
|
}
|
||||||
|
@ -104,10 +61,6 @@ bool nullGpu() {
|
||||||
return isNullGpu;
|
return isNullGpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool copyGPUCmdBuffers() {
|
|
||||||
return shouldCopyGPUBuffers;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool dumpShaders() {
|
bool dumpShaders() {
|
||||||
return shouldDumpShaders;
|
return shouldDumpShaders;
|
||||||
}
|
}
|
||||||
|
@ -116,220 +69,6 @@ bool dumpPM4() {
|
||||||
return shouldDumpPM4;
|
return shouldDumpPM4;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isRdocEnabled() {
|
|
||||||
return rdocEnable;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isMarkersEnabled() {
|
|
||||||
return rdocMarkersEnable;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 vblankDiv() {
|
|
||||||
return vblankDivider;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool vkValidationEnabled() {
|
|
||||||
return vkValidation;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool vkValidationSyncEnabled() {
|
|
||||||
return vkValidationSync;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool vkValidationGpuEnabled() {
|
|
||||||
return vkValidationGpu;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setGpuId(s32 selectedGpuId) {
|
|
||||||
gpuId = selectedGpuId;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setScreenWidth(u32 width) {
|
|
||||||
screenWidth = width;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setScreenHeight(u32 height) {
|
|
||||||
screenHeight = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setDebugDump(bool enable) {
|
|
||||||
isDebugDump = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setShowSplash(bool enable) {
|
|
||||||
isShowSplash = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setNullGpu(bool enable) {
|
|
||||||
isNullGpu = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setCopyGPUCmdBuffers(bool enable) {
|
|
||||||
shouldCopyGPUBuffers = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setDumpShaders(bool enable) {
|
|
||||||
shouldDumpShaders = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setDumpPM4(bool enable) {
|
|
||||||
shouldDumpPM4 = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setVkValidation(bool enable) {
|
|
||||||
vkValidation = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setVkSyncValidation(bool enable) {
|
|
||||||
vkValidationSync = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setRdocEnabled(bool enable) {
|
|
||||||
rdocEnable = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setVblankDiv(u32 value) {
|
|
||||||
vblankDivider = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setFullscreenMode(bool enable) {
|
|
||||||
isFullscreen = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setLanguage(u32 language) {
|
|
||||||
m_language = language;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setNeoMode(bool enable) {
|
|
||||||
isNeo = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setLogType(const std::string& type) {
|
|
||||||
logType = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setLogFilter(const std::string& type) {
|
|
||||||
logFilter = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setUserName(const std::string& type) {
|
|
||||||
userName = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setUseSpecialPad(bool use) {
|
|
||||||
useSpecialPad = use;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setSpecialPadClass(int type) {
|
|
||||||
specialPadClass = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h) {
|
|
||||||
main_window_geometry_x = x;
|
|
||||||
main_window_geometry_y = y;
|
|
||||||
main_window_geometry_w = w;
|
|
||||||
main_window_geometry_h = h;
|
|
||||||
}
|
|
||||||
void setGameInstallDir(const std::string& dir) {
|
|
||||||
settings_install_dir = dir;
|
|
||||||
}
|
|
||||||
void setMainWindowTheme(u32 theme) {
|
|
||||||
mw_themes = theme;
|
|
||||||
}
|
|
||||||
void setIconSize(u32 size) {
|
|
||||||
m_icon_size = size;
|
|
||||||
}
|
|
||||||
void setIconSizeGrid(u32 size) {
|
|
||||||
m_icon_size_grid = size;
|
|
||||||
}
|
|
||||||
void setSliderPosition(u32 pos) {
|
|
||||||
m_slider_pos = pos;
|
|
||||||
}
|
|
||||||
void setSliderPositionGrid(u32 pos) {
|
|
||||||
m_slider_pos_grid = pos;
|
|
||||||
}
|
|
||||||
void setTableMode(u32 mode) {
|
|
||||||
m_table_mode = mode;
|
|
||||||
}
|
|
||||||
void setMainWindowWidth(u32 width) {
|
|
||||||
m_window_size_W = width;
|
|
||||||
}
|
|
||||||
void setMainWindowHeight(u32 height) {
|
|
||||||
m_window_size_H = height;
|
|
||||||
}
|
|
||||||
void setPkgViewer(const std::vector<std::string>& pkgList) {
|
|
||||||
m_pkg_viewer.resize(pkgList.size());
|
|
||||||
m_pkg_viewer = pkgList;
|
|
||||||
}
|
|
||||||
void setElfViewer(const std::vector<std::string>& elfList) {
|
|
||||||
m_elf_viewer.resize(elfList.size());
|
|
||||||
m_elf_viewer = elfList;
|
|
||||||
}
|
|
||||||
void setRecentFiles(const std::vector<std::string>& recentFiles) {
|
|
||||||
m_recent_files.resize(recentFiles.size());
|
|
||||||
m_recent_files = recentFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setEmulatorLanguage(std::string language) {
|
|
||||||
emulator_language = language;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 getMainWindowGeometryX() {
|
|
||||||
return main_window_geometry_x;
|
|
||||||
}
|
|
||||||
u32 getMainWindowGeometryY() {
|
|
||||||
return main_window_geometry_y;
|
|
||||||
}
|
|
||||||
u32 getMainWindowGeometryW() {
|
|
||||||
return main_window_geometry_w;
|
|
||||||
}
|
|
||||||
u32 getMainWindowGeometryH() {
|
|
||||||
return main_window_geometry_h;
|
|
||||||
}
|
|
||||||
std::string getGameInstallDir() {
|
|
||||||
return settings_install_dir;
|
|
||||||
}
|
|
||||||
u32 getMainWindowTheme() {
|
|
||||||
return mw_themes;
|
|
||||||
}
|
|
||||||
u32 getIconSize() {
|
|
||||||
return m_icon_size;
|
|
||||||
}
|
|
||||||
u32 getIconSizeGrid() {
|
|
||||||
return m_icon_size_grid;
|
|
||||||
}
|
|
||||||
u32 getSliderPosition() {
|
|
||||||
return m_slider_pos;
|
|
||||||
}
|
|
||||||
u32 getSliderPositionGrid() {
|
|
||||||
return m_slider_pos_grid;
|
|
||||||
}
|
|
||||||
u32 getTableMode() {
|
|
||||||
return m_table_mode;
|
|
||||||
}
|
|
||||||
u32 getMainWindowWidth() {
|
|
||||||
return m_window_size_W;
|
|
||||||
}
|
|
||||||
u32 getMainWindowHeight() {
|
|
||||||
return m_window_size_H;
|
|
||||||
}
|
|
||||||
std::vector<std::string> getPkgViewer() {
|
|
||||||
return m_pkg_viewer;
|
|
||||||
}
|
|
||||||
std::vector<std::string> getElfViewer() {
|
|
||||||
return m_elf_viewer;
|
|
||||||
}
|
|
||||||
std::vector<std::string> getRecentFiles() {
|
|
||||||
return m_recent_files;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getEmulatorLanguage() {
|
|
||||||
return emulator_language;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 GetLanguage() {
|
|
||||||
return m_language;
|
|
||||||
}
|
|
||||||
void load(const std::filesystem::path& path) {
|
void load(const std::filesystem::path& path) {
|
||||||
// If the configuration file does not exist, create it and return
|
// If the configuration file does not exist, create it and return
|
||||||
std::error_code error;
|
std::error_code error;
|
||||||
|
@ -346,88 +85,55 @@ void load(const std::filesystem::path& path) {
|
||||||
fmt::print("Got exception trying to load config file. Exception: {}\n", ex.what());
|
fmt::print("Got exception trying to load config file. Exception: {}\n", ex.what());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.contains("General")) {
|
if (data.contains("General")) {
|
||||||
const toml::value& general = data.at("General");
|
auto generalResult = toml::expect<toml::value>(data.at("General"));
|
||||||
|
if (generalResult.is_ok()) {
|
||||||
|
auto general = generalResult.unwrap();
|
||||||
|
|
||||||
isNeo = toml::find_or<bool>(general, "isPS4Pro", false);
|
isNeo = toml::find_or<toml::boolean>(general, "isPS4Pro", false);
|
||||||
isFullscreen = toml::find_or<bool>(general, "Fullscreen", false);
|
logFilter = toml::find_or<toml::string>(general, "logFilter", "");
|
||||||
logFilter = toml::find_or<std::string>(general, "logFilter", "");
|
logType = toml::find_or<toml::string>(general, "logType", "sync");
|
||||||
logType = toml::find_or<std::string>(general, "logType", "sync");
|
isShowSplash = toml::find_or<toml::boolean>(general, "showSplash", true);
|
||||||
userName = toml::find_or<std::string>(general, "userName", "shadPS4");
|
|
||||||
isShowSplash = toml::find_or<bool>(general, "showSplash", true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.contains("Input")) {
|
|
||||||
const toml::value& input = data.at("Input");
|
|
||||||
|
|
||||||
useSpecialPad = toml::find_or<bool>(input, "useSpecialPad", false);
|
|
||||||
specialPadClass = toml::find_or<int>(input, "specialPadClass", 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.contains("GPU")) {
|
if (data.contains("GPU")) {
|
||||||
const toml::value& gpu = data.at("GPU");
|
auto gpuResult = toml::expect<toml::value>(data.at("GPU"));
|
||||||
|
if (gpuResult.is_ok()) {
|
||||||
|
auto gpu = gpuResult.unwrap();
|
||||||
|
|
||||||
screenWidth = toml::find_or<int>(gpu, "screenWidth", screenWidth);
|
screenWidth = toml::find_or<toml::integer>(gpu, "screenWidth", screenWidth);
|
||||||
screenHeight = toml::find_or<int>(gpu, "screenHeight", screenHeight);
|
screenHeight = toml::find_or<toml::integer>(gpu, "screenHeight", screenHeight);
|
||||||
isNullGpu = toml::find_or<bool>(gpu, "nullGpu", false);
|
gpuId = toml::find_or<toml::integer>(gpu, "gpuId", 0);
|
||||||
shouldCopyGPUBuffers = toml::find_or<bool>(gpu, "copyGPUBuffers", false);
|
isNullGpu = toml::find_or<toml::boolean>(gpu, "nullGpu", false);
|
||||||
shouldDumpShaders = toml::find_or<bool>(gpu, "dumpShaders", false);
|
shouldDumpShaders = toml::find_or<toml::boolean>(gpu, "dumpShaders", false);
|
||||||
shouldDumpPM4 = toml::find_or<bool>(gpu, "dumpPM4", false);
|
shouldDumpPM4 = toml::find_or<toml::boolean>(gpu, "dumpPM4", false);
|
||||||
vblankDivider = toml::find_or<int>(gpu, "vblankDivider", 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.contains("Vulkan")) {
|
|
||||||
const toml::value& vk = data.at("Vulkan");
|
|
||||||
|
|
||||||
gpuId = toml::find_or<int>(vk, "gpuId", -1);
|
|
||||||
vkValidation = toml::find_or<bool>(vk, "validation", false);
|
|
||||||
vkValidationSync = toml::find_or<bool>(vk, "validation_sync", false);
|
|
||||||
vkValidationGpu = toml::find_or<bool>(vk, "validation_gpu", true);
|
|
||||||
rdocEnable = toml::find_or<bool>(vk, "rdocEnable", false);
|
|
||||||
rdocMarkersEnable = toml::find_or<bool>(vk, "rdocMarkersEnable", false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.contains("Debug")) {
|
if (data.contains("Debug")) {
|
||||||
const toml::value& debug = data.at("Debug");
|
auto debugResult = toml::expect<toml::value>(data.at("Debug"));
|
||||||
|
if (debugResult.is_ok()) {
|
||||||
|
auto debug = debugResult.unwrap();
|
||||||
|
|
||||||
isDebugDump = toml::find_or<bool>(debug, "DebugDump", false);
|
isDebugDump = toml::find_or<toml::boolean>(debug, "DebugDump", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.contains("GUI")) {
|
|
||||||
const toml::value& gui = data.at("GUI");
|
|
||||||
|
|
||||||
m_icon_size = toml::find_or<int>(gui, "iconSize", 0);
|
|
||||||
m_icon_size_grid = toml::find_or<int>(gui, "iconSizeGrid", 0);
|
|
||||||
m_slider_pos = toml::find_or<int>(gui, "sliderPos", 0);
|
|
||||||
m_slider_pos_grid = toml::find_or<int>(gui, "sliderPosGrid", 0);
|
|
||||||
mw_themes = toml::find_or<int>(gui, "theme", 0);
|
|
||||||
m_window_size_W = toml::find_or<int>(gui, "mw_width", 0);
|
|
||||||
m_window_size_H = toml::find_or<int>(gui, "mw_height", 0);
|
|
||||||
settings_install_dir = toml::find_or<std::string>(gui, "installDir", "");
|
|
||||||
main_window_geometry_x = toml::find_or<int>(gui, "geometry_x", 0);
|
|
||||||
main_window_geometry_y = toml::find_or<int>(gui, "geometry_y", 0);
|
|
||||||
main_window_geometry_w = toml::find_or<int>(gui, "geometry_w", 0);
|
|
||||||
main_window_geometry_h = toml::find_or<int>(gui, "geometry_h", 0);
|
|
||||||
m_pkg_viewer = toml::find_or<std::vector<std::string>>(gui, "pkgDirs", {});
|
|
||||||
m_elf_viewer = toml::find_or<std::vector<std::string>>(gui, "elfDirs", {});
|
|
||||||
m_recent_files = toml::find_or<std::vector<std::string>>(gui, "recentFiles", {});
|
|
||||||
m_table_mode = toml::find_or<int>(gui, "gameTableMode", 0);
|
|
||||||
emulator_language = toml::find_or<std::string>(gui, "emulatorLanguage", "en");
|
|
||||||
}
|
}
|
||||||
|
if (data.contains("LLE")) {
|
||||||
|
auto lleResult = toml::expect<toml::value>(data.at("LLE"));
|
||||||
|
if (lleResult.is_ok()) {
|
||||||
|
auto lle = lleResult.unwrap();
|
||||||
|
|
||||||
if (data.contains("Settings")) {
|
isLibc = toml::find_or<toml::boolean>(lle, "libc", true);
|
||||||
const toml::value& settings = data.at("Settings");
|
}
|
||||||
|
|
||||||
m_language = toml::find_or<int>(settings, "consoleLanguage", 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void save(const std::filesystem::path& path) {
|
void save(const std::filesystem::path& path) {
|
||||||
toml::value data;
|
toml::basic_value<toml::preserve_comments> data;
|
||||||
|
|
||||||
std::error_code error;
|
std::error_code error;
|
||||||
if (std::filesystem::exists(path, error)) {
|
if (std::filesystem::exists(path, error)) {
|
||||||
try {
|
try {
|
||||||
data = toml::parse(path);
|
data = toml::parse<toml::preserve_comments>(path);
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
fmt::print("Exception trying to parse config file. Exception: {}\n", ex.what());
|
fmt::print("Exception trying to parse config file. Exception: {}\n", ex.what());
|
||||||
return;
|
return;
|
||||||
|
@ -441,73 +147,20 @@ void save(const std::filesystem::path& path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
data["General"]["isPS4Pro"] = isNeo;
|
data["General"]["isPS4Pro"] = isNeo;
|
||||||
data["General"]["Fullscreen"] = isFullscreen;
|
|
||||||
data["General"]["logFilter"] = logFilter;
|
data["General"]["logFilter"] = logFilter;
|
||||||
data["General"]["logType"] = logType;
|
data["General"]["logType"] = logType;
|
||||||
data["General"]["userName"] = userName;
|
|
||||||
data["General"]["showSplash"] = isShowSplash;
|
data["General"]["showSplash"] = isShowSplash;
|
||||||
data["Input"]["useSpecialPad"] = useSpecialPad;
|
data["GPU"]["gpuId"] = gpuId;
|
||||||
data["Input"]["specialPadClass"] = specialPadClass;
|
|
||||||
data["GPU"]["screenWidth"] = screenWidth;
|
data["GPU"]["screenWidth"] = screenWidth;
|
||||||
data["GPU"]["screenHeight"] = screenHeight;
|
data["GPU"]["screenHeight"] = screenHeight;
|
||||||
data["GPU"]["nullGpu"] = isNullGpu;
|
data["GPU"]["nullGpu"] = isNullGpu;
|
||||||
data["GPU"]["copyGPUBuffers"] = shouldCopyGPUBuffers;
|
|
||||||
data["GPU"]["dumpShaders"] = shouldDumpShaders;
|
data["GPU"]["dumpShaders"] = shouldDumpShaders;
|
||||||
data["GPU"]["dumpPM4"] = shouldDumpPM4;
|
data["GPU"]["dumpPM4"] = shouldDumpPM4;
|
||||||
data["GPU"]["vblankDivider"] = vblankDivider;
|
|
||||||
data["Vulkan"]["gpuId"] = gpuId;
|
|
||||||
data["Vulkan"]["validation"] = vkValidation;
|
|
||||||
data["Vulkan"]["validation_sync"] = vkValidationSync;
|
|
||||||
data["Vulkan"]["validation_gpu"] = vkValidationGpu;
|
|
||||||
data["Vulkan"]["rdocEnable"] = rdocEnable;
|
|
||||||
data["Vulkan"]["rdocMarkersEnable"] = rdocMarkersEnable;
|
|
||||||
data["Debug"]["DebugDump"] = isDebugDump;
|
data["Debug"]["DebugDump"] = isDebugDump;
|
||||||
data["GUI"]["theme"] = mw_themes;
|
data["LLE"]["libc"] = isLibc;
|
||||||
data["GUI"]["iconSize"] = m_icon_size;
|
|
||||||
data["GUI"]["sliderPos"] = m_slider_pos;
|
|
||||||
data["GUI"]["iconSizeGrid"] = m_icon_size_grid;
|
|
||||||
data["GUI"]["sliderPosGrid"] = m_slider_pos_grid;
|
|
||||||
data["GUI"]["gameTableMode"] = m_table_mode;
|
|
||||||
data["GUI"]["mw_width"] = m_window_size_W;
|
|
||||||
data["GUI"]["mw_height"] = m_window_size_H;
|
|
||||||
data["GUI"]["installDir"] = settings_install_dir;
|
|
||||||
data["GUI"]["geometry_x"] = main_window_geometry_x;
|
|
||||||
data["GUI"]["geometry_y"] = main_window_geometry_y;
|
|
||||||
data["GUI"]["geometry_w"] = main_window_geometry_w;
|
|
||||||
data["GUI"]["geometry_h"] = main_window_geometry_h;
|
|
||||||
data["GUI"]["pkgDirs"] = m_pkg_viewer;
|
|
||||||
data["GUI"]["elfDirs"] = m_elf_viewer;
|
|
||||||
data["GUI"]["recentFiles"] = m_recent_files;
|
|
||||||
data["GUI"]["emulatorLanguage"] = emulator_language;
|
|
||||||
|
|
||||||
data["Settings"]["consoleLanguage"] = m_language;
|
|
||||||
|
|
||||||
std::ofstream file(path, std::ios::out);
|
std::ofstream file(path, std::ios::out);
|
||||||
file << data;
|
file << data;
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDefaultValues() {
|
|
||||||
isNeo = false;
|
|
||||||
isFullscreen = false;
|
|
||||||
screenWidth = 1280;
|
|
||||||
screenHeight = 720;
|
|
||||||
logFilter = "";
|
|
||||||
logType = "async";
|
|
||||||
userName = "shadPS4";
|
|
||||||
useSpecialPad = false;
|
|
||||||
specialPadClass = 1;
|
|
||||||
isDebugDump = false;
|
|
||||||
isShowSplash = false;
|
|
||||||
isNullGpu = false;
|
|
||||||
shouldDumpShaders = false;
|
|
||||||
shouldDumpPM4 = false;
|
|
||||||
vblankDivider = 1;
|
|
||||||
vkValidation = false;
|
|
||||||
rdocEnable = false;
|
|
||||||
emulator_language = "en";
|
|
||||||
m_language = 1;
|
|
||||||
gpuId = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Config
|
} // namespace Config
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <vector>
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
namespace Config {
|
namespace Config {
|
||||||
|
@ -12,93 +11,18 @@ void load(const std::filesystem::path& path);
|
||||||
void save(const std::filesystem::path& path);
|
void save(const std::filesystem::path& path);
|
||||||
|
|
||||||
bool isNeoMode();
|
bool isNeoMode();
|
||||||
bool isFullscreenMode();
|
|
||||||
std::string getLogFilter();
|
std::string getLogFilter();
|
||||||
std::string getLogType();
|
std::string getLogType();
|
||||||
std::string getUserName();
|
|
||||||
|
|
||||||
bool getUseSpecialPad();
|
|
||||||
int getSpecialPadClass();
|
|
||||||
|
|
||||||
u32 getScreenWidth();
|
u32 getScreenWidth();
|
||||||
u32 getScreenHeight();
|
u32 getScreenHeight();
|
||||||
s32 getGpuId();
|
s32 getGpuId();
|
||||||
|
|
||||||
bool debugDump();
|
bool debugDump();
|
||||||
|
bool isLleLibc();
|
||||||
bool showSplash();
|
bool showSplash();
|
||||||
bool nullGpu();
|
bool nullGpu();
|
||||||
bool copyGPUCmdBuffers();
|
|
||||||
bool dumpShaders();
|
bool dumpShaders();
|
||||||
bool dumpPM4();
|
bool dumpPM4();
|
||||||
bool isRdocEnabled();
|
|
||||||
bool isMarkersEnabled();
|
|
||||||
u32 vblankDiv();
|
|
||||||
|
|
||||||
void setDebugDump(bool enable);
|
|
||||||
void setShowSplash(bool enable);
|
|
||||||
void setNullGpu(bool enable);
|
|
||||||
void setCopyGPUCmdBuffers(bool enable);
|
|
||||||
void setDumpShaders(bool enable);
|
|
||||||
void setDumpPM4(bool enable);
|
|
||||||
void setVblankDiv(u32 value);
|
|
||||||
void setGpuId(s32 selectedGpuId);
|
|
||||||
void setScreenWidth(u32 width);
|
|
||||||
void setScreenHeight(u32 height);
|
|
||||||
void setFullscreenMode(bool enable);
|
|
||||||
void setLanguage(u32 language);
|
|
||||||
void setNeoMode(bool enable);
|
|
||||||
void setUserName(const std::string& type);
|
|
||||||
|
|
||||||
void setUseSpecialPad(bool use);
|
|
||||||
void setSpecialPadClass(int type);
|
|
||||||
|
|
||||||
void setLogType(const std::string& type);
|
|
||||||
void setLogFilter(const std::string& type);
|
|
||||||
|
|
||||||
void setVkValidation(bool enable);
|
|
||||||
void setVkSyncValidation(bool enable);
|
|
||||||
void setRdocEnabled(bool enable);
|
|
||||||
|
|
||||||
bool vkValidationEnabled();
|
|
||||||
bool vkValidationSyncEnabled();
|
|
||||||
bool vkValidationGpuEnabled();
|
|
||||||
|
|
||||||
// Gui
|
|
||||||
void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h);
|
|
||||||
void setGameInstallDir(const std::string& dir);
|
|
||||||
void setMainWindowTheme(u32 theme);
|
|
||||||
void setIconSize(u32 size);
|
|
||||||
void setIconSizeGrid(u32 size);
|
|
||||||
void setSliderPosition(u32 pos);
|
|
||||||
void setSliderPositionGrid(u32 pos);
|
|
||||||
void setTableMode(u32 mode);
|
|
||||||
void setMainWindowWidth(u32 width);
|
|
||||||
void setMainWindowHeight(u32 height);
|
|
||||||
void setPkgViewer(const std::vector<std::string>& pkgList);
|
|
||||||
void setElfViewer(const std::vector<std::string>& elfList);
|
|
||||||
void setRecentFiles(const std::vector<std::string>& recentFiles);
|
|
||||||
void setEmulatorLanguage(std::string language);
|
|
||||||
|
|
||||||
u32 getMainWindowGeometryX();
|
|
||||||
u32 getMainWindowGeometryY();
|
|
||||||
u32 getMainWindowGeometryW();
|
|
||||||
u32 getMainWindowGeometryH();
|
|
||||||
std::string getGameInstallDir();
|
|
||||||
u32 getMainWindowTheme();
|
|
||||||
u32 getIconSize();
|
|
||||||
u32 getIconSizeGrid();
|
|
||||||
u32 getSliderPosition();
|
|
||||||
u32 getSliderPositionGrid();
|
|
||||||
u32 getTableMode();
|
|
||||||
u32 getMainWindowWidth();
|
|
||||||
u32 getMainWindowHeight();
|
|
||||||
std::vector<std::string> getPkgViewer();
|
|
||||||
std::vector<std::string> getElfViewer();
|
|
||||||
std::vector<std::string> getRecentFiles();
|
|
||||||
std::string getEmulatorLanguage();
|
|
||||||
|
|
||||||
void setDefaultValues();
|
|
||||||
|
|
||||||
// settings
|
|
||||||
u32 GetLanguage();
|
|
||||||
}; // namespace Config
|
}; // namespace Config
|
||||||
|
|
|
@ -10,50 +10,3 @@
|
||||||
#else
|
#else
|
||||||
#error What the fuck is this compiler
|
#error What the fuck is this compiler
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <tracy/Tracy.hpp>
|
|
||||||
|
|
||||||
static inline bool IsProfilerConnected() {
|
|
||||||
return tracy::GetProfiler().IsConnected();
|
|
||||||
}
|
|
||||||
|
|
||||||
#define CUSTOM_LOCK(type, varname) \
|
|
||||||
tracy::LockableCtx varname { \
|
|
||||||
[]() -> const tracy::SourceLocationData* { \
|
|
||||||
static constexpr tracy::SourceLocationData srcloc{nullptr, #type " " #varname, \
|
|
||||||
TracyFile, TracyLine, 0}; \
|
|
||||||
return &srcloc; \
|
|
||||||
}() \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define TRACK_ALLOC(ptr, size, pool) TracyAllocN(std::bit_cast<void*>(ptr), (size), (pool))
|
|
||||||
#define TRACK_FREE(ptr, pool) TracyFreeN(std::bit_cast<void*>(ptr), (pool))
|
|
||||||
|
|
||||||
enum MarkersPalette : int {
|
|
||||||
EmulatorMarkerColor = 0x264653,
|
|
||||||
RendererMarkerColor = 0x2a9d8f,
|
|
||||||
HleMarkerColor = 0xe9c46a,
|
|
||||||
GpuMarkerColor = 0xf4a261,
|
|
||||||
Reserved1 = 0xe76f51,
|
|
||||||
};
|
|
||||||
|
|
||||||
#define EMULATOR_TRACE ZoneScopedC(EmulatorMarkerColor)
|
|
||||||
#define RENDERER_TRACE ZoneScopedC(RendererMarkerColor)
|
|
||||||
#define HLE_TRACE ZoneScopedC(HleMarkerColor)
|
|
||||||
|
|
||||||
#define TRACE_HINT(str) ZoneText(str.c_str(), str.size())
|
|
||||||
|
|
||||||
#define TRACE_WARN(msg) \
|
|
||||||
[](const auto& msg) { TracyMessageC(msg.c_str(), msg.size(), tracy::Color::DarkOrange); }(msg);
|
|
||||||
#define TRACE_ERROR(msg) \
|
|
||||||
[](const auto& msg) { TracyMessageC(msg.c_str(), msg.size(), tracy::Color::Red); }(msg)
|
|
||||||
#define TRACE_CRIT(msg) \
|
|
||||||
[](const auto& msg) { TracyMessageC(msg.c_str(), msg.size(), tracy::Color::HotPink); }(msg)
|
|
||||||
|
|
||||||
#define GPU_SCOPE_LOCATION(name, color) \
|
|
||||||
tracy::SourceLocationData{name, TracyFunction, TracyFile, (uint32_t)TracyLine, color};
|
|
||||||
|
|
||||||
#define MUTEX_LOCATION(name) \
|
|
||||||
tracy::SourceLocationData{nullptr, name, TracyFile, (uint32_t)TracyLine, 0};
|
|
||||||
|
|
||||||
#define FRAME_END FrameMark
|
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
#include <type_traits>
|
|
||||||
|
|
||||||
namespace Common {
|
|
||||||
|
|
||||||
/// Ceiled integer division.
|
|
||||||
template <typename N, typename D>
|
|
||||||
requires std::is_integral_v<N> && std::is_unsigned_v<D>
|
|
||||||
[[nodiscard]] constexpr N DivCeil(N number, D divisor) {
|
|
||||||
return static_cast<N>((static_cast<D>(number) + divisor - 1) / divisor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Ceiled integer division with logarithmic divisor in base 2
|
|
||||||
template <typename N, typename D>
|
|
||||||
requires std::is_integral_v<N> && std::is_unsigned_v<D>
|
|
||||||
[[nodiscard]] constexpr N DivCeilLog2(N value, D alignment_log2) {
|
|
||||||
return static_cast<N>((static_cast<D>(value) + (D(1) << alignment_log2) - 1) >> alignment_log2);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Common
|
|
|
@ -20,7 +20,7 @@ std::string NativeErrorToString(int e) {
|
||||||
|
|
||||||
DWORD res = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
DWORD res = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
nullptr, e, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
|
nullptr, e, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
reinterpret_cast<LPSTR>(&err_str), 1, nullptr);
|
reinterpret_cast<LPSTR>(&err_str), 1, nullptr);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
return "(FormatMessageA failed to format error)";
|
return "(FormatMessageA failed to format error)";
|
||||||
|
|
|
@ -3,19 +3,13 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "common/alignment.h"
|
|
||||||
#include "common/assert.h"
|
|
||||||
#include "common/error.h"
|
|
||||||
#include "common/io_file.h"
|
#include "common/io_file.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/path_util.h"
|
#include "common/path_util.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "common/ntapi.h"
|
|
||||||
|
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <share.h>
|
#include <share.h>
|
||||||
#include <windows.h>
|
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -169,7 +163,7 @@ IOFile& IOFile::operator=(IOFile&& other) noexcept {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
int IOFile::Open(const fs::path& path, FileAccessMode mode, FileType type, FileShareFlag flag) {
|
void IOFile::Open(const fs::path& path, FileAccessMode mode, FileType type, FileShareFlag flag) {
|
||||||
Close();
|
Close();
|
||||||
|
|
||||||
file_path = path;
|
file_path = path;
|
||||||
|
@ -177,26 +171,22 @@ int IOFile::Open(const fs::path& path, FileAccessMode mode, FileType type, FileS
|
||||||
file_type = type;
|
file_type = type;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
int result = 0;
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (flag != FileShareFlag::ShareNone) {
|
if (flag != FileShareFlag::ShareNone) {
|
||||||
file = _wfsopen(path.c_str(), AccessModeToWStr(mode, type), ToWindowsFileShareFlag(flag));
|
file = _wfsopen(path.c_str(), AccessModeToWStr(mode, type), ToWindowsFileShareFlag(flag));
|
||||||
result = errno;
|
|
||||||
} else {
|
} else {
|
||||||
result = _wfopen_s(&file, path.c_str(), AccessModeToWStr(mode, type));
|
_wfopen_s(&file, path.c_str(), AccessModeToWStr(mode, type));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
file = std::fopen(path.c_str(), AccessModeToStr(mode, type));
|
file = std::fopen(path.c_str(), AccessModeToStr(mode, type));
|
||||||
result = errno;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!IsOpen()) {
|
if (!IsOpen()) {
|
||||||
LOG_ERROR(Common_Filesystem, "Failed to open the file at path={}",
|
const auto ec = std::error_code{errno, std::generic_category()};
|
||||||
PathToUTF8String(file_path));
|
// LOG_ERROR(Common_Filesystem, "Failed to open the file at path={}, ec_message={}",
|
||||||
|
// PathToUTF8String(file_path), ec.message());
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IOFile::Close() {
|
void IOFile::Close() {
|
||||||
|
@ -215,60 +205,6 @@ void IOFile::Close() {
|
||||||
}
|
}
|
||||||
|
|
||||||
file = nullptr;
|
file = nullptr;
|
||||||
|
|
||||||
#ifdef _WIN64
|
|
||||||
if (file_mapping && file_access_mode == FileAccessMode::ReadWrite) {
|
|
||||||
CloseHandle(std::bit_cast<HANDLE>(file_mapping));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void IOFile::Unlink() {
|
|
||||||
if (!IsOpen()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mark the file for deletion
|
|
||||||
// TODO: Also remove the file path?
|
|
||||||
#if _WIN64
|
|
||||||
FILE_DISPOSITION_INFORMATION disposition;
|
|
||||||
IO_STATUS_BLOCK iosb;
|
|
||||||
|
|
||||||
const int fd = fileno(file);
|
|
||||||
HANDLE hfile = reinterpret_cast<HANDLE>(_get_osfhandle(fd));
|
|
||||||
|
|
||||||
disposition.DeleteFile = TRUE;
|
|
||||||
NtSetInformationFile(hfile, &iosb, &disposition, sizeof(disposition),
|
|
||||||
FileDispositionInformation);
|
|
||||||
#else
|
|
||||||
UNREACHABLE_MSG("Missing Linux implementation");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
uintptr_t IOFile::GetFileMapping() {
|
|
||||||
if (file_mapping) {
|
|
||||||
return file_mapping;
|
|
||||||
}
|
|
||||||
#ifdef _WIN64
|
|
||||||
const int fd = fileno(file);
|
|
||||||
|
|
||||||
HANDLE hfile = reinterpret_cast<HANDLE>(_get_osfhandle(fd));
|
|
||||||
HANDLE mapping = nullptr;
|
|
||||||
|
|
||||||
if (file_access_mode == FileAccessMode::ReadWrite) {
|
|
||||||
mapping = CreateFileMapping2(hfile, NULL, FILE_MAP_WRITE, PAGE_READWRITE, SEC_COMMIT, 0,
|
|
||||||
NULL, NULL, 0);
|
|
||||||
} else {
|
|
||||||
mapping = hfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
file_mapping = std::bit_cast<uintptr_t>(mapping);
|
|
||||||
ASSERT_MSG(file_mapping, "{}", Common::GetLastErrorMsg());
|
|
||||||
return file_mapping;
|
|
||||||
#else
|
|
||||||
file_mapping = fileno(file);
|
|
||||||
return file_mapping;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string IOFile::ReadString(size_t length) const {
|
std::string IOFile::ReadString(size_t length) const {
|
||||||
|
|
|
@ -100,15 +100,11 @@ public:
|
||||||
return file != nullptr;
|
return file != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
uintptr_t GetFileMapping();
|
void Open(const std::filesystem::path& path, FileAccessMode mode,
|
||||||
|
|
||||||
int Open(const std::filesystem::path& path, FileAccessMode mode,
|
|
||||||
FileType type = FileType::BinaryFile,
|
FileType type = FileType::BinaryFile,
|
||||||
FileShareFlag flag = FileShareFlag::ShareReadOnly);
|
FileShareFlag flag = FileShareFlag::ShareReadOnly);
|
||||||
void Close();
|
void Close();
|
||||||
|
|
||||||
void Unlink();
|
|
||||||
|
|
||||||
bool Flush() const;
|
bool Flush() const;
|
||||||
bool Commit() const;
|
bool Commit() const;
|
||||||
|
|
||||||
|
@ -183,7 +179,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
size_t WriteRaw(const void* data, size_t size) const {
|
size_t WriteRaw(void* data, size_t size) const {
|
||||||
return std::fwrite(data, sizeof(T), size, file);
|
return std::fwrite(data, sizeof(T), size, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,18 +201,12 @@ public:
|
||||||
return WriteSpan(string);
|
return WriteSpan(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void WriteBytes(const std::filesystem::path path, std::span<const u8> data) {
|
|
||||||
IOFile out(path, FileAccessMode::Write);
|
|
||||||
out.Write(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::filesystem::path file_path;
|
std::filesystem::path file_path;
|
||||||
FileAccessMode file_access_mode{};
|
FileAccessMode file_access_mode{};
|
||||||
FileType file_type{};
|
FileType file_type{};
|
||||||
|
|
||||||
std::FILE* file = nullptr;
|
std::FILE* file = nullptr;
|
||||||
uintptr_t file_mapping = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Common::FS
|
} // namespace Common::FS
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
#include "common/bounded_threadsafe_queue.h"
|
#include "common/bounded_threadsafe_queue.h"
|
||||||
#include "common/config.h"
|
#include "common/config.h"
|
||||||
#include "common/debug.h"
|
|
||||||
#include "common/io_file.h"
|
#include "common/io_file.h"
|
||||||
#include "common/logging/backend.h"
|
#include "common/logging/backend.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
|
@ -168,24 +167,6 @@ public:
|
||||||
|
|
||||||
void PushEntry(Class log_class, Level log_level, const char* filename, unsigned int line_num,
|
void PushEntry(Class log_class, Level log_level, const char* filename, unsigned int line_num,
|
||||||
const char* function, std::string message) {
|
const char* function, std::string message) {
|
||||||
// Propagate important log messages to the profiler
|
|
||||||
if (IsProfilerConnected()) {
|
|
||||||
const auto& msg_str = fmt::format("[{}] {}", GetLogClassName(log_class), message);
|
|
||||||
switch (log_level) {
|
|
||||||
case Level::Warning:
|
|
||||||
TRACE_WARN(msg_str);
|
|
||||||
break;
|
|
||||||
case Level::Error:
|
|
||||||
TRACE_ERROR(msg_str);
|
|
||||||
break;
|
|
||||||
case Level::Critical:
|
|
||||||
TRACE_CRIT(msg_str);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!filter.CheckMessage(log_class, log_level)) {
|
if (!filter.CheckMessage(log_class, log_level)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -207,7 +188,6 @@ public:
|
||||||
message_queue.EmplaceWait(entry);
|
message_queue.EmplaceWait(entry);
|
||||||
} else {
|
} else {
|
||||||
ForEachBackend([&entry](auto& backend) { backend.Write(entry); });
|
ForEachBackend([&entry](auto& backend) { backend.Write(entry); });
|
||||||
std::fflush(stdout);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,21 +102,9 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) {
|
||||||
SUB(Lib, Screenshot) \
|
SUB(Lib, Screenshot) \
|
||||||
SUB(Lib, LibCInternal) \
|
SUB(Lib, LibCInternal) \
|
||||||
SUB(Lib, AppContent) \
|
SUB(Lib, AppContent) \
|
||||||
SUB(Lib, Rtc) \
|
|
||||||
SUB(Lib, DiscMap) \
|
|
||||||
SUB(Lib, Png) \
|
|
||||||
SUB(Lib, PlayGo) \
|
|
||||||
SUB(Lib, Random) \
|
|
||||||
SUB(Lib, Usbd) \
|
|
||||||
SUB(Lib, Ajm) \
|
|
||||||
SUB(Lib, ErrorDialog) \
|
|
||||||
SUB(Lib, ImeDialog) \
|
|
||||||
SUB(Lib, AvPlayer) \
|
|
||||||
SUB(Lib, Ngs2) \
|
|
||||||
CLS(Frontend) \
|
CLS(Frontend) \
|
||||||
CLS(Render) \
|
CLS(Render) \
|
||||||
SUB(Render, Vulkan) \
|
SUB(Render, Vulkan) \
|
||||||
SUB(Render, Recompiler) \
|
|
||||||
CLS(Input) \
|
CLS(Input) \
|
||||||
CLS(Tty) \
|
CLS(Tty) \
|
||||||
CLS(Loader)
|
CLS(Loader)
|
||||||
|
|
|
@ -69,21 +69,9 @@ enum class Class : u8 {
|
||||||
Lib_Screenshot, ///< The LibSceScreenshot implementation
|
Lib_Screenshot, ///< The LibSceScreenshot implementation
|
||||||
Lib_LibCInternal, ///< The LibCInternal implementation.
|
Lib_LibCInternal, ///< The LibCInternal implementation.
|
||||||
Lib_AppContent, ///< The LibSceAppContent implementation.
|
Lib_AppContent, ///< The LibSceAppContent implementation.
|
||||||
Lib_Rtc, ///< The LibSceRtc implementation.
|
|
||||||
Lib_DiscMap, ///< The LibSceDiscMap implementation.
|
|
||||||
Lib_Png, ///< The LibScePng implementation.
|
|
||||||
Lib_PlayGo, ///< The LibScePlayGo implementation.
|
|
||||||
Lib_Random, ///< The libSceRandom implementation.
|
|
||||||
Lib_Usbd, ///< The LibSceUsbd implementation.
|
|
||||||
Lib_Ajm, ///< The LibSceAjm implementation.
|
|
||||||
Lib_ErrorDialog, ///< The LibSceErrorDialog implementation.
|
|
||||||
Lib_ImeDialog, ///< The LibSceImeDialog implementation.
|
|
||||||
Lib_AvPlayer, ///< The LibSceAvPlayer implementation.
|
|
||||||
Lib_Ngs2, ///< The LibSceNgs2 implementation.
|
|
||||||
Frontend, ///< Emulator UI
|
Frontend, ///< Emulator UI
|
||||||
Render, ///< Video Core
|
Render, ///< Video Core
|
||||||
Render_Vulkan, ///< Vulkan backend
|
Render_Vulkan, ///< Vulkan backend
|
||||||
Render_Recompiler, ///< Shader recompiler
|
|
||||||
Loader, ///< ROM loader
|
Loader, ///< ROM loader
|
||||||
Input, ///< Input emulation
|
Input, ///< Input emulation
|
||||||
Tty, ///< Debug output from emu
|
Tty, ///< Debug output from emu
|
||||||
|
|
|
@ -18,16 +18,16 @@ NativeClock::NativeClock()
|
||||||
us_rdtsc_factor{GetFixedPoint64Factor(std::micro::den, rdtsc_frequency)},
|
us_rdtsc_factor{GetFixedPoint64Factor(std::micro::den, rdtsc_frequency)},
|
||||||
ms_rdtsc_factor{GetFixedPoint64Factor(std::milli::den, rdtsc_frequency)} {}
|
ms_rdtsc_factor{GetFixedPoint64Factor(std::milli::den, rdtsc_frequency)} {}
|
||||||
|
|
||||||
u64 NativeClock::GetTimeNS(u64 base_ptc /*= 0*/) const {
|
u64 NativeClock::GetTimeNS() const {
|
||||||
return MultiplyHigh(GetUptime() - base_ptc, ns_rdtsc_factor);
|
return MultiplyHigh(GetUptime(), ns_rdtsc_factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 NativeClock::GetTimeUS(u64 base_ptc /*= 0*/) const {
|
u64 NativeClock::GetTimeUS() const {
|
||||||
return MultiplyHigh(GetUptime() - base_ptc, us_rdtsc_factor);
|
return MultiplyHigh(GetUptime(), us_rdtsc_factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 NativeClock::GetTimeMS(u64 base_ptc /*= 0*/) const {
|
u64 NativeClock::GetTimeMS() const {
|
||||||
return MultiplyHigh(GetUptime() - base_ptc, ms_rdtsc_factor);
|
return MultiplyHigh(GetUptime(), ms_rdtsc_factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 NativeClock::GetUptime() const {
|
u64 NativeClock::GetUptime() const {
|
||||||
|
|
|
@ -16,9 +16,9 @@ public:
|
||||||
return rdtsc_frequency;
|
return rdtsc_frequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 GetTimeNS(u64 base_ptc = 0) const;
|
u64 GetTimeNS() const;
|
||||||
u64 GetTimeUS(u64 base_ptc = 0) const;
|
u64 GetTimeUS() const;
|
||||||
u64 GetTimeMS(u64 base_ptc = 0) const;
|
u64 GetTimeMS() const;
|
||||||
u64 GetUptime() const;
|
u64 GetUptime() const;
|
||||||
u64 GetProcessTimeUS() const;
|
u64 GetProcessTimeUS() const;
|
||||||
|
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
|
|
||||||
#include "ntapi.h"
|
|
||||||
|
|
||||||
NtDelayExecution_t NtDelayExecution = nullptr;
|
|
||||||
NtSetInformationFile_t NtSetInformationFile = nullptr;
|
|
||||||
|
|
||||||
namespace Common::NtApi {
|
|
||||||
|
|
||||||
void Initialize() {
|
|
||||||
HMODULE nt_handle = GetModuleHandleA("ntdll.dll");
|
|
||||||
|
|
||||||
// http://stackoverflow.com/a/31411628/4725495
|
|
||||||
NtDelayExecution = (NtDelayExecution_t)GetProcAddress(nt_handle, "NtDelayExecution");
|
|
||||||
NtSetInformationFile =
|
|
||||||
(NtSetInformationFile_t)GetProcAddress(nt_handle, "NtSetInformationFile");
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Common::NtApi
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,124 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include "common/types.h"
|
|
||||||
|
|
||||||
typedef enum _FILE_INFORMATION_CLASS {
|
|
||||||
FileDirectoryInformation = 1,
|
|
||||||
FileFullDirectoryInformation = 2,
|
|
||||||
FileBothDirectoryInformation = 3,
|
|
||||||
FileBasicInformation = 4,
|
|
||||||
FileStandardInformation = 5,
|
|
||||||
FileInternalInformation = 6,
|
|
||||||
FileEaInformation = 7,
|
|
||||||
FileAccessInformation = 8,
|
|
||||||
FileNameInformation = 9,
|
|
||||||
FileRenameInformation = 10,
|
|
||||||
FileLinkInformation = 11,
|
|
||||||
FileNamesInformation = 12,
|
|
||||||
FileDispositionInformation = 13,
|
|
||||||
FilePositionInformation = 14,
|
|
||||||
FileFullEaInformation = 15,
|
|
||||||
FileModeInformation = 16,
|
|
||||||
FileAlignmentInformation = 17,
|
|
||||||
FileAllInformation = 18,
|
|
||||||
FileAllocationInformation = 19,
|
|
||||||
FileEndOfFileInformation = 20,
|
|
||||||
FileAlternateNameInformation = 21,
|
|
||||||
FileStreamInformation = 22,
|
|
||||||
FilePipeInformation = 23,
|
|
||||||
FilePipeLocalInformation = 24,
|
|
||||||
FilePipeRemoteInformation = 25,
|
|
||||||
FileMailslotQueryInformation = 26,
|
|
||||||
FileMailslotSetInformation = 27,
|
|
||||||
FileCompressionInformation = 28,
|
|
||||||
FileObjectIdInformation = 29,
|
|
||||||
FileCompletionInformation = 30,
|
|
||||||
FileMoveClusterInformation = 31,
|
|
||||||
FileQuotaInformation = 32,
|
|
||||||
FileReparsePointInformation = 33,
|
|
||||||
FileNetworkOpenInformation = 34,
|
|
||||||
FileAttributeTagInformation = 35,
|
|
||||||
FileTrackingInformation = 36,
|
|
||||||
FileIdBothDirectoryInformation = 37,
|
|
||||||
FileIdFullDirectoryInformation = 38,
|
|
||||||
FileValidDataLengthInformation = 39,
|
|
||||||
FileShortNameInformation = 40,
|
|
||||||
FileIoCompletionNotificationInformation = 41,
|
|
||||||
FileIoStatusBlockRangeInformation = 42,
|
|
||||||
FileIoPriorityHintInformation = 43,
|
|
||||||
FileSfioReserveInformation = 44,
|
|
||||||
FileSfioVolumeInformation = 45,
|
|
||||||
FileHardLinkInformation = 46,
|
|
||||||
FileProcessIdsUsingFileInformation = 47,
|
|
||||||
FileNormalizedNameInformation = 48,
|
|
||||||
FileNetworkPhysicalNameInformation = 49,
|
|
||||||
FileIdGlobalTxDirectoryInformation = 50,
|
|
||||||
FileIsRemoteDeviceInformation = 51,
|
|
||||||
FileUnusedInformation = 52,
|
|
||||||
FileNumaNodeInformation = 53,
|
|
||||||
FileStandardLinkInformation = 54,
|
|
||||||
FileRemoteProtocolInformation = 55,
|
|
||||||
FileRenameInformationBypassAccessCheck = 56,
|
|
||||||
FileLinkInformationBypassAccessCheck = 57,
|
|
||||||
FileVolumeNameInformation = 58,
|
|
||||||
FileIdInformation = 59,
|
|
||||||
FileIdExtdDirectoryInformation = 60,
|
|
||||||
FileReplaceCompletionInformation = 61,
|
|
||||||
FileHardLinkFullIdInformation = 62,
|
|
||||||
FileIdExtdBothDirectoryInformation = 63,
|
|
||||||
FileDispositionInformationEx = 64,
|
|
||||||
FileRenameInformationEx = 65,
|
|
||||||
FileRenameInformationExBypassAccessCheck = 66,
|
|
||||||
FileDesiredStorageClassInformation = 67,
|
|
||||||
FileStatInformation = 68,
|
|
||||||
FileMemoryPartitionInformation = 69,
|
|
||||||
FileStatLxInformation = 70,
|
|
||||||
FileCaseSensitiveInformation = 71,
|
|
||||||
FileLinkInformationEx = 72,
|
|
||||||
FileLinkInformationExBypassAccessCheck = 73,
|
|
||||||
FileStorageReserveIdInformation = 74,
|
|
||||||
FileCaseSensitiveInformationForceAccessCheck = 75,
|
|
||||||
FileKnownFolderInformation = 76,
|
|
||||||
FileStatBasicInformation = 77,
|
|
||||||
FileId64ExtdDirectoryInformation = 78,
|
|
||||||
FileId64ExtdBothDirectoryInformation = 79,
|
|
||||||
FileIdAllExtdDirectoryInformation = 80,
|
|
||||||
FileIdAllExtdBothDirectoryInformation = 81,
|
|
||||||
FileStreamReservationInformation,
|
|
||||||
FileMupProviderInfo,
|
|
||||||
FileMaximumInformation
|
|
||||||
} FILE_INFORMATION_CLASS,
|
|
||||||
*PFILE_INFORMATION_CLASS;
|
|
||||||
|
|
||||||
typedef struct _IO_STATUS_BLOCK {
|
|
||||||
union {
|
|
||||||
u32 Status;
|
|
||||||
PVOID Pointer;
|
|
||||||
};
|
|
||||||
ULONG_PTR Information;
|
|
||||||
} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
|
|
||||||
|
|
||||||
typedef struct _FILE_DISPOSITION_INFORMATION {
|
|
||||||
BOOLEAN DeleteFile;
|
|
||||||
} FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION;
|
|
||||||
|
|
||||||
typedef u32(__stdcall* NtDelayExecution_t)(BOOL Alertable, PLARGE_INTEGER DelayInterval);
|
|
||||||
|
|
||||||
typedef u32(__stdcall* NtSetInformationFile_t)(HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock,
|
|
||||||
PVOID FileInformation, ULONG Length,
|
|
||||||
FILE_INFORMATION_CLASS FileInformationClass);
|
|
||||||
|
|
||||||
extern NtDelayExecution_t NtDelayExecution;
|
|
||||||
extern NtSetInformationFile_t NtSetInformationFile;
|
|
||||||
|
|
||||||
namespace Common::NtApi {
|
|
||||||
void Initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,16 +1,12 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <sstream>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/path_util.h"
|
#include "common/path_util.h"
|
||||||
#include "common/scope_exit.h"
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
#include <CoreFoundation/CFBundle.h>
|
|
||||||
#include <dlfcn.h>
|
|
||||||
#include <sys/param.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MAX_PATH
|
#ifndef MAX_PATH
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -26,65 +22,7 @@ namespace Common::FS {
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
using IsTranslocatedURLFunc = Boolean (*)(CFURLRef path, bool* isTranslocated,
|
|
||||||
CFErrorRef* __nullable error);
|
|
||||||
using CreateOriginalPathForURLFunc = CFURLRef __nullable (*)(CFURLRef translocatedPath,
|
|
||||||
CFErrorRef* __nullable error);
|
|
||||||
|
|
||||||
static CFURLRef UntranslocateBundlePath(const CFURLRef bundle_path) {
|
|
||||||
if (void* security_handle =
|
|
||||||
dlopen("/System/Library/Frameworks/Security.framework/Security", RTLD_LAZY)) {
|
|
||||||
SCOPE_EXIT {
|
|
||||||
dlclose(security_handle);
|
|
||||||
};
|
|
||||||
|
|
||||||
const auto IsTranslocatedURL = reinterpret_cast<IsTranslocatedURLFunc>(
|
|
||||||
dlsym(security_handle, "SecTranslocateIsTranslocatedURL"));
|
|
||||||
const auto CreateOriginalPathForURL = reinterpret_cast<CreateOriginalPathForURLFunc>(
|
|
||||||
dlsym(security_handle, "SecTranslocateCreateOriginalPathForURL"));
|
|
||||||
|
|
||||||
bool is_translocated = false;
|
|
||||||
if (IsTranslocatedURL && CreateOriginalPathForURL &&
|
|
||||||
IsTranslocatedURL(bundle_path, &is_translocated, nullptr) && is_translocated) {
|
|
||||||
return CreateOriginalPathForURL(bundle_path, nullptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::filesystem::path GetBundleParentDirectory() {
|
|
||||||
if (CFBundleRef bundle_ref = CFBundleGetMainBundle()) {
|
|
||||||
if (CFURLRef bundle_url_ref = CFBundleCopyBundleURL(bundle_ref)) {
|
|
||||||
SCOPE_EXIT {
|
|
||||||
CFRelease(bundle_url_ref);
|
|
||||||
};
|
|
||||||
|
|
||||||
CFURLRef untranslocated_url_ref = UntranslocateBundlePath(bundle_url_ref);
|
|
||||||
SCOPE_EXIT {
|
|
||||||
if (untranslocated_url_ref) {
|
|
||||||
CFRelease(untranslocated_url_ref);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
char app_bundle_path[MAXPATHLEN];
|
|
||||||
if (CFURLGetFileSystemRepresentation(
|
|
||||||
untranslocated_url_ref ? untranslocated_url_ref : bundle_url_ref, true,
|
|
||||||
reinterpret_cast<u8*>(app_bundle_path), sizeof(app_bundle_path))) {
|
|
||||||
std::filesystem::path bundle_path{app_bundle_path};
|
|
||||||
return bundle_path.parent_path();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return std::filesystem::current_path();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static auto UserPaths = [] {
|
static auto UserPaths = [] {
|
||||||
#ifdef __APPLE__
|
|
||||||
std::filesystem::current_path(GetBundleParentDirectory());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::unordered_map<PathType, fs::path> paths;
|
std::unordered_map<PathType, fs::path> paths;
|
||||||
const auto user_dir = std::filesystem::current_path() / PORTABLE_DIR;
|
const auto user_dir = std::filesystem::current_path() / PORTABLE_DIR;
|
||||||
|
|
||||||
|
@ -99,14 +37,7 @@ static auto UserPaths = [] {
|
||||||
create_path(PathType::ShaderDir, user_dir / SHADER_DIR);
|
create_path(PathType::ShaderDir, user_dir / SHADER_DIR);
|
||||||
create_path(PathType::PM4Dir, user_dir / PM4_DIR);
|
create_path(PathType::PM4Dir, user_dir / PM4_DIR);
|
||||||
create_path(PathType::SaveDataDir, user_dir / SAVEDATA_DIR);
|
create_path(PathType::SaveDataDir, user_dir / SAVEDATA_DIR);
|
||||||
create_path(PathType::GameDataDir, user_dir / GAMEDATA_DIR);
|
|
||||||
create_path(PathType::TempDataDir, user_dir / TEMPDATA_DIR);
|
|
||||||
create_path(PathType::SysModuleDir, user_dir / SYSMODULES_DIR);
|
create_path(PathType::SysModuleDir, user_dir / SYSMODULES_DIR);
|
||||||
create_path(PathType::DownloadDir, user_dir / DOWNLOAD_DIR);
|
|
||||||
create_path(PathType::CapturesDir, user_dir / CAPTURES_DIR);
|
|
||||||
create_path(PathType::CheatsDir, user_dir / CHEATS_DIR);
|
|
||||||
create_path(PathType::PatchesDir, user_dir / PATCHES_DIR);
|
|
||||||
create_path(PathType::AddonsDir, user_dir / ADDONS_DIR);
|
|
||||||
|
|
||||||
return paths;
|
return paths;
|
||||||
}();
|
}();
|
||||||
|
|
|
@ -15,14 +15,7 @@ enum class PathType {
|
||||||
ShaderDir, // Where shaders are stored.
|
ShaderDir, // Where shaders are stored.
|
||||||
PM4Dir, // Where command lists are stored.
|
PM4Dir, // Where command lists are stored.
|
||||||
SaveDataDir, // Where guest save data is stored.
|
SaveDataDir, // Where guest save data is stored.
|
||||||
TempDataDir, // Where game temp data is stored.
|
|
||||||
GameDataDir, // Where game data is stored.
|
|
||||||
SysModuleDir, // Where system modules are stored.
|
SysModuleDir, // Where system modules are stored.
|
||||||
DownloadDir, // Where downloads/temp files are stored.
|
|
||||||
CapturesDir, // Where rdoc captures are stored.
|
|
||||||
CheatsDir, // Where cheats are stored.
|
|
||||||
PatchesDir, // Where patches are stored.
|
|
||||||
AddonsDir, // Where additional content is stored.
|
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr auto PORTABLE_DIR = "user";
|
constexpr auto PORTABLE_DIR = "user";
|
||||||
|
@ -33,14 +26,7 @@ constexpr auto SCREENSHOTS_DIR = "screenshots";
|
||||||
constexpr auto SHADER_DIR = "shader";
|
constexpr auto SHADER_DIR = "shader";
|
||||||
constexpr auto PM4_DIR = "pm4";
|
constexpr auto PM4_DIR = "pm4";
|
||||||
constexpr auto SAVEDATA_DIR = "savedata";
|
constexpr auto SAVEDATA_DIR = "savedata";
|
||||||
constexpr auto GAMEDATA_DIR = "data";
|
|
||||||
constexpr auto TEMPDATA_DIR = "temp";
|
|
||||||
constexpr auto SYSMODULES_DIR = "sys_modules";
|
constexpr auto SYSMODULES_DIR = "sys_modules";
|
||||||
constexpr auto DOWNLOAD_DIR = "download";
|
|
||||||
constexpr auto CAPTURES_DIR = "captures";
|
|
||||||
constexpr auto CHEATS_DIR = "cheats";
|
|
||||||
constexpr auto PATCHES_DIR = "patches";
|
|
||||||
constexpr auto ADDONS_DIR = "addcont";
|
|
||||||
|
|
||||||
// Filenames
|
// Filenames
|
||||||
constexpr auto LOG_FILE = "shad_log.txt";
|
constexpr auto LOG_FILE = "shad_log.txt";
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#include "common/scm_rev.h"
|
|
||||||
|
|
||||||
#define GIT_REV "@GIT_REV@"
|
|
||||||
#define GIT_BRANCH "@GIT_BRANCH@"
|
|
||||||
#define GIT_DESC "@GIT_DESC@"
|
|
||||||
|
|
||||||
namespace Common {
|
|
||||||
|
|
||||||
const char g_scm_rev[] = GIT_REV;
|
|
||||||
const char g_scm_branch[] = GIT_BRANCH;
|
|
||||||
const char g_scm_desc[] = GIT_DESC;
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
namespace Common {
|
|
||||||
|
|
||||||
extern const char g_scm_rev[];
|
|
||||||
extern const char g_scm_branch[];
|
|
||||||
extern const char g_scm_desc[];
|
|
||||||
|
|
||||||
} // namespace Common
|
|
|
@ -14,12 +14,6 @@
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
std::string ToLower(std::string str) {
|
|
||||||
std::transform(str.begin(), str.end(), str.begin(),
|
|
||||||
[](unsigned char c) { return static_cast<char>(std::tolower(c)); });
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::string> SplitString(const std::string& str, char delimiter) {
|
std::vector<std::string> SplitString(const std::string& str, char delimiter) {
|
||||||
std::istringstream iss(str);
|
std::istringstream iss(str);
|
||||||
std::vector<std::string> output(1);
|
std::vector<std::string> output(1);
|
||||||
|
|
|
@ -9,9 +9,6 @@
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
/// Make a string lowercase
|
|
||||||
[[nodiscard]] std::string ToLower(std::string str);
|
|
||||||
|
|
||||||
std::vector<std::string> SplitString(const std::string& str, char delimiter);
|
std::vector<std::string> SplitString(const std::string& str, char delimiter);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include "common/thread.h"
|
#include "common/thread.h"
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <mach/mach.h>
|
#include <mach/mach.h>
|
||||||
#include <pthread.h>
|
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
|
|
|
@ -94,7 +94,7 @@ namespace Common {
|
||||||
|
|
||||||
// This function divides a u128 by a u32 value and produces two u64 values:
|
// This function divides a u128 by a u32 value and produces two u64 values:
|
||||||
// the result of division and the remainder
|
// the result of division and the remainder
|
||||||
[[nodiscard]] static inline std::pair<u64, u64> Divide128On32(const u128& dividend, u32 divisor) {
|
[[nodiscard]] static inline std::pair<u64, u64> Divide128On32(u128 dividend, u32 divisor) {
|
||||||
u64 remainder = dividend[0] % divisor;
|
u64 remainder = dividend[0] % divisor;
|
||||||
u64 accum = dividend[0] / divisor;
|
u64 accum = dividend[0] / divisor;
|
||||||
if (dividend[1] == 0)
|
if (dividend[1] == 0)
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
namespace Common {
|
|
||||||
|
|
||||||
/// General purpose function wrapper similar to std::function.
|
|
||||||
/// Unlike std::function, the captured values don't have to be copyable.
|
|
||||||
/// This class can be moved but not copied.
|
|
||||||
template <typename ResultType, typename... Args>
|
|
||||||
class UniqueFunction {
|
|
||||||
class CallableBase {
|
|
||||||
public:
|
|
||||||
virtual ~CallableBase() = default;
|
|
||||||
virtual ResultType operator()(Args&&...) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Functor>
|
|
||||||
class Callable final : public CallableBase {
|
|
||||||
public:
|
|
||||||
Callable(Functor&& functor_) : functor{std::move(functor_)} {}
|
|
||||||
~Callable() override = default;
|
|
||||||
|
|
||||||
ResultType operator()(Args&&... args) override {
|
|
||||||
return functor(std::forward<Args>(args)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Functor functor;
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
UniqueFunction() = default;
|
|
||||||
|
|
||||||
template <typename Functor>
|
|
||||||
UniqueFunction(Functor&& functor)
|
|
||||||
: callable{std::make_unique<Callable<Functor>>(std::move(functor))} {}
|
|
||||||
|
|
||||||
UniqueFunction& operator=(UniqueFunction&& rhs) noexcept = default;
|
|
||||||
UniqueFunction(UniqueFunction&& rhs) noexcept = default;
|
|
||||||
|
|
||||||
UniqueFunction& operator=(const UniqueFunction&) = delete;
|
|
||||||
UniqueFunction(const UniqueFunction&) = delete;
|
|
||||||
|
|
||||||
ResultType operator()(Args&&... args) const {
|
|
||||||
return (*callable)(std::forward<Args>(args)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
explicit operator bool() const noexcept {
|
|
||||||
return static_cast<bool>(callable);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::unique_ptr<CallableBase> callable;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Common
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
constexpr char VERSION[] = "0.2.1 WIP";
|
constexpr char VERSION[] = "0.0.4 WIP";
|
||||||
constexpr bool isRelease = false;
|
|
||||||
|
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
|
|
@ -2,104 +2,31 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include <boost/icl/separate_interval_set.hpp>
|
#include <boost/icl/separate_interval_set.hpp>
|
||||||
#include "common/alignment.h"
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/error.h"
|
#include "common/error.h"
|
||||||
#include "core/address_space.h"
|
#include "core/address_space.h"
|
||||||
#include "core/libraries/kernel/memory_management.h"
|
#include "core/libraries/kernel/memory_management.h"
|
||||||
#include "core/memory.h"
|
#include "core/virtual_memory.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#else
|
#else
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
// Reserve space for the system address space using a zerofill section.
|
|
||||||
asm(".zerofill GUEST_SYSTEM,GUEST_SYSTEM,__guest_system,0xFBFC00000");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
static constexpr size_t BackingSize = SCE_KERNEL_MAIN_DMEM_SIZE;
|
static constexpr size_t BackingSize = SCE_KERNEL_MAIN_DMEM_SIZE;
|
||||||
|
static constexpr size_t VirtualSize = USER_MAX - USER_MIN + 1;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
[[nodiscard]] constexpr u64 ToWindowsProt(Core::MemoryProt prot) {
|
|
||||||
switch (prot) {
|
|
||||||
case Core::MemoryProt::NoAccess:
|
|
||||||
default:
|
|
||||||
return PAGE_NOACCESS;
|
|
||||||
case Core::MemoryProt::CpuRead:
|
|
||||||
return PAGE_READONLY;
|
|
||||||
case Core::MemoryProt::CpuReadWrite:
|
|
||||||
return PAGE_READWRITE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct AddressSpace::Impl {
|
struct AddressSpace::Impl {
|
||||||
Impl() : process{GetCurrentProcess()} {
|
Impl() : process{GetCurrentProcess()} {
|
||||||
// Allocate virtual address placeholder for our address space.
|
|
||||||
MEM_ADDRESS_REQUIREMENTS req{};
|
|
||||||
MEM_EXTENDED_PARAMETER param{};
|
|
||||||
req.LowestStartingAddress = reinterpret_cast<PVOID>(SYSTEM_MANAGED_MIN);
|
|
||||||
// The ending address must align to page boundary - 1
|
|
||||||
// https://stackoverflow.com/questions/54223343/virtualalloc2-with-memextendedparameteraddressrequirements-always-produces-error
|
|
||||||
req.HighestEndingAddress = reinterpret_cast<PVOID>(USER_MIN + UserSize - 1);
|
|
||||||
req.Alignment = 0;
|
|
||||||
param.Type = MemExtendedParameterAddressRequirements;
|
|
||||||
param.Pointer = &req;
|
|
||||||
|
|
||||||
// Typically, lower parts of system managed area is already reserved in windows.
|
|
||||||
// If reservation fails attempt again by reducing the area size a little bit.
|
|
||||||
// System managed is about 31GB in size so also cap the number of times we can reduce it
|
|
||||||
// to a reasonable amount.
|
|
||||||
static constexpr size_t ReductionOnFail = 1_GB;
|
|
||||||
static constexpr size_t MaxReductions = 10;
|
|
||||||
|
|
||||||
size_t reduction = 0;
|
|
||||||
size_t virtual_size = SystemManagedSize + SystemReservedSize + UserSize;
|
|
||||||
for (u32 i = 0; i < MaxReductions; i++) {
|
|
||||||
virtual_base = static_cast<u8*>(VirtualAlloc2(process, NULL, virtual_size - reduction,
|
|
||||||
MEM_RESERVE | MEM_RESERVE_PLACEHOLDER,
|
|
||||||
PAGE_NOACCESS, ¶m, 1));
|
|
||||||
if (virtual_base) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
reduction += ReductionOnFail;
|
|
||||||
}
|
|
||||||
ASSERT_MSG(virtual_base, "Unable to reserve virtual address space!");
|
|
||||||
|
|
||||||
// Take the reduction off of the system managed area, and leave the others unchanged.
|
|
||||||
system_managed_base = virtual_base;
|
|
||||||
system_managed_size = SystemManagedSize - reduction;
|
|
||||||
system_reserved_base = reinterpret_cast<u8*>(SYSTEM_RESERVED_MIN);
|
|
||||||
system_reserved_size = SystemReservedSize;
|
|
||||||
user_base = reinterpret_cast<u8*>(USER_MIN);
|
|
||||||
user_size = UserSize;
|
|
||||||
|
|
||||||
LOG_INFO(Kernel_Vmm, "System managed virtual memory region: {} - {}",
|
|
||||||
fmt::ptr(system_managed_base),
|
|
||||||
fmt::ptr(system_managed_base + system_managed_size - 1));
|
|
||||||
LOG_INFO(Kernel_Vmm, "System reserved virtual memory region: {} - {}",
|
|
||||||
fmt::ptr(system_reserved_base),
|
|
||||||
fmt::ptr(system_reserved_base + system_reserved_size - 1));
|
|
||||||
LOG_INFO(Kernel_Vmm, "User virtual memory region: {} - {}", fmt::ptr(user_base),
|
|
||||||
fmt::ptr(user_base + user_size - 1));
|
|
||||||
|
|
||||||
// Initializer placeholder tracker
|
|
||||||
const uintptr_t system_managed_addr = reinterpret_cast<uintptr_t>(system_managed_base);
|
|
||||||
const uintptr_t system_reserved_addr = reinterpret_cast<uintptr_t>(system_reserved_base);
|
|
||||||
const uintptr_t user_addr = reinterpret_cast<uintptr_t>(user_base);
|
|
||||||
placeholders.insert({system_managed_addr, virtual_size - reduction});
|
|
||||||
|
|
||||||
// Allocate backing file that represents the total physical memory.
|
// Allocate backing file that represents the total physical memory.
|
||||||
backing_handle =
|
backing_handle =
|
||||||
CreateFileMapping2(INVALID_HANDLE_VALUE, nullptr, FILE_MAP_WRITE | FILE_MAP_READ,
|
CreateFileMapping2(INVALID_HANDLE_VALUE, nullptr, FILE_MAP_WRITE | FILE_MAP_READ,
|
||||||
PAGE_READWRITE, SEC_COMMIT, BackingSize, nullptr, nullptr, 0);
|
PAGE_READWRITE, SEC_COMMIT, BackingSize, nullptr, nullptr, 0);
|
||||||
ASSERT_MSG(backing_handle, "{}", Common::GetLastErrorMsg());
|
ASSERT(backing_handle);
|
||||||
// Allocate a virtual memory for the backing file map as placeholder
|
// Allocate a virtual memory for the backing file map as placeholder
|
||||||
backing_base = static_cast<u8*>(VirtualAlloc2(process, nullptr, BackingSize,
|
backing_base = static_cast<u8*>(VirtualAlloc2(process, nullptr, BackingSize,
|
||||||
MEM_RESERVE | MEM_RESERVE_PLACEHOLDER,
|
MEM_RESERVE | MEM_RESERVE_PLACEHOLDER,
|
||||||
|
@ -107,7 +34,22 @@ struct AddressSpace::Impl {
|
||||||
// Map backing placeholder. This will commit the pages
|
// Map backing placeholder. This will commit the pages
|
||||||
void* const ret = MapViewOfFile3(backing_handle, process, backing_base, 0, BackingSize,
|
void* const ret = MapViewOfFile3(backing_handle, process, backing_base, 0, BackingSize,
|
||||||
MEM_REPLACE_PLACEHOLDER, PAGE_READWRITE, nullptr, 0);
|
MEM_REPLACE_PLACEHOLDER, PAGE_READWRITE, nullptr, 0);
|
||||||
ASSERT_MSG(ret == backing_base, "{}", Common::GetLastErrorMsg());
|
ASSERT(ret == backing_base);
|
||||||
|
// Allocate virtual address placeholder for our address space.
|
||||||
|
MEM_ADDRESS_REQUIREMENTS req{};
|
||||||
|
MEM_EXTENDED_PARAMETER param{};
|
||||||
|
req.LowestStartingAddress = reinterpret_cast<PVOID>(USER_MIN);
|
||||||
|
req.HighestEndingAddress = reinterpret_cast<PVOID>(USER_MAX);
|
||||||
|
req.Alignment = 0;
|
||||||
|
param.Type = MemExtendedParameterAddressRequirements;
|
||||||
|
param.Pointer = &req;
|
||||||
|
virtual_base = static_cast<u8*>(VirtualAlloc2(process, nullptr, VirtualSize,
|
||||||
|
MEM_RESERVE | MEM_RESERVE_PLACEHOLDER,
|
||||||
|
PAGE_NOACCESS, ¶m, 1));
|
||||||
|
ASSERT(virtual_base);
|
||||||
|
|
||||||
|
const uintptr_t virtual_addr = reinterpret_cast<uintptr_t>(virtual_base);
|
||||||
|
placeholders.insert({virtual_addr, virtual_addr + VirtualSize});
|
||||||
}
|
}
|
||||||
|
|
||||||
~Impl() {
|
~Impl() {
|
||||||
|
@ -129,11 +71,10 @@ struct AddressSpace::Impl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Map(VAddr virtual_addr, PAddr phys_addr, size_t size, ULONG prot, uintptr_t fd = 0) {
|
void* MapUser(VAddr virtual_addr, PAddr phys_addr, size_t size, ULONG prot) {
|
||||||
const size_t aligned_size = Common::AlignUp(size, 16_KB);
|
|
||||||
const auto it = placeholders.find(virtual_addr);
|
const auto it = placeholders.find(virtual_addr);
|
||||||
ASSERT_MSG(it != placeholders.end(), "Cannot map already mapped region");
|
ASSERT_MSG(it != placeholders.end(), "Cannot map already mapped region");
|
||||||
ASSERT_MSG(virtual_addr >= it->lower() && virtual_addr + aligned_size <= it->upper(),
|
ASSERT_MSG(virtual_addr >= it->lower() && virtual_addr + size <= it->upper(),
|
||||||
"Map range must be fully contained in a placeholder");
|
"Map range must be fully contained in a placeholder");
|
||||||
|
|
||||||
// Windows only allows splitting a placeholder into two.
|
// Windows only allows splitting a placeholder into two.
|
||||||
|
@ -142,7 +83,7 @@ struct AddressSpace::Impl {
|
||||||
// one at the start and at the end.
|
// one at the start and at the end.
|
||||||
const VAddr placeholder_start = it->lower();
|
const VAddr placeholder_start = it->lower();
|
||||||
const VAddr placeholder_end = it->upper();
|
const VAddr placeholder_end = it->upper();
|
||||||
const VAddr virtual_end = virtual_addr + aligned_size;
|
const VAddr virtual_end = virtual_addr + size;
|
||||||
|
|
||||||
// If the placeholder doesn't exactly start at virtual_addr, split it at the start.
|
// If the placeholder doesn't exactly start at virtual_addr, split it at the start.
|
||||||
if (placeholder_start != virtual_addr) {
|
if (placeholder_start != virtual_addr) {
|
||||||
|
@ -162,41 +103,37 @@ struct AddressSpace::Impl {
|
||||||
// Perform the map.
|
// Perform the map.
|
||||||
void* ptr = nullptr;
|
void* ptr = nullptr;
|
||||||
if (phys_addr != -1) {
|
if (phys_addr != -1) {
|
||||||
HANDLE backing = fd ? reinterpret_cast<HANDLE>(fd) : backing_handle;
|
ptr = MapViewOfFile3(backing_handle, process, reinterpret_cast<PVOID>(virtual_addr),
|
||||||
if (fd && prot == PAGE_READONLY) {
|
phys_addr, size, MEM_REPLACE_PLACEHOLDER, prot, nullptr, 0);
|
||||||
DWORD resultvar;
|
|
||||||
ptr = VirtualAlloc2(process, reinterpret_cast<PVOID>(virtual_addr), aligned_size,
|
|
||||||
MEM_RESERVE | MEM_COMMIT | MEM_REPLACE_PLACEHOLDER,
|
|
||||||
PAGE_READWRITE, nullptr, 0);
|
|
||||||
bool ret = ReadFile(backing, ptr, size, &resultvar, NULL);
|
|
||||||
ASSERT_MSG(ret, "ReadFile failed. {}", Common::GetLastErrorMsg());
|
|
||||||
ret = VirtualProtect(ptr, size, prot, &resultvar);
|
|
||||||
ASSERT_MSG(ret, "VirtualProtect failed. {}", Common::GetLastErrorMsg());
|
|
||||||
} else {
|
} else {
|
||||||
ptr = MapViewOfFile3(backing, process, reinterpret_cast<PVOID>(virtual_addr),
|
ptr = VirtualAlloc2(process, reinterpret_cast<PVOID>(virtual_addr), size,
|
||||||
phys_addr, aligned_size, MEM_REPLACE_PLACEHOLDER, prot,
|
MEM_REPLACE_PLACEHOLDER, prot, nullptr, 0);
|
||||||
nullptr, 0);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ptr =
|
|
||||||
VirtualAlloc2(process, reinterpret_cast<PVOID>(virtual_addr), aligned_size,
|
|
||||||
MEM_RESERVE | MEM_COMMIT | MEM_REPLACE_PLACEHOLDER, prot, nullptr, 0);
|
|
||||||
}
|
}
|
||||||
ASSERT_MSG(ptr, "{}", Common::GetLastErrorMsg());
|
ASSERT_MSG(ptr, "{}", Common::GetLastErrorMsg());
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unmap(VAddr virtual_addr, size_t size, bool has_backing) {
|
void* MapPrivate(VAddr virtual_addr, size_t size, u64 alignment, ULONG prot) {
|
||||||
bool ret;
|
// Map a private allocation
|
||||||
if (has_backing) {
|
MEM_ADDRESS_REQUIREMENTS req{};
|
||||||
ret = UnmapViewOfFile2(process, reinterpret_cast<PVOID>(virtual_addr),
|
MEM_EXTENDED_PARAMETER param{};
|
||||||
MEM_PRESERVE_PLACEHOLDER);
|
// req.LowestStartingAddress =
|
||||||
} else {
|
// (virtual_addr == 0 ? reinterpret_cast<PVOID>(SYSTEM_MANAGED_MIN)
|
||||||
ret = VirtualFreeEx(process, reinterpret_cast<PVOID>(virtual_addr), size,
|
// : reinterpret_cast<PVOID>(virtual_addr));
|
||||||
MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER);
|
req.HighestEndingAddress = reinterpret_cast<PVOID>(SYSTEM_MANAGED_MAX);
|
||||||
|
req.Alignment = alignment < 64_KB ? 0 : alignment;
|
||||||
|
param.Type = MemExtendedParameterAddressRequirements;
|
||||||
|
param.Pointer = &req;
|
||||||
|
ULONG alloc_type = MEM_COMMIT | MEM_RESERVE | (alignment > 2_MB ? MEM_LARGE_PAGES : 0);
|
||||||
|
void* const ptr = VirtualAlloc2(process, nullptr, size, alloc_type, prot, ¶m, 1);
|
||||||
|
ASSERT_MSG(ptr, "{}", Common::GetLastErrorMsg());
|
||||||
|
return ptr;
|
||||||
}
|
}
|
||||||
ASSERT_MSG(ret, "Unmap operation on virtual_addr={:#X} failed: {}", virtual_addr,
|
|
||||||
Common::GetLastErrorMsg());
|
void UnmapUser(VAddr virtual_addr, size_t size) {
|
||||||
|
const bool ret = UnmapViewOfFile2(process, reinterpret_cast<PVOID>(virtual_addr),
|
||||||
|
MEM_PRESERVE_PLACEHOLDER);
|
||||||
|
ASSERT_MSG(ret, "Unmap operation on virtual_addr={:#X} failed", virtual_addr);
|
||||||
|
|
||||||
// The unmap call will create a new placeholder region. We need to see if we can coalesce it
|
// The unmap call will create a new placeholder region. We need to see if we can coalesce it
|
||||||
// with neighbors.
|
// with neighbors.
|
||||||
|
@ -229,6 +166,12 @@ struct AddressSpace::Impl {
|
||||||
placeholders.insert({placeholder_start, placeholder_end});
|
placeholders.insert({placeholder_start, placeholder_end});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UnmapPrivate(VAddr virtual_addr, size_t size) {
|
||||||
|
const bool ret =
|
||||||
|
VirtualFreeEx(process, reinterpret_cast<LPVOID>(virtual_addr), 0, MEM_RELEASE);
|
||||||
|
ASSERT_MSG(ret, "{}", Common::GetLastErrorMsg());
|
||||||
|
}
|
||||||
|
|
||||||
void Protect(VAddr virtual_addr, size_t size, bool read, bool write, bool execute) {
|
void Protect(VAddr virtual_addr, size_t size, bool read, bool write, bool execute) {
|
||||||
DWORD new_flags{};
|
DWORD new_flags{};
|
||||||
if (read && write) {
|
if (read && write) {
|
||||||
|
@ -258,12 +201,6 @@ struct AddressSpace::Impl {
|
||||||
HANDLE backing_handle{};
|
HANDLE backing_handle{};
|
||||||
u8* backing_base{};
|
u8* backing_base{};
|
||||||
u8* virtual_base{};
|
u8* virtual_base{};
|
||||||
u8* system_managed_base{};
|
|
||||||
size_t system_managed_size{};
|
|
||||||
u8* system_reserved_base{};
|
|
||||||
size_t system_reserved_size{};
|
|
||||||
u8* user_base{};
|
|
||||||
size_t user_size{};
|
|
||||||
boost::icl::separate_interval_set<uintptr_t> placeholders;
|
boost::icl::separate_interval_set<uintptr_t> placeholders;
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
|
@ -277,219 +214,57 @@ enum PosixPageProtection {
|
||||||
PAGE_EXECUTE_READWRITE = PROT_EXEC | PROT_READ | PROT_WRITE
|
PAGE_EXECUTE_READWRITE = PROT_EXEC | PROT_READ | PROT_WRITE
|
||||||
};
|
};
|
||||||
|
|
||||||
[[nodiscard]] constexpr PosixPageProtection ToPosixProt(Core::MemoryProt prot) {
|
|
||||||
switch (prot) {
|
|
||||||
case Core::MemoryProt::NoAccess:
|
|
||||||
default:
|
|
||||||
return PAGE_NOACCESS;
|
|
||||||
case Core::MemoryProt::CpuRead:
|
|
||||||
return PAGE_READONLY;
|
|
||||||
case Core::MemoryProt::CpuReadWrite:
|
|
||||||
return PAGE_READWRITE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct AddressSpace::Impl {
|
struct AddressSpace::Impl {
|
||||||
Impl() {
|
Impl() {
|
||||||
// Allocate virtual address placeholder for our address space.
|
UNREACHABLE();
|
||||||
system_managed_size = SystemManagedSize;
|
|
||||||
system_reserved_size = SystemReservedSize;
|
|
||||||
user_size = UserSize;
|
|
||||||
|
|
||||||
constexpr int protection_flags = PROT_READ | PROT_WRITE;
|
|
||||||
constexpr int base_map_flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE;
|
|
||||||
#ifdef __APPLE__
|
|
||||||
// On ARM64 Macs, we run into limitations due to the commpage from 0xFC0000000 - 0xFFFFFFFFF
|
|
||||||
// and the GPU carveout region from 0x1000000000 - 0x6FFFFFFFFF. We can allocate the system
|
|
||||||
// managed region, as well as system reserved if reduced in size slightly, but we cannot map
|
|
||||||
// the user region where we want, so we must let the OS put it wherever possible and hope
|
|
||||||
// the game won't rely on its location.
|
|
||||||
system_managed_base = reinterpret_cast<u8*>(
|
|
||||||
mmap(reinterpret_cast<void*>(SYSTEM_MANAGED_MIN), system_managed_size, protection_flags,
|
|
||||||
base_map_flags | MAP_FIXED, -1, 0));
|
|
||||||
system_reserved_base = reinterpret_cast<u8*>(
|
|
||||||
mmap(reinterpret_cast<void*>(SYSTEM_RESERVED_MIN), system_reserved_size,
|
|
||||||
protection_flags, base_map_flags | MAP_FIXED, -1, 0));
|
|
||||||
// Cannot guarantee enough space for these areas at the desired addresses, so not MAP_FIXED.
|
|
||||||
user_base = reinterpret_cast<u8*>(mmap(reinterpret_cast<void*>(USER_MIN), user_size,
|
|
||||||
protection_flags, base_map_flags, -1, 0));
|
|
||||||
#else
|
|
||||||
const auto virtual_size = system_managed_size + system_reserved_size + user_size;
|
|
||||||
const auto virtual_base =
|
|
||||||
reinterpret_cast<u8*>(mmap(reinterpret_cast<void*>(SYSTEM_MANAGED_MIN), virtual_size,
|
|
||||||
protection_flags, base_map_flags | MAP_FIXED, -1, 0));
|
|
||||||
system_managed_base = virtual_base;
|
|
||||||
system_reserved_base = reinterpret_cast<u8*>(SYSTEM_RESERVED_MIN);
|
|
||||||
user_base = reinterpret_cast<u8*>(USER_MIN);
|
|
||||||
#endif
|
|
||||||
if (system_managed_base == MAP_FAILED || system_reserved_base == MAP_FAILED ||
|
|
||||||
user_base == MAP_FAILED) {
|
|
||||||
LOG_CRITICAL(Kernel_Vmm, "mmap failed: {}", strerror(errno));
|
|
||||||
throw std::bad_alloc{};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO(Kernel_Vmm, "System managed virtual memory region: {} - {}",
|
void* MapUser(VAddr virtual_addr, PAddr phys_addr, size_t size, PosixPageProtection prot) {
|
||||||
fmt::ptr(system_managed_base),
|
UNREACHABLE();
|
||||||
fmt::ptr(system_managed_base + system_managed_size - 1));
|
return nullptr;
|
||||||
LOG_INFO(Kernel_Vmm, "System reserved virtual memory region: {} - {}",
|
|
||||||
fmt::ptr(system_reserved_base),
|
|
||||||
fmt::ptr(system_reserved_base + system_reserved_size - 1));
|
|
||||||
LOG_INFO(Kernel_Vmm, "User virtual memory region: {} - {}", fmt::ptr(user_base),
|
|
||||||
fmt::ptr(user_base + user_size - 1));
|
|
||||||
|
|
||||||
const VAddr system_managed_addr = reinterpret_cast<VAddr>(system_managed_base);
|
|
||||||
const VAddr system_reserved_addr = reinterpret_cast<VAddr>(system_managed_base);
|
|
||||||
const VAddr user_addr = reinterpret_cast<VAddr>(user_base);
|
|
||||||
m_free_regions.insert({system_managed_addr, system_managed_addr + system_managed_size});
|
|
||||||
m_free_regions.insert({system_reserved_addr, system_reserved_addr + system_reserved_size});
|
|
||||||
m_free_regions.insert({user_addr, user_addr + user_size});
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
const auto shm_path = fmt::format("/BackingDmem{}", getpid());
|
|
||||||
backing_fd = shm_open(shm_path.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600);
|
|
||||||
if (backing_fd < 0) {
|
|
||||||
LOG_CRITICAL(Kernel_Vmm, "shm_open failed: {}", strerror(errno));
|
|
||||||
throw std::bad_alloc{};
|
|
||||||
}
|
|
||||||
shm_unlink(shm_path.c_str());
|
|
||||||
#else
|
|
||||||
madvise(virtual_base, virtual_size, MADV_HUGEPAGE);
|
|
||||||
|
|
||||||
backing_fd = memfd_create("BackingDmem", 0);
|
|
||||||
if (backing_fd < 0) {
|
|
||||||
LOG_CRITICAL(Kernel_Vmm, "memfd_create failed: {}", strerror(errno));
|
|
||||||
throw std::bad_alloc{};
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Defined to extend the file with zeros
|
|
||||||
int ret = ftruncate(backing_fd, BackingSize);
|
|
||||||
if (ret != 0) {
|
|
||||||
LOG_CRITICAL(Kernel_Vmm, "ftruncate failed with {}, are you out-of-memory?",
|
|
||||||
strerror(errno));
|
|
||||||
throw std::bad_alloc{};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map backing dmem handle.
|
void* MapPrivate(VAddr virtual_addr, size_t size, u64 alignment, PosixPageProtection prot) {
|
||||||
backing_base = static_cast<u8*>(
|
UNREACHABLE();
|
||||||
mmap(nullptr, BackingSize, PROT_READ | PROT_WRITE, MAP_SHARED, backing_fd, 0));
|
return nullptr;
|
||||||
if (backing_base == MAP_FAILED) {
|
|
||||||
LOG_CRITICAL(Kernel_Vmm, "mmap failed: {}", strerror(errno));
|
|
||||||
throw std::bad_alloc{};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Map(VAddr virtual_addr, PAddr phys_addr, size_t size, PosixPageProtection prot,
|
void UnmapUser(VAddr virtual_addr, size_t size) {
|
||||||
int fd = -1) {
|
UNREACHABLE();
|
||||||
m_free_regions.subtract({virtual_addr, virtual_addr + size});
|
|
||||||
const int handle = phys_addr != -1 ? (fd == -1 ? backing_fd : fd) : -1;
|
|
||||||
const off_t host_offset = phys_addr != -1 ? phys_addr : 0;
|
|
||||||
const int flag = phys_addr != -1 ? MAP_SHARED : (MAP_ANONYMOUS | MAP_PRIVATE);
|
|
||||||
void* ret = mmap(reinterpret_cast<void*>(virtual_addr), size, prot, MAP_FIXED | flag,
|
|
||||||
handle, host_offset);
|
|
||||||
ASSERT_MSG(ret != MAP_FAILED, "mmap failed: {}", strerror(errno));
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unmap(VAddr virtual_addr, size_t size, bool) {
|
void UnmapPrivate(VAddr virtual_addr, size_t size) {
|
||||||
// Check to see if we are adjacent to any regions.
|
UNREACHABLE();
|
||||||
auto start_address = virtual_addr;
|
|
||||||
auto end_address = start_address + size;
|
|
||||||
auto it = m_free_regions.find({start_address - 1, end_address + 1});
|
|
||||||
|
|
||||||
// If we are, join with them, ensuring we stay in bounds.
|
|
||||||
if (it != m_free_regions.end()) {
|
|
||||||
start_address = std::min(start_address, it->lower());
|
|
||||||
end_address = std::max(end_address, it->upper());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Free the relevant region.
|
|
||||||
m_free_regions.insert({start_address, end_address});
|
|
||||||
|
|
||||||
// Return the adjusted pointers.
|
|
||||||
void* ret = mmap(reinterpret_cast<void*>(start_address), end_address - start_address,
|
|
||||||
PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
|
|
||||||
ASSERT_MSG(ret != MAP_FAILED, "mmap failed: {}", strerror(errno));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Protect(VAddr virtual_addr, size_t size, bool read, bool write, bool execute) {
|
void Protect(VAddr virtual_addr, size_t size, bool read, bool write, bool execute) {
|
||||||
int flags = PROT_NONE;
|
UNREACHABLE();
|
||||||
if (read) {
|
|
||||||
flags |= PROT_READ;
|
|
||||||
}
|
|
||||||
if (write) {
|
|
||||||
flags |= PROT_WRITE;
|
|
||||||
}
|
|
||||||
if (execute) {
|
|
||||||
flags |= PROT_EXEC;
|
|
||||||
}
|
|
||||||
int ret = mprotect(reinterpret_cast<void*>(virtual_addr), size, flags);
|
|
||||||
ASSERT_MSG(ret == 0, "mprotect failed: {}", strerror(errno));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int backing_fd;
|
|
||||||
u8* backing_base{};
|
u8* backing_base{};
|
||||||
u8* system_managed_base{};
|
u8* virtual_base{};
|
||||||
size_t system_managed_size{};
|
|
||||||
u8* system_reserved_base{};
|
|
||||||
size_t system_reserved_size{};
|
|
||||||
u8* user_base{};
|
|
||||||
size_t user_size{};
|
|
||||||
boost::icl::interval_set<VAddr> m_free_regions;
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
AddressSpace::AddressSpace() : impl{std::make_unique<Impl>()} {
|
AddressSpace::AddressSpace() : impl{std::make_unique<Impl>()} {
|
||||||
|
virtual_base = impl->virtual_base;
|
||||||
backing_base = impl->backing_base;
|
backing_base = impl->backing_base;
|
||||||
system_managed_base = impl->system_managed_base;
|
|
||||||
system_managed_size = impl->system_managed_size;
|
|
||||||
system_reserved_base = impl->system_reserved_base;
|
|
||||||
system_reserved_size = impl->system_reserved_size;
|
|
||||||
user_base = impl->user_base;
|
|
||||||
user_size = impl->user_size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AddressSpace::~AddressSpace() = default;
|
AddressSpace::~AddressSpace() = default;
|
||||||
|
|
||||||
void* AddressSpace::Map(VAddr virtual_addr, size_t size, u64 alignment, PAddr phys_addr,
|
void* AddressSpace::Map(VAddr virtual_addr, size_t size, u64 alignment, PAddr phys_addr) {
|
||||||
bool is_exec) {
|
if (virtual_addr >= USER_MIN) {
|
||||||
return impl->Map(virtual_addr, phys_addr, size,
|
return impl->MapUser(virtual_addr, phys_addr, size, PAGE_READWRITE);
|
||||||
is_exec ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE);
|
}
|
||||||
|
return impl->MapPrivate(virtual_addr, size, alignment, PAGE_READWRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* AddressSpace::MapFile(VAddr virtual_addr, size_t size, size_t offset, u32 prot,
|
void AddressSpace::Unmap(VAddr virtual_addr, size_t size) {
|
||||||
uintptr_t fd) {
|
if (virtual_addr >= USER_MIN) {
|
||||||
#ifdef _WIN32
|
return impl->UnmapUser(virtual_addr, size);
|
||||||
return impl->Map(virtual_addr, offset, size,
|
|
||||||
ToWindowsProt(std::bit_cast<Core::MemoryProt>(prot)), fd);
|
|
||||||
#else
|
|
||||||
return impl->Map(virtual_addr, offset, size, ToPosixProt(std::bit_cast<Core::MemoryProt>(prot)),
|
|
||||||
fd);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
return impl->UnmapPrivate(virtual_addr, size);
|
||||||
void AddressSpace::Unmap(VAddr virtual_addr, size_t size, VAddr start_in_vma, VAddr end_in_vma,
|
|
||||||
PAddr phys_base, bool is_exec, bool has_backing, bool readonly_file) {
|
|
||||||
#ifdef _WIN32
|
|
||||||
// There does not appear to be comparable support for partial unmapping on Windows.
|
|
||||||
// Unfortunately, a least one title was found to require this. The workaround is to unmap
|
|
||||||
// the entire allocation and remap the portions outside of the requested unmapping range.
|
|
||||||
impl->Unmap(virtual_addr, size, has_backing && !readonly_file);
|
|
||||||
|
|
||||||
// TODO: Determine if any titles require partial unmapping support for flexible allocations.
|
|
||||||
ASSERT_MSG(has_backing || (start_in_vma == 0 && end_in_vma == size),
|
|
||||||
"Partial unmapping of flexible allocations is not supported");
|
|
||||||
|
|
||||||
if (start_in_vma != 0) {
|
|
||||||
Map(virtual_addr, start_in_vma, 0, phys_base, is_exec);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (end_in_vma != size) {
|
|
||||||
Map(virtual_addr + end_in_vma, size - end_in_vma, 0, phys_base + end_in_vma, is_exec);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
impl->Unmap(virtual_addr + start_in_vma, end_in_vma - start_in_vma, has_backing);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressSpace::Protect(VAddr virtual_addr, size_t size, MemoryPermission perms) {
|
void AddressSpace::Protect(VAddr virtual_addr, size_t size, MemoryPermission perms) {
|
||||||
|
|
|
@ -14,28 +14,9 @@ enum class MemoryPermission : u32 {
|
||||||
Write = 1 << 1,
|
Write = 1 << 1,
|
||||||
ReadWrite = Read | Write,
|
ReadWrite = Read | Write,
|
||||||
Execute = 1 << 2,
|
Execute = 1 << 2,
|
||||||
ReadWriteExecute = Read | Write | Execute,
|
|
||||||
};
|
};
|
||||||
DECLARE_ENUM_FLAG_OPERATORS(MemoryPermission)
|
DECLARE_ENUM_FLAG_OPERATORS(MemoryPermission)
|
||||||
|
|
||||||
constexpr VAddr CODE_BASE_OFFSET = 0x100000000ULL;
|
|
||||||
|
|
||||||
constexpr VAddr SYSTEM_MANAGED_MIN = 0x00000400000ULL;
|
|
||||||
constexpr VAddr SYSTEM_MANAGED_MAX = 0x07FFFFBFFFULL;
|
|
||||||
constexpr VAddr SYSTEM_RESERVED_MIN = 0x07FFFFC000ULL;
|
|
||||||
#ifdef __APPLE__
|
|
||||||
// Can only comfortably reserve the first 0x7C0000000 of system reserved space.
|
|
||||||
constexpr VAddr SYSTEM_RESERVED_MAX = 0xFBFFFFFFFULL;
|
|
||||||
#else
|
|
||||||
constexpr VAddr SYSTEM_RESERVED_MAX = 0xFFFFFFFFFULL;
|
|
||||||
#endif
|
|
||||||
constexpr VAddr USER_MIN = 0x1000000000ULL;
|
|
||||||
constexpr VAddr USER_MAX = 0xFBFFFFFFFFULL;
|
|
||||||
|
|
||||||
static constexpr size_t SystemManagedSize = SYSTEM_MANAGED_MAX - SYSTEM_MANAGED_MIN + 1;
|
|
||||||
static constexpr size_t SystemReservedSize = SYSTEM_RESERVED_MAX - SYSTEM_RESERVED_MIN + 1;
|
|
||||||
static constexpr size_t UserSize = 1ULL << 40;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the user virtual address space backed by a dmem memory block
|
* Represents the user virtual address space backed by a dmem memory block
|
||||||
*/
|
*/
|
||||||
|
@ -44,34 +25,11 @@ public:
|
||||||
explicit AddressSpace();
|
explicit AddressSpace();
|
||||||
~AddressSpace();
|
~AddressSpace();
|
||||||
|
|
||||||
[[nodiscard]] VAddr SystemManagedVirtualBase() noexcept {
|
[[nodiscard]] u8* VirtualBase() noexcept {
|
||||||
return reinterpret_cast<VAddr>(system_managed_base);
|
return virtual_base;
|
||||||
}
|
}
|
||||||
[[nodiscard]] const u8* SystemManagedVirtualBase() const noexcept {
|
[[nodiscard]] const u8* VirtualBase() const noexcept {
|
||||||
return system_managed_base;
|
return virtual_base;
|
||||||
}
|
|
||||||
[[nodiscard]] size_t SystemManagedVirtualSize() const noexcept {
|
|
||||||
return system_managed_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] VAddr SystemReservedVirtualBase() noexcept {
|
|
||||||
return reinterpret_cast<VAddr>(system_reserved_base);
|
|
||||||
}
|
|
||||||
[[nodiscard]] const u8* SystemReservedVirtualBase() const noexcept {
|
|
||||||
return system_reserved_base;
|
|
||||||
}
|
|
||||||
[[nodiscard]] size_t SystemReservedVirtualSize() const noexcept {
|
|
||||||
return system_reserved_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] VAddr UserVirtualBase() noexcept {
|
|
||||||
return reinterpret_cast<VAddr>(user_base);
|
|
||||||
}
|
|
||||||
[[nodiscard]] const u8* UserVirtualBase() const noexcept {
|
|
||||||
return user_base;
|
|
||||||
}
|
|
||||||
[[nodiscard]] size_t UserVirtualSize() const noexcept {
|
|
||||||
return user_size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,15 +42,10 @@ public:
|
||||||
* If zero is provided the mapping is considered as private.
|
* If zero is provided the mapping is considered as private.
|
||||||
* @return A pointer to the mapped memory.
|
* @return A pointer to the mapped memory.
|
||||||
*/
|
*/
|
||||||
void* Map(VAddr virtual_addr, size_t size, u64 alignment = 0, PAddr phys_addr = -1,
|
void* Map(VAddr virtual_addr, size_t size, u64 alignment = 0, PAddr phys_addr = -1);
|
||||||
bool exec = false);
|
|
||||||
|
|
||||||
/// Memory maps a specified file descriptor.
|
|
||||||
void* MapFile(VAddr virtual_addr, size_t size, size_t offset, u32 prot, uintptr_t fd);
|
|
||||||
|
|
||||||
/// Unmaps specified virtual memory area.
|
/// Unmaps specified virtual memory area.
|
||||||
void Unmap(VAddr virtual_addr, size_t size, VAddr start_in_vma, VAddr end_in_vma,
|
void Unmap(VAddr virtual_addr, size_t size);
|
||||||
PAddr phys_base, bool is_exec, bool has_backing, bool readonly_file);
|
|
||||||
|
|
||||||
void Protect(VAddr virtual_addr, size_t size, MemoryPermission perms);
|
void Protect(VAddr virtual_addr, size_t size, MemoryPermission perms);
|
||||||
|
|
||||||
|
@ -100,12 +53,7 @@ private:
|
||||||
struct Impl;
|
struct Impl;
|
||||||
std::unique_ptr<Impl> impl;
|
std::unique_ptr<Impl> impl;
|
||||||
u8* backing_base{};
|
u8* backing_base{};
|
||||||
u8* system_managed_base{};
|
u8* virtual_base{};
|
||||||
size_t system_managed_size{};
|
|
||||||
u8* system_reserved_base{};
|
|
||||||
size_t system_reserved_size{};
|
|
||||||
u8* user_base{};
|
|
||||||
size_t user_size{};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|
|
@ -114108,7 +114108,7 @@ STUB(
|
||||||
_ZN3sce2Np9CppWebApi6Common12IntrusivePtrINS1_7Matches2V124RequestCompetitiveResultEE7add_refEv)
|
_ZN3sce2Np9CppWebApi6Common12IntrusivePtrINS1_7Matches2V124RequestCompetitiveResultEE7add_refEv)
|
||||||
STUB("efPahl2FufA",
|
STUB("efPahl2FufA",
|
||||||
_ZN3sce2Np9CppWebApi30CommunicationRestrictionStatus2V35Error8fromJsonERKNS_4Json5ValueE)
|
_ZN3sce2Np9CppWebApi30CommunicationRestrictionStatus2V35Error8fromJsonERKNS_4Json5ValueE)
|
||||||
STUB("efX3lrPwdKA", sceAppContentAddcontMountByEntitlementId)
|
STUB("efX3lrPwdKA", sceAppContentAddcontMountByEntitlemetId)
|
||||||
STUB("efXnxYFN5oE", _ZNSt11range_errorD0Ev)
|
STUB("efXnxYFN5oE", _ZNSt11range_errorD0Ev)
|
||||||
STUB("efcwuDLsAM0", _ZThn120_NK7WebCore16HTMLMediaElement5mutedEv)
|
STUB("efcwuDLsAM0", _ZThn120_NK7WebCore16HTMLMediaElement5mutedEv)
|
||||||
STUB("efhGArzWdxE", _ZN7bmalloc6IsoTLS15s_didInitializeE)
|
STUB("efhGArzWdxE", _ZN7bmalloc6IsoTLS15s_didInitializeE)
|
||||||
|
@ -129493,7 +129493,7 @@ STUB(
|
||||||
STUB("kJlYH5uMAWI", sceNetResolverDestroy)
|
STUB("kJlYH5uMAWI", sceNetResolverDestroy)
|
||||||
STUB("kJmdxo4uM+8",
|
STUB("kJmdxo4uM+8",
|
||||||
_ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE5_InitERKSt8_Locinfo)
|
_ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE5_InitERKSt8_Locinfo)
|
||||||
STUB("kJmjt81mXKQ", sceAppContentAddcontEnqueueDownloadByEntitlementId)
|
STUB("kJmjt81mXKQ", sceAppContentAddcontEnqueueDownloadByEntitlemetId)
|
||||||
STUB(
|
STUB(
|
||||||
"kJoY9lMIFzY",
|
"kJoY9lMIFzY",
|
||||||
_ZN3sce2Np9CppWebApi6Common8IteratorINS2_12IntrusivePtrINS1_21AdvancedPlayerProfile2V138MatchCompletionRateDisconnectedMetricsEEEEmmEi)
|
_ZN3sce2Np9CppWebApi6Common8IteratorINS2_12IntrusivePtrINS1_21AdvancedPlayerProfile2V138MatchCompletionRateDisconnectedMetricsEEEEmmEi)
|
||||||
|
|
|
@ -13,13 +13,13 @@ namespace Core::AeroLib {
|
||||||
// on lookup, setting up the nid_entry they are matched with
|
// on lookup, setting up the nid_entry they are matched with
|
||||||
//
|
//
|
||||||
// If it runs out of stubs with name information, it will return
|
// If it runs out of stubs with name information, it will return
|
||||||
// a default implementation without function name details
|
// a default implemetnation without function name details
|
||||||
|
|
||||||
// Up to 512, larger values lead to more resolve stub slots
|
// Up to 512, larger values lead to more resolve stub slots
|
||||||
// and to longer compile / CI times
|
// and to longer compile / CI times
|
||||||
//
|
//
|
||||||
// Must match STUBS_LIST define
|
// Must match STUBS_LIST define
|
||||||
constexpr u32 MAX_STUBS = 1024;
|
constexpr u32 MAX_STUBS = 512;
|
||||||
|
|
||||||
u64 UnresolvedStub() {
|
u64 UnresolvedStub() {
|
||||||
LOG_ERROR(Core, "Returning zero to {}", __builtin_return_address(0));
|
LOG_ERROR(Core, "Returning zero to {}", __builtin_return_address(0));
|
||||||
|
@ -60,9 +60,8 @@ static u32 UsedStubEntries;
|
||||||
#define XREP_128(x) XREP_64(x) XREP_64(x + 64)
|
#define XREP_128(x) XREP_64(x) XREP_64(x + 64)
|
||||||
#define XREP_256(x) XREP_128(x) XREP_128(x + 128)
|
#define XREP_256(x) XREP_128(x) XREP_128(x + 128)
|
||||||
#define XREP_512(x) XREP_256(x) XREP_256(x + 256)
|
#define XREP_512(x) XREP_256(x) XREP_256(x + 256)
|
||||||
#define XREP_1024(x) XREP_512(x) XREP_512(x + 512)
|
|
||||||
|
|
||||||
#define STUBS_LIST XREP_1024(0)
|
#define STUBS_LIST XREP_512(0)
|
||||||
|
|
||||||
static u64 (*stub_handlers[MAX_STUBS])() = {STUBS_LIST};
|
static u64 (*stub_handlers[MAX_STUBS])() = {STUBS_LIST};
|
||||||
|
|
||||||
|
|
|
@ -1,640 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <mutex>
|
|
||||||
#include <Zydis/Zydis.h>
|
|
||||||
#include <xbyak/xbyak.h>
|
|
||||||
#include "common/assert.h"
|
|
||||||
#include "common/types.h"
|
|
||||||
#include "core/tls.h"
|
|
||||||
#include "cpu_patches.h"
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <windows.h>
|
|
||||||
#else
|
|
||||||
#include <pthread.h>
|
|
||||||
#ifdef __APPLE__
|
|
||||||
#include <half.hpp>
|
|
||||||
#include <sys/sysctl.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace Xbyak::util;
|
|
||||||
|
|
||||||
namespace Core {
|
|
||||||
|
|
||||||
static Xbyak::Reg ZydisToXbyakRegister(const ZydisRegister reg) {
|
|
||||||
if (reg >= ZYDIS_REGISTER_EAX && reg <= ZYDIS_REGISTER_R15D) {
|
|
||||||
return Xbyak::Reg32(reg - ZYDIS_REGISTER_EAX + Xbyak::Operand::EAX);
|
|
||||||
}
|
|
||||||
if (reg >= ZYDIS_REGISTER_RAX && reg <= ZYDIS_REGISTER_R15) {
|
|
||||||
return Xbyak::Reg64(reg - ZYDIS_REGISTER_RAX + Xbyak::Operand::RAX);
|
|
||||||
}
|
|
||||||
if (reg >= ZYDIS_REGISTER_XMM0 && reg <= ZYDIS_REGISTER_XMM31) {
|
|
||||||
return Xbyak::Xmm(reg - ZYDIS_REGISTER_XMM0 + xmm0.getIdx());
|
|
||||||
}
|
|
||||||
if (reg >= ZYDIS_REGISTER_YMM0 && reg <= ZYDIS_REGISTER_YMM31) {
|
|
||||||
return Xbyak::Ymm(reg - ZYDIS_REGISTER_YMM0 + ymm0.getIdx());
|
|
||||||
}
|
|
||||||
UNREACHABLE_MSG("Unsupported register: {}", static_cast<u32>(reg));
|
|
||||||
}
|
|
||||||
|
|
||||||
static Xbyak::Reg ZydisToXbyakRegisterOperand(const ZydisDecodedOperand& operand) {
|
|
||||||
ASSERT_MSG(operand.type == ZYDIS_OPERAND_TYPE_REGISTER,
|
|
||||||
"Expected register operand, got type: {}", static_cast<u32>(operand.type));
|
|
||||||
|
|
||||||
return ZydisToXbyakRegister(operand.reg.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Xbyak::Address ZydisToXbyakMemoryOperand(const ZydisDecodedOperand& operand) {
|
|
||||||
ASSERT_MSG(operand.type == ZYDIS_OPERAND_TYPE_MEMORY, "Expected memory operand, got type: {}",
|
|
||||||
static_cast<u32>(operand.type));
|
|
||||||
|
|
||||||
if (operand.mem.base == ZYDIS_REGISTER_RIP) {
|
|
||||||
return ptr[rip + operand.mem.disp.value];
|
|
||||||
}
|
|
||||||
|
|
||||||
Xbyak::RegExp expression{};
|
|
||||||
if (operand.mem.base != ZYDIS_REGISTER_NONE) {
|
|
||||||
expression = expression + ZydisToXbyakRegister(operand.mem.base);
|
|
||||||
}
|
|
||||||
if (operand.mem.index != ZYDIS_REGISTER_NONE) {
|
|
||||||
if (operand.mem.scale != 0) {
|
|
||||||
expression = expression + ZydisToXbyakRegister(operand.mem.index) * operand.mem.scale;
|
|
||||||
} else {
|
|
||||||
expression = expression + ZydisToXbyakRegister(operand.mem.index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (operand.mem.disp.size != 0 && operand.mem.disp.value != 0) {
|
|
||||||
expression = expression + operand.mem.disp.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ptr[expression];
|
|
||||||
}
|
|
||||||
|
|
||||||
static u64 ZydisToXbyakImmediateOperand(const ZydisDecodedOperand& operand) {
|
|
||||||
ASSERT_MSG(operand.type == ZYDIS_OPERAND_TYPE_IMMEDIATE,
|
|
||||||
"Expected immediate operand, got type: {}", static_cast<u32>(operand.type));
|
|
||||||
return operand.imm.value.u;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::unique_ptr<Xbyak::Operand> ZydisToXbyakOperand(const ZydisDecodedOperand& operand) {
|
|
||||||
switch (operand.type) {
|
|
||||||
case ZYDIS_OPERAND_TYPE_REGISTER: {
|
|
||||||
return std::make_unique<Xbyak::Reg>(ZydisToXbyakRegisterOperand(operand));
|
|
||||||
}
|
|
||||||
case ZYDIS_OPERAND_TYPE_MEMORY: {
|
|
||||||
return std::make_unique<Xbyak::Address>(ZydisToXbyakMemoryOperand(operand));
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
UNREACHABLE_MSG("Unsupported operand type: {}", static_cast<u32>(operand.type));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool OperandUsesRegister(const Xbyak::Operand* operand, int index) {
|
|
||||||
if (operand->isREG()) {
|
|
||||||
return operand->getIdx() == index;
|
|
||||||
}
|
|
||||||
if (operand->isMEM()) {
|
|
||||||
const Xbyak::RegExp& reg_exp = operand->getAddress().getRegExp();
|
|
||||||
return reg_exp.getBase().getIdx() == index || reg_exp.getIndex().getIdx() == index;
|
|
||||||
}
|
|
||||||
UNREACHABLE_MSG("Unsupported operand kind: {}", static_cast<u32>(operand->getKind()));
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool IsRegisterAllocated(
|
|
||||||
const std::initializer_list<const Xbyak::Operand*>& allocated_registers, const int index) {
|
|
||||||
return std::ranges::find_if(allocated_registers.begin(), allocated_registers.end(),
|
|
||||||
[index](const Xbyak::Operand* operand) {
|
|
||||||
return OperandUsesRegister(operand, index);
|
|
||||||
}) != allocated_registers.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
static Xbyak::Reg AllocateScratchRegister(
|
|
||||||
const std::initializer_list<const Xbyak::Operand*> allocated_registers, const u32 bits) {
|
|
||||||
for (int index = Xbyak::Operand::R8; index <= Xbyak::Operand::R15; index++) {
|
|
||||||
if (!IsRegisterAllocated(allocated_registers, index)) {
|
|
||||||
return Xbyak::Reg32e(index, static_cast<int>(bits));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
UNREACHABLE_MSG("Out of scratch registers!");
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
|
|
||||||
static pthread_key_t stack_pointer_slot;
|
|
||||||
static pthread_key_t patch_stack_slot;
|
|
||||||
static std::once_flag patch_context_slots_init_flag;
|
|
||||||
|
|
||||||
static_assert(sizeof(void*) == sizeof(u64),
|
|
||||||
"Cannot fit a register inside a thread local storage slot.");
|
|
||||||
|
|
||||||
static void InitializePatchContextSlots() {
|
|
||||||
ASSERT_MSG(pthread_key_create(&stack_pointer_slot, nullptr) == 0,
|
|
||||||
"Unable to allocate thread-local register for stack pointer.");
|
|
||||||
ASSERT_MSG(pthread_key_create(&patch_stack_slot, nullptr) == 0,
|
|
||||||
"Unable to allocate thread-local register for patch stack.");
|
|
||||||
}
|
|
||||||
|
|
||||||
void InitializeThreadPatchStack() {
|
|
||||||
std::call_once(patch_context_slots_init_flag, InitializePatchContextSlots);
|
|
||||||
|
|
||||||
const auto* patch_stack = std::malloc(0x1000);
|
|
||||||
pthread_setspecific(patch_stack_slot, patch_stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CleanupThreadPatchStack() {
|
|
||||||
std::call_once(patch_context_slots_init_flag, InitializePatchContextSlots);
|
|
||||||
|
|
||||||
auto* patch_stack = pthread_getspecific(patch_stack_slot);
|
|
||||||
if (patch_stack != nullptr) {
|
|
||||||
std::free(patch_stack);
|
|
||||||
pthread_setspecific(patch_stack_slot, nullptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Saves the stack pointer to thread local storage and loads the patch stack.
|
|
||||||
static void SaveStack(Xbyak::CodeGenerator& c) {
|
|
||||||
std::call_once(patch_context_slots_init_flag, InitializePatchContextSlots);
|
|
||||||
|
|
||||||
// Save stack pointer and load patch stack.
|
|
||||||
c.putSeg(gs);
|
|
||||||
c.mov(qword[reinterpret_cast<void*>(stack_pointer_slot * sizeof(void*))], rsp);
|
|
||||||
c.putSeg(gs);
|
|
||||||
c.mov(rsp, qword[reinterpret_cast<void*>(patch_stack_slot * sizeof(void*))]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Restores the stack pointer from thread local storage.
|
|
||||||
static void RestoreStack(Xbyak::CodeGenerator& c) {
|
|
||||||
std::call_once(patch_context_slots_init_flag, InitializePatchContextSlots);
|
|
||||||
|
|
||||||
// Save patch stack pointer and load original stack.
|
|
||||||
c.putSeg(gs);
|
|
||||||
c.mov(qword[reinterpret_cast<void*>(patch_stack_slot * sizeof(void*))], rsp);
|
|
||||||
c.putSeg(gs);
|
|
||||||
c.mov(rsp, qword[reinterpret_cast<void*>(stack_pointer_slot * sizeof(void*))]);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
// These utilities are not implemented as we can't save anything to thread local storage without
|
|
||||||
// temporary registers.
|
|
||||||
void InitializeThreadPatchStack() {
|
|
||||||
// No-op
|
|
||||||
}
|
|
||||||
|
|
||||||
void CleanupThreadPatchStack() {
|
|
||||||
// No-op
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Saves the stack pointer to thread local storage and loads the patch stack.
|
|
||||||
static void SaveStack(Xbyak::CodeGenerator& c) {
|
|
||||||
UNIMPLEMENTED();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Restores the stack pointer from thread local storage.
|
|
||||||
static void RestoreStack(Xbyak::CodeGenerator& c) {
|
|
||||||
UNIMPLEMENTED();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// Switches to the patch stack, saves registers, and restores the original stack.
|
|
||||||
static void SaveRegisters(Xbyak::CodeGenerator& c, const std::initializer_list<Xbyak::Reg> regs) {
|
|
||||||
SaveStack(c);
|
|
||||||
for (const auto& reg : regs) {
|
|
||||||
c.push(reg.cvt64());
|
|
||||||
}
|
|
||||||
RestoreStack(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Switches to the patch stack, restores registers, and restores the original stack.
|
|
||||||
static void RestoreRegisters(Xbyak::CodeGenerator& c,
|
|
||||||
const std::initializer_list<Xbyak::Reg> regs) {
|
|
||||||
SaveStack(c);
|
|
||||||
for (const auto& reg : regs) {
|
|
||||||
c.pop(reg.cvt64());
|
|
||||||
}
|
|
||||||
RestoreStack(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Switches to the patch stack and stores all registers.
|
|
||||||
static void SaveContext(Xbyak::CodeGenerator& c) {
|
|
||||||
SaveStack(c);
|
|
||||||
for (int reg = Xbyak::Operand::RAX; reg <= Xbyak::Operand::R15; reg++) {
|
|
||||||
c.push(Xbyak::Reg64(reg));
|
|
||||||
}
|
|
||||||
for (int reg = 0; reg <= 7; reg++) {
|
|
||||||
c.sub(rsp, 32);
|
|
||||||
c.vmovdqu(ptr[rsp], Xbyak::Ymm(reg));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Restores all registers and restores the original stack.
|
|
||||||
/// If the destination is a register, it is not restored to preserve the output.
|
|
||||||
static void RestoreContext(Xbyak::CodeGenerator& c, const Xbyak::Operand& dst) {
|
|
||||||
for (int reg = 7; reg >= 0; reg--) {
|
|
||||||
if ((!dst.isXMM() && !dst.isYMM()) || dst.getIdx() != reg) {
|
|
||||||
c.vmovdqu(Xbyak::Ymm(reg), ptr[rsp]);
|
|
||||||
}
|
|
||||||
c.add(rsp, 32);
|
|
||||||
}
|
|
||||||
for (int reg = Xbyak::Operand::R15; reg >= Xbyak::Operand::RAX; reg--) {
|
|
||||||
if (!dst.isREG() || dst.getIdx() != reg) {
|
|
||||||
c.pop(Xbyak::Reg64(reg));
|
|
||||||
} else {
|
|
||||||
c.add(rsp, 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
RestoreStack(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
|
|
||||||
static void GenerateANDN(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) {
|
|
||||||
const auto dst = ZydisToXbyakRegisterOperand(operands[0]);
|
|
||||||
const auto src1 = ZydisToXbyakRegisterOperand(operands[1]);
|
|
||||||
const auto src2 = ZydisToXbyakOperand(operands[2]);
|
|
||||||
|
|
||||||
const auto scratch = AllocateScratchRegister({&dst, &src1, src2.get()}, dst.getBit());
|
|
||||||
|
|
||||||
SaveRegisters(c, {scratch});
|
|
||||||
|
|
||||||
c.mov(scratch, src1);
|
|
||||||
c.not_(scratch);
|
|
||||||
c.and_(scratch, *src2);
|
|
||||||
c.mov(dst, scratch);
|
|
||||||
|
|
||||||
RestoreRegisters(c, {scratch});
|
|
||||||
}
|
|
||||||
|
|
||||||
static void GenerateBEXTR(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) {
|
|
||||||
const auto dst = ZydisToXbyakRegisterOperand(operands[0]);
|
|
||||||
const auto src = ZydisToXbyakOperand(operands[1]);
|
|
||||||
const auto start_len = ZydisToXbyakRegisterOperand(operands[2]);
|
|
||||||
|
|
||||||
const Xbyak::Reg32e shift(Xbyak::Operand::RCX, static_cast<int>(start_len.getBit()));
|
|
||||||
const auto scratch1 =
|
|
||||||
AllocateScratchRegister({&dst, src.get(), &start_len, &shift}, dst.getBit());
|
|
||||||
const auto scratch2 =
|
|
||||||
AllocateScratchRegister({&dst, src.get(), &start_len, &shift, &scratch1}, dst.getBit());
|
|
||||||
|
|
||||||
if (dst.getIdx() == shift.getIdx()) {
|
|
||||||
SaveRegisters(c, {scratch1, scratch2});
|
|
||||||
} else {
|
|
||||||
SaveRegisters(c, {scratch1, scratch2, shift});
|
|
||||||
}
|
|
||||||
|
|
||||||
c.mov(scratch1, *src);
|
|
||||||
if (shift.getIdx() != start_len.getIdx()) {
|
|
||||||
c.mov(shift, start_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
c.shr(scratch1, shift.cvt8());
|
|
||||||
c.shr(shift, 8);
|
|
||||||
c.mov(scratch2, 1);
|
|
||||||
c.shl(scratch2, shift.cvt8());
|
|
||||||
c.dec(scratch2);
|
|
||||||
|
|
||||||
c.mov(dst, scratch1);
|
|
||||||
c.and_(dst, scratch2);
|
|
||||||
|
|
||||||
if (dst.getIdx() == shift.getIdx()) {
|
|
||||||
RestoreRegisters(c, {scratch2, scratch1});
|
|
||||||
} else {
|
|
||||||
RestoreRegisters(c, {shift, scratch2, scratch1});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void GenerateBLSI(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) {
|
|
||||||
const auto dst = ZydisToXbyakRegisterOperand(operands[0]);
|
|
||||||
const auto src = ZydisToXbyakOperand(operands[1]);
|
|
||||||
|
|
||||||
const auto scratch = AllocateScratchRegister({&dst, src.get()}, dst.getBit());
|
|
||||||
|
|
||||||
SaveRegisters(c, {scratch});
|
|
||||||
|
|
||||||
c.mov(scratch, *src);
|
|
||||||
c.neg(scratch);
|
|
||||||
c.and_(scratch, *src);
|
|
||||||
c.mov(dst, scratch);
|
|
||||||
|
|
||||||
RestoreRegisters(c, {scratch});
|
|
||||||
}
|
|
||||||
|
|
||||||
static void GenerateBLSMSK(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) {
|
|
||||||
const auto dst = ZydisToXbyakRegisterOperand(operands[0]);
|
|
||||||
const auto src = ZydisToXbyakOperand(operands[1]);
|
|
||||||
|
|
||||||
const auto scratch = AllocateScratchRegister({&dst, src.get()}, dst.getBit());
|
|
||||||
|
|
||||||
SaveRegisters(c, {scratch});
|
|
||||||
|
|
||||||
c.mov(scratch, *src);
|
|
||||||
c.dec(scratch);
|
|
||||||
c.xor_(scratch, *src);
|
|
||||||
c.mov(dst, scratch);
|
|
||||||
|
|
||||||
RestoreRegisters(c, {scratch});
|
|
||||||
}
|
|
||||||
|
|
||||||
static void GenerateBLSR(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) {
|
|
||||||
const auto dst = ZydisToXbyakRegisterOperand(operands[0]);
|
|
||||||
const auto src = ZydisToXbyakOperand(operands[1]);
|
|
||||||
|
|
||||||
const auto scratch = AllocateScratchRegister({&dst, src.get()}, dst.getBit());
|
|
||||||
|
|
||||||
SaveRegisters(c, {scratch});
|
|
||||||
|
|
||||||
c.mov(scratch, *src);
|
|
||||||
c.dec(scratch);
|
|
||||||
c.and_(scratch, *src);
|
|
||||||
c.mov(dst, scratch);
|
|
||||||
|
|
||||||
RestoreRegisters(c, {scratch});
|
|
||||||
}
|
|
||||||
|
|
||||||
static __attribute__((sysv_abi)) void PerformVCVTPH2PS(float* out, const half_float::half* in,
|
|
||||||
const u32 count) {
|
|
||||||
for (u32 i = 0; i < count; i++) {
|
|
||||||
out[i] = half_float::half_cast<float>(in[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void GenerateVCVTPH2PS(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) {
|
|
||||||
const auto dst = ZydisToXbyakRegisterOperand(operands[0]);
|
|
||||||
const auto src = ZydisToXbyakOperand(operands[1]);
|
|
||||||
|
|
||||||
const auto float_count = dst.getBit() / 32;
|
|
||||||
const auto byte_count = float_count * 4;
|
|
||||||
|
|
||||||
SaveContext(c);
|
|
||||||
|
|
||||||
// Allocate stack space for outputs and load into first parameter.
|
|
||||||
c.sub(rsp, byte_count);
|
|
||||||
c.mov(rdi, rsp);
|
|
||||||
|
|
||||||
if (src->isXMM()) {
|
|
||||||
// Allocate stack space for inputs and load into second parameter.
|
|
||||||
c.sub(rsp, byte_count);
|
|
||||||
c.mov(rsi, rsp);
|
|
||||||
|
|
||||||
// Move input to the allocated space.
|
|
||||||
c.movdqu(ptr[rsp], *reinterpret_cast<Xbyak::Xmm*>(src.get()));
|
|
||||||
} else {
|
|
||||||
c.lea(rsi, src->getAddress());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load float count into third parameter.
|
|
||||||
c.mov(rdx, float_count);
|
|
||||||
|
|
||||||
c.mov(rax, reinterpret_cast<u64>(PerformVCVTPH2PS));
|
|
||||||
c.call(rax);
|
|
||||||
|
|
||||||
if (src->isXMM()) {
|
|
||||||
// Clean up after inputs space.
|
|
||||||
c.add(rsp, byte_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load outputs into destination register and clean up space.
|
|
||||||
if (dst.isYMM()) {
|
|
||||||
c.vmovdqu(*reinterpret_cast<const Xbyak::Ymm*>(&dst), ptr[rsp]);
|
|
||||||
} else {
|
|
||||||
c.movdqu(*reinterpret_cast<const Xbyak::Xmm*>(&dst), ptr[rsp]);
|
|
||||||
}
|
|
||||||
c.add(rsp, byte_count);
|
|
||||||
|
|
||||||
RestoreContext(c, dst);
|
|
||||||
}
|
|
||||||
|
|
||||||
using SingleToHalfFloatConverter = half_float::half (*)(float);
|
|
||||||
static const SingleToHalfFloatConverter SingleToHalfFloatConverters[4] = {
|
|
||||||
half_float::half_cast<half_float::half, std::round_to_nearest, float>,
|
|
||||||
half_float::half_cast<half_float::half, std::round_toward_neg_infinity, float>,
|
|
||||||
half_float::half_cast<half_float::half, std::round_toward_infinity, float>,
|
|
||||||
half_float::half_cast<half_float::half, std::round_toward_zero, float>,
|
|
||||||
};
|
|
||||||
|
|
||||||
static __attribute__((sysv_abi)) void PerformVCVTPS2PH(half_float::half* out, const float* in,
|
|
||||||
const u32 count, const u8 rounding_mode) {
|
|
||||||
const auto conversion_func = SingleToHalfFloatConverters[rounding_mode];
|
|
||||||
|
|
||||||
for (u32 i = 0; i < count; i++) {
|
|
||||||
out[i] = conversion_func(in[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void GenerateVCVTPS2PH(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) {
|
|
||||||
const auto dst = ZydisToXbyakOperand(operands[0]);
|
|
||||||
const auto src = ZydisToXbyakRegisterOperand(operands[1]);
|
|
||||||
const auto ctrl = ZydisToXbyakImmediateOperand(operands[2]);
|
|
||||||
|
|
||||||
const auto float_count = src.getBit() / 32;
|
|
||||||
const auto byte_count = float_count * 4;
|
|
||||||
|
|
||||||
SaveContext(c);
|
|
||||||
|
|
||||||
if (dst->isXMM()) {
|
|
||||||
// Allocate stack space for outputs and load into first parameter.
|
|
||||||
c.sub(rsp, byte_count);
|
|
||||||
c.mov(rdi, rsp);
|
|
||||||
} else {
|
|
||||||
c.lea(rdi, dst->getAddress());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allocate stack space for inputs and load into second parameter.
|
|
||||||
c.sub(rsp, byte_count);
|
|
||||||
c.mov(rsi, rsp);
|
|
||||||
|
|
||||||
// Move input to the allocated space.
|
|
||||||
if (src.isYMM()) {
|
|
||||||
c.vmovdqu(ptr[rsp], *reinterpret_cast<const Xbyak::Ymm*>(&src));
|
|
||||||
} else {
|
|
||||||
c.movdqu(ptr[rsp], *reinterpret_cast<const Xbyak::Xmm*>(&src));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load float count into third parameter.
|
|
||||||
c.mov(rdx, float_count);
|
|
||||||
|
|
||||||
// Load rounding mode into fourth parameter.
|
|
||||||
if (ctrl & 4) {
|
|
||||||
// Load from MXCSR.RC.
|
|
||||||
c.stmxcsr(ptr[rsp - 4]);
|
|
||||||
c.mov(rcx, ptr[rsp - 4]);
|
|
||||||
c.shr(rcx, 13);
|
|
||||||
c.and_(rcx, 3);
|
|
||||||
} else {
|
|
||||||
c.mov(rcx, ctrl & 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
c.mov(rax, reinterpret_cast<u64>(PerformVCVTPS2PH));
|
|
||||||
c.call(rax);
|
|
||||||
|
|
||||||
// Clean up after inputs space.
|
|
||||||
c.add(rsp, byte_count);
|
|
||||||
|
|
||||||
if (dst->isXMM()) {
|
|
||||||
// Load outputs into destination register and clean up space.
|
|
||||||
c.movdqu(*reinterpret_cast<Xbyak::Xmm*>(dst.get()), ptr[rsp]);
|
|
||||||
c.add(rsp, byte_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
RestoreContext(c, *dst);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool FilterRosetta2Only(const ZydisDecodedOperand*) {
|
|
||||||
int ret = 0;
|
|
||||||
size_t size = sizeof(ret);
|
|
||||||
if (sysctlbyname("sysctl.proc_translated", &ret, &size, nullptr, 0) != 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // __APPLE__
|
|
||||||
|
|
||||||
static bool FilterTcbAccess(const ZydisDecodedOperand* operands) {
|
|
||||||
const auto& dst_op = operands[0];
|
|
||||||
const auto& src_op = operands[1];
|
|
||||||
|
|
||||||
// Patch only 'mov (64-bit register), fs:[0]'
|
|
||||||
return src_op.type == ZYDIS_OPERAND_TYPE_MEMORY && src_op.mem.segment == ZYDIS_REGISTER_FS &&
|
|
||||||
src_op.mem.base == ZYDIS_REGISTER_NONE && src_op.mem.index == ZYDIS_REGISTER_NONE &&
|
|
||||||
src_op.mem.disp.value == 0 && dst_op.reg.value >= ZYDIS_REGISTER_RAX &&
|
|
||||||
dst_op.reg.value <= ZYDIS_REGISTER_R15;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void GenerateTcbAccess(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) {
|
|
||||||
const auto dst = ZydisToXbyakRegisterOperand(operands[0]);
|
|
||||||
const auto slot = GetTcbKey();
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
// The following logic is based on the Kernel32.dll asm of TlsGetValue
|
|
||||||
static constexpr u32 TlsSlotsOffset = 0x1480;
|
|
||||||
static constexpr u32 TlsExpansionSlotsOffset = 0x1780;
|
|
||||||
static constexpr u32 TlsMinimumAvailable = 64;
|
|
||||||
|
|
||||||
// Load the pointer to the table of TLS slots.
|
|
||||||
c.putSeg(gs);
|
|
||||||
if (slot < TlsMinimumAvailable) {
|
|
||||||
// Load the pointer to TLS slots.
|
|
||||||
c.mov(dst, ptr[reinterpret_cast<void*>(TlsSlotsOffset + slot * sizeof(LPVOID))]);
|
|
||||||
} else {
|
|
||||||
const u32 tls_index = slot - TlsMinimumAvailable;
|
|
||||||
|
|
||||||
// Load the pointer to the table of TLS expansion slots.
|
|
||||||
c.mov(dst, ptr[reinterpret_cast<void*>(TlsExpansionSlotsOffset)]);
|
|
||||||
// Load the pointer to our buffer.
|
|
||||||
c.mov(dst, qword[dst + tls_index * sizeof(LPVOID)]);
|
|
||||||
}
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
// The following logic is based on the Darwin implementation of _os_tsd_get_direct, used by
|
|
||||||
// pthread_getspecific https://github.com/apple/darwin-xnu/blob/main/libsyscall/os/tsd.h#L89-L96
|
|
||||||
c.putSeg(gs);
|
|
||||||
c.mov(dst, qword[reinterpret_cast<void*>(slot * sizeof(void*))]);
|
|
||||||
#else
|
|
||||||
const auto src = ZydisToXbyakMemoryOperand(operands[1]);
|
|
||||||
|
|
||||||
// Replace fs read with gs read.
|
|
||||||
c.putSeg(gs);
|
|
||||||
c.mov(dst, src);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
using PatchFilter = bool (*)(const ZydisDecodedOperand*);
|
|
||||||
using InstructionGenerator = void (*)(const ZydisDecodedOperand*, Xbyak::CodeGenerator&);
|
|
||||||
struct PatchInfo {
|
|
||||||
/// Filter for more granular patch conditions past just the instruction mnemonic.
|
|
||||||
PatchFilter filter;
|
|
||||||
|
|
||||||
/// Generator for the patch/trampoline.
|
|
||||||
InstructionGenerator generator;
|
|
||||||
|
|
||||||
/// Whether to use a trampoline for this patch.
|
|
||||||
bool trampoline;
|
|
||||||
};
|
|
||||||
|
|
||||||
static const std::unordered_map<ZydisMnemonic, PatchInfo> Patches = {
|
|
||||||
#if defined(_WIN32) || defined(__APPLE__)
|
|
||||||
// Windows and Apple need a trampoline.
|
|
||||||
{ZYDIS_MNEMONIC_MOV, {FilterTcbAccess, GenerateTcbAccess, true}},
|
|
||||||
#else
|
|
||||||
{ZYDIS_MNEMONIC_MOV, {FilterTcbAccess, GenerateTcbAccess, false}},
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
// Patches for instruction sets not supported by Rosetta 2.
|
|
||||||
// BMI1
|
|
||||||
{ZYDIS_MNEMONIC_ANDN, {FilterRosetta2Only, GenerateANDN, true}},
|
|
||||||
{ZYDIS_MNEMONIC_BEXTR, {FilterRosetta2Only, GenerateBEXTR, true}},
|
|
||||||
{ZYDIS_MNEMONIC_BLSI, {FilterRosetta2Only, GenerateBLSI, true}},
|
|
||||||
{ZYDIS_MNEMONIC_BLSMSK, {FilterRosetta2Only, GenerateBLSMSK, true}},
|
|
||||||
{ZYDIS_MNEMONIC_BLSR, {FilterRosetta2Only, GenerateBLSR, true}},
|
|
||||||
// F16C
|
|
||||||
{ZYDIS_MNEMONIC_VCVTPH2PS, {FilterRosetta2Only, GenerateVCVTPH2PS, true}},
|
|
||||||
{ZYDIS_MNEMONIC_VCVTPS2PH, {FilterRosetta2Only, GenerateVCVTPS2PH, true}},
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
void PatchInstructions(u64 segment_addr, u64 segment_size, Xbyak::CodeGenerator& c) {
|
|
||||||
if (Patches.empty()) {
|
|
||||||
// Nothing to patch on this platform.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ZydisDecoder instr_decoder;
|
|
||||||
ZydisDecodedInstruction instruction;
|
|
||||||
ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT];
|
|
||||||
ZydisDecoderInit(&instr_decoder, ZYDIS_MACHINE_MODE_LONG_64, ZYDIS_STACK_WIDTH_64);
|
|
||||||
|
|
||||||
u8* code = reinterpret_cast<u8*>(segment_addr);
|
|
||||||
u8* end = code + segment_size;
|
|
||||||
while (code < end) {
|
|
||||||
ZyanStatus status =
|
|
||||||
ZydisDecoderDecodeFull(&instr_decoder, code, end - code, &instruction, operands);
|
|
||||||
if (!ZYAN_SUCCESS(status)) {
|
|
||||||
code++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Patches.contains(instruction.mnemonic)) {
|
|
||||||
auto patch_info = Patches.at(instruction.mnemonic);
|
|
||||||
if (patch_info.filter(operands)) {
|
|
||||||
auto patch_gen = Xbyak::CodeGenerator(instruction.length, code);
|
|
||||||
|
|
||||||
if (patch_info.trampoline) {
|
|
||||||
const auto trampoline_ptr = c.getCurr();
|
|
||||||
|
|
||||||
patch_info.generator(operands, c);
|
|
||||||
|
|
||||||
// Return to the following instruction at the end of the trampoline.
|
|
||||||
c.jmp(code + instruction.length);
|
|
||||||
|
|
||||||
// Replace instruction with near jump to the trampoline.
|
|
||||||
patch_gen.jmp(trampoline_ptr, Xbyak::CodeGenerator::LabelType::T_NEAR);
|
|
||||||
} else {
|
|
||||||
patch_info.generator(operands, patch_gen);
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto patch_size = patch_gen.getCurr() - code;
|
|
||||||
if (patch_size > 0) {
|
|
||||||
ASSERT_MSG(instruction.length >= patch_size,
|
|
||||||
"Instruction {} with length {} is too short to replace at: {}",
|
|
||||||
ZydisMnemonicGetString(instruction.mnemonic), instruction.length,
|
|
||||||
fmt::ptr(code));
|
|
||||||
|
|
||||||
// Fill remaining space with nops.
|
|
||||||
patch_gen.nop(instruction.length - patch_size);
|
|
||||||
|
|
||||||
LOG_DEBUG(Core, "Patched instruction '{}' at: {}",
|
|
||||||
ZydisMnemonicGetString(instruction.mnemonic), fmt::ptr(code));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
code += instruction.length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Core
|
|
|
@ -1,21 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
namespace Xbyak {
|
|
||||||
class CodeGenerator;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Core {
|
|
||||||
|
|
||||||
/// Initializes a stack for the current thread for use by patch implementations.
|
|
||||||
void InitializeThreadPatchStack();
|
|
||||||
|
|
||||||
/// Cleans up the patch stack for the current thread.
|
|
||||||
void CleanupThreadPatchStack();
|
|
||||||
|
|
||||||
/// Patches CPU instructions that cannot run as-is on the host.
|
|
||||||
void PatchInstructions(u64 segment_addr, u64 segment_size, Xbyak::CodeGenerator& c);
|
|
||||||
|
|
||||||
} // namespace Core
|
|
|
@ -4,66 +4,67 @@
|
||||||
#include <array>
|
#include <array>
|
||||||
#include "crypto.h"
|
#include "crypto.h"
|
||||||
|
|
||||||
CryptoPP::RSA::PrivateKey Crypto::key_pkg_derived_key3_keyset_init() {
|
RSA::PrivateKey Crypto::key_pkg_derived_key3_keyset_init() {
|
||||||
CryptoPP::InvertibleRSAFunction params;
|
InvertibleRSAFunction params;
|
||||||
params.SetPrime1(CryptoPP::Integer(PkgDerivedKey3Keyset::Prime1, 0x80));
|
params.SetPrime1(Integer(pkg_derived_key3_keyset.Prime1, 0x80));
|
||||||
params.SetPrime2(CryptoPP::Integer(PkgDerivedKey3Keyset::Prime2, 0x80));
|
params.SetPrime2(Integer(pkg_derived_key3_keyset.Prime2, 0x80));
|
||||||
|
|
||||||
params.SetPublicExponent(CryptoPP::Integer(PkgDerivedKey3Keyset::PublicExponent, 4));
|
params.SetPublicExponent(Integer(pkg_derived_key3_keyset.PublicExponent, 4));
|
||||||
params.SetPrivateExponent(CryptoPP::Integer(PkgDerivedKey3Keyset::PrivateExponent, 0x100));
|
params.SetPrivateExponent(Integer(pkg_derived_key3_keyset.PrivateExponent, 0x100));
|
||||||
|
|
||||||
params.SetModPrime1PrivateExponent(CryptoPP::Integer(PkgDerivedKey3Keyset::Exponent1, 0x80));
|
params.SetModPrime1PrivateExponent(Integer(pkg_derived_key3_keyset.Exponent1, 0x80));
|
||||||
params.SetModPrime2PrivateExponent(CryptoPP::Integer(PkgDerivedKey3Keyset::Exponent2, 0x80));
|
params.SetModPrime2PrivateExponent(Integer(pkg_derived_key3_keyset.Exponent2, 0x80));
|
||||||
|
|
||||||
params.SetModulus(CryptoPP::Integer(PkgDerivedKey3Keyset::Modulus, 0x100));
|
params.SetModulus(Integer(pkg_derived_key3_keyset.Modulus, 0x100));
|
||||||
params.SetMultiplicativeInverseOfPrime2ModPrime1(
|
params.SetMultiplicativeInverseOfPrime2ModPrime1(
|
||||||
CryptoPP::Integer(PkgDerivedKey3Keyset::Coefficient, 0x80));
|
Integer(pkg_derived_key3_keyset.Coefficient, 0x80));
|
||||||
|
|
||||||
CryptoPP::RSA::PrivateKey privateKey(params);
|
RSA::PrivateKey privateKey(params);
|
||||||
|
|
||||||
return privateKey;
|
return privateKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
CryptoPP::RSA::PrivateKey Crypto::FakeKeyset_keyset_init() {
|
RSA::PrivateKey Crypto::FakeKeyset_keyset_init() {
|
||||||
CryptoPP::InvertibleRSAFunction params;
|
InvertibleRSAFunction params;
|
||||||
params.SetPrime1(CryptoPP::Integer(FakeKeyset::Prime1, 0x80));
|
params.SetPrime1(Integer(FakeKeyset_keyset.Prime1, 0x80));
|
||||||
params.SetPrime2(CryptoPP::Integer(FakeKeyset::Prime2, 0x80));
|
params.SetPrime2(Integer(FakeKeyset_keyset.Prime2, 0x80));
|
||||||
|
|
||||||
params.SetPublicExponent(CryptoPP::Integer(FakeKeyset::PublicExponent, 4));
|
params.SetPublicExponent(Integer(FakeKeyset_keyset.PublicExponent, 4));
|
||||||
params.SetPrivateExponent(CryptoPP::Integer(FakeKeyset::PrivateExponent, 0x100));
|
params.SetPrivateExponent(Integer(FakeKeyset_keyset.PrivateExponent, 0x100));
|
||||||
|
|
||||||
params.SetModPrime1PrivateExponent(CryptoPP::Integer(FakeKeyset::Exponent1, 0x80));
|
params.SetModPrime1PrivateExponent(Integer(FakeKeyset_keyset.Exponent1, 0x80));
|
||||||
params.SetModPrime2PrivateExponent(CryptoPP::Integer(FakeKeyset::Exponent2, 0x80));
|
params.SetModPrime2PrivateExponent(Integer(FakeKeyset_keyset.Exponent2, 0x80));
|
||||||
|
|
||||||
params.SetModulus(CryptoPP::Integer(FakeKeyset::Modulus, 0x100));
|
params.SetModulus(Integer(FakeKeyset_keyset.Modulus, 0x100));
|
||||||
params.SetMultiplicativeInverseOfPrime2ModPrime1(
|
params.SetMultiplicativeInverseOfPrime2ModPrime1(Integer(FakeKeyset_keyset.Coefficient, 0x80));
|
||||||
CryptoPP::Integer(FakeKeyset::Coefficient, 0x80));
|
|
||||||
|
|
||||||
CryptoPP::RSA::PrivateKey privateKey(params);
|
RSA::PrivateKey privateKey(params);
|
||||||
|
|
||||||
return privateKey;
|
return privateKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
CryptoPP::RSA::PrivateKey Crypto::DebugRifKeyset_init() {
|
RSA::PrivateKey Crypto::DebugRifKeyset_init() {
|
||||||
CryptoPP::InvertibleRSAFunction params;
|
AutoSeededRandomPool rng;
|
||||||
params.SetPrime1(CryptoPP::Integer(DebugRifKeyset::Prime1, sizeof(DebugRifKeyset::Prime1)));
|
InvertibleRSAFunction params;
|
||||||
params.SetPrime2(CryptoPP::Integer(DebugRifKeyset::Prime2, sizeof(DebugRifKeyset::Prime2)));
|
params.SetPrime1(Integer(DebugRifKeyset_keyset.Prime1, sizeof(DebugRifKeyset_keyset.Prime1)));
|
||||||
|
params.SetPrime2(Integer(DebugRifKeyset_keyset.Prime2, sizeof(DebugRifKeyset_keyset.Prime2)));
|
||||||
|
|
||||||
params.SetPublicExponent(
|
params.SetPublicExponent(Integer(DebugRifKeyset_keyset.PrivateExponent,
|
||||||
CryptoPP::Integer(DebugRifKeyset::PublicExponent, sizeof(DebugRifKeyset::PublicExponent)));
|
sizeof(DebugRifKeyset_keyset.PrivateExponent)));
|
||||||
params.SetPrivateExponent(CryptoPP::Integer(DebugRifKeyset::PrivateExponent,
|
params.SetPrivateExponent(Integer(DebugRifKeyset_keyset.PrivateExponent,
|
||||||
sizeof(DebugRifKeyset::PrivateExponent)));
|
sizeof(DebugRifKeyset_keyset.PrivateExponent)));
|
||||||
|
|
||||||
params.SetModPrime1PrivateExponent(
|
params.SetModPrime1PrivateExponent(
|
||||||
CryptoPP::Integer(DebugRifKeyset::Exponent1, sizeof(DebugRifKeyset::Exponent1)));
|
Integer(DebugRifKeyset_keyset.Exponent1, sizeof(DebugRifKeyset_keyset.Exponent1)));
|
||||||
params.SetModPrime2PrivateExponent(
|
params.SetModPrime2PrivateExponent(
|
||||||
CryptoPP::Integer(DebugRifKeyset::Exponent2, sizeof(DebugRifKeyset::Exponent2)));
|
Integer(DebugRifKeyset_keyset.Exponent2, sizeof(DebugRifKeyset_keyset.Exponent2)));
|
||||||
|
|
||||||
params.SetModulus(CryptoPP::Integer(DebugRifKeyset::Modulus, sizeof(DebugRifKeyset::Modulus)));
|
params.SetModulus(
|
||||||
|
Integer(DebugRifKeyset_keyset.Modulus, sizeof(DebugRifKeyset_keyset.Modulus)));
|
||||||
params.SetMultiplicativeInverseOfPrime2ModPrime1(
|
params.SetMultiplicativeInverseOfPrime2ModPrime1(
|
||||||
CryptoPP::Integer(DebugRifKeyset::Coefficient, sizeof(DebugRifKeyset::Coefficient)));
|
Integer(DebugRifKeyset_keyset.Coefficient, sizeof(DebugRifKeyset_keyset.Coefficient)));
|
||||||
|
|
||||||
CryptoPP::RSA::PrivateKey privateKey(params);
|
RSA::PrivateKey privateKey(params);
|
||||||
|
|
||||||
return privateKey;
|
return privateKey;
|
||||||
}
|
}
|
||||||
|
@ -72,21 +73,21 @@ void Crypto::RSA2048Decrypt(std::span<CryptoPP::byte, 32> dec_key,
|
||||||
std::span<const CryptoPP::byte, 256> ciphertext,
|
std::span<const CryptoPP::byte, 256> ciphertext,
|
||||||
bool is_dk3) { // RSAES_PKCS1v15_
|
bool is_dk3) { // RSAES_PKCS1v15_
|
||||||
// Create an RSA decryptor
|
// Create an RSA decryptor
|
||||||
CryptoPP::RSA::PrivateKey privateKey;
|
RSA::PrivateKey privateKey;
|
||||||
if (is_dk3) {
|
if (is_dk3) {
|
||||||
privateKey = key_pkg_derived_key3_keyset_init();
|
privateKey = key_pkg_derived_key3_keyset_init();
|
||||||
} else {
|
} else {
|
||||||
privateKey = FakeKeyset_keyset_init();
|
privateKey = FakeKeyset_keyset_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
CryptoPP::RSAES_PKCS1v15_Decryptor rsaDecryptor(privateKey);
|
RSAES_PKCS1v15_Decryptor rsaDecryptor(privateKey);
|
||||||
|
|
||||||
// Allocate memory for the decrypted data
|
// Allocate memory for the decrypted data
|
||||||
std::array<CryptoPP::byte, 256> decrypted;
|
std::array<CryptoPP::byte, 256> decrypted;
|
||||||
|
|
||||||
// Perform the decryption
|
// Perform the decryption
|
||||||
CryptoPP::AutoSeededRandomPool rng;
|
AutoSeededRandomPool rng;
|
||||||
CryptoPP::DecodingResult result =
|
DecodingResult result =
|
||||||
rsaDecryptor.Decrypt(rng, ciphertext.data(), decrypted.size(), decrypted.data());
|
rsaDecryptor.Decrypt(rng, ciphertext.data(), decrypted.size(), decrypted.data());
|
||||||
std::copy(decrypted.begin(), decrypted.begin() + dec_key.size(), dec_key.begin());
|
std::copy(decrypted.begin(), decrypted.begin() + dec_key.size(), dec_key.begin());
|
||||||
}
|
}
|
||||||
|
@ -119,47 +120,6 @@ void Crypto::aesCbcCfb128Decrypt(std::span<const CryptoPP::byte, 32> ivkey,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Crypto::aesCbcCfb128DecryptEntry(std::span<const CryptoPP::byte, 32> ivkey,
|
|
||||||
std::span<CryptoPP::byte> ciphertext,
|
|
||||||
std::span<CryptoPP::byte> decrypted) {
|
|
||||||
std::array<CryptoPP::byte, CryptoPP::AES::DEFAULT_KEYLENGTH> key;
|
|
||||||
std::array<CryptoPP::byte, CryptoPP::AES::DEFAULT_KEYLENGTH> iv;
|
|
||||||
|
|
||||||
std::copy(ivkey.begin() + 16, ivkey.begin() + 16 + key.size(), key.begin());
|
|
||||||
std::copy(ivkey.begin(), ivkey.begin() + iv.size(), iv.begin());
|
|
||||||
|
|
||||||
CryptoPP::AES::Decryption aesDecryption(key.data(), CryptoPP::AES::DEFAULT_KEYLENGTH);
|
|
||||||
CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption(aesDecryption, iv.data());
|
|
||||||
|
|
||||||
for (size_t i = 0; i < decrypted.size(); i += CryptoPP::AES::BLOCKSIZE) {
|
|
||||||
cbcDecryption.ProcessData(decrypted.data() + i, ciphertext.data() + i,
|
|
||||||
CryptoPP::AES::BLOCKSIZE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Crypto::decryptEFSM(std::span<CryptoPP::byte, 16> NPcommID,
|
|
||||||
std::span<CryptoPP::byte, 16> efsmIv, std::span<CryptoPP::byte> ciphertext,
|
|
||||||
std::span<CryptoPP::byte> decrypted) {
|
|
||||||
|
|
||||||
std::vector<CryptoPP::byte> TrophyKey = {0x21, 0xF4, 0x1A, 0x6B, 0xAD, 0x8A, 0x1D, 0x3E,
|
|
||||||
0xCA, 0x7A, 0xD5, 0x86, 0xC1, 0x01, 0xB7, 0xA9};
|
|
||||||
std::vector<CryptoPP::byte> TrophyIV = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
||||||
// step 1: Encrypt NPcommID
|
|
||||||
CryptoPP::CBC_Mode<CryptoPP::AES>::Encryption encrypt;
|
|
||||||
encrypt.SetKeyWithIV(TrophyKey.data(), TrophyKey.size(), TrophyIV.data());
|
|
||||||
|
|
||||||
std::vector<CryptoPP::byte> trpKey(16);
|
|
||||||
|
|
||||||
encrypt.ProcessData(trpKey.data(), NPcommID.data(), 16);
|
|
||||||
// step 2: decrypt efsm.
|
|
||||||
CryptoPP::CBC_Mode<CryptoPP::AES>::Decryption decrypt;
|
|
||||||
decrypt.SetKeyWithIV(trpKey.data(), trpKey.size(), efsmIv.data());
|
|
||||||
|
|
||||||
for (size_t i = 0; i < decrypted.size(); i += CryptoPP::AES::BLOCKSIZE) {
|
|
||||||
decrypt.ProcessData(decrypted.data() + i, ciphertext.data() + i, CryptoPP::AES::BLOCKSIZE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Crypto::PfsGenCryptoKey(std::span<const CryptoPP::byte, 32> ekpfs,
|
void Crypto::PfsGenCryptoKey(std::span<const CryptoPP::byte, 32> ekpfs,
|
||||||
std::span<const CryptoPP::byte, 16> seed,
|
std::span<const CryptoPP::byte, 16> seed,
|
||||||
std::span<CryptoPP::byte, 16> dataKey,
|
std::span<CryptoPP::byte, 16> dataKey,
|
||||||
|
@ -191,8 +151,8 @@ void Crypto::decryptPFS(std::span<const CryptoPP::byte, 16> dataKey,
|
||||||
// Start at 0x10000 to keep the header when decrypting the whole pfs_image.
|
// Start at 0x10000 to keep the header when decrypting the whole pfs_image.
|
||||||
for (int i = 0; i < src_image.size(); i += 0x1000) {
|
for (int i = 0; i < src_image.size(); i += 0x1000) {
|
||||||
const u64 current_sector = sector + (i / 0x1000);
|
const u64 current_sector = sector + (i / 0x1000);
|
||||||
CryptoPP::ECB_Mode<CryptoPP::AES>::Encryption encrypt(tweakKey.data(), tweakKey.size());
|
CryptoPP::ECB_Mode<AES>::Encryption encrypt(tweakKey.data(), tweakKey.size());
|
||||||
CryptoPP::ECB_Mode<CryptoPP::AES>::Decryption decrypt(dataKey.data(), dataKey.size());
|
CryptoPP::ECB_Mode<AES>::Decryption decrypt(dataKey.data(), dataKey.size());
|
||||||
|
|
||||||
std::array<CryptoPP::byte, 16> tweak{};
|
std::array<CryptoPP::byte, 16> tweak{};
|
||||||
std::array<CryptoPP::byte, 16> encryptedTweak;
|
std::array<CryptoPP::byte, 16> encryptedTweak;
|
||||||
|
|
|
@ -4,22 +4,28 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <span>
|
#include <span>
|
||||||
#include <cryptopp/aes.h>
|
#include <aes.h>
|
||||||
#include <cryptopp/filters.h>
|
#include <filters.h>
|
||||||
#include <cryptopp/modes.h>
|
#include <modes.h>
|
||||||
#include <cryptopp/oaep.h>
|
#include <oaep.h>
|
||||||
#include <cryptopp/osrng.h>
|
#include <osrng.h>
|
||||||
#include <cryptopp/rsa.h>
|
#include <rsa.h>
|
||||||
#include <cryptopp/sha.h>
|
#include <sha.h>
|
||||||
|
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
|
|
||||||
|
using namespace CryptoPP;
|
||||||
|
|
||||||
class Crypto {
|
class Crypto {
|
||||||
public:
|
public:
|
||||||
CryptoPP::RSA::PrivateKey key_pkg_derived_key3_keyset_init();
|
PkgDerivedKey3Keyset pkg_derived_key3_keyset;
|
||||||
CryptoPP::RSA::PrivateKey FakeKeyset_keyset_init();
|
FakeKeyset FakeKeyset_keyset;
|
||||||
CryptoPP::RSA::PrivateKey DebugRifKeyset_init();
|
DebugRifKeyset DebugRifKeyset_keyset;
|
||||||
|
|
||||||
|
RSA::PrivateKey key_pkg_derived_key3_keyset_init();
|
||||||
|
RSA::PrivateKey FakeKeyset_keyset_init();
|
||||||
|
RSA::PrivateKey DebugRifKeyset_init();
|
||||||
|
|
||||||
void RSA2048Decrypt(std::span<CryptoPP::byte, 32> dk3,
|
void RSA2048Decrypt(std::span<CryptoPP::byte, 32> dk3,
|
||||||
std::span<const CryptoPP::byte, 256> ciphertext,
|
std::span<const CryptoPP::byte, 256> ciphertext,
|
||||||
|
@ -29,11 +35,6 @@ public:
|
||||||
void aesCbcCfb128Decrypt(std::span<const CryptoPP::byte, 32> ivkey,
|
void aesCbcCfb128Decrypt(std::span<const CryptoPP::byte, 32> ivkey,
|
||||||
std::span<const CryptoPP::byte, 256> ciphertext,
|
std::span<const CryptoPP::byte, 256> ciphertext,
|
||||||
std::span<CryptoPP::byte, 256> decrypted);
|
std::span<CryptoPP::byte, 256> decrypted);
|
||||||
void aesCbcCfb128DecryptEntry(std::span<const CryptoPP::byte, 32> ivkey,
|
|
||||||
std::span<CryptoPP::byte> ciphertext,
|
|
||||||
std::span<CryptoPP::byte> decrypted);
|
|
||||||
void decryptEFSM(std::span<CryptoPP::byte, 16>, std::span<CryptoPP::byte, 16> efsmIv,
|
|
||||||
std::span<CryptoPP::byte> ciphertext, std::span<CryptoPP::byte> decrypted);
|
|
||||||
void PfsGenCryptoKey(std::span<const CryptoPP::byte, 32> ekpfs,
|
void PfsGenCryptoKey(std::span<const CryptoPP::byte, 32> ekpfs,
|
||||||
std::span<const CryptoPP::byte, 16> seed,
|
std::span<const CryptoPP::byte, 16> seed,
|
||||||
std::span<CryptoPP::byte, 16> dataKey,
|
std::span<CryptoPP::byte, 16> dataKey,
|
||||||
|
|