mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-07-10 01:27:15 +00:00
Implement query for IDXGraphicsAnalysis with DXGIGetDebugInterface1
Closes #897
This commit is contained in:
@@ -503,6 +503,12 @@ public:
|
||||
return dev == m_ActiveWindow.dev && wnd == m_ActiveWindow.wnd;
|
||||
}
|
||||
|
||||
void GetActiveWindow(void *&dev, void *&wnd)
|
||||
{
|
||||
dev = m_ActiveWindow.dev;
|
||||
wnd = m_ActiveWindow.wnd;
|
||||
}
|
||||
|
||||
void TriggerCapture(uint32_t numFrames) { m_Cap = numFrames; }
|
||||
uint32_t GetOverlayBits() { return m_Overlay; }
|
||||
void MaskOverlayBits(uint32_t And, uint32_t Or) { m_Overlay = (m_Overlay & And) | Or; }
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
* THE SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#include "core/core.h"
|
||||
#include "hooks/hooks.h"
|
||||
#include "dxgi_wrapped.h"
|
||||
|
||||
@@ -30,6 +31,45 @@
|
||||
|
||||
typedef HRESULT(WINAPI *PFN_CREATE_DXGI_FACTORY)(REFIID, void **);
|
||||
typedef HRESULT(WINAPI *PFN_CREATE_DXGI_FACTORY2)(UINT, REFIID, void **);
|
||||
typedef HRESULT(WINAPI *PFN_GET_DEBUG_INTERFACE)(REFIID, void **);
|
||||
typedef HRESULT(WINAPI *PFN_GET_DEBUG_INTERFACE1)(UINT, REFIID, void **);
|
||||
|
||||
MIDL_INTERFACE("9F251514-9D4D-4902-9D60-18988AB7D4B5")
|
||||
IDXGraphicsAnalysis : public IUnknown
|
||||
{
|
||||
virtual void STDMETHODCALLTYPE BeginCapture() = 0;
|
||||
virtual void STDMETHODCALLTYPE EndCapture() = 0;
|
||||
};
|
||||
|
||||
struct RenderDocAnalysis : IDXGraphicsAnalysis
|
||||
{
|
||||
// IUnknown boilerplate
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject) { return E_NOINTERFACE; }
|
||||
ULONG STDMETHODCALLTYPE AddRef()
|
||||
{
|
||||
InterlockedIncrement(&m_iRefcount);
|
||||
return m_iRefcount;
|
||||
}
|
||||
ULONG STDMETHODCALLTYPE Release() { return InterlockedDecrement(&m_iRefcount); }
|
||||
unsigned int m_iRefcount = 0;
|
||||
|
||||
// IDXGraphicsAnalysis
|
||||
void BeginCapture()
|
||||
{
|
||||
void *dev = NULL, *wnd = NULL;
|
||||
RenderDoc::Inst().GetActiveWindow(dev, wnd);
|
||||
|
||||
RenderDoc::Inst().StartFrameCapture(dev, wnd);
|
||||
}
|
||||
|
||||
void EndCapture()
|
||||
{
|
||||
void *dev = NULL, *wnd = NULL;
|
||||
RenderDoc::Inst().GetActiveWindow(dev, wnd);
|
||||
|
||||
RenderDoc::Inst().EndFrameCapture(dev, wnd);
|
||||
}
|
||||
};
|
||||
|
||||
class DXGIHook : LibraryHook
|
||||
{
|
||||
@@ -47,8 +87,10 @@ public:
|
||||
|
||||
success &= CreateDXGIFactory.Initialize("CreateDXGIFactory", DLL_NAME, CreateDXGIFactory_hook);
|
||||
success &= CreateDXGIFactory1.Initialize("CreateDXGIFactory1", DLL_NAME, CreateDXGIFactory1_hook);
|
||||
// don't mind if this doesn't succeed
|
||||
// don't mind if these dosn't succeed
|
||||
CreateDXGIFactory2.Initialize("CreateDXGIFactory2", DLL_NAME, CreateDXGIFactory2_hook);
|
||||
GetDebugInterface.Initialize("DXGIGetDebugInterface", DLL_NAME, DXGIGetDebugInterface_hook);
|
||||
GetDebugInterface1.Initialize("DXGIGetDebugInterface1", DLL_NAME, DXGIGetDebugInterface1_hook);
|
||||
|
||||
if(!success)
|
||||
return false;
|
||||
@@ -132,9 +174,13 @@ private:
|
||||
bool m_HasHooks;
|
||||
bool m_EnabledHooks;
|
||||
|
||||
RenderDocAnalysis m_RenderDocAnalysis;
|
||||
|
||||
Hook<PFN_CREATE_DXGI_FACTORY> CreateDXGIFactory;
|
||||
Hook<PFN_CREATE_DXGI_FACTORY> CreateDXGIFactory1;
|
||||
Hook<PFN_CREATE_DXGI_FACTORY2> CreateDXGIFactory2;
|
||||
Hook<PFN_GET_DEBUG_INTERFACE> GetDebugInterface;
|
||||
Hook<PFN_GET_DEBUG_INTERFACE1> GetDebugInterface1;
|
||||
|
||||
static HRESULT WINAPI CreateDXGIFactory_hook(__in REFIID riid, __out void **ppFactory)
|
||||
{
|
||||
@@ -171,6 +217,42 @@ private:
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI DXGIGetDebugInterface_hook(REFIID riid, void **ppDebug)
|
||||
{
|
||||
if(ppDebug)
|
||||
*ppDebug = NULL;
|
||||
|
||||
if(riid == __uuidof(IDXGraphicsAnalysis))
|
||||
{
|
||||
dxgihooks.m_RenderDocAnalysis.AddRef();
|
||||
*ppDebug = &dxgihooks.m_RenderDocAnalysis;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if(dxgihooks.GetDebugInterface())
|
||||
return dxgihooks.GetDebugInterface()(riid, ppDebug);
|
||||
else
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI DXGIGetDebugInterface1_hook(UINT Flags, REFIID riid, void **ppDebug)
|
||||
{
|
||||
if(ppDebug)
|
||||
*ppDebug = NULL;
|
||||
|
||||
if(riid == __uuidof(IDXGraphicsAnalysis))
|
||||
{
|
||||
dxgihooks.m_RenderDocAnalysis.AddRef();
|
||||
*ppDebug = &dxgihooks.m_RenderDocAnalysis;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if(dxgihooks.GetDebugInterface1())
|
||||
return dxgihooks.GetDebugInterface1()(Flags, riid, ppDebug);
|
||||
else
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
};
|
||||
|
||||
DXGIHook DXGIHook::dxgihooks;
|
||||
|
||||
Reference in New Issue
Block a user