Skip to content

Commit

Permalink
Remove UAV flag from BCn textures for calling GetCopyableFootprints
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
baldurk committed Jun 1, 2023
1 parent 00dc732 commit 35b13a8
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions renderdoc/driver/d3d12/d3d12_initstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,12 @@ bool D3D12ResourceManager::Prepare_InitialState(ID3D12DeviceChild *res)
rdcarray<D3D12_PLACED_SUBRESOURCE_FOOTPRINT> copyLayouts;
rdcarray<uint32_t> 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
Expand 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;
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit 35b13a8

Please sign in to comment.