diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/CMakeLists.txt | 5 | ||||
| -rw-r--r-- | src/core/core.cpp | 11 | ||||
| -rw-r--r-- | src/core/core.h | 6 | ||||
| -rw-r--r-- | src/core/tools/renderdoc.cpp | 55 | ||||
| -rw-r--r-- | src/core/tools/renderdoc.h | 22 |
5 files changed, 98 insertions, 1 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 6cd1a28f2..30d2f7df6 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -864,6 +864,8 @@ add_library(core STATIC | |||
| 864 | telemetry_session.h | 864 | telemetry_session.h |
| 865 | tools/freezer.cpp | 865 | tools/freezer.cpp |
| 866 | tools/freezer.h | 866 | tools/freezer.h |
| 867 | tools/renderdoc.cpp | ||
| 868 | tools/renderdoc.h | ||
| 867 | ) | 869 | ) |
| 868 | 870 | ||
| 869 | if (MSVC) | 871 | if (MSVC) |
| @@ -879,6 +881,7 @@ else() | |||
| 879 | -Werror=conversion | 881 | -Werror=conversion |
| 880 | 882 | ||
| 881 | -Wno-sign-conversion | 883 | -Wno-sign-conversion |
| 884 | -Wno-cast-function-type | ||
| 882 | 885 | ||
| 883 | $<$<CXX_COMPILER_ID:Clang>:-fsized-deallocation> | 886 | $<$<CXX_COMPILER_ID:Clang>:-fsized-deallocation> |
| 884 | ) | 887 | ) |
| @@ -887,7 +890,7 @@ endif() | |||
| 887 | create_target_directory_groups(core) | 890 | create_target_directory_groups(core) |
| 888 | 891 | ||
| 889 | target_link_libraries(core PUBLIC common PRIVATE audio_core network video_core nx_tzdb) | 892 | target_link_libraries(core PUBLIC common PRIVATE audio_core network video_core nx_tzdb) |
| 890 | target_link_libraries(core PUBLIC Boost::headers PRIVATE fmt::fmt nlohmann_json::nlohmann_json mbedtls Opus::opus) | 893 | target_link_libraries(core PUBLIC Boost::headers PRIVATE fmt::fmt nlohmann_json::nlohmann_json mbedtls Opus::opus renderdoc) |
| 891 | if (MINGW) | 894 | if (MINGW) |
| 892 | target_link_libraries(core PRIVATE ${MSWSOCK_LIBRARY}) | 895 | target_link_libraries(core PRIVATE ${MSWSOCK_LIBRARY}) |
| 893 | endif() | 896 | endif() |
diff --git a/src/core/core.cpp b/src/core/core.cpp index 2d6e61398..e8300cd05 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -51,6 +51,7 @@ | |||
| 51 | #include "core/reporter.h" | 51 | #include "core/reporter.h" |
| 52 | #include "core/telemetry_session.h" | 52 | #include "core/telemetry_session.h" |
| 53 | #include "core/tools/freezer.h" | 53 | #include "core/tools/freezer.h" |
| 54 | #include "core/tools/renderdoc.h" | ||
| 54 | #include "network/network.h" | 55 | #include "network/network.h" |
| 55 | #include "video_core/host1x/host1x.h" | 56 | #include "video_core/host1x/host1x.h" |
| 56 | #include "video_core/renderer_base.h" | 57 | #include "video_core/renderer_base.h" |
| @@ -281,6 +282,10 @@ struct System::Impl { | |||
| 281 | microprofile_cpu[2] = MICROPROFILE_TOKEN(ARM_CPU2); | 282 | microprofile_cpu[2] = MICROPROFILE_TOKEN(ARM_CPU2); |
| 282 | microprofile_cpu[3] = MICROPROFILE_TOKEN(ARM_CPU3); | 283 | microprofile_cpu[3] = MICROPROFILE_TOKEN(ARM_CPU3); |
| 283 | 284 | ||
| 285 | if (Settings::values.enable_renderdoc_hotkey) { | ||
| 286 | renderdoc_api = std::make_unique<Tools::RenderdocAPI>(); | ||
| 287 | } | ||
| 288 | |||
| 284 | LOG_DEBUG(Core, "Initialized OK"); | 289 | LOG_DEBUG(Core, "Initialized OK"); |
| 285 | 290 | ||
| 286 | return SystemResultStatus::Success; | 291 | return SystemResultStatus::Success; |
| @@ -521,6 +526,8 @@ struct System::Impl { | |||
| 521 | std::unique_ptr<Tools::Freezer> memory_freezer; | 526 | std::unique_ptr<Tools::Freezer> memory_freezer; |
| 522 | std::array<u8, 0x20> build_id{}; | 527 | std::array<u8, 0x20> build_id{}; |
| 523 | 528 | ||
| 529 | std::unique_ptr<Tools::RenderdocAPI> renderdoc_api; | ||
| 530 | |||
| 524 | /// Frontend applets | 531 | /// Frontend applets |
| 525 | Service::AM::Applets::AppletManager applet_manager; | 532 | Service::AM::Applets::AppletManager applet_manager; |
| 526 | 533 | ||
| @@ -1024,6 +1031,10 @@ const Network::RoomNetwork& System::GetRoomNetwork() const { | |||
| 1024 | return impl->room_network; | 1031 | return impl->room_network; |
| 1025 | } | 1032 | } |
| 1026 | 1033 | ||
| 1034 | Tools::RenderdocAPI& System::GetRenderdocAPI() { | ||
| 1035 | return *impl->renderdoc_api; | ||
| 1036 | } | ||
| 1037 | |||
| 1027 | void System::RunServer(std::unique_ptr<Service::ServerManager>&& server_manager) { | 1038 | void System::RunServer(std::unique_ptr<Service::ServerManager>&& server_manager) { |
| 1028 | return impl->kernel.RunServer(std::move(server_manager)); | 1039 | return impl->kernel.RunServer(std::move(server_manager)); |
| 1029 | } | 1040 | } |
diff --git a/src/core/core.h b/src/core/core.h index fba312125..df20f26f3 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
| @@ -102,6 +102,10 @@ namespace Network { | |||
| 102 | class RoomNetwork; | 102 | class RoomNetwork; |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | namespace Tools { | ||
| 106 | class RenderdocAPI; | ||
| 107 | } | ||
| 108 | |||
| 105 | namespace Core { | 109 | namespace Core { |
| 106 | 110 | ||
| 107 | class ARM_Interface; | 111 | class ARM_Interface; |
| @@ -413,6 +417,8 @@ public: | |||
| 413 | /// Gets an immutable reference to the Room Network. | 417 | /// Gets an immutable reference to the Room Network. |
| 414 | [[nodiscard]] const Network::RoomNetwork& GetRoomNetwork() const; | 418 | [[nodiscard]] const Network::RoomNetwork& GetRoomNetwork() const; |
| 415 | 419 | ||
| 420 | [[nodiscard]] Tools::RenderdocAPI& GetRenderdocAPI(); | ||
| 421 | |||
| 416 | void SetExitLocked(bool locked); | 422 | void SetExitLocked(bool locked); |
| 417 | bool GetExitLocked() const; | 423 | bool GetExitLocked() const; |
| 418 | 424 | ||
diff --git a/src/core/tools/renderdoc.cpp b/src/core/tools/renderdoc.cpp new file mode 100644 index 000000000..44d24822a --- /dev/null +++ b/src/core/tools/renderdoc.cpp | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include <renderdoc_app.h> | ||
| 5 | |||
| 6 | #include "common/assert.h" | ||
| 7 | #include "common/dynamic_library.h" | ||
| 8 | #include "core/tools/renderdoc.h" | ||
| 9 | |||
| 10 | #ifdef WIN32 | ||
| 11 | #include <windows.h> | ||
| 12 | #else | ||
| 13 | #include <dlfcn.h> | ||
| 14 | #endif | ||
| 15 | |||
| 16 | namespace Tools { | ||
| 17 | |||
| 18 | RenderdocAPI::RenderdocAPI() { | ||
| 19 | #ifdef WIN32 | ||
| 20 | if (HMODULE mod = GetModuleHandleA("renderdoc.dll")) { | ||
| 21 | const auto RENDERDOC_GetAPI = | ||
| 22 | reinterpret_cast<pRENDERDOC_GetAPI>(GetProcAddress(mod, "RENDERDOC_GetAPI")); | ||
| 23 | const s32 ret = RENDERDOC_GetAPI(eRENDERDOC_API_Version_1_6_0, (void**)&rdoc_api); | ||
| 24 | ASSERT(ret == 1); | ||
| 25 | } | ||
| 26 | #else | ||
| 27 | #ifdef ANDROID | ||
| 28 | static constexpr const char RENDERDOC_LIB[] = "libVkLayer_GLES_RenderDoc.so"; | ||
| 29 | #else | ||
| 30 | static constexpr const char RENDERDOC_LIB[] = "librenderdoc.so"; | ||
| 31 | #endif | ||
| 32 | if (void* mod = dlopen(RENDERDOC_LIB, RTLD_NOW | RTLD_NOLOAD)) { | ||
| 33 | const auto RENDERDOC_GetAPI = | ||
| 34 | reinterpret_cast<pRENDERDOC_GetAPI>(dlsym(mod, "RENDERDOC_GetAPI")); | ||
| 35 | const s32 ret = RENDERDOC_GetAPI(eRENDERDOC_API_Version_1_6_0, (void**)&rdoc_api); | ||
| 36 | ASSERT(ret == 1); | ||
| 37 | } | ||
| 38 | #endif | ||
| 39 | } | ||
| 40 | |||
| 41 | RenderdocAPI::~RenderdocAPI() = default; | ||
| 42 | |||
| 43 | void RenderdocAPI::ToggleCapture() { | ||
| 44 | if (!rdoc_api) [[unlikely]] { | ||
| 45 | return; | ||
| 46 | } | ||
| 47 | if (!is_capturing) { | ||
| 48 | rdoc_api->StartFrameCapture(NULL, NULL); | ||
| 49 | } else { | ||
| 50 | rdoc_api->EndFrameCapture(NULL, NULL); | ||
| 51 | } | ||
| 52 | is_capturing = !is_capturing; | ||
| 53 | } | ||
| 54 | |||
| 55 | } // namespace Tools | ||
diff --git a/src/core/tools/renderdoc.h b/src/core/tools/renderdoc.h new file mode 100644 index 000000000..0e5e43da5 --- /dev/null +++ b/src/core/tools/renderdoc.h | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | struct RENDERDOC_API_1_6_0; | ||
| 7 | |||
| 8 | namespace Tools { | ||
| 9 | |||
| 10 | class RenderdocAPI { | ||
| 11 | public: | ||
| 12 | explicit RenderdocAPI(); | ||
| 13 | ~RenderdocAPI(); | ||
| 14 | |||
| 15 | void ToggleCapture(); | ||
| 16 | |||
| 17 | private: | ||
| 18 | RENDERDOC_API_1_6_0* rdoc_api{}; | ||
| 19 | bool is_capturing{false}; | ||
| 20 | }; | ||
| 21 | |||
| 22 | } // namespace Tools | ||