From 7648a55f8d3e684e32cc94a55ae596a67d6a0c98 Mon Sep 17 00:00:00 2001 From: pupbrained Date: Tue, 1 Oct 2024 18:33:05 -0400 Subject: [PATCH] Framebuffers --- src/main.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 3d12239..d395d07 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -66,6 +66,8 @@ class VulkanApp { vk::UniquePipelineLayout mPipelineLayout; vk::UniquePipeline mGraphicsPipeline; + std::vector mSwapChainFramebuffers; + struct QueueFamilyIndices { std::optional graphics_family; std::optional present_family; @@ -117,6 +119,7 @@ class VulkanApp { createImageViews(); createRenderPass(); createGraphicsPipeline(); + createFramebuffers(); } fn mainLoop() -> void { @@ -444,6 +447,23 @@ class VulkanApp { mGraphicsPipeline = mDevice->createGraphicsPipelineUnique(nullptr, pipelineInfo).value; } + fn createFramebuffers() -> void { + mSwapChainFramebuffers.resize(mSwapChainImageViews.size()); + + for (usize i = 0; i < mSwapChainImageViews.size(); i++) { + vk::FramebufferCreateInfo framebufferInfo { + .renderPass = mRenderPass.get(), + .attachmentCount = 1, + .pAttachments = &mSwapChainImageViews[i].get(), + .width = mSwapChainExtent.width, + .height = mSwapChainExtent.height, + .layers = 1, + }; + + mSwapChainFramebuffers[i] = mDevice->createFramebufferUnique(framebufferInfo); + } + } + fn createShaderModule(const std::vector& code) -> vk::UniqueShaderModule { vk::ShaderModuleCreateInfo createInfo { .codeSize = code.size(), .pCode = std::bit_cast(code.data()) };