Handle the typeless/typed castability fudging for backbuffers

This commit is contained in:
baldurk
2016-09-16 10:22:39 +02:00
parent fedc20dd36
commit b332404365
3 changed files with 41 additions and 1 deletions
+7 -1
View File
@@ -540,7 +540,7 @@ bool WrappedID3D12Device::Serialise_WrapSwapchainBuffer(WrappedIDXGISwapChain3 *
// DXGI swap chain back buffers can be freely cast as a special-case.
// translate the format to a typeless format to allow for this.
// the original type will be stored in the texture below
// the original type is stored separately below
Descriptor.Format = GetTypelessFormat(Descriptor.Format);
HRESULT hr = S_OK;
@@ -571,6 +571,8 @@ bool WrappedID3D12Device::Serialise_WrapSwapchainBuffer(WrappedIDXGISwapChain3 *
GetResourceManager()->AddLiveResource(TexID, fakeBB);
m_BackbufferFormat = std::make_pair(wrapped->GetResourceID(), swapFormat);
SubresourceStateVector &states = m_ResourceStates[wrapped->GetResourceID()];
states.resize(1, D3D12_RESOURCE_STATE_PRESENT);
@@ -611,6 +613,10 @@ IUnknown *WrappedID3D12Device::WrapSwapchainBuffer(WrappedIDXGISwapChain3 *swap,
record->SpecialResource = true;
record->Length = 0;
WrappedID3D12Resource *wrapped = (WrappedID3D12Resource *)pRes;
wrapped->SetResourceRecord(record);
SCOPED_LOCK(m_D3DLock);
SCOPED_SERIALISE_CONTEXT(CREATE_SWAP_BUFFER);
+2
View File
@@ -288,6 +288,7 @@ private:
};
map<WrappedIDXGISwapChain3 *, SwapPresentInfo> m_SwapChains;
pair<ResourceId, DXGI_FORMAT> m_BackbufferFormat;
WrappedIDXGISwapChain3 *m_LastSwap;
@@ -329,6 +330,7 @@ public:
return m_ResourceStates[id];
}
const pair<ResourceId, DXGI_FORMAT> GetBackbufferFormat() { return m_BackbufferFormat; }
void SetLogFile(const char *logfile);
void SetLogVersion(uint32_t fileversion) { m_InitParams.SerialiseVersion = fileversion; }
D3D12Replay *GetReplay() { return &m_Replay; }
+32
View File
@@ -145,6 +145,18 @@ void D3D12Descriptor::Create(WrappedID3D12Device *dev, D3D12_CPU_DESCRIPTOR_HAND
if(desc->ViewDimension == D3D12_SRV_DIMENSION_UNKNOWN)
{
desc = nonsamp.resource ? NULL : defaultSRV();
// fixup for backbuffers
if(dev->GetBackbufferFormat().first == GetResID(nonsamp.resource))
{
D3D12_SHADER_RESOURCE_VIEW_DESC bbDesc = {};
bbDesc.Format = dev->GetBackbufferFormat().second;
bbDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
bbDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
bbDesc.Texture2D.MipLevels = 1;
dev->CreateShaderResourceView(nonsamp.resource, &bbDesc, handle);
return;
}
}
dev->CreateShaderResourceView(nonsamp.resource, desc, handle);
@@ -156,6 +168,16 @@ void D3D12Descriptor::Create(WrappedID3D12Device *dev, D3D12_CPU_DESCRIPTOR_HAND
if(desc->ViewDimension == D3D12_RTV_DIMENSION_UNKNOWN)
{
desc = nonsamp.resource ? NULL : defaultRTV();
// fixup for backbuffers
if(dev->GetBackbufferFormat().first == GetResID(nonsamp.resource))
{
D3D12_RENDER_TARGET_VIEW_DESC bbDesc = {};
bbDesc.Format = dev->GetBackbufferFormat().second;
bbDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D;
dev->CreateRenderTargetView(nonsamp.resource, &bbDesc, handle);
return;
}
}
dev->CreateRenderTargetView(nonsamp.resource, desc, handle);
@@ -178,6 +200,16 @@ void D3D12Descriptor::Create(WrappedID3D12Device *dev, D3D12_CPU_DESCRIPTOR_HAND
if(uavdesc.ViewDimension == D3D12_SRV_DIMENSION_UNKNOWN)
{
desc = nonsamp.resource ? NULL : defaultUAV();
// fixup for backbuffers
if(dev->GetBackbufferFormat().first == GetResID(nonsamp.resource))
{
D3D12_UNORDERED_ACCESS_VIEW_DESC bbDesc = {};
bbDesc.Format = dev->GetBackbufferFormat().second;
bbDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D;
dev->CreateUnorderedAccessView(nonsamp.resource, NULL, &bbDesc, handle);
return;
}
}
dev->CreateUnorderedAccessView(nonsamp.resource, nonsamp.uav.counterResource, desc, handle);