mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
Merge pull request #2026 from mrgreywater/d3d-debugbreak
D3D: More debug information and break on error
This commit is contained in:
@ -32,6 +32,7 @@ namespace D3D
|
||||
ID3D11Device* device = nullptr;
|
||||
ID3D11DeviceContext* context = nullptr;
|
||||
static IDXGISwapChain* swapchain = nullptr;
|
||||
static ID3D11Debug* debug = nullptr;
|
||||
D3D_FEATURE_LEVEL featlevel;
|
||||
D3DTexture2D* backbuf = nullptr;
|
||||
HWND hWnd;
|
||||
@ -263,8 +264,7 @@ HRESULT Create(HWND wnd)
|
||||
UpdateActiveConfig();
|
||||
}
|
||||
|
||||
DXGI_SWAP_CHAIN_DESC swap_chain_desc;
|
||||
memset(&swap_chain_desc, 0, sizeof(swap_chain_desc));
|
||||
DXGI_SWAP_CHAIN_DESC swap_chain_desc = {};
|
||||
swap_chain_desc.BufferCount = 1;
|
||||
swap_chain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||
swap_chain_desc.OutputWindow = wnd;
|
||||
@ -272,12 +272,10 @@ HRESULT Create(HWND wnd)
|
||||
swap_chain_desc.SampleDesc.Quality = 0;
|
||||
swap_chain_desc.Windowed = !g_Config.bFullscreen;
|
||||
|
||||
DXGI_OUTPUT_DESC out_desc;
|
||||
memset(&out_desc, 0, sizeof(out_desc));
|
||||
DXGI_OUTPUT_DESC out_desc = {};
|
||||
output->GetDesc(&out_desc);
|
||||
|
||||
DXGI_MODE_DESC mode_desc;
|
||||
memset(&mode_desc, 0, sizeof(mode_desc));
|
||||
DXGI_MODE_DESC mode_desc = {};
|
||||
mode_desc.Width = out_desc.DesktopCoordinates.right - out_desc.DesktopCoordinates.left;
|
||||
mode_desc.Height = out_desc.DesktopCoordinates.bottom - out_desc.DesktopCoordinates.top;
|
||||
mode_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
@ -302,6 +300,27 @@ HRESULT Create(HWND wnd)
|
||||
supported_feature_levels, NUM_SUPPORTED_FEATURE_LEVELS,
|
||||
D3D11_SDK_VERSION, &swap_chain_desc, &swapchain, &device,
|
||||
&featlevel, &context);
|
||||
// Debugbreak on D3D error
|
||||
if (SUCCEEDED(hr) && SUCCEEDED(device->QueryInterface(__uuidof(ID3D11Debug), (void**)&debug)))
|
||||
{
|
||||
ID3D11InfoQueue* infoQueue = nullptr;
|
||||
if (SUCCEEDED(debug->QueryInterface(__uuidof(ID3D11InfoQueue), (void**)&infoQueue)))
|
||||
{
|
||||
infoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_CORRUPTION, true);
|
||||
infoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_ERROR, true);
|
||||
|
||||
D3D11_MESSAGE_ID hide[] =
|
||||
{
|
||||
D3D11_MESSAGE_ID_SETPRIVATEDATA_CHANGINGPARAMS
|
||||
};
|
||||
|
||||
D3D11_INFO_QUEUE_FILTER filter = {};
|
||||
filter.DenyList.NumIDs = sizeof(hide) / sizeof(D3D11_MESSAGE_ID);
|
||||
filter.DenyList.pIDList = hide;
|
||||
infoQueue->AddStorageFilterEntries(&filter);
|
||||
infoQueue->Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (FAILED(hr))
|
||||
@ -375,6 +394,21 @@ void Close()
|
||||
|
||||
SAFE_RELEASE(context);
|
||||
ULONG references = device->Release();
|
||||
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
if (debug)
|
||||
{
|
||||
--references; // the debug interface increases the refcount of the device, subtract that.
|
||||
if (references)
|
||||
{
|
||||
// print out alive objects, but only if we actually have pending references
|
||||
// note this will also print out internal live objects to the debug console
|
||||
debug->ReportLiveDeviceObjects(D3D11_RLDO_SUMMARY | D3D11_RLDO_DETAIL);
|
||||
}
|
||||
SAFE_RELEASE(debug)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (references)
|
||||
{
|
||||
ERROR_LOG(VIDEO, "Unreleased references: %i.", references);
|
||||
|
Reference in New Issue
Block a user