diff options
Diffstat (limited to 'Whisper/D3D/RenderDoc/renderDoc.cpp')
| -rw-r--r-- | Whisper/D3D/RenderDoc/renderDoc.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/Whisper/D3D/RenderDoc/renderDoc.cpp b/Whisper/D3D/RenderDoc/renderDoc.cpp new file mode 100644 index 0000000..e811c1e --- /dev/null +++ b/Whisper/D3D/RenderDoc/renderDoc.cpp @@ -0,0 +1,72 @@ +#include "stdafx.h" +#include "renderDoc.h" +#include "renderdoc_app.h" +#include "../device.h" + +#define ENABLE_RENDERDOC_DEBUGGER 1 + +#if ENABLE_RENDERDOC_DEBUGGER +namespace +{ + static HMODULE hmRenderDoc = nullptr; + static RENDERDOC_API_1_6_0* api = nullptr; +} + +bool DirectCompute::initializeRenderDoc() +{ + hmRenderDoc = GetModuleHandleW( L"renderdoc.dll" ); + if( nullptr == hmRenderDoc ) + return false; + + pRENDERDOC_GetAPI getApi = (pRENDERDOC_GetAPI)GetProcAddress( hmRenderDoc, "RENDERDOC_GetAPI" ); + if( nullptr == getApi ) + return false; + if( 1 != getApi( eRENDERDOC_API_Version_1_6_0, (void**)&api ) ) + return false; + if( nullptr == api ) + return false; + + return true; +} + +namespace +{ + using namespace DirectCompute; + inline bool isKeyPressed( int vKey ) + { + return 0 != ( GetAsyncKeyState( vKey ) & 0x8000 ); + } +} + +CaptureRaii::CaptureRaii() : capturing( false ) +{ + if( nullptr == api ) + return; + if( !isKeyPressed( VK_F12 ) ) + return; + ID3D11Device* const dev = device(); + if( nullptr == dev ) + return; + + api->StartFrameCapture( dev, nullptr ); + capturing = true; +} + +CaptureRaii::~CaptureRaii() +{ + if( !capturing ) + return; + api->EndFrameCapture( device(), nullptr ); +} +#else // !ENABLE_RENDERDOC_DEBUGGER +bool DirectCompute::initializeRenderDoc() +{ + return false; +} +DirectCompute::CaptureRaii::CaptureRaii() : capturing( false ) +{ +} +DirectCompute::CaptureRaii::~CaptureRaii() +{ +} +#endif
\ No newline at end of file |
