summaryrefslogtreecommitdiffstats
path: root/src/core/tools/renderdoc.cpp
diff options
context:
space:
mode:
authorGPUCode <geoster3d@gmail.com>2023-09-10 22:26:09 +0200
committerGPUCode <geoster3d@gmail.com>2023-09-14 15:37:41 +0200
commitc656105a6c6ce14ced695f8edb1864cbba4e66dd (patch)
tree65f998b067a4b01aac8841f11575214fe942fdfe /src/core/tools/renderdoc.cpp
parentMerge pull request #11496 from liamwhite/ngc (diff)
downloadyuzu-c656105a6c6ce14ced695f8edb1864cbba4e66dd.tar
yuzu-c656105a6c6ce14ced695f8edb1864cbba4e66dd.tar.gz
yuzu-c656105a6c6ce14ced695f8edb1864cbba4e66dd.tar.bz2
yuzu-c656105a6c6ce14ced695f8edb1864cbba4e66dd.tar.lz
yuzu-c656105a6c6ce14ced695f8edb1864cbba4e66dd.tar.xz
yuzu-c656105a6c6ce14ced695f8edb1864cbba4e66dd.tar.zst
yuzu-c656105a6c6ce14ced695f8edb1864cbba4e66dd.zip
Diffstat (limited to '')
-rw-r--r--src/core/tools/renderdoc.cpp55
1 files changed, 55 insertions, 0 deletions
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 @@
+// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <renderdoc_app.h>
+
+#include "common/assert.h"
+#include "common/dynamic_library.h"
+#include "core/tools/renderdoc.h"
+
+#ifdef WIN32
+#include <windows.h>
+#else
+#include <dlfcn.h>
+#endif
+
+namespace Tools {
+
+RenderdocAPI::RenderdocAPI() {
+#ifdef WIN32
+ if (HMODULE mod = GetModuleHandleA("renderdoc.dll")) {
+ const auto RENDERDOC_GetAPI =
+ reinterpret_cast<pRENDERDOC_GetAPI>(GetProcAddress(mod, "RENDERDOC_GetAPI"));
+ const s32 ret = RENDERDOC_GetAPI(eRENDERDOC_API_Version_1_6_0, (void**)&rdoc_api);
+ ASSERT(ret == 1);
+ }
+#else
+#ifdef ANDROID
+ static constexpr const char RENDERDOC_LIB[] = "libVkLayer_GLES_RenderDoc.so";
+#else
+ static constexpr const char RENDERDOC_LIB[] = "librenderdoc.so";
+#endif
+ if (void* mod = dlopen(RENDERDOC_LIB, RTLD_NOW | RTLD_NOLOAD)) {
+ const auto RENDERDOC_GetAPI =
+ reinterpret_cast<pRENDERDOC_GetAPI>(dlsym(mod, "RENDERDOC_GetAPI"));
+ const s32 ret = RENDERDOC_GetAPI(eRENDERDOC_API_Version_1_6_0, (void**)&rdoc_api);
+ ASSERT(ret == 1);
+ }
+#endif
+}
+
+RenderdocAPI::~RenderdocAPI() = default;
+
+void RenderdocAPI::ToggleCapture() {
+ if (!rdoc_api) [[unlikely]] {
+ return;
+ }
+ if (!is_capturing) {
+ rdoc_api->StartFrameCapture(NULL, NULL);
+ } else {
+ rdoc_api->EndFrameCapture(NULL, NULL);
+ }
+ is_capturing = !is_capturing;
+}
+
+} // namespace Tools