Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
RenderDoc.cpp
Go to the documentation of this file.
2
3#include <iostream>
4#include <vulkan/vulkan_core.h>
5
6#ifdef RENDERDOC_ENABLED
7#include <renderdoc_app.h>
8#include <GLFW/glfw3native.h>
9#include <iostream>
10#ifdef WIN32
11#include <windows.h>
12#endif
13#endif
14
16 static RenderDoc instance;
17 return instance;
18}
19
21#ifdef RENDERDOC_ENABLED
22 if (m_available) return true;
23
24 // Check if RenderDoc is injected
25 if (HMODULE mod = GetModuleHandleA("renderdoc.dll")) {
26 pRENDERDOC_GetAPI getAPI = (pRENDERDOC_GetAPI)GetProcAddress(mod, "RENDERDOC_GetAPI");
27
28 if (getAPI) {
29 int ret = getAPI(eRENDERDOC_API_Version_1_6_0, (void**)&m_api);
30 if (ret == 1) {
31 m_available = true;
32 std::cout << "RenderDoc API 1.6.0 connected\n";
33 } else {
34 ret = getAPI(eRENDERDOC_API_Version_1_1_2, (void**)&m_api);
35 if (ret == 1) {
36 m_available = true;
37 std::cout << "RenderDoc API 1.1.2 connected\n";
38 } else {
39 std::cout << "RenderDoc API not supported (tried 1.6.0 and 1.1.2)\n";
40 return false;
41 }
42 }
43
44 m_api->SetCaptureOptionU32(eRENDERDOC_Option_AllowVSync, 0);
45 m_api->SetCaptureOptionU32(eRENDERDOC_Option_AllowFullscreen, 0);
46 m_api->SetCaptureOptionU32(eRENDERDOC_Option_APIValidation, 0);
47 m_api->SetCaptureOptionU32(eRENDERDOC_Option_CaptureCallstacks, 1);
48 m_api->SetCaptureOptionU32(eRENDERDOC_Option_HookIntoChildren, 1);
49
50 return true;
51 }
52 }
53
54 return false;
55#else
56 return false;
57#endif
58}
59
60void RenderDoc::startCapture(VkDevice device) const {
61#ifdef RENDERDOC_ENABLED
62 if (m_api) {
63 m_api->StartFrameCapture(nullptr, nullptr);
64 }
65#endif
66}
67
68void RenderDoc::endCapture(VkDevice device) const {
69#ifdef RENDERDOC_ENABLED
70 if (m_api) {
71 uint32_t result = m_api->EndFrameCapture(nullptr, nullptr);
72 std::cout << "RenderDoc end frame capture result: " << result << std::endl;
73 if (result) {
74 std::cout << "Frame captured successfully\n";
75 }
76 }
77#endif
78}
79
81#ifdef RENDERDOC_ENABLED
82 if (m_api) {
83 std::cout << "RenderDoc: Triggering capture...\n";
84 m_api->TriggerCapture();
85 std::cout << "RenderDoc: Trigger capture called successfully\n";
86 } else {
87 std::cout << "RenderDoc: API not available for trigger\n";
88 }
89#endif
90}
91
93#ifdef RENDERDOC_ENABLED
94 if (m_api) {
95 bool capturing = m_api->IsFrameCapturing() == 1;
96 if (capturing) {
97 std::cout << "RenderDoc: Frame is currently capturing\n";
98 }
99 return capturing;
100 }
101#endif
102 return false;
103}
104
106#ifdef RENDERDOC_ENABLED
107 if (m_api) {
108 return m_api->IsTargetControlConnected() == 1;
109 }
110#endif
111 return false;
112}
113
114void RenderDoc::setCaptureTitle(const std::string& title) {
115#ifdef RENDERDOC_ENABLED
116 if (m_api && isCapturing()) {
117 m_api->SetCaptureTitle(title.c_str());
118 }
119#endif
120}
121
122void RenderDoc::setCapturePath(const std::string& pathTemplate) {
123#ifdef RENDERDOC_ENABLED
124 if (m_api) {
125 m_api->SetCaptureFilePathTemplate(pathTemplate.c_str());
126 }
127#endif
128}
129
130void RenderDoc::triggerMultiFrameCapture(uint32_t numFrames) {
131#ifdef RENDERDOC_ENABLED
132 if (m_api) {
133 m_api->TriggerMultiFrameCapture(numFrames);
134 }
135#endif
136}
137
139#ifdef RENDERDOC_ENABLED
140 if (m_api) {
141 std::cout << "RenderDoc Status:\n";
142 std::cout << " - API Available: Yes\n";
143 std::cout << " - Currently Capturing: " << (isCapturing() ? "Yes" : "No") << "\n";
144 std::cout << " - UI Connected: " << (isConnected() ? "Yes" : "No") << "\n";
145 std::cout << " - Total Captures: " << getNumCaptures() << "\n";
146 } else {
147 std::cout << "RenderDoc Status: API not available\n";
148 }
149#else
150 std::cout << "RenderDoc Status: Not compiled in\n";
151#endif
152}
153
155#ifdef RENDERDOC_ENABLED
156 if (m_api) {
157 return m_api->GetNumCaptures();
158 }
159#endif
160 return 0;
161}
162
164#ifdef RENDERDOC_ENABLED
165 if (m_api) {
166 m_api->LaunchReplayUI(1, nullptr);
167 }
168#endif
169}
170
172#ifdef RENDERDOC_ENABLED
173 if (m_api) {
174 m_api->ShowReplayUI();
175 }
176#endif
177}
178
180#ifdef RENDERDOC_ENABLED
181 if (m_api) {
182 m_api->SetCaptureOptionU32(eRENDERDOC_Option_CaptureCallstacks, enable ? 1 : 0);
183 }
184#endif
185}
186
188#ifdef RENDERDOC_ENABLED
189 if (m_api) {
190 m_api->SetCaptureOptionU32(eRENDERDOC_Option_APIValidation, enable ? 1 : 0);
191 }
192#endif
193}
194
195void RenderDoc::enableOverlay(bool enable) {
196#ifdef RENDERDOC_ENABLED
197 if (m_api) {
198 uint32_t mask = enable ? eRENDERDOC_Overlay_Default : eRENDERDOC_Overlay_None;
199 m_api->MaskOverlayBits(~0U, mask);
200 }
201#endif
202}
void printStatus() const
bool init()
Definition RenderDoc.cpp:20
void showUI()
void launchUI()
void startCapture(VkDevice device) const
Definition RenderDoc.cpp:60
void setCaptureTitle(const std::string &title)
void setCapturePath(const std::string &pathTemplate)
void enableCallstacks(bool enable)
void triggerMultiFrameCapture(uint32_t numFrames)
void endCapture(VkDevice device) const
Definition RenderDoc.cpp:68
RenderDoc()=default
bool m_available
Definition RenderDoc.h:52
uint32_t getNumCaptures() const
static RenderDoc & get()
Definition RenderDoc.cpp:15
void enableAPIValidation(bool enable)
void enableOverlay(bool enable)
void triggerCapture()
Definition RenderDoc.cpp:80
bool isConnected() const
bool isCapturing() const
Definition RenderDoc.cpp:92