Fix image subresource order

When importing captures from v1.6 and before, the order that image
subresource states are listed in the capture differs from the order
expected in `ImageState`. This change sorts the subresources into the
correct order before importing.

Change-Id: I1bb1420bc79e39ba8e1fb2e932307a218878e1c2
This commit is contained in:
Benson Joeris
2020-03-05 10:46:00 -05:00
committed by Baldur Karlsson
parent fac4367cae
commit bc56fd091d
2 changed files with 28 additions and 0 deletions
+4
View File
@@ -320,7 +320,11 @@ void VulkanResourceManager::SerialiseImageStates(SerialiserType &ser,
}
if(!subresourceStates.empty())
{
std::sort(subresourceStates.begin(), subresourceStates.end(),
ImageSubresourceStateForRange::CompareRangeBegin);
imageState.subresourceStates.FromArray(subresourceStates);
}
imageState.maxRefType = eFrameRef_Unknown;
}
}
+24
View File
@@ -1317,6 +1317,30 @@ struct ImageSubresourceStateForRange
{
ImageSubresourceRange range;
ImageSubresourceState state;
inline static bool CompareRangeBegin(const ImageSubresourceStateForRange &x,
const ImageSubresourceStateForRange &y)
{
const ImageSubresourceRange &rx = x.range;
const ImageSubresourceRange &ry = y.range;
// Find the first (least significant) aspcet bit
VkImageAspectFlags ax = *ImageAspectFlagIter::begin(rx.aspectMask);
VkImageAspectFlags ay = *ImageAspectFlagIter::begin(ry.aspectMask);
if(ax == ay)
{
if(rx.baseMipLevel == ry.baseMipLevel)
{
if(rx.baseArrayLayer == ry.baseArrayLayer)
{
return rx.baseDepthSlice < ry.baseDepthSlice;
}
return rx.baseArrayLayer < ry.baseArrayLayer;
}
return rx.baseMipLevel < ry.baseMipLevel;
}
return ax < ay;
}
};
DECLARE_REFLECTION_STRUCT(ImageSubresourceStateForRange);