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.
This commit is contained in:
baldurk
2019-03-08 15:40:11 +00:00
parent db89f50a30
commit a31e6335e5
2 changed files with 15 additions and 0 deletions
@@ -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);
@@ -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);