mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Merge pull request #2026 from mrgreywater/d3d-debugbreak
D3D: More debug information and break on error
This commit is contained in:
commit
268b8fd26f
@ -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);
|
||||
|
@ -70,10 +70,29 @@ void SetDebugObjectName(T resource, const char* name)
|
||||
static_assert(std::is_convertible<T, ID3D11DeviceChild*>::value,
|
||||
"resource must be convertible to ID3D11DeviceChild*");
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
resource->SetPrivateData(WKPDID_D3DDebugObjectName, (UINT)strlen(name), name);
|
||||
if (resource)
|
||||
resource->SetPrivateData(WKPDID_D3DDebugObjectName, (UINT)(name ? strlen(name) : 0), name);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string GetDebugObjectName(T resource)
|
||||
{
|
||||
static_assert(std::is_convertible<T, ID3D11DeviceChild*>::value,
|
||||
"resource must be convertible to ID3D11DeviceChild*");
|
||||
std::string name;
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
if (resource)
|
||||
{
|
||||
UINT size = 0;
|
||||
resource->GetPrivateData(WKPDID_D3DDebugObjectName, &size, nullptr); //get required size
|
||||
name.resize(size);
|
||||
resource->GetPrivateData(WKPDID_D3DDebugObjectName, &size, const_cast<char*>(name.data()));
|
||||
}
|
||||
#endif
|
||||
return name;
|
||||
}
|
||||
|
||||
} // namespace D3D
|
||||
|
||||
typedef HRESULT (WINAPI* CREATEDXGIFACTORY)(REFIID, void**);
|
||||
|
@ -253,6 +253,11 @@ ID3D11PixelShader* PSTextureEncoder::SetStaticShader(unsigned int dstFormat, PEC
|
||||
HRESULT hr = D3D::device->CreatePixelShader(bytecode->Data(), bytecode->Size(), nullptr, &newShader);
|
||||
CHECK(SUCCEEDED(hr), "create efb encoder pixel shader");
|
||||
|
||||
char debugName[255] = {};
|
||||
sprintf_s(debugName, "efb encoder pixel shader (dst:%d, src:%d, intensity:%d, scale:%d)",
|
||||
dstFormat, srcFormat, isIntensity, scaleByHalf);
|
||||
D3D::SetDebugObjectName(newShader, debugName);
|
||||
|
||||
it = m_staticShaders.insert(std::make_pair(key, newShader)).first;
|
||||
bytecode->Release();
|
||||
}
|
||||
|
@ -361,8 +361,8 @@ void XFBEncoder::Encode(u8* dst, u32 width, u32 height, const EFBRectangle& srcR
|
||||
D3D::context->Unmap(m_outStage, 0);
|
||||
|
||||
// Restore API
|
||||
|
||||
g_renderer->RestoreAPIState();
|
||||
D3D::stateman->Apply(); // force unbind efb texture as shader resource
|
||||
D3D::context->OMSetRenderTargets(1,
|
||||
&FramebufferManager::GetEFBColorTexture()->GetRTV(),
|
||||
FramebufferManager::GetEFBDepthTexture()->GetDSV());
|
||||
|
Loading…
Reference in New Issue
Block a user