vulkan framebuffers

This commit is contained in:
Greg Wells
2025-05-29 12:26:02 -04:00
parent 9a43b15fb7
commit 5158bef0dd
6 changed files with 54 additions and 3 deletions

View File

@@ -0,0 +1,34 @@
#include "vulkan_framebuffer.h"
#include "textures/vulkan_texture.h"
#include "renderpass/vulkan_render_pass_descriptor.h"
#include "output_device/vulkan_output_devices.h"
gnReturnCode gnCreateFramebufferFn(struct gnFramebuffer_t* framebuffer, struct gnOutputDevice_t* device, struct gnFramebufferInfo_t info) {
framebuffer->framebuffer = malloc(sizeof(struct gnPlatformFramebuffer_t));
VkImageView* attachments = malloc(sizeof(VkImageView) * info.attachmentCount);
for (int i = 0; i < info.attachmentCount; i++)
attachments[i] = info.attachments[i].texture->imageView;
VkFramebufferCreateInfo framebufferInfo = {
.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
.renderPass = info.renderPassDescriptor->renderPassDescriptor->renderPass,
.attachmentCount = info.attachmentCount,
.pAttachments = attachments,
.width = info.size.x,
.height = info.size.y,
.layers = 1
};
if (vkCreateFramebuffer(device->outputDevice->device, &framebufferInfo, NULL, &framebuffer->framebuffer->framebuffer) != VK_SUCCESS) {
return GN_FAILED_TO_CREATE_FRAMEBUFFER;
}
free(attachments);
return GN_SUCCESS;
}
void gnDestroyFramebufferFn(struct gnFramebuffer_t* framebuffer) {
vkDestroyFramebuffer(framebuffer->device->outputDevice->device, framebuffer->framebuffer->framebuffer, NULL);
free(framebuffer->framebuffer);
}

View File

@@ -0,0 +1,7 @@
#pragma once
#include "core/framebuffer/gryphn_framebuffer.h"
#include <vulkan/vulkan.h>
typedef struct gnPlatformFramebuffer_t {
VkFramebuffer framebuffer;
} gnPlatformFramebuffer;