MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ acquire_next_image()

std::optional< uint32_t > MayaFlux::Core::VKSwapchain::acquire_next_image ( vk::Semaphore  signal_semaphore,
uint64_t  timeout_ns = UINT64_MAX 
)

Acquire next image from swapchain.

Parameters
signal_semaphoreSemaphore to signal when image is acquired
timeout_nsTimeout in nanoseconds (UINT64_MAX = no timeout)
Returns
Image index, or empty if acquisition failed

Definition at line 187 of file VKSwapchain.cpp.

190{
191 if (!m_context) {
193 "Cannot acquire image: no context set");
194 return std::nullopt;
195 }
196
197 vk::Device device = m_context->get_device();
198
199 try {
200 auto result = device.acquireNextImageKHR(
202 timeout_ns,
203 signal_semaphore,
204 nullptr);
205
206 if (result.result == vk::Result::eErrorOutOfDateKHR) {
207 return std::nullopt;
208 }
209
210 if (result.result != vk::Result::eSuccess && result.result != vk::Result::eSuboptimalKHR) {
212 "Failed to acquire swapchain image");
213 return std::nullopt;
214 }
215
216 return result.value;
217
218 } catch (const vk::SystemError& e) {
220 "Exception acquiring swapchain image: {}", e.what());
221 return std::nullopt;
222 }
223}
#define MF_RT_ERROR(comp, ctx,...)
vk::Device get_device() const
Get logical device.
Definition VKContext.hpp:49
vk::SwapchainKHR m_swapchain
@ GraphicsBackend
Graphics/visual rendering backend (Vulkan, OpenGL)
@ Core
Core engine, backend, subsystems.

References MayaFlux::Journal::Core, MayaFlux::Core::VKContext::get_device(), MayaFlux::Journal::GraphicsBackend, m_context, m_swapchain, and MF_RT_ERROR.

+ Here is the call graph for this function: