Fixed problems with image layouts and layout transitions.

This commit is contained in:
plapins 2017-02-21 12:53:27 +01:00
parent 0f8bed9fde
commit 2141145523
5 changed files with 16 additions and 30 deletions

View file

@ -28,7 +28,6 @@ namespace vks
VkFormat format;
VkImageSubresourceRange subresourceRange;
VkAttachmentDescription description;
VkImageLayout initialLayout;
/**
* @brief Returns true if the attachment has a depth component
@ -139,7 +138,6 @@ namespace vks
attachment.format = createinfo.format;
VkImageAspectFlags aspectMask = VK_FLAGS_NONE;
VkImageLayout imageLayout;
// Select aspect mask and layout depending on usage
@ -147,8 +145,6 @@ namespace vks
if (createinfo.usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT)
{
aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
attachment.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
imageLayout = (createinfo.usage & VK_IMAGE_USAGE_SAMPLED_BIT) ? VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL : VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
}
// Depth (and/or stencil) attachment
@ -162,8 +158,6 @@ namespace vks
{
aspectMask = aspectMask | VK_IMAGE_ASPECT_STENCIL_BIT;
}
attachment.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
imageLayout = (createinfo.usage & VK_IMAGE_USAGE_SAMPLED_BIT) ? VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL : VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
}
assert(aspectMask > 0);
@ -218,11 +212,11 @@ namespace vks
// If not, final layout depends on attachment type
if (attachment.hasDepth() || attachment.hasStencil())
{
attachment.description.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
attachment.description.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL;
}
else
{
attachment.description.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
attachment.description.finalLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
}
attachments.push_back(attachment);