MayaFlux 0.4.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 225 of file VKSwapchain.cpp.

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