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

◆ present()

bool MayaFlux::Core::VKSwapchain::present ( uint32_t  image_index,
vk::Semaphore  wait_semaphore,
vk::Queue  present_queue = nullptr 
)

Present image to screen.

Parameters
image_indexIndex of image to present
wait_semaphoreSemaphore to wait on before presenting
present_queueQueue to submit present operation to (optional, uses context's graphics queue if null)
Returns
True if present succeeded, false if swapchain out of date

Definition at line 226 of file VKSwapchain.cpp.

229{
230 if (!m_context) {
232 "Cannot present: no context set");
233 return false;
234 }
235
236 vk::Queue queue = present_queue ? present_queue : m_context->get_graphics_queue();
237
238 vk::PresentInfoKHR present_info {};
239 present_info.waitSemaphoreCount = 1;
240 present_info.pWaitSemaphores = &wait_semaphore;
241
242 present_info.swapchainCount = 1;
243 present_info.pSwapchains = &m_swapchain;
244 present_info.pImageIndices = &image_index;
245 present_info.pResults = nullptr;
246
247 try {
248 auto result = queue.presentKHR(present_info);
249
250 if (result == vk::Result::eErrorOutOfDateKHR || result == vk::Result::eSuboptimalKHR) {
251 return false;
252 }
253
254 if (result != vk::Result::eSuccess) {
256 "Failed to present swapchain image");
257 return false;
258 }
259
260 return true;
261
262 } catch (const vk::SystemError& e) {
264 "Exception presenting swapchain image: {}", e.what());
265 return false;
266 }
267}
#define MF_RT_ERROR(comp, ctx,...)
vk::Queue get_graphics_queue() const
Get graphics queue.
Definition VKContext.hpp:54
@ GraphicsBackend
Graphics/visual rendering backend (Vulkan, OpenGL)
@ Core
Core engine, backend, subsystems.

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

+ Here is the call graph for this function: