From a31e6335e5288e249ab93ea591159de129ceb1b4 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 8 Mar 2019 13:52:19 +0000 Subject: [PATCH] Fix handling of ID3D12Device3::OpenExistingHeap* * The descriptor returned by these heaps is actually impossible to satisfy, so we need to remove the SHARED flags to make it possible. --- renderdoc/driver/d3d12/d3d12_device_wrap.cpp | 9 +++++++++ renderdoc/driver/d3d12/d3d12_device_wrap3.cpp | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/renderdoc/driver/d3d12/d3d12_device_wrap.cpp b/renderdoc/driver/d3d12/d3d12_device_wrap.cpp index e524f0293..4c3b0e0b6 100644 --- a/renderdoc/driver/d3d12/d3d12_device_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_device_wrap.cpp @@ -1498,6 +1498,15 @@ bool WrappedID3D12Device::Serialise_CreatePlacedResource( // always allow SRVs on replay so we can inspect resources Descriptor.Flags &= ~D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE; + D3D12_HEAP_DESC heapDesc = pHeap->GetDesc(); + + // if the heap was from OpenExistingHeap* then we will have removed the shared flags from it as + // it's CPU-visible and impossible to share. + // That means any resources placed to it would have had this flag that we then need to remove as + // well. + if((heapDesc.Flags & D3D12_HEAP_FLAG_SHARED_CROSS_ADAPTER) == 0) + Descriptor.Flags &= ~D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER; + ID3D12Resource *ret = NULL; HRESULT hr = m_pDevice->CreatePlacedResource(Unwrap(pHeap), HeapOffset, &Descriptor, InitialState, pOptimizedClearValue, guid, (void **)&ret); diff --git a/renderdoc/driver/d3d12/d3d12_device_wrap3.cpp b/renderdoc/driver/d3d12/d3d12_device_wrap3.cpp index 9c3bb8312..347b07ae5 100644 --- a/renderdoc/driver/d3d12/d3d12_device_wrap3.cpp +++ b/renderdoc/driver/d3d12/d3d12_device_wrap3.cpp @@ -48,6 +48,9 @@ HRESULT WrappedID3D12Device::OpenExistingHeapFromAddress(const void *pAddress, R D3D12_HEAP_DESC heapDesc = wrapped->GetDesc(); + // remove SHARED flags that are not allowed on real heaps + heapDesc.Flags &= ~(D3D12_HEAP_FLAG_SHARED | D3D12_HEAP_FLAG_SHARED_CROSS_ADAPTER); + SCOPED_SERIALISE_CHUNK(D3D12Chunk::Device_CreateHeapFromAddress); Serialise_CreateHeap(ser, &heapDesc, riid, (void **)&wrapped); @@ -93,6 +96,9 @@ HRESULT WrappedID3D12Device::OpenExistingHeapFromFileMapping(HANDLE hFileMapping D3D12_HEAP_DESC heapDesc = wrapped->GetDesc(); + // remove SHARED flags that are not allowed on real heaps + heapDesc.Flags &= ~(D3D12_HEAP_FLAG_SHARED | D3D12_HEAP_FLAG_SHARED_CROSS_ADAPTER); + SCOPED_SERIALISE_CHUNK(D3D12Chunk::Device_CreateHeapFromFileMapping); Serialise_CreateHeap(ser, &heapDesc, riid, (void **)&wrapped);