From 0e7697dc673c4c58a01fba0a74bdb4c941002292 Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Mon, 26 Aug 2024 00:43:36 +0300 Subject: [PATCH] Add Renderdoc scope classes --- include/renderdoc.hpp | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/include/renderdoc.hpp b/include/renderdoc.hpp index 94a0f494..ea2c8a3d 100644 --- a/include/renderdoc.hpp +++ b/include/renderdoc.hpp @@ -35,4 +35,35 @@ namespace Renderdoc { static void setOutputDir(const std::string& path, const std::string& prefix) {} static constexpr bool isSupported() { return false; } } // namespace Renderdoc -#endif \ No newline at end of file +#endif + +namespace Renderdoc { + // RAII scope class that encloses a Renderdoc capture, as long as it's triggered by triggerCapture + struct Scope { + Scope() { Renderdoc::startCapture(); } + ~Scope() { Renderdoc::endCapture(); } + + Scope(const Scope&) = delete; + Scope& operator=(const Scope&) = delete; + + Scope(Scope&&) = delete; + Scope& operator=(const Scope&&) = delete; + }; + + // RAII scope class that encloses a Renderdoc capture. Unlike regular Scope it doesn't wait for a trigger, it will always issue the capture + // trigger on its own and take a capture + struct InstantScope { + InstantScope() { + Renderdoc::triggerCapture(); + Renderdoc::startCapture(); + } + + ~InstantScope() { Renderdoc::endCapture(); } + + InstantScope(const InstantScope&) = delete; + InstantScope& operator=(const InstantScope&) = delete; + + InstantScope(InstantScope&&) = delete; + InstantScope& operator=(const InstantScope&&) = delete; + }; +} // namespace Renderdoc \ No newline at end of file