blob: e811c1e02bdc2a52ae6309a0ea4267c70f1a2683 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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
|