Skip to content

Commit 4a5c502

Browse files
committed
Cleanup
1 parent f02c582 commit 4a5c502

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed
-1.27 MB
Binary file not shown.

guide/src/rendering/swapchain_update.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Swapchain Acquire/Present
1+
# Swapchain Update
22

33
Swapchain 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

1010
Expressing as a helper function in `swapchain.cpp`:
@@ -59,8 +59,7 @@ Similarly, present:
5959
```cpp
6060
auto 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
// ...
8685
auto 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);

src/swapchain.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,9 @@ auto Swapchain::acquire_next_image(vk::Semaphore const to_signal)
137137
}
138138

139139
auto Swapchain::base_barrier() const -> vk::ImageMemoryBarrier2 {
140-
assert(m_image_index);
141140
// fill up the parts common to all barriers.
142141
auto ret = vk::ImageMemoryBarrier2{};
143-
ret.setImage(m_images.at(*m_image_index))
142+
ret.setImage(m_images.at(m_image_index.value()))
144143
.setSubresourceRange(subresource_range_v)
145144
.setSrcQueueFamilyIndex(m_gpu.queue_family)
146145
.setDstQueueFamilyIndex(m_gpu.queue_family);
@@ -149,8 +148,7 @@ auto Swapchain::base_barrier() const -> vk::ImageMemoryBarrier2 {
149148

150149
auto Swapchain::present(vk::Queue const queue, vk::Semaphore const to_wait)
151150
-> bool {
152-
assert(m_image_index);
153-
auto const image_index = static_cast<std::uint32_t>(*m_image_index);
151+
auto const image_index = static_cast<std::uint32_t>(m_image_index.value());
154152
auto present_info = vk::PresentInfoKHR{};
155153
present_info.setSwapchains(*m_swapchain)
156154
.setImageIndices(image_index)

0 commit comments

Comments
 (0)