diff options
author | Kissaki <kissaki@gmx.de> | 2014-02-16 23:33:45 +0400 |
---|---|---|
committer | Kissaki <kissaki@gmx.de> | 2014-02-17 01:24:30 +0400 |
commit | f789386b67e023d1a5e28389071fda66b4f96c3b (patch) | |
tree | 5ef4feafeb25dd45c4a9d6fdd931be3f3a34ba8a /overlay | |
parent | d3e00deecfd9ae10e481f3dc467051e289be297f (diff) |
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.
Diffstat (limited to 'overlay')
-rw-r--r-- | overlay/d3d9.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/overlay/d3d9.cpp b/overlay/d3d9.cpp index d1df235a2..82ca25df6 100644 --- a/overlay/d3d9.cpp +++ b/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(); |