#include "commons/commons_renderdoc.h" #if !defined(NDEBUG) #include "commons/commons_base.h" #include "commons/commons_renderdoc_app.h" #include static auto GetRenderDocAPI() -> RENDERDOC_API_1_6_0* { static RENDERDOC_API_1_6_0* renderdocApi = nullptr; if (renderdocApi) { return renderdocApi; } if (void* mod = dlopen("librenderdoc.so", RTLD_NOW | RTLD_NOLOAD)) { pRENDERDOC_GetAPI renderdocGetApi = reinterpret_cast(dlsym(mod, "RENDERDOC_GetAPI")); if (renderdocGetApi && renderdocGetApi(eRENDERDOC_API_Version_1_6_0, (void**)&renderdocApi) == 1) { LOG("got renderdoc api"); return renderdocApi; } LOG("failed to get renderdoc api"); TRAP(); } return nullptr; } auto RenderDocCaptureStart() -> bool { if (auto api = GetRenderDocAPI()) { api->StartFrameCapture(nullptr, nullptr); return true; } return false; } auto RenderDocCaptureEnd() -> bool { if (auto api = GetRenderDocAPI()) { api->EndFrameCapture(nullptr, nullptr); return true; } return false; } auto RenderDocTriggerCapture() -> bool { if (auto api = GetRenderDocAPI()) { api->TriggerCapture(); return true; } return false; } #else auto RenderDocCaptureStart() -> bool { return false; } auto RenderDocCaptureEnd() -> bool { return false; } auto RenderDocTriggerCapture() -> bool { return false; } #endif