mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-23 06:56:40 +00:00
Handle strange D3D12 singleton device per adapter behaviour. Refs #1595
This commit is contained in:
@@ -40,6 +40,9 @@
|
||||
|
||||
WRAPPED_POOL_INST(WrappedID3D12Device);
|
||||
|
||||
Threading::CriticalSection WrappedID3D12Device::m_DeviceWrappersLock;
|
||||
std::map<ID3D12Device *, WrappedID3D12Device *> WrappedID3D12Device::m_DeviceWrappers;
|
||||
|
||||
void WrappedID3D12Device::RemoveQueue(WrappedID3D12CommandQueue *queue)
|
||||
{
|
||||
auto it = std::remove_if(m_Queues.begin(), m_Queues.end(),
|
||||
@@ -445,6 +448,11 @@ WrappedID3D12Device::WrappedID3D12Device(ID3D12Device *realDevice, D3D12InitPara
|
||||
RDCDEBUG("Couldn't get ID3D12InfoQueue.");
|
||||
}
|
||||
|
||||
{
|
||||
SCOPED_LOCK(m_DeviceWrappersLock);
|
||||
m_DeviceWrappers[m_pDevice] = this;
|
||||
}
|
||||
|
||||
if(!RenderDoc::Inst().IsReplayApp())
|
||||
{
|
||||
FirstFrame(NULL);
|
||||
@@ -453,6 +461,11 @@ WrappedID3D12Device::WrappedID3D12Device(ID3D12Device *realDevice, D3D12InitPara
|
||||
|
||||
WrappedID3D12Device::~WrappedID3D12Device()
|
||||
{
|
||||
{
|
||||
SCOPED_LOCK(m_DeviceWrappersLock);
|
||||
m_DeviceWrappers.erase(m_pDevice);
|
||||
}
|
||||
|
||||
RenderDoc::Inst().RemoveDeviceFrameCapturer((ID3D12Device *)this);
|
||||
|
||||
if(!m_InternalCmds.pendingcmds.empty())
|
||||
@@ -530,6 +543,23 @@ WrappedID3D12Device::~WrappedID3D12Device()
|
||||
RenderDoc::Inst().GetCrashHandler()->UnregisterMemoryRegion(this);
|
||||
}
|
||||
|
||||
WrappedID3D12Device *WrappedID3D12Device::Create(ID3D12Device *realDevice, D3D12InitParams params,
|
||||
bool enabledDebugLayer)
|
||||
{
|
||||
{
|
||||
SCOPED_LOCK(m_DeviceWrappersLock);
|
||||
|
||||
auto it = m_DeviceWrappers.find(realDevice);
|
||||
if(it != m_DeviceWrappers.end())
|
||||
{
|
||||
it->second->AddRef();
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
|
||||
return new WrappedID3D12Device(realDevice, params, enabledDebugLayer);
|
||||
}
|
||||
|
||||
HRESULT WrappedID3D12Device::QueryInterface(REFIID riid, void **ppvObject)
|
||||
{
|
||||
// DEFINE_GUID(IID_IDirect3DDevice9, 0xd0223b96, 0xbf7a, 0x43fd, 0x92, 0xbd, 0xa4, 0x3b, 0xd,
|
||||
|
||||
@@ -506,6 +506,9 @@ private:
|
||||
|
||||
bool m_debugLayerEnabled;
|
||||
|
||||
static Threading::CriticalSection m_DeviceWrappersLock;
|
||||
static std::map<ID3D12Device *, WrappedID3D12Device *> m_DeviceWrappers;
|
||||
|
||||
public:
|
||||
static const int AllocPoolCount = 4;
|
||||
ALLOCATE_WITH_WRAPPED_POOL(WrappedID3D12Device, AllocPoolCount);
|
||||
@@ -514,6 +517,9 @@ public:
|
||||
bool IsDebugLayerEnabled() const { return m_debugLayerEnabled; }
|
||||
virtual ~WrappedID3D12Device();
|
||||
|
||||
static WrappedID3D12Device *Create(ID3D12Device *realDevice, D3D12InitParams params,
|
||||
bool enabledDebugLayer);
|
||||
|
||||
UINT GetUnwrappedDescriptorIncrement(D3D12_DESCRIPTOR_HEAP_TYPE type)
|
||||
{
|
||||
return m_DescriptorIncrements[type];
|
||||
|
||||
@@ -343,7 +343,7 @@ private:
|
||||
dev = (ID3D12Device *)dev6;
|
||||
}
|
||||
|
||||
WrappedID3D12Device *wrap = new WrappedID3D12Device(dev, params, EnableDebugLayer);
|
||||
WrappedID3D12Device *wrap = WrappedID3D12Device::Create(dev, params, EnableDebugLayer);
|
||||
|
||||
RDCDEBUG("created wrapped device.");
|
||||
|
||||
|
||||
@@ -207,6 +207,7 @@ rdcstr DoStringise(const long &el)
|
||||
switch(hr)
|
||||
{
|
||||
STRINGISE_ENUM(S_OK)
|
||||
STRINGISE_ENUM(S_FALSE)
|
||||
STRINGISE_ENUM(DXGI_ERROR_INVALID_CALL)
|
||||
STRINGISE_ENUM(DXGI_ERROR_NOT_FOUND)
|
||||
STRINGISE_ENUM(DXGI_ERROR_DEVICE_REMOVED)
|
||||
|
||||
Reference in New Issue
Block a user