[WIP] Add descriptors and pipeline builder

This commit is contained in:
Piotr Krygier committed 2025-06-20 13:44:33 +02:00
1 parent 173a82b9d1
commit f8eb98ddf4
36 files changed
+613 -458

No files matched your search

+13 -9
View File
@@ -1,5 +1,5 @@
/**
* @file vulkanBase.cpp
* @file vulkanBase.cp
* @author Piotr Krygier (everyonecancode@gmail.com)
* @brief Base configuration for Vulkan API
* @version 0.1
@@ -27,6 +27,7 @@
#include "vk_mem_alloc.h"
// #pragma GCC diagnostic pop
#include "utilities/commons.h"
#include "utilities/errors_common.h"
#include "utilities/logger.h"
#include "vulkan/vulkan_core.h"
@@ -35,8 +36,10 @@
#include "vulkan_commons.h"
#include "vulkan_commands.h"
#include "vulkan_buffers.h"
#include "vulkan_descriptors.h"
#include "vulkan_image.h"
#include "vulkan_render_pass.h"
#include "vulkan_swapchain.h"
#include "pipeline_builder.h"
#include <stddef.h>
#include <stdlib.h>
@@ -558,9 +561,11 @@ rse_err_t init_vulkan(struct graphics_context_t* context)
STATUS_CHECK(pick_physical_device(context->instance, &context->physical_device));
STATUS_CHECK(create_device(context));
STATUS_CHECK(create_memory_allocator(context));
STATUS_CHECK(create_render_pass(context));
STATUS_CHECK(init_commands(context));
STATUS_CHECK(create_buffers(context));
STATUS_CHECK(init_vulkan_images(context));
STATUS_CHECK(create_swapchain_and_framebuffers(context));
return status;
}
@@ -569,7 +574,6 @@ rse_err_t run_vulkan(struct graphics_context_t* context)
{
rse_err_t status = RSE_ERROR_NO_ERROR;
STATUS_CHECK(create_descriptors(context));
STATUS_CHECK(create_sync_objects(context));
init_time();
@@ -596,7 +600,7 @@ rse_err_t draw_frame(struct graphics_context_t* context)
VK_NULL_HANDLE, &image_index);
if (result == VK_ERROR_OUT_OF_DATE_KHR) {
recreate_swapchain();
recreate_swapchain(context);
return RSE_ERROR_NO_ERROR;
} else if (result != VK_SUCCESS && result != VK_SUBOPTIMAL_KHR) {
LOGF(_("Failed to acquire swapchain image\n"));
@@ -646,7 +650,7 @@ rse_err_t draw_frame(struct graphics_context_t* context)
if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR || context->is_framebuffer_resized) {
context->is_framebuffer_resized = false;
recreate_swapchain();
recreate_swapchain(context);
} else if (result != VK_SUCCESS) {
LOGF(_("Failed to submit draw command buffer!\n"));
return VULKAN_ERROR_DRAW_FAILED;
@@ -659,8 +663,6 @@ rse_err_t draw_frame(struct graphics_context_t* context)
void deinit_vulkan(struct graphics_context_t* context)
{
cleanup_swapchain();
destroy_descriptors();
destroy_buffers(context);
for (size_t i = 0; i < SWAP_BUFFER_COUNT; ++i) {
vkDestroySemaphore(context->device, context->image_available_semaphores[i], NULL);
@@ -668,11 +670,13 @@ void deinit_vulkan(struct graphics_context_t* context)
vkDestroyFence(context->device, context->in_flight_fences[i], NULL);
}
destroy_textures();
destroy_textures(context);
destroy_commands(context);
destroy_pipeline();
destroy_render_pass(context);
cleanup_swapchain(context);
destroy_pipelines(context);
vmaDestroyAllocator(context->allocator);
vkDestroyDevice(context->device, NULL);