Skip to content

Commit 566d8f3

Browse files
committed
Explicitly ignore return values from Vulkan functions in RenderFrame
Because these functions can return statuses that aren't strictly an error (and thus don't raise an exception), but might have to be handled, they return a `vk::Result` that's `[[nodiscard]]`. Ideally some of the result statuses would be handled here, but to get it to compile, cast the result to void.
1 parent 2f74aca commit 566d8f3

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

code/graphics/vulkan/RenderFrame.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ void RenderFrame::waitForFinish()
2020
return;
2121
}
2222

23-
m_device.waitForFences(m_frameInFlightFence.get(), true, std::numeric_limits<uint64_t>::max());
23+
// waitForFences can theoretically return a timeout, but as this passes the maximum uint64_t value in microseconds,
24+
// this won't happen in practice, and the result can be ignored.
25+
(void)m_device.waitForFences(m_frameInFlightFence.get(), true, std::numeric_limits<uint64_t>::max());
2426
m_device.resetFences(m_frameInFlightFence.get());
2527

2628
// That frame is now definitely not in flight anymore so we can call the functions that depend on that
@@ -41,11 +43,14 @@ uint32_t RenderFrame::acquireSwapchainImage()
4143
Assertion(!m_inFlight, "Cannot acquire swapchain image when frame is still in flight.");
4244

4345
uint32_t imageIndex;
44-
m_device.acquireNextImageKHR(m_swapChain,
46+
vk::Result res = m_device.acquireNextImageKHR(m_swapChain,
4547
std::numeric_limits<uint64_t>::max(),
4648
m_imageAvailableSemaphore.get(),
4749
nullptr,
4850
&imageIndex);
51+
// TODO: This should handle at least VK_SUBOPTIMAL_KHR, which means that the swap chain is no longer
52+
// optimal and should be recreated.
53+
(void)res;
4954

5055
m_swapChainIdx = imageIndex;
5156

@@ -85,7 +90,10 @@ void RenderFrame::submitAndPresent(const std::vector<vk::CommandBuffer>& cmdBuff
8590
presentInfo.pImageIndices = &m_swapChainIdx;
8691
presentInfo.pResults = nullptr;
8792

88-
m_presentQueue.presentKHR(presentInfo);
93+
vk::Result res = m_presentQueue.presentKHR(presentInfo);
94+
// TODO: This should handle at least VK_SUBOPTIMAL_KHR, which means that the swap chain is no longer
95+
// optimal and should be recreated.
96+
(void)res;
8997
}
9098

9199
} // namespace vulkan

0 commit comments

Comments
 (0)