Skip to content
Permalink
Browse files

Overlay: Less obtrusive logging.

* Present, AddRef and Release calls are not useful most of the time.
They were only logged in DEBUG builds, but as these methods are called very often heavily degrades performance.
Add define-guards so when one actually wants to debug and see them he can enable them.
Now, (normal) debug builds will not have the heavy performance loss any more.
  • Loading branch information...
Kissaki committed Jun 23, 2013
1 parent 9d0de38 commit 1919b2cd71125976a1a8b10f91c7c5d0713c3907
Showing with 43 additions and 1 deletion.
  1. +4 −1 overlay/d3d10.cpp
  2. +39 −0 overlay/d3d9.cpp
@@ -443,7 +443,10 @@ void D10State::draw() {


static HRESULT __stdcall myPresent(IDXGISwapChain *pSwapChain, UINT SyncInterval, UINT Flags) {
// Present is called for each frame. Thus, we do not want to always log here.
#ifdef EXTENDED_OVERLAY_DEBUGOUTPUT
ods("D3D10: Call to Present; Drawing and then chaining the call");
#endif

ID3D10Device *pDevice = NULL;
HRESULT hr = pSwapChain->GetDevice(__uuidof(ID3D10Device), (void **) &pDevice);
@@ -466,7 +469,7 @@ static HRESULT __stdcall myPresent(IDXGISwapChain *pSwapChain, UINT SyncInterval
ds->draw();
pDevice->Release();
} else {
ods("D3D10: Could not draw as ID3D10Device could not be retrieved.");
ods("D3D10: Could not draw because ID3D10Device could not be retrieved.");
}

//TODO: Move logic to HardHook.
@@ -105,7 +105,10 @@ void DevState::releaseData() {
}

void DevState::blit(unsigned int x, unsigned int y, unsigned int w, unsigned int h) {
// Blit is called often. Thus, we do not want to always log here.
#ifdef EXTENDED_OVERLAY_DEBUGOUTPUT
ods("D3D9: Blit %d %d %d %d", x, y, w, h);
#endif

if (! texTexture || !a_ucTexture)
return;
@@ -329,7 +332,10 @@ static void doPresent(IDirect3DDevice9 *idd) {
idd->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pTarget);
idd->GetRenderTarget(0, &pRenderTarget);

// Present is called for each frame. Thus, we do not want to always log here.
#ifdef EXTENDED_OVERLAY_DEBUGOUTPUT
ods("D3D9: doPresent BackB %p RenderT %p", pTarget, pRenderTarget);
#endif

IDirect3DStateBlock9* pStateBlock = NULL;
idd->CreateStateBlock(D3DSBT_ALL, &pStateBlock);
@@ -358,7 +364,10 @@ static void doPresent(IDirect3DDevice9 *idd) {

typedef HRESULT(__stdcall *SwapPresentType)(IDirect3DSwapChain9 *, CONST RECT *, CONST RECT *, HWND, CONST RGNDATA *, DWORD);
static HRESULT __stdcall mySwapPresent(IDirect3DSwapChain9 * ids, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion, DWORD dwFlags) {
// Present is called for each frame. Thus, we do not want to always log here.
#ifdef EXTENDED_OVERLAY_DEBUGOUTPUT
ods("D3D9: SwapChain Present");
#endif

IDirect3DDevice9 *idd = NULL;
ids->GetDevice(&idd);
@@ -379,7 +388,10 @@ static HRESULT __stdcall mySwapPresent(IDirect3DSwapChain9 * ids, CONST RECT *pS

typedef HRESULT(__stdcall *PresentType)(IDirect3DDevice9 *, CONST RECT *, CONST RECT *, HWND, CONST RGNDATA *);
static HRESULT __stdcall myPresent(IDirect3DDevice9 * idd, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) {
// Present is called for each frame. Thus, we do not want to always log here.
#ifdef EXTENDED_OVERLAY_DEBUGOUTPUT
ods("D3D9: Device Present");
#endif

doPresent(idd);

@@ -395,7 +407,10 @@ static HRESULT __stdcall myPresent(IDirect3DDevice9 * idd, CONST RECT* pSourceRe

typedef HRESULT(__stdcall *PresentExType)(IDirect3DDevice9Ex *, CONST RECT *, CONST RECT *, HWND, CONST RGNDATA *, DWORD);
static HRESULT __stdcall myPresentEx(IDirect3DDevice9Ex * idd, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion, DWORD dwFlags) {
// Present is called for each frame. Thus, we do not want to always log here.
#ifdef EXTENDED_OVERLAY_DEBUGOUTPUT
ods("D3D9: Device Present Ex");
#endif

doPresent(idd);

@@ -467,7 +482,10 @@ typedef ULONG(__stdcall *AddRefType)(IDirect3DDevice9 *);
static ULONG __stdcall myAddRef(IDirect3DDevice9 *idd) {
Mutex m;

// AddRef is called very often. Thus, we do not want to always log here.
#ifdef EXTENDED_OVERLAY_DEBUGOUTPUT
ods("D3D9: Chaining AddRef");
#endif

DevState *ds = devMap[idd];
if (ds) {
@@ -486,15 +504,21 @@ static ULONG __stdcall myAddRef(IDirect3DDevice9 *idd) {
ULONG res = oAddRef(idd);
hhAddRef.inject();

// AddRef is called very often. Thus, we do not want to always log here.
#ifdef EXTENDED_OVERLAY_DEBUGOUTPUT
ods("D3D9: Chained AddRef with result %d", res);
#endif

return res;
}

static ULONG __stdcall myWin8AddRef(IDirect3DDevice9 *idd) {
Mutex m;

// AddRef is called very often. Thus, we do not want to always log here.
#ifdef EXTENDED_OVERLAY_DEBUGOUTPUT
ods("D3D9: Chaining AddRef (Win8)");
#endif

DevState *ds = devMap[idd];
if (ds && ds->dwMyThread == GetCurrentThreadId()) {
@@ -512,7 +536,10 @@ static ULONG __stdcall myWin8AddRef(IDirect3DDevice9 *idd) {
if (ds)
ds->refCount = res;

// AddRef is called very often. Thus, we do not want to always log here.
#ifdef EXTENDED_OVERLAY_DEBUGOUTPUT
ods("D3D9: Chained AddRef (Win8) with result %d", res);
#endif

return res;
}
@@ -521,7 +548,10 @@ typedef ULONG(__stdcall *ReleaseType)(IDirect3DDevice9 *);
static ULONG __stdcall myRelease(IDirect3DDevice9 *idd) {
Mutex m;

// Release is called very often. Thus, we do not want to always log here.
#ifdef EXTENDED_OVERLAY_DEBUGOUTPUT
ods("D3D9: Chaining Release");
#endif

DevState *ds = devMap[idd];
if (ds) {
@@ -563,15 +593,21 @@ static ULONG __stdcall myRelease(IDirect3DDevice9 *idd) {
ULONG res = oRelease(idd);
hhRelease.inject();

// Release is called very often. Thus, we do not want to always log here.
#ifdef EXTENDED_OVERLAY_DEBUGOUTPUT
ods("D3D9: Chained Release with result %d", res);
#endif

return res;
}

static ULONG __stdcall myWin8Release(IDirect3DDevice9 *idd) {
Mutex m;

// Release is called very often. Thus, we do not want to always log here.
#ifdef EXTENDED_OVERLAY_DEBUGOUTPUT
ods("D3D9: Chaining Release (Win8)");
#endif

DevState *ds = devMap[idd];
if (ds) {
@@ -607,7 +643,10 @@ static ULONG __stdcall myWin8Release(IDirect3DDevice9 *idd) {
if (ds)
ds->refCount = res;

// Release is called very often. Thus, we do not want to always log here.
#ifdef EXTENDED_OVERLAY_DEBUGOUTPUT
ods("D3D9: Chained Release (Win8) with result: %d", res);
#endif

return res;
}

0 comments on commit 1919b2c

Please sign in to comment.
You can’t perform that action at this time.