Skip to content

Commit

Permalink
Fix assertion with layout_transitions sample.
Browse files Browse the repository at this point in the history
  • Loading branch information
asuessenbach committed Jul 19, 2023
1 parent d98cfcc commit 3041275
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 20 deletions.
3 changes: 1 addition & 2 deletions framework/core/command_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,13 +679,12 @@ void CommandBuffer::flush_descriptor_state(VkPipelineBindPoint pipeline_bind_poi
image_info.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
break;
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
if (is_depth_stencil_format(image_view->get_format()))
if (is_depth_format(image_view->get_format()))
{
image_info.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL;
}
else
{
assert(!vkb::is_depth_format(image_view->get_format()));
image_info.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
}
break;
Expand Down
3 changes: 1 addition & 2 deletions framework/core/hpp_command_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,9 +701,8 @@ void HPPCommandBuffer::flush_descriptor_state(vk::PipelineBindPoint pipeline_bin
image_info.imageLayout = vk::ImageLayout::eShaderReadOnlyOptimal;
break;
case vk::DescriptorType::eInputAttachment:
assert(!vkb::common::is_depth_stencil_format(image_view->get_format()) || !vkb::common::is_depth_format(image_view->get_format()));
image_info.imageLayout =
vkb::common::is_depth_stencil_format(image_view->get_format()) ? vk::ImageLayout::eDepthStencilReadOnlyOptimal : vk::ImageLayout::eShaderReadOnlyOptimal;
vkb::common::is_depth_format(image_view->get_format()) ? vk::ImageLayout::eDepthStencilReadOnlyOptimal : vk::ImageLayout::eShaderReadOnlyOptimal;
break;
case vk::DescriptorType::eStorageImage:
image_info.imageLayout = vk::ImageLayout::eGeneral;
Expand Down
14 changes: 4 additions & 10 deletions framework/core/render_pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,8 @@ std::vector<T> get_attachment_descriptions(const std::vector<Attachment> &attach
attachment.format = attachments[i].format;
attachment.samples = attachments[i].samples;
attachment.initialLayout = attachments[i].initial_layout;
assert(!vkb::is_depth_stencil_format(attachment.format) || !vkb::is_depth_format(attachment.format));
attachment.finalLayout =
vkb::is_depth_stencil_format(attachment.format) ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
vkb::is_depth_format(attachment.format) ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;

if (i < load_store_infos.size())
{
Expand Down Expand Up @@ -215,9 +214,7 @@ void set_attachment_layouts(std::vector<T_SubpassDescription> &subpass_descripti
attachment_descriptions[reference.attachment].finalLayout = reference.layout;

// Do not use depth attachment if used as input
assert(!vkb::is_depth_stencil_format(attachment_descriptions[reference.attachment].format) ||
!vkb::is_depth_format(attachment_descriptions[reference.attachment].format));
if (vkb::is_depth_stencil_format(attachment_descriptions[reference.attachment].format))
if (vkb::is_depth_format(attachment_descriptions[reference.attachment].format))
{
subpass.pDepthStencilAttachment = nullptr;
}
Expand Down Expand Up @@ -324,9 +321,7 @@ void RenderPass::create_renderpass(const std::vector<Attachment> &attachments, c
// Fill input attachments references
for (auto i_attachment : subpass.input_attachments)
{
assert(!vkb::is_depth_stencil_format(attachment_descriptions[i_attachment].format) ||
!vkb::is_depth_format(attachment_descriptions[i_attachment].format));
auto default_layout = vkb::is_depth_stencil_format(attachment_descriptions[i_attachment].format) ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL : VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
auto default_layout = vkb::is_depth_format(attachment_descriptions[i_attachment].format) ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL : VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
auto initial_layout = attachments[i_attachment].initial_layout == VK_IMAGE_LAYOUT_UNDEFINED ? default_layout : attachments[i_attachment].initial_layout;
input_attachments[i].push_back(get_attachment_reference<T_AttachmentReference>(i_attachment, initial_layout));
}
Expand Down Expand Up @@ -411,8 +406,7 @@ void RenderPass::create_renderpass(const std::vector<Attachment> &attachments, c

for (uint32_t k = 0U; k < to_u32(attachment_descriptions.size()); ++k)
{
assert(!vkb::is_depth_stencil_format(attachments[k].format) || !vkb::is_depth_format(attachments[k].format));
if (vkb::is_depth_stencil_format(attachments[k].format))
if (vkb::is_depth_format(attachments[k].format))
{
if (default_depth_stencil_attachment == VK_ATTACHMENT_UNUSED)
{
Expand Down
3 changes: 1 addition & 2 deletions framework/hpp_api_vulkan_sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,8 +838,7 @@ vk::ImageLayout HPPApiVulkanSample::descriptor_type_to_image_layout(vk::Descript
{
case vk::DescriptorType::eCombinedImageSampler:
case vk::DescriptorType::eInputAttachment:
assert(!vkb::common::is_depth_stencil_format(format) || !vkb::common::is_depth_format(format));
return vkb::common::is_depth_stencil_format(format) ? vk::ImageLayout::eDepthStencilReadOnlyOptimal : vk::ImageLayout::eShaderReadOnlyOptimal;
return vkb::common::is_depth_format(format) ? vk::ImageLayout::eDepthStencilReadOnlyOptimal : vk::ImageLayout::eShaderReadOnlyOptimal;
case vk::DescriptorType::eStorageImage:
return vk::ImageLayout::eGeneral;
default:
Expand Down
7 changes: 3 additions & 4 deletions framework/rendering/postprocessing_renderpass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,9 @@ void PostProcessingRenderPass::transition_attachments(
for (uint32_t output : output_attachments)
{
assert(output < views.size());
const VkFormat attachment_format = views[output].get_format();
assert(!vkb::is_depth_stencil_format(attachment_format) || !vkb::is_depth_format(attachment_format));
const bool is_depth_stencil = vkb::is_depth_stencil_format(attachment_format);
const VkImageLayout output_layout = is_depth_stencil ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
const VkFormat attachment_format = views[output].get_format();
const bool is_depth_stencil = vkb::is_depth_format(attachment_format);
const VkImageLayout output_layout = is_depth_stencil ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
if (render_target.get_layout(output) == output_layout)
{
// No-op
Expand Down

0 comments on commit 3041275

Please sign in to comment.