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

221{
222 if (!m_context) {
224 "Cannot present: no context set");
225 return false;
226 }
227
228 vk::Queue queue = present_queue ? present_queue : m_context->get_graphics_queue();
229
230 vk::PresentInfoKHR present_info {};
231 present_info.waitSemaphoreCount = 1;
232 present_info.pWaitSemaphores = &wait_semaphore;
233
234 present_info.swapchainCount = 1;
235 present_info.pSwapchains = &m_swapchain;
236 present_info.pImageIndices = &image_index;
237 present_info.pResults = nullptr;
238
239 try {
240 auto result = queue.presentKHR(present_info);
241
242 if (result == vk::Result::eErrorOutOfDateKHR || result == vk::Result::eSuboptimalKHR) {
243 return false;
244 }
245
246 if (result != vk::Result::eSuccess) {
248 "Failed to present swapchain image");
249 return false;
250 }
251
252 return true;
253
254 } catch (const vk::SystemError& e) {
256 "Exception presenting swapchain image: {}", e.what());
257 return false;
258 }
259}
#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: