mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Try to merge subresource states for resources that were split apart
* When a barrier applies to only one subresource out of an image, it's split into individual subresource tracking. There's nothing to merge it back together again, so it remains split even if the subresources go back to all being in the same state again. Simply checking when fetching the frame-initial states if we can merge can be a big win.
This commit is contained in:
@@ -325,6 +325,40 @@ void VulkanResourceManager::SerialiseImageStates(map<ResourceId, ImageLayouts> &
|
||||
else
|
||||
++it;
|
||||
}
|
||||
|
||||
// try to merge images that have been split up by subresource but are now all in the same state
|
||||
// again.
|
||||
for(auto it = states.begin(); it != states.end(); ++it)
|
||||
{
|
||||
ImageLayouts &layouts = it->second;
|
||||
|
||||
if(layouts.subresourceStates.size() > 1 &&
|
||||
layouts.subresourceStates.size() == layouts.layerCount * layouts.levelCount)
|
||||
{
|
||||
VkImageLayout layout = layouts.subresourceStates[0].newLayout;
|
||||
|
||||
bool allIdentical = true;
|
||||
|
||||
for(size_t i = 0; i < layouts.subresourceStates.size(); i++)
|
||||
{
|
||||
if(layouts.subresourceStates[i].newLayout != layout)
|
||||
{
|
||||
allIdentical = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(allIdentical)
|
||||
{
|
||||
layouts.subresourceStates.erase(layouts.subresourceStates.begin() + 1,
|
||||
layouts.subresourceStates.end());
|
||||
layouts.subresourceStates[0].subresourceRange.baseArrayLayer = 0;
|
||||
layouts.subresourceStates[0].subresourceRange.baseMipLevel = 0;
|
||||
layouts.subresourceStates[0].subresourceRange.layerCount = layouts.layerCount;
|
||||
layouts.subresourceStates[0].subresourceRange.levelCount = layouts.levelCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VulkanResourceManager::MarkSparseMapReferenced(SparseMapping *sparse)
|
||||
|
||||
Reference in New Issue
Block a user