Make sure to set stencil aspect flag correctly when handling images

This commit is contained in:
baldurk
2016-06-08 14:12:54 -07:00
parent 0105967ebc
commit b722ddf16d
3 changed files with 27 additions and 3 deletions
+15 -3
View File
@@ -1074,7 +1074,9 @@ bool WrappedVulkan::Prepare_InitialState(WrappedVkRes *res)
RDCASSERTEQUAL(vkr, VK_SUCCESS);
VkImageAspectFlags aspectFlags = VK_IMAGE_ASPECT_COLOR_BIT;
if(IsDepthStencilFormat(layout->format))
if(IsStencilOnlyFormat(layout->format))
aspectFlags = VK_IMAGE_ASPECT_STENCIL_BIT;
else if(IsDepthStencilFormat(layout->format))
aspectFlags = VK_IMAGE_ASPECT_DEPTH_BIT;
VkImageMemoryBarrier srcimBarrier = {
@@ -1089,6 +1091,9 @@ bool WrappedVulkan::Prepare_InitialState(WrappedVkRes *res)
im->real.As<VkImage>(),
{aspectFlags, 0, (uint32_t)layout->levelCount, 0, (uint32_t)layout->layerCount}};
if(aspectFlags == VK_IMAGE_ASPECT_DEPTH_BIT && !IsDepthOnlyFormat(layout->format))
srcimBarrier.subresourceRange.aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT;
// update the real image layout into transfer-source
srcimBarrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
@@ -1619,7 +1624,9 @@ bool WrappedVulkan::Serialise_InitialState(ResourceId resid, WrappedVkRes *)
VkImageAspectFlags aspectFlags = VK_IMAGE_ASPECT_COLOR_BIT;
VkFormat fmt = m_CreationInfo.m_Image[liveim->id].format;
if(IsDepthStencilFormat(fmt))
if(IsStencilOnlyFormat(fmt))
aspectFlags = VK_IMAGE_ASPECT_STENCIL_BIT;
else if(IsDepthStencilFormat(fmt))
aspectFlags = VK_IMAGE_ASPECT_DEPTH_BIT;
VkImageMemoryBarrier srcimBarrier = {
@@ -2069,7 +2076,9 @@ void WrappedVulkan::Apply_InitialState(WrappedVkRes *live,
VkImageAspectFlags aspectFlags = VK_IMAGE_ASPECT_COLOR_BIT;
VkFormat fmt = m_CreationInfo.m_Image[id].format;
if(IsDepthStencilFormat(fmt))
if(IsStencilOnlyFormat(fmt))
aspectFlags = VK_IMAGE_ASPECT_STENCIL_BIT;
else if(IsDepthStencilFormat(fmt))
aspectFlags = VK_IMAGE_ASPECT_DEPTH_BIT;
VkImageMemoryBarrier dstimBarrier = {
@@ -2084,6 +2093,9 @@ void WrappedVulkan::Apply_InitialState(WrappedVkRes *live,
ToHandle<VkImage>(live),
{aspectFlags, 0, 1, 0, (uint32_t)m_CreationInfo.m_Image[id].arrayLayers}};
if(aspectFlags == VK_IMAGE_ASPECT_DEPTH_BIT && !IsDepthOnlyFormat(fmt))
dstimBarrier.subresourceRange.aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT;
// loop over every mip
for(int m = 0; m < m_CreationInfo.m_Image[id].mipLevels; m++)
{
+11
View File
@@ -235,6 +235,17 @@ bool IsDepthOnlyFormat(VkFormat f)
return false;
}
bool IsStencilOnlyFormat(VkFormat f)
{
switch(f)
{
case VK_FORMAT_S8_UINT: return true;
default: break;
}
return false;
}
bool IsSRGBFormat(VkFormat f)
{
switch(f)
+1
View File
@@ -1064,6 +1064,7 @@ bool IsBlockFormat(VkFormat f);
bool IsDepthStencilFormat(VkFormat f);
bool IsDepthOnlyFormat(VkFormat f);
bool IsStencilFormat(VkFormat f);
bool IsStencilOnlyFormat(VkFormat f);
bool IsSRGBFormat(VkFormat f);
bool IsUIntFormat(VkFormat f);
bool IsSIntFormat(VkFormat f);