diff --git a/README.md b/README.md index ae992310..84f6dbf2 100644 --- a/README.md +++ b/README.md @@ -319,6 +319,44 @@ build/tests/threading/Debug/xcengine_threading_tests.exe - **Profiler**: 性能分析工具 - **RenderDocCapture**: RenderDoc 帧捕获集成,支持动态加载 renderdoc.dll 进行 GPU 帧调试 +#### RenderDocCapture API + +支持 D3D12 和 OpenGL 的帧捕获调试: + +```cpp +// 初始化(设备创建之前调用) +RenderDocCapture::Get().Initialize(nullptr, hwnd); +RenderDocCapture::Get().SetDevice(device); // D3D12: ID3D12Device*, OpenGL: HGLRC + +// 捕获配置 +RenderDocCapture::Get().SetCaptureFilePath(".\\capture"); +RenderDocCapture::Get().SetCaptureComments("Comment"); +RenderDocCapture::Get().SetCaptureOptionU32(option, value); + +// 帧捕获 +bool BeginCapture(const char* title = nullptr); // 返回 bool +bool EndCapture(); // 返回 bool +void TriggerCapture(); // 捕获下一帧 +bool IsCapturing() const; +uint32_t GetNumCaptures() const; + +// 获取捕获信息 +struct RenderDocCaptureInfo { + char filename[256]; + uint32_t length; + uint64_t timestamp; +}; +bool GetCapture(uint32_t index, RenderDocCaptureInfo* info); + +// 打开 RenderDoc replay UI +bool LaunchReplayUI(uint32_t connect = 1, const char* cmdline = nullptr); +``` + +> **注意**: +> - OpenGL 后端需要传递 `HGLRC`(OpenGL 上下文)作为 device,不是 `HDC` +> - `renderdoc.dll` 需放置于 `engine/third_party/renderdoc/renderdoc.dll` +> - D3D12 和 OpenGL 均已验证可正常捕获 + ### Memory(内存管理) - **IAllocator**: 内存分配器接口 @@ -421,10 +459,11 @@ mvs(Multiple Version Samples)展示游戏引擎的各类功能。所有示 ### RenderDoc -D3D12 + RenderDoc 集成示例,展示如何使用 RenderDoc API 进行 GPU 帧捕获和调试: +D3D12 / OpenGL + RenderDoc 集成示例,展示如何使用 RenderDoc API 进行 GPU 帧捕获和调试: - 动态加载 renderdoc.dll -- 帧捕获 API(StartFrameCapture/EndFrameCapture/TriggerCapture) +- 帧捕获 API(BeginCapture/EndCapture/TriggerCapture) - 捕获文件路径和注释设置 +- 支持 D3D12 和 OpenGL 双后端 > 注意:renderdoc.dll 需单独放置于 `engine/third_party/renderdoc/renderdoc.dll`