Skip to content
Permalink
Browse files

Overlay: Introduce D3D call result logging

* Introduce return code checking and logging on failure to D3D API calls.
This should make logging more elaborative and may point to issues when
debugging/looking for issues.
  • Loading branch information...
Kissaki committed Feb 16, 2014
1 parent d3e00de commit f789386b67e023d1a5e28389071fda66b4f96c3b
Showing with 24 additions and 4 deletions.
  1. +24 −4 overlay/d3d9.cpp
@@ -354,8 +354,24 @@ static void doPresent(IDirect3DDevice9 *idd) {

IDirect3DSurface9 *pTarget = NULL;
IDirect3DSurface9 *pRenderTarget = NULL;
idd->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pTarget);
idd->GetRenderTarget(0, &pRenderTarget);
HRESULT hres = idd->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pTarget);
if (FAILED(hres)) {
if (hres == D3DERR_INVALIDCALL) {
ods("D3D9: IDirect3DDevice9::GetBackBuffer failed. BackBuffer index equals or exceeds the total number of back buffers");
} else {
ods("D3D9: IDirect3DDevice9::GetBackBuffer failed");
}
}
hres = idd->GetRenderTarget(0, &pRenderTarget);
if (FAILED(hres)) {
if (hres == D3DERR_NOTFOUND) {
ods("D3D9: IDirect3DDevice9::GetRenderTarget failed. There is no render target with the specified index");
} else if (hres == D3DERR_INVALIDCALL) {
ods("D3D9: IDirect3DDevice9::GetRenderTarget failed. One of the passed arguments was invalid");
} else {
ods("D3D9: IDirect3DDevice9::GetRenderTarget failed");
}
}

// Present is called for each frame. Thus, we do not want to always log here.
#ifdef EXTENDED_OVERLAY_DEBUGOUTPUT
@@ -368,8 +384,12 @@ static void doPresent(IDirect3DDevice9 *idd) {

ds->pSB->Apply();

if (pTarget != pRenderTarget)
idd->SetRenderTarget(0, pTarget);
if (pTarget != pRenderTarget) {
hres = idd->SetRenderTarget(0, pTarget);
if (FAILED(hres)) {
ods("D3D9: IDirect3DDevice9::SetRenderTarget failed");
}
}

idd->BeginScene();
ds->draw();

0 comments on commit f789386

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