d3d12: Add a dummy D3D12Lib struct that load/unload d3d12.dll

It allows to unload the lib after everything else has been released, it
fixes a crash when leaving an app with d3d12 backend.
This commit is contained in:
Vincent Lejeune 2015-08-14 23:02:46 +02:00
parent 09cc127dd9
commit 3b0afe92e3
2 changed files with 21 additions and 4 deletions

View File

@ -203,8 +203,18 @@ bool D3D12GSRender::invalidateTexture(u32 addr)
return handled;
}
D3D12DLLManagement::D3D12DLLManagement()
{
loadD3D12FunctionPointers();
}
D3D12DLLManagement::~D3D12DLLManagement()
{
unloadD3D12FunctionPointers();
}
D3D12GSRender::D3D12GSRender()
: GSRender(), m_PSO(nullptr)
: GSRender(), m_D3D12Lib(), m_PSO(nullptr)
{
gfxHandler = [this](u32 addr) {
bool result = invalidateTexture(addr);
@ -212,7 +222,6 @@ D3D12GSRender::D3D12GSRender()
LOG_WARNING(RSX, "Reporting Cell writing to %x", addr);
return result;
};
loadD3D12FunctionPointers();
if (Ini.GSDebugOutputEnable.GetValue())
{
Microsoft::WRL::ComPtr<ID3D12Debug> debugInterface;
@ -383,7 +392,6 @@ D3D12GSRender::~D3D12GSRender()
for (auto &tmp : m_texturesCache)
tmp.second->Release();
m_outputScalingPass.Release();
unloadD3D12FunctionPointers();
}
void D3D12GSRender::Close()

View File

@ -227,12 +227,22 @@ struct GarbageCollectionThread
void waitForCompletion();
};
/**
* Structure used to load/unload D3D12 lib.
*/
struct D3D12DLLManagement
{
D3D12DLLManagement();
~D3D12DLLManagement();
};
class D3D12GSRender : public GSRender
{
private:
/** D3D12 structures.
* Note: they should be declared in reverse order of destruction
*/
D3D12DLLManagement m_D3D12Lib;
ComPtr<ID3D12Device> m_device;
ComPtr<ID3D12CommandQueue> m_commandQueueGraphic;
ComPtr<struct IDXGISwapChain3> m_swapChain;
@ -240,7 +250,6 @@ private:
ComPtr<ID3D12DescriptorHeap> m_backbufferAsRendertarget[2];
// m_rootSignatures[N] is RS with N texture/sample
ComPtr<ID3D12RootSignature> m_rootSignatures[17];
/**
* Mutex protecting m_texturesCache and m_Textoclean access
* Memory protection fault catch can be generated by any thread and