Remove DENY_SHADER_RESOURCE flag on MSAA textures in D3D12

* We need to use MSAA textures as SRVs for copying them out in initial states.
This commit is contained in:
baldurk
2019-06-27 10:22:14 +01:00
parent ada5e55b28
commit 9b70400eff
+24 -2
View File
@@ -1382,10 +1382,21 @@ HRESULT WrappedID3D12Device::CreateCommittedResource(const D3D12_HEAP_PROPERTIES
if(riidResource != __uuidof(ID3D12Resource) && riidResource != __uuidof(ID3D12Resource1))
return E_NOINTERFACE;
const D3D12_RESOURCE_DESC *pCreateDesc = pDesc;
D3D12_RESOURCE_DESC localDesc;
if(pDesc && pDesc->Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE2D && pDesc->SampleDesc.Count > 1)
{
localDesc = *pDesc;
// need to be able to create SRVs of MSAA textures to copy out their contents
localDesc.Flags &= ~D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE;
pCreateDesc = &localDesc;
}
void *realptr = NULL;
HRESULT ret;
SERIALISE_TIME_CALL(ret = m_pDevice->CreateCommittedResource(
pHeapProperties, HeapFlags, pDesc, InitialResourceState,
pHeapProperties, HeapFlags, pCreateDesc, InitialResourceState,
pOptimizedClearValue, riidResource, &realptr));
ID3D12Resource *real = NULL;
@@ -1649,9 +1660,20 @@ HRESULT WrappedID3D12Device::CreatePlacedResource(ID3D12Heap *pHeap, UINT64 Heap
if(riid != __uuidof(ID3D12Resource))
return E_NOINTERFACE;
const D3D12_RESOURCE_DESC *pCreateDesc = pDesc;
D3D12_RESOURCE_DESC localDesc;
if(pDesc && pDesc->Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE2D && pDesc->SampleDesc.Count > 1)
{
localDesc = *pDesc;
// need to be able to create SRVs of MSAA textures to copy out their contents
localDesc.Flags &= ~D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE;
pCreateDesc = &localDesc;
}
ID3D12Resource *real = NULL;
HRESULT ret;
SERIALISE_TIME_CALL(ret = m_pDevice->CreatePlacedResource(Unwrap(pHeap), HeapOffset, pDesc,
SERIALISE_TIME_CALL(ret = m_pDevice->CreatePlacedResource(Unwrap(pHeap), HeapOffset, pCreateDesc,
InitialState, pOptimizedClearValue,
riid, (void **)&real));