Files
XCEngine/engine/include/XCEngine/Debug/RenderDocCapture.h
ssdfasd 1acea6bf69 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
2026-03-23 18:37:22 +08:00

90 lines
3.5 KiB
C++

#pragma once
#include <cstdint>
#include <windows.h>
namespace XCEngine {
namespace Debug {
#define RENDERDOC_CC __cdecl
struct RenderDocCaptureInfo {
char filename[256];
uint32_t length;
uint64_t timestamp;
};
class RenderDocCapture {
public:
static RenderDocCapture& Get();
bool Initialize(void* device = nullptr, void* window = nullptr);
void Shutdown();
void SetDevice(void* device);
void SetWindow(void* window);
bool IsLoaded() const { return m_isLoaded; }
bool IsCapturing() const;
uint32_t GetNumCaptures() const;
bool GetCapture(uint32_t index, RenderDocCaptureInfo* info) const;
bool BeginCapture(const char* title = nullptr);
bool EndCapture();
void TriggerCapture();
void SetCaptureFilePath(const char* path);
void SetCaptureComments(const char* comments);
void SetCaptureOptionU32(uint32_t option, uint32_t value);
bool LaunchReplayUI(uint32_t connect = 1, const char* cmdline = nullptr);
private:
RenderDocCapture() = default;
~RenderDocCapture() = default;
bool LoadRenderDoc();
void UnloadRenderDoc();
struct RENDERDOC_API_1_7_0 {
void (RENDERDOC_CC* GetAPIVersion)(int* major, int* minor, int* patch);
void (RENDERDOC_CC* SetCaptureOptionU32)(uint32_t opt, uint32_t val);
void (RENDERDOC_CC* SetCaptureOptionF32)(uint32_t opt, float val);
uint32_t (RENDERDOC_CC* GetCaptureOptionU32)(uint32_t opt);
float (RENDERDOC_CC* GetCaptureOptionF32)(uint32_t opt);
void (RENDERDOC_CC* SetFocusToggleKeys)(const char* const* keys, int num);
void (RENDERDOC_CC* SetCaptureKeys)(const char* const* keys, int num);
uint32_t (RENDERDOC_CC* GetOverlayBits)();
void (RENDERDOC_CC* MaskOverlayBits)(uint32_t And, uint32_t Or);
void (RENDERDOC_CC* RemoveHooks)();
void (RENDERDOC_CC* UnloadCrashHandler)();
void (RENDERDOC_CC* SetCaptureFilePathTemplate)(const char* path);
const char* (RENDERDOC_CC* GetCaptureFilePathTemplate)();
uint32_t (RENDERDOC_CC* GetNumCaptures)();
uint32_t (RENDERDOC_CC* GetCapture)(uint32_t idx, char* filename, uint32_t* length, uint64_t* timestamp);
void (RENDERDOC_CC* TriggerCapture)();
uint32_t (RENDERDOC_CC* IsTargetControlConnected)();
void (RENDERDOC_CC* LaunchReplayUI)(uint32_t connect, const char* cmdline);
void (RENDERDOC_CC* SetActiveWindow)(void* device, void* window);
void (RENDERDOC_CC* StartFrameCapture)(void* device, void* window);
uint32_t (RENDERDOC_CC* IsFrameCapturing)();
void (RENDERDOC_CC* EndFrameCapture)(void* device, void* window);
void (RENDERDOC_CC* TriggerMultiFrameCapture)(uint32_t numFrames);
void (RENDERDOC_CC* SetCaptureFileComments)(const char* filePath, const char* comments);
uint32_t (RENDERDOC_CC* DiscardFrameCapture)(void* device, void* window);
uint32_t (RENDERDOC_CC* ShowReplayUI)();
void (RENDERDOC_CC* SetCaptureTitle)(const char* title);
void (RENDERDOC_CC* SetObjectAnnotation)(void* device, void* object, const char* key, int valueType, uint32_t valueVectorWidth, const void* value);
void (RENDERDOC_CC* SetCommandAnnotation)(void* device, void* queueOrCommandBuffer, const char* key, int valueType, uint32_t valueVectorWidth, const void* value);
};
HMODULE m_renderDocModule = nullptr;
RENDERDOC_API_1_7_0* m_api = nullptr;
void* m_device = nullptr;
void* m_window = nullptr;
bool m_isLoaded = false;
bool m_initialized = false;
};
} // namespace Debug
} // namespace XCEngine