From 0649bf2a00b9ac25febd4d743b9d0d013b6776b2 Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Fri, 18 Jun 2010 14:14:13 +0000 Subject: [PATCH] Improve the CHECK macro used in DX9 and DX11 to allow more flexible error messages. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5733 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Plugins/Plugin_VideoDX11/Src/D3DBase.h | 1 + Source/Plugins/Plugin_VideoDX11/Src/D3DTexture.cpp | 2 +- Source/Plugins/Plugin_VideoDX11/Src/FBManager.cpp | 13 +++++-------- .../Plugin_VideoDX9/Src/FramebufferManager.cpp | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.h b/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.h index 7a5f7b166e..8593927db1 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.h +++ b/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.h @@ -22,6 +22,7 @@ #include "D3DBlob.h" #define SAFE_RELEASE(x) { if (x) (x)->Release(); (x) = NULL; } +#define CHECK(cond, Message, ...) if (!(cond)) { PanicAlert(__FUNCTION__ "Failed in %s at line %d: " Message, __FILE__, __LINE__, __VA_ARGS__); } class D3DTexture2D; namespace D3D diff --git a/Source/Plugins/Plugin_VideoDX11/Src/D3DTexture.cpp b/Source/Plugins/Plugin_VideoDX11/Src/D3DTexture.cpp index 754f8cae54..0aa209b3f1 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/D3DTexture.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/D3DTexture.cpp @@ -155,7 +155,7 @@ D3DTexture2D* D3DTexture2D::Create(unsigned int width, unsigned int height, D3D1 hr = D3D::device->CreateTexture2D(&texdesc, NULL, &pTexture); if (FAILED(hr)) { - PanicAlert("Failed to create texture at %s %d\n", __FILE__, __LINE__); + PanicAlert("Failed to create texture at %s, line %d: hr=%#x\n", __FILE__, __LINE__, hr); return NULL; } diff --git a/Source/Plugins/Plugin_VideoDX11/Src/FBManager.cpp b/Source/Plugins/Plugin_VideoDX11/Src/FBManager.cpp index 35b4d8a2f6..fc8308ece4 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/FBManager.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/FBManager.cpp @@ -24,9 +24,6 @@ #include "PixelShaderCache.h" #include "VertexShaderCache.h" -#undef CHECK -#define CHECK(cond, Message) if (!(cond)) { PanicAlert(__FUNCTION__ "Failed in %s at line %d: %s" , __FILE__, __LINE__, Message); } - FramebufferManager FBManager; ID3D11SamplerState* copytoVirtualXFBsampler = NULL; @@ -47,7 +44,7 @@ void FramebufferManager::Create() // create framebuffer color texture m_efb.color_tex = D3DTexture2D::Create(target_width, target_height, (D3D11_BIND_FLAG)(D3D11_BIND_RENDER_TARGET|D3D11_BIND_SHADER_RESOURCE), D3D11_USAGE_DEFAULT, DXGI_FORMAT_R8G8B8A8_UNORM); - CHECK(m_efb.color_tex != NULL, "create EFB color texture"); + CHECK(m_efb.color_tex!=NULL, "create EFB color texture (size: %dx%d)", target_width, target_height); D3D::SetDebugObjectName((ID3D11DeviceChild*)m_efb.color_tex->GetTex(), "EFB color texture"); D3D::SetDebugObjectName((ID3D11DeviceChild*)m_efb.color_tex->GetRTV(), "EFB color texture render target view"); D3D::SetDebugObjectName((ID3D11DeviceChild*)m_efb.color_tex->GetSRV(), "EFB color texture shader resource view"); @@ -55,14 +52,14 @@ void FramebufferManager::Create() // create a staging texture for Renderer::AccessEFB texdesc = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_R8G8B8A8_UNORM, 1, 1, 1, 1, 0, D3D11_USAGE_STAGING, D3D11_CPU_ACCESS_WRITE|D3D11_CPU_ACCESS_READ); hr = D3D::device->CreateTexture2D(&texdesc, NULL, &m_efb.color_staging_buf); - CHECK(hr==S_OK, "create EFB color staging buffer"); + CHECK(hr==S_OK, "create EFB color staging buffer (hr=%#x)", hr); D3D::SetDebugObjectName((ID3D11DeviceChild*)m_efb.color_staging_buf, "EFB color staging texture (used for Renderer::AccessEFB)"); // EFB depth buffer // TODO: Only bind as shader resource if EFB access enabled texdesc = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_R24G8_TYPELESS, target_width, target_height, 1, 1, D3D11_BIND_DEPTH_STENCIL|D3D11_BIND_SHADER_RESOURCE); hr = D3D::device->CreateTexture2D(&texdesc, NULL, &buf); - CHECK(hr==S_OK, "create EFB depth texture"); + CHECK(hr==S_OK, "create EFB depth texture (size: %dx%d; hr=%#x)", target_width, target_height, hr); m_efb.depth_tex = new D3DTexture2D(buf, (D3D11_BIND_FLAG)(D3D11_BIND_DEPTH_STENCIL|D3D11_BIND_SHADER_RESOURCE), DXGI_FORMAT_R24_UNORM_X8_TYPELESS, DXGI_FORMAT_D24_UNORM_S8_UINT); buf->Release(); D3D::SetDebugObjectName((ID3D11DeviceChild*)m_efb.depth_tex->GetTex(), "EFB depth texture"); @@ -72,7 +69,7 @@ void FramebufferManager::Create() // render target for depth buffer access in Renderer::AccessEFB texdesc = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_R32_FLOAT, 4, 4, 1, 1, D3D11_BIND_RENDER_TARGET); hr = D3D::device->CreateTexture2D(&texdesc, NULL, &buf); - CHECK(hr==S_OK, "create EFB depth read texture"); + CHECK(hr==S_OK, "create EFB depth read texture (hr=%#x)", hr); m_efb.depth_read_texture = new D3DTexture2D(buf, D3D11_BIND_RENDER_TARGET); buf->Release(); D3D::SetDebugObjectName((ID3D11DeviceChild*)m_efb.depth_read_texture->GetTex(), "EFB depth read texture (used in Renderer::AccessEFB)"); @@ -81,7 +78,7 @@ void FramebufferManager::Create() // staging texture to which we copy the data from m_efb.depth_read_texture texdesc = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_R32_FLOAT, 4, 4, 1, 1, 0, D3D11_USAGE_STAGING, D3D11_CPU_ACCESS_READ|D3D11_CPU_ACCESS_WRITE); hr = D3D::device->CreateTexture2D(&texdesc, NULL, &m_efb.depth_staging_buf); - CHECK(hr==S_OK, "create EFB depth staging buffer"); + CHECK(hr==S_OK, "create EFB depth staging buffer (hr=%#x)", hr); D3D::SetDebugObjectName((ID3D11DeviceChild*)m_efb.depth_staging_buf, "EFB depth staging texture (used for Renderer::AccessEFB)"); // sampler state for FramebufferManager::copyToVirtualXFB diff --git a/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp b/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp index 14c073672e..64032990a3 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp @@ -24,7 +24,7 @@ #include "TextureConverter.h" #undef CHECK -#define CHECK(hr, Message) if (FAILED(hr)) { PanicAlert(__FUNCTION__ " FAIL: %s" , Message); } +#define CHECK(hr, Message, ...) if (FAILED(hr)) { PanicAlert(__FUNCTION__ "Failed in %s at line %d: " Message, __FILE__, __LINE__, __VA_ARGS__); } FramebufferManager FBManager;