MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
VKFramebuffer.cpp
Go to the documentation of this file.
1#include "VKFramebuffer.hpp"
2
4
5namespace MayaFlux::Core {
6
7bool VKFramebuffer::create(vk::Device device,
8 vk::RenderPass render_pass,
9 const std::vector<vk::ImageView>& attachments,
10 uint32_t width,
11 uint32_t height,
12 uint32_t layers)
13{
14
15 if (attachments.empty()) {
17 "Cannot create framebuffer with no attachments");
18 return false;
19 }
20
21 if (width == 0 || height == 0) {
23 "Cannot create framebuffer with zero dimensions ({}x{})", width, height);
24 return false;
25 }
26
27 m_width = width;
28 m_height = height;
29 m_layers = layers;
30
31 vk::FramebufferCreateInfo framebuffer_info {};
32 framebuffer_info.renderPass = render_pass;
33 framebuffer_info.attachmentCount = static_cast<uint32_t>(attachments.size());
34 framebuffer_info.pAttachments = attachments.data();
35 framebuffer_info.width = width;
36 framebuffer_info.height = height;
37 framebuffer_info.layers = layers;
38
39 try {
40 m_framebuffer = device.createFramebuffer(framebuffer_info);
41
43 "Framebuffer created ({}x{}, {} attachments)",
44 width, height, attachments.size());
45
46 return true;
47 } catch (const vk::SystemError& e) {
49 "Failed to create framebuffer: {}", e.what());
50 return false;
51 }
52}
53
54void VKFramebuffer::cleanup(vk::Device device)
55{
56 if (m_framebuffer) {
57 device.destroyFramebuffer(m_framebuffer);
58 m_framebuffer = nullptr;
59 m_width = 0;
60 m_height = 0;
61 m_layers = 1;
62 }
63}
64
65} // namespace MayaFlux::Core
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
void cleanup(vk::Device device)
Cleanup framebuffer.
bool create(vk::Device device, vk::RenderPass render_pass, const std::vector< vk::ImageView > &attachments, uint32_t width, uint32_t height, uint32_t layers=1)
Create framebuffer.
@ GraphicsBackend
Graphics/visual rendering backend (Vulkan, OpenGL)
@ Core
Core engine, backend, subsystems.