Improve RenderDocCapture API

- Add SetWindow() method for separate window configuration
- BeginCapture/EndCapture now return bool for error feedback
- Add GetCapture() method to retrieve capture file info
- Add LaunchReplayUI() method
- Add SetCaptureOptionU32() for user-configurable capture options
- Add null pointer checks in BeginCapture with Logger warnings
- Add RenderDocCaptureInfo struct for capture file metadata
This commit is contained in:
2026-03-23 18:37:22 +08:00
parent 36683b4bb3
commit 1acea6bf69
2 changed files with 70 additions and 8 deletions

View File

@@ -50,6 +50,10 @@ void RenderDocCapture::SetDevice(void* device) {
m_device = device;
}
void RenderDocCapture::SetWindow(void* window) {
m_window = window;
}
bool RenderDocCapture::LoadRenderDoc() {
char exePath[MAX_PATH];
GetModuleFileNameA(NULL, exePath, MAX_PATH);
@@ -115,10 +119,32 @@ uint32_t RenderDocCapture::GetNumCaptures() const {
return m_api->GetNumCaptures();
}
void RenderDocCapture::BeginCapture(const char* title) {
if (!m_isLoaded || !m_api) {
return;
bool RenderDocCapture::GetCapture(uint32_t index, RenderDocCaptureInfo* info) const {
if (!m_isLoaded || !m_api || !info) {
return false;
}
uint32_t length = 0;
uint64_t timestamp = 0;
uint32_t result = m_api->GetCapture(index, info->filename, &length, &timestamp);
info->length = length;
info->timestamp = timestamp;
return result == 1;
}
bool RenderDocCapture::BeginCapture(const char* title) {
if (!m_isLoaded || !m_api) {
Logger::Get().Warning(LogCategory::General, "BeginCapture called but RenderDoc not loaded");
return false;
}
if (IsCapturing()) {
Logger::Get().Warning(LogCategory::General, "BeginCapture called while already capturing");
return false;
}
if (!m_device || !m_window) {
Logger::Get().Warning(LogCategory::General, "BeginCapture called with null device or window");
return false;
}
if (title) {
m_api->SetCaptureTitle(title);
}
@@ -128,13 +154,22 @@ void RenderDocCapture::BeginCapture(const char* title) {
m_api->SetActiveWindow(m_device, m_window);
m_api->StartFrameCapture(m_device, m_window);
return true;
}
void RenderDocCapture::EndCapture() {
bool RenderDocCapture::EndCapture() {
if (!m_isLoaded || !m_api) {
return;
Logger::Get().Warning(LogCategory::General, "EndCapture called but RenderDoc not loaded");
return false;
}
if (!IsCapturing()) {
Logger::Get().Warning(LogCategory::General, "EndCapture called but not currently capturing");
return false;
}
m_api->EndFrameCapture(m_device, m_window);
return true;
}
void RenderDocCapture::TriggerCapture() {
@@ -158,5 +193,21 @@ void RenderDocCapture::SetCaptureComments(const char* comments) {
m_api->SetCaptureFileComments(nullptr, comments);
}
void RenderDocCapture::SetCaptureOptionU32(uint32_t option, uint32_t value) {
if (!m_isLoaded || !m_api) {
return;
}
m_api->SetCaptureOptionU32(option, value);
}
bool RenderDocCapture::LaunchReplayUI(uint32_t connect, const char* cmdline) {
if (!m_isLoaded || !m_api) {
Logger::Get().Warning(LogCategory::General, "LaunchReplayUI called but RenderDoc not loaded");
return false;
}
m_api->LaunchReplayUI(connect, cmdline);
return true;
}
} // namespace Debug
} // namespace XCEngine