1- # Swapchain Acquire/Present
1+ # Swapchain Update
22
33Swapchain acquire/present operations can have various results. We constrain ourselves to the following:
44
55- ` eSuccess ` : all good
6- - ` eSuboptimalKHR ` : also all good (this is also unlikely to occur on a desktop)
7- - ` eErrorOutOfDateKHR ` : Swapchain needs to be recreated, consider the operation to have not succeeded
6+ - ` eSuboptimalKHR ` : also all good (not an error, and this is unlikely to occur on a desktop)
7+ - ` eErrorOutOfDateKHR ` : Swapchain needs to be recreated
88- Any other ` vk::Result ` : fatal/unexpected error
99
1010Expressing as a helper function in ` swapchain.cpp ` :
@@ -59,8 +59,7 @@ Similarly, present:
5959```cpp
6060auto Swapchain::present(vk::Queue const queue, vk::Semaphore const to_wait)
6161 -> bool {
62- assert(m_image_index);
63- auto const image_index = static_cast<std::uint32_t>(*m_image_index);
62+ auto const image_index = static_cast<std::uint32_t>(m_image_index.value());
6463 auto present_info = vk::PresentInfoKHR{};
6564 present_info.setSwapchains(*m_swapchain)
6665 .setImageIndices(image_index)
@@ -84,10 +83,9 @@ constexpr auto subresource_range_v = [] {
8483
8584// ...
8685auto Swapchain::base_barrier () const -> vk::ImageMemoryBarrier2 {
87- assert (m_image_index);
8886 // fill up the parts common to all barriers.
8987 auto ret = vk::ImageMemoryBarrier2{};
90- ret.setImage(m_images.at(* m_image_index))
88+ ret.setImage(m_images.at(m_image_index.value() ))
9189 .setSubresourceRange(subresource_range_v)
9290 .setSrcQueueFamilyIndex(m_gpu.queue_family)
9391 .setDstQueueFamilyIndex(m_gpu.queue_family);
0 commit comments