Skip to content

Commit

Permalink
Merge branch 'shadps4-emu:main' into bb-deadlock-shaders-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Foul-Tarnished authored Sep 8, 2024
2 parents 7246ef2 + e3c2a91 commit 9438980
Show file tree
Hide file tree
Showing 40 changed files with 3,155 additions and 199 deletions.
5 changes: 5 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,8 @@
[submodule "externals/half"]
path = externals/half
url = https://github.com/ROCm/half.git
[submodule "externals/dear_imgui"]
path = externals/dear_imgui
url = https://github.com/shadps4-emu/ext-imgui.git
shallow = true
branch = docking
22 changes: 21 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ set(SYSTEM_LIBS src/core/libraries/system/commondialog.cpp
src/core/libraries/system/commondialog.h
src/core/libraries/system/msgdialog.cpp
src/core/libraries/system/msgdialog.h
src/core/libraries/system/msgdialog_ui.cpp
src/core/libraries/system/posix.cpp
src/core/libraries/system/posix.h
src/core/libraries/save_data/error_codes.h
Expand Down Expand Up @@ -325,6 +326,7 @@ set(COMMON src/common/logging/backend.cpp
src/common/error.cpp
src/common/error.h
src/common/scope_exit.h
src/common/fixed_value.h
src/common/func_traits.h
src/common/native_clock.cpp
src/common/native_clock.h
Expand Down Expand Up @@ -561,6 +563,19 @@ set(VIDEO_CORE src/video_core/amdgpu/liverpool.cpp
src/video_core/renderdoc.h
)

set(IMGUI src/imgui/imgui_config.h
src/imgui/imgui_layer.h
src/imgui/imgui_std.h
src/imgui/layer/video_info.cpp
src/imgui/layer/video_info.h
src/imgui/renderer/imgui_core.cpp
src/imgui/renderer/imgui_core.h
src/imgui/renderer/imgui_impl_sdl3.cpp
src/imgui/renderer/imgui_impl_sdl3.h
src/imgui/renderer/imgui_impl_vulkan.cpp
src/imgui/renderer/imgui_impl_vulkan.h
)

set(INPUT src/input/controller.cpp
src/input/controller.h
)
Expand Down Expand Up @@ -617,6 +632,7 @@ endif()
if (ENABLE_QT_GUI)
qt_add_executable(shadps4
${AUDIO_CORE}
${IMGUI}
${INPUT}
${QT_GUI}
${COMMON}
Expand All @@ -629,6 +645,7 @@ if (ENABLE_QT_GUI)
else()
add_executable(shadps4
${AUDIO_CORE}
${IMGUI}
${INPUT}
${COMMON}
${CORE}
Expand All @@ -645,9 +662,12 @@ endif()

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::xbyak Tracy::TracyClient RenderDoc::API FFmpeg::ffmpeg Dear_ImGui)
target_link_libraries(shadps4 PRIVATE Boost::headers GPUOpen::VulkanMemoryAllocator sirit Vulkan::Headers xxHash::xxhash Zydis::Zydis glslang::SPIRV glslang::glslang SDL3::SDL3)

target_compile_definitions(shadps4 PRIVATE IMGUI_USER_CONFIG="imgui/imgui_config.h")
target_compile_definitions(Dear_ImGui PRIVATE IMGUI_USER_CONFIG="${PROJECT_SOURCE_DIR}/src/imgui/imgui_config.h")

if (APPLE)
option(USE_SYSTEM_VULKAN_LOADER "Enables using the system Vulkan loader instead of directly linking with MoltenVK. Useful for loading validation layers." OFF)
if (USE_SYSTEM_VULKAN_LOADER)
Expand Down
13 changes: 8 additions & 5 deletions documents/building-linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ SPDX-License-Identifier: GPL-2.0-or-later

#### 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
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 qt6-base-dev qt6-tools-dev
```

#### Fedora
Expand All @@ -34,9 +34,9 @@ git clone --recursive https://github.com/shadps4-emu/shadPS4.git
cd shadPS4
```

Generate the build directory in the shadPS4 directory:
Generate the build directory in the shadPS4 directory. To enable the QT GUI, pass the ```-DENABLE_QT_GUI=ON``` flag:
```
cmake -S . -B build/
cmake -S . -B build/ -DENABLE_QT_GUI=ON
```

Enter the directory:
Expand All @@ -49,8 +49,11 @@ Use make to build the project:
cmake --build . --parallel$(nproc)
```

Now run the emulator:

Now run the emulator. If QT is enabled:
```
./shadps4
```
Otherwise, specify the path to your PKG's boot file:
```
./shadps4 /"PATH"/"TO"/"GAME"/"FOLDER"/eboot.bin
```
11 changes: 11 additions & 0 deletions externals/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,17 @@ if (APPLE)
endif()
endif()

# Dear ImGui
add_library(Dear_ImGui
dear_imgui/imgui.cpp
dear_imgui/imgui_demo.cpp
dear_imgui/imgui_draw.cpp
dear_imgui/imgui_internal.h
dear_imgui/imgui_tables.cpp
dear_imgui/imgui_widgets.cpp
)
target_include_directories(Dear_ImGui INTERFACE dear_imgui/)

# Tracy
option(TRACY_ENABLE "" ON)
option(TRACY_NO_CRASH_HANDLER "" ON) # Otherwise texture cache exceptions will be treaten as a crash
Expand Down
1 change: 1 addition & 0 deletions externals/dear_imgui
Submodule dear_imgui added at 636cd4
5 changes: 5 additions & 0 deletions src/common/assert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ void assert_fail_impl() {
Crash();
throw std::runtime_error("Unreachable code");
}

void assert_fail_debug_msg(const char* msg) {
LOG_CRITICAL(Debug, "Assertion Failed!\n{}", msg);
assert_fail_impl();
}
35 changes: 35 additions & 0 deletions src/common/fixed_value.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

/**
* @brief A template class that encapsulates a fixed, compile-time constant value.
*
* @tparam T The type of the value.
* @tparam Value The fixed value of type T.
*
* This class provides a way to encapsulate a value that is constant and known at compile-time.
* The value is stored as a private member and cannot be changed. Any attempt to assign a new
* value to an object of this class will reset it to the fixed value.
*/
template <typename T, T Value>
class FixedValue {
T m_value{Value};

public:
constexpr FixedValue() = default;

constexpr explicit(false) operator T() const {
return m_value;
}

FixedValue& operator=(const T&) {
m_value = Value;
return *this;
}
FixedValue& operator=(T&&) noexcept {
m_value = {Value};
return *this;
}
};
1 change: 1 addition & 0 deletions src/common/logging/filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) {
CLS(Render) \
SUB(Render, Vulkan) \
SUB(Render, Recompiler) \
CLS(ImGui) \
CLS(Input) \
CLS(Tty) \
CLS(Loader)
Expand Down
1 change: 1 addition & 0 deletions src/common/logging/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ enum class Class : u8 {
Render, ///< Video Core
Render_Vulkan, ///< Vulkan backend
Render_Recompiler, ///< Shader recompiler
ImGui, ///< ImGui
Loader, ///< ROM loader
Input, ///< Input emulation
Tty, ///< Debug output from emu
Expand Down
11 changes: 11 additions & 0 deletions src/core/libraries/avplayer/avplayer_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ extern "C" {
#include <libswscale/swscale.h>
}

// The av_err2str macro in libavutil/error.h does not play nice with C++
#ifdef av_err2str
#undef av_err2str
#include <string>
av_always_inline std::string av_err2string(int errnum) {
char errbuf[AV_ERROR_MAX_STRING_SIZE];
return av_make_error_string(errbuf, AV_ERROR_MAX_STRING_SIZE, errnum);
}
#define av_err2str(err) av_err2string(err).c_str()
#endif // av_err2str

namespace Libraries::AvPlayer {

using namespace Kernel;
Expand Down
1 change: 1 addition & 0 deletions src/core/libraries/kernel/thread_management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,7 @@ int PS4_SYSV_ABI scePthreadCondattrDestroy(ScePthreadCondattr* attr) {
int result = pthread_condattr_destroy(&(*attr)->cond_attr);

LOG_DEBUG(Kernel_Pthread, "scePthreadCondattrDestroy: result = {} ", result);
delete *attr;

switch (result) {
case 0:
Expand Down
20 changes: 14 additions & 6 deletions src/core/libraries/system/commondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

namespace Libraries::CommonDialog {

bool g_isInitialized = false;
bool g_isUsed = false;

int PS4_SYSV_ABI _ZN3sce16CommonDialogUtil12getSelfAppIdEv() {
LOG_ERROR(Lib_CommonDlg, "(STUBBED) called");
return ORBIS_OK;
Expand Down Expand Up @@ -83,14 +86,19 @@ int PS4_SYSV_ABI _ZTVN3sce16CommonDialogUtil6ClientE() {
return ORBIS_OK;
}

int PS4_SYSV_ABI sceCommonDialogInitialize() {
LOG_ERROR(Lib_CommonDlg, "(DUMMY) called");
return ORBIS_OK;
Error PS4_SYSV_ABI sceCommonDialogInitialize() {
if (g_isInitialized) {
LOG_INFO(Lib_CommonDlg, "already initialized");
return Error::ALREADY_SYSTEM_INITIALIZED;
}
LOG_DEBUG(Lib_CommonDlg, "initialized");
g_isInitialized = true;
return Error::OK;
}

int PS4_SYSV_ABI sceCommonDialogIsUsed() {
LOG_ERROR(Lib_CommonDlg, "(STUBBED) called");
return ORBIS_OK;
bool PS4_SYSV_ABI sceCommonDialogIsUsed() {
LOG_TRACE(Lib_CommonDlg, "called");
return g_isUsed;
}

int PS4_SYSV_ABI Func_0FF577E4E8457883() {
Expand Down
43 changes: 39 additions & 4 deletions src/core/libraries/system/commondialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,44 @@ class SymbolsResolver;

namespace Libraries::CommonDialog {

struct OrbisCommonDialogBaseParam {
enum class Status : u32 {
NONE = 0,
INITIALIZED = 1,
RUNNING = 2,
FINISHED = 3,
};

enum class Result : u32 {
OK = 0,
USER_CANCELED = 1,
};

enum class Error : u32 {
OK = 0,
NOT_SYSTEM_INITIALIZED = 0x80B80001,
ALREADY_SYSTEM_INITIALIZED = 0x80B80002,
NOT_INITIALIZED = 0x80B80003,
ALREADY_INITIALIZED = 0x80B80004,
NOT_FINISHED = 0x80B80005,
INVALID_STATE = 0x80B80006,
RESULT_NONE = 0x80B80007,
BUSY = 0x80B80008,
OUT_OF_MEMORY = 0x80B80009,
PARAM_INVALID = 0x80B8000A,
NOT_RUNNING = 0x80B8000B,
ALREADY_CLOSE = 0x80B8000C,
ARG_NULL = 0x80B8000D,
UNEXPECTED_FATAL = 0x80B8000E,
NOT_SUPPORTED = 0x80B8000F,
INHIBIT_SHAREPLAY_CLIENT = 0x80B80010,
};

extern bool g_isInitialized;
extern bool g_isUsed;

struct BaseParam {
std::size_t size;
u8 reserved[36];
std::array<u8, 36> reserved;
u32 magic;
};

Expand All @@ -32,8 +67,8 @@ int PS4_SYSV_ABI _ZNK3sce16CommonDialogUtil6Client8getAppIdEv();
int PS4_SYSV_ABI _ZNK3sce16CommonDialogUtil6Client8isFinishEv();
int PS4_SYSV_ABI _ZNK3sce16CommonDialogUtil6Client9getResultEv();
int PS4_SYSV_ABI _ZTVN3sce16CommonDialogUtil6ClientE();
int PS4_SYSV_ABI sceCommonDialogInitialize();
int PS4_SYSV_ABI sceCommonDialogIsUsed();
Error PS4_SYSV_ABI sceCommonDialogInitialize();
bool PS4_SYSV_ABI sceCommonDialogIsUsed();
int PS4_SYSV_ABI Func_0FF577E4E8457883();
int PS4_SYSV_ABI Func_41716C2CE379416C();
int PS4_SYSV_ABI Func_483A427D8F6E0748();
Expand Down
Loading

0 comments on commit 9438980

Please sign in to comment.