37 lines
1.2 KiB
C
37 lines
1.2 KiB
C
/* SPDX-License-Identifier:BSD-3-Clause */
|
|
#include "framebuffer.h"
|
|
#include "../../core/log.h"
|
|
#include <stdlib.h>
|
|
|
|
void vk_framebuffers_init(struct renderer_context *context)
|
|
{
|
|
context->swapchain.framebuffers = malloc(sizeof(VkFramebuffer) * context->swapchain.image_count);
|
|
|
|
for (u32 i = 0; i < context->swapchain.image_count; i++) {
|
|
VkImageView attachments[] = { context->swapchain.image_views[i] };
|
|
|
|
VkFramebufferCreateInfo framebuffer_info = {
|
|
.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
|
|
.renderPass = context->render_pass,
|
|
.attachmentCount = 1,
|
|
.pAttachments = attachments,
|
|
.width = context->swapchain.extent.width,
|
|
.height = context->swapchain.extent.height,
|
|
.layers = 1
|
|
};
|
|
|
|
if (vkCreateFramebuffer(context->device, &framebuffer_info, NULL, &context->swapchain.framebuffers[i]) != VK_SUCCESS) {
|
|
fatal("Can't create framebuffer.\n");
|
|
}
|
|
}
|
|
|
|
log_info("Framebuffers created.\n");
|
|
}
|
|
|
|
void vk_framebuffers_deinit(struct renderer_context *context)
|
|
{
|
|
for (u32 i = 0; i < context->swapchain.image_count; i++) {
|
|
vkDestroyFramebuffer(context->device, context->swapchain.framebuffers[i], NULL);
|
|
}
|
|
free(context->swapchain.framebuffers);
|
|
}
|