You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We also want to return the Image, Image View, and size upon successful acquisition of the underlying Swapchain Image. Wrapping those in a `struct`:
25
+
26
+
```cpp
27
+
struct RenderTarget {
28
+
vk::Image image{};
29
+
vk::ImageView image_view{};
30
+
vk::Extent2D extent{};
31
+
};
32
+
```
33
+
34
+
VulkanHPP's primary API throws if the `vk::Result` corresponds to an error (based on the spec). `eErrorOutOfDateKHR` is technically an error, but it's quite possible to get it when the framebuffer size doesn't match the Swapchain size. To avoid having to deal with exceptions here, we use the alternate API for the acquire and present calls (overloads distinguished by pointer arguments and/or out parameters, and returning a `vk::Result`).
auto Swapchain::present(vk::Queue const queue, vk::Semaphore const to_wait)
61
+
-> bool {
62
+
assert(m_image_index);
63
+
auto const image_index = static_cast<std::uint32_t>(*m_image_index);
64
+
auto present_info = vk::PresentInfoKHR{};
65
+
present_info.setSwapchains(*m_swapchain)
66
+
.setImageIndices(image_index)
67
+
.setWaitSemaphores(to_wait);
68
+
auto const result = queue.presentKHR(&present_info);
69
+
m_image_index.reset();
70
+
return !needs_recreation(result);
71
+
}
72
+
```
73
+
74
+
It is the responsibility of the user (`class App`) to recreate the Swapchain on receiving `std::nullopt` / `false` return values for either operation. Users will also need to transition the layouts of the returned images between acquire and present operations. Add a helper to assist in that process, and extract the Image Subresource Range out as a common constant:
0 commit comments