From 35b13a8e8fd2a331854dba6da81a20452e142d6f Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 1 Jun 2023 13:00:03 +0100 Subject: [PATCH] Remove UAV flag from BCn textures for calling GetCopyableFootprints * This can happen when using the new format casting functionality, if the base type is BCn but UAV is allowed for an RGBA32_UINT cast. --- renderdoc/driver/d3d12/d3d12_initstate.cpp | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/renderdoc/driver/d3d12/d3d12_initstate.cpp b/renderdoc/driver/d3d12/d3d12_initstate.cpp index 86ab35eb93..bfa6fe4e0c 100644 --- a/renderdoc/driver/d3d12/d3d12_initstate.cpp +++ b/renderdoc/driver/d3d12/d3d12_initstate.cpp @@ -283,6 +283,12 @@ bool D3D12ResourceManager::Prepare_InitialState(ID3D12DeviceChild *res) rdcarray copyLayouts; rdcarray subresources; + if(IsBlockFormat(desc.Format) && (desc.Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS)) + { + RDCDEBUG("Removing UAV flag from BCn desc to allow GetCopyableFootprints"); + desc.Flags &= ~D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; + } + for(UINT i = 0; i < numSubresources; i++) { // skip non-MSAA sparse subresources that are not mapped at all @@ -292,6 +298,12 @@ bool D3D12ResourceManager::Prepare_InitialState(ID3D12DeviceChild *res) UINT64 subSize = 0; m_Device->GetCopyableFootprints(&desc, i, 1, bufDesc.Width, &layout, NULL, NULL, &subSize); + if(subSize == ~0ULL) + { + RDCERR("Failed to call GetCopyableFootprints on %s! skipping copy", ToStr(id).c_str()); + continue; + } + copyLayouts.push_back(layout); subresources.push_back(i); bufDesc.Width += subSize; @@ -1248,6 +1260,12 @@ void D3D12ResourceManager::Apply_InitialState(ID3D12DeviceChild *live, UINT64 offset = 0; UINT64 subSize = 0; + if(IsBlockFormat(desc.Format) && (desc.Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS)) + { + RDCDEBUG("Removing UAV flag from BCn desc to allow GetCopyableFootprints"); + desc.Flags &= ~D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; + } + for(UINT i = 0; i < numSubresources; i++) { // if we have a list of subresources included, only copy those @@ -1266,6 +1284,12 @@ void D3D12ResourceManager::Apply_InitialState(ID3D12DeviceChild *live, m_Device->GetCopyableFootprints(&desc, i, 1, offset, &src.PlacedFootprint, NULL, NULL, &subSize); + if(subSize == ~0ULL) + { + RDCERR("Failed to call GetCopyableFootprints on %s! skipping copy", ToStr(id).c_str()); + continue; + } + list->CopyTextureRegion(&dst, 0, 0, 0, &src, NULL); offset += subSize;