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

◆ create_sync_objects()

bool MayaFlux::Core::BackendWindowHandler::create_sync_objects ( WindowRenderContext config)
private

Create synchronization objects for a window's swapchain.

Parameters
configWindow swapchain configuration to populate
Returns
True if creation succeeded

Definition at line 243 of file BackendWindowHandler.cpp.

244{
245 auto device = m_context.get_device();
246 uint32_t image_count = config.swapchain->get_image_count();
247
248 try {
249 config.image_available.resize(image_count);
250 config.render_finished.resize(image_count);
251 config.in_flight.resize(image_count);
252
253 vk::SemaphoreCreateInfo semaphore_info {};
254 vk::FenceCreateInfo fence_info {};
255 fence_info.flags = vk::FenceCreateFlagBits::eSignaled;
256
257 for (uint32_t i = 0; i < image_count; ++i) {
258 config.image_available[i] = device.createSemaphore(semaphore_info);
259 config.render_finished[i] = device.createSemaphore(semaphore_info);
260 }
261
262 for (auto& i : config.in_flight) {
263 i = device.createFence(fence_info);
264 }
265
266 config.current_frame = 0;
267
268 config.render_pass = std::make_unique<VKRenderPass>();
269 if (!config.render_pass->create(device, config.swapchain->get_image_format())) {
271 "Failed to create render pass");
272 return false;
273 }
274
275 config.framebuffers.resize(image_count);
276 auto extent = config.swapchain->get_extent();
277 const auto& image_views = config.swapchain->get_image_views();
278
279 for (uint32_t i = 0; i < image_count; ++i) {
280 config.framebuffers[i] = std::make_unique<VKFramebuffer>();
281
282 std::vector<vk::ImageView> attachments = { image_views[i] };
283
284 if (!config.framebuffers[i]->create(
285 device,
286 config.render_pass->get(),
287 attachments,
288 extent.width,
289 extent.height)) {
291 "Failed to create framebuffer {}", i);
292 return false;
293 }
294 }
295
296 return true;
297 } catch (const vk::SystemError& e) {
299 "Failed to create sync objects: {}", e.what());
300 return false;
301 }
302}
#define MF_RT_ERROR(comp, ctx,...)
vk::Device get_device() const
Get logical device.
Definition VKContext.hpp:49
@ GraphicsCallback
Graphics/visual rendering callback - frame-rate real-time.
@ Core
Core engine, backend, subsystems.

References MayaFlux::Journal::Core, MayaFlux::Core::WindowRenderContext::current_frame, MayaFlux::Core::WindowRenderContext::framebuffers, MayaFlux::Journal::GraphicsCallback, MayaFlux::Core::WindowRenderContext::image_available, MayaFlux::Core::WindowRenderContext::in_flight, MF_RT_ERROR, MayaFlux::Core::WindowRenderContext::render_finished, MayaFlux::Core::WindowRenderContext::render_pass, and MayaFlux::Core::WindowRenderContext::swapchain.

Referenced by register_window().

+ Here is the caller graph for this function: