MayaFlux 0.1.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 180 of file VKSwapchain.cpp.

183{
184 if (!m_context) {
186 "Cannot acquire image: no context set");
187 return std::nullopt;
188 }
189
190 vk::Device device = m_context->get_device();
191
192 try {
193 auto result = device.acquireNextImageKHR(
195 timeout_ns,
196 signal_semaphore,
197 nullptr);
198
199 if (result.result == vk::Result::eErrorOutOfDateKHR) {
200 return std::nullopt;
201 }
202
203 if (result.result != vk::Result::eSuccess && result.result != vk::Result::eSuboptimalKHR) {
205 "Failed to acquire swapchain image");
206 return std::nullopt;
207 }
208
209 return result.value;
210
211 } catch (const vk::SystemError& e) {
213 "Exception acquiring swapchain image: {}", e.what());
214 return std::nullopt;
215 }
216}
#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: