Framebuffers

This commit is contained in:
Mars 2024-10-01 18:33:05 -04:00
parent e0b7e93bd8
commit 7648a55f8d
Signed by untrusted user: pupbrained
GPG key ID: 0FF5B8826803F895

View file

@ -66,6 +66,8 @@ class VulkanApp {
vk::UniquePipelineLayout mPipelineLayout; vk::UniquePipelineLayout mPipelineLayout;
vk::UniquePipeline mGraphicsPipeline; vk::UniquePipeline mGraphicsPipeline;
std::vector<vk::UniqueFramebuffer> mSwapChainFramebuffers;
struct QueueFamilyIndices { struct QueueFamilyIndices {
std::optional<u32> graphics_family; std::optional<u32> graphics_family;
std::optional<u32> present_family; std::optional<u32> present_family;
@ -117,6 +119,7 @@ class VulkanApp {
createImageViews(); createImageViews();
createRenderPass(); createRenderPass();
createGraphicsPipeline(); createGraphicsPipeline();
createFramebuffers();
} }
fn mainLoop() -> void { fn mainLoop() -> void {
@ -444,6 +447,23 @@ class VulkanApp {
mGraphicsPipeline = mDevice->createGraphicsPipelineUnique(nullptr, pipelineInfo).value; 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<char>& code) -> vk::UniqueShaderModule { fn createShaderModule(const std::vector<char>& code) -> vk::UniqueShaderModule {
vk::ShaderModuleCreateInfo createInfo { .codeSize = code.size(), vk::ShaderModuleCreateInfo createInfo { .codeSize = code.size(),
.pCode = std::bit_cast<const u32*>(code.data()) }; .pCode = std::bit_cast<const u32*>(code.data()) };