From 3041275d193fff32d597d8bfc06e9c1fb62166de Mon Sep 17 00:00:00 2001 From: asuessenbach Date: Mon, 17 Jul 2023 16:32:23 +0200 Subject: [PATCH] Fix assertion with layout_transitions sample. --- framework/core/command_buffer.cpp | 3 +-- framework/core/hpp_command_buffer.cpp | 3 +-- framework/core/render_pass.cpp | 14 ++++---------- framework/hpp_api_vulkan_sample.cpp | 3 +-- framework/rendering/postprocessing_renderpass.cpp | 7 +++---- 5 files changed, 10 insertions(+), 20 deletions(-) diff --git a/framework/core/command_buffer.cpp b/framework/core/command_buffer.cpp index 075f950f0..266d2bd76 100644 --- a/framework/core/command_buffer.cpp +++ b/framework/core/command_buffer.cpp @@ -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; diff --git a/framework/core/hpp_command_buffer.cpp b/framework/core/hpp_command_buffer.cpp index b13c8c922..6ef1a08f5 100644 --- a/framework/core/hpp_command_buffer.cpp +++ b/framework/core/hpp_command_buffer.cpp @@ -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; diff --git a/framework/core/render_pass.cpp b/framework/core/render_pass.cpp index f699577f3..4f5b11e28 100644 --- a/framework/core/render_pass.cpp +++ b/framework/core/render_pass.cpp @@ -120,9 +120,8 @@ std::vector get_attachment_descriptions(const std::vector &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()) { @@ -215,9 +214,7 @@ void set_attachment_layouts(std::vector &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; } @@ -324,9 +321,7 @@ void RenderPass::create_renderpass(const std::vector &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(i_attachment, initial_layout)); } @@ -411,8 +406,7 @@ void RenderPass::create_renderpass(const std::vector &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) { diff --git a/framework/hpp_api_vulkan_sample.cpp b/framework/hpp_api_vulkan_sample.cpp index 30232dc29..ad0508036 100644 --- a/framework/hpp_api_vulkan_sample.cpp +++ b/framework/hpp_api_vulkan_sample.cpp @@ -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: diff --git a/framework/rendering/postprocessing_renderpass.cpp b/framework/rendering/postprocessing_renderpass.cpp index 78945702f..33fd3b998 100644 --- a/framework/rendering/postprocessing_renderpass.cpp +++ b/framework/rendering/postprocessing_renderpass.cpp @@ -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