Handle creating backbuffer views with non-NULL non-typed descriptor

* We already handle the case where e.g. D3D12_RENDER_TARGET_VIEW_DESC is NULL
  and we need to substitute in a typed descriptor for backbuffers. We didn't
  handle the case where
This commit is contained in:
baldurk
2019-02-25 13:16:01 +00:00
parent 2507532623
commit 2dc37ac232
3 changed files with 50 additions and 3 deletions
+4 -2
View File
@@ -547,9 +547,10 @@ D3D12_CPU_DESCRIPTOR_HANDLE D3D12DebugManager::GetTempDescriptor(const D3D12Desc
const D3D12_RENDER_TARGET_VIEW_DESC *rtvdesc = &desc.GetRTV();
if(rtvdesc->ViewDimension == D3D12_RTV_DIMENSION_UNKNOWN)
{
rtvdesc = NULL;
if(rtvdesc == NULL || rtvdesc->Format == DXGI_FORMAT_UNKNOWN)
{
const std::map<ResourceId, DXGI_FORMAT> &bbs = m_pDevice->GetBackbufferFormats();
auto it = bbs.find(GetResID(res));
@@ -589,9 +590,10 @@ D3D12_CPU_DESCRIPTOR_HANDLE D3D12DebugManager::GetTempDescriptor(const D3D12Desc
const D3D12_UNORDERED_ACCESS_VIEW_DESC *uavdesc = &unpacked;
if(uavdesc->ViewDimension == D3D12_UAV_DIMENSION_UNKNOWN)
{
uavdesc = NULL;
if(uavdesc == NULL || uavdesc->Format == DXGI_FORMAT_UNKNOWN)
{
const std::map<ResourceId, DXGI_FORMAT> &bbs = m_pDevice->GetBackbufferFormats();
auto it = bbs.find(GetResID(res));
+1 -1
View File
@@ -871,7 +871,7 @@ bool WrappedID3D12Device::Serialise_WrapSwapchainBuffer(SerialiserType &ser,
WrappedID3D12Resource1 *pRes = (WrappedID3D12Resource1 *)realSurface;
SERIALISE_ELEMENT(Buffer);
SERIALISE_ELEMENT_LOCAL(SwapbufferID, GetResID(pRes)).TypedAs("IDXGISwapChain *");
SERIALISE_ELEMENT_LOCAL(SwapbufferID, GetResID(pRes)).TypedAs("ID3D12Resource *");
SERIALISE_ELEMENT_LOCAL(BackbufferDescriptor, pRes->GetDesc());
SERIALISE_CHECK_READ_ERRORS();
+45
View File
@@ -187,6 +187,21 @@ void D3D12Descriptor::Create(D3D12_DESCRIPTOR_HEAP_TYPE heapType, WrappedID3D12D
// by referring to a resource that was deleted), use a default descriptor
desc = defaultSRV();
}
else if(desc->Format == DXGI_FORMAT_UNKNOWN)
{
const map<ResourceId, DXGI_FORMAT> &bbs = dev->GetBackbufferFormats();
auto it = bbs.find(GetResID(res));
// fixup for backbuffers
if(it != bbs.end())
{
D3D12_SHADER_RESOURCE_VIEW_DESC bbDesc = *desc;
bbDesc.Format = it->second;
dev->CreateShaderResourceView(res, &bbDesc, handle);
return;
}
}
D3D12_SHADER_RESOURCE_VIEW_DESC planeDesc;
// ensure that multi-plane formats have a valid plane slice specified. This shouldn't be
@@ -262,6 +277,21 @@ void D3D12Descriptor::Create(D3D12_DESCRIPTOR_HEAP_TYPE heapType, WrappedID3D12D
// by referring to a resource that was deleted), use a default descriptor
desc = defaultRTV();
}
else if(desc->Format == DXGI_FORMAT_UNKNOWN)
{
const map<ResourceId, DXGI_FORMAT> &bbs = dev->GetBackbufferFormats();
auto it = bbs.find(GetResID(res));
// fixup for backbuffers
if(it != bbs.end())
{
D3D12_RENDER_TARGET_VIEW_DESC bbDesc = *desc;
bbDesc.Format = it->second;
dev->CreateRenderTargetView(res, &bbDesc, handle);
return;
}
}
D3D12_RENDER_TARGET_VIEW_DESC planeDesc;
// ensure that multi-plane formats have a valid plane slice specified. This shouldn't be
@@ -356,6 +386,21 @@ void D3D12Descriptor::Create(D3D12_DESCRIPTOR_HEAP_TYPE heapType, WrappedID3D12D
// default descriptor
desc = defaultUAV();
}
else if(desc->Format == DXGI_FORMAT_UNKNOWN)
{
const map<ResourceId, DXGI_FORMAT> &bbs = dev->GetBackbufferFormats();
auto it = bbs.find(GetResID(res));
// fixup for backbuffers
if(it != bbs.end())
{
D3D12_UNORDERED_ACCESS_VIEW_DESC bbDesc = *desc;
bbDesc.Format = it->second;
dev->CreateUnorderedAccessView(res, NULL, &bbDesc, handle);
return;
}
}
if(countRes == NULL && desc && desc->ViewDimension == D3D12_UAV_DIMENSION_BUFFER)
desc->Buffer.CounterOffsetInBytes = 0;