vulkan command pools

This commit is contained in:
Greg Wells
2025-05-29 14:56:29 -04:00
parent 088d5a2adf
commit e3ec7619ed
7 changed files with 65 additions and 1 deletions

View File

@@ -0,0 +1,23 @@
#include "vulkan_command_pool.h"
#include "output_device/vulkan_output_devices.h"
gnReturnCode gnCreateCommandPoolFn(struct gnCommandPool_t* commandPool, struct gnOutputDevice_t* device, struct gnCommandPoolInfo_t info) {
commandPool->commandPool = malloc(sizeof(gnPlatformCommandPool));
VkCommandPoolCreateInfo poolInfo = {
.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,
.queueFamilyIndex = info.queueIndex
};
if (vkCreateCommandPool(device->outputDevice->device, &poolInfo, NULL, &commandPool->commandPool->commandPool) != VK_SUCCESS) {
return GN_FAILED_TO_CREATE_COMMAND_POOL;
}
return GN_SUCCESS;
}
void gnDestroyCommandPoolFn(struct gnCommandPool_t* commandPool) {
vkDestroyCommandPool(commandPool->device->outputDevice->device, commandPool->commandPool->commandPool, NULL);
free(commandPool->commandPool);
}

View File

@@ -0,0 +1,7 @@
#pragma once
#include <vulkan/vulkan.h>
#include "core/command/command_pool/gryphn_command_pool.h"
typedef struct gnPlatformCommandPool_t {
VkCommandPool commandPool;
} gnPlatformCommandPool;

View File

@@ -0,0 +1,11 @@
#include "gryphn_command_pool.h"
#include "core/gryphn_platform_functions.h"
gnReturnCode gnCreateCommandPool(struct gnCommandPool_t* commandPool, struct gnOutputDevice_t* device, struct gnCommandPoolInfo_t info) {
commandPool->device = device;
return device->deviceFunctions->_gnCreateCommandPool(commandPool, device, info);
}
void gnDestroyCommandPool(struct gnCommandPool_t* commandPool) {
commandPool->device->deviceFunctions->_gnDestroyCommandPool(commandPool);
}

View File

@@ -0,0 +1,15 @@
#pragma once
#include "stdint.h"
#include <core/output_device/gryphn_output_device.h>
typedef struct gnCommandPoolInfo_t {
uint32_t queueIndex;
} gnCommandPoolInfo;
typedef struct gnCommandPool_t {
struct gnPlatformCommandPool_t* commandPool;
struct gnOutputDevice_t* device;
} gnCommandPool;
gnReturnCode gnCreateCommandPool(struct gnCommandPool_t* commandPool, struct gnOutputDevice_t* device, struct gnCommandPoolInfo_t info);
void gnDestroyCommandPool(struct gnCommandPool_t* commandPool);

View File

@@ -11,6 +11,7 @@
#include "renderpass/gryphn_render_pass_descriptor.h" #include "renderpass/gryphn_render_pass_descriptor.h"
#include "pipelines/graphics_pipeline/gryphn_graphics_pipeline.h" #include "pipelines/graphics_pipeline/gryphn_graphics_pipeline.h"
#include "framebuffer/gryphn_framebuffer.h" #include "framebuffer/gryphn_framebuffer.h"
#include "command/command_pool/gryphn_command_pool.h"
typedef struct gnFunctions_t { typedef struct gnFunctions_t {
gnReturnCode (*_gnCreateInstance)(gnInstance* instance, struct gnInstanceInfo_t info); gnReturnCode (*_gnCreateInstance)(gnInstance* instance, struct gnInstanceInfo_t info);
@@ -66,4 +67,7 @@ typedef struct gnDeviceFunctions_t {
gnReturnCode (*_gnCreateFramebuffer)(struct gnFramebuffer_t* framebuffer, struct gnOutputDevice_t* device, struct gnFramebufferInfo_t framebufferInfo); gnReturnCode (*_gnCreateFramebuffer)(struct gnFramebuffer_t* framebuffer, struct gnOutputDevice_t* device, struct gnFramebufferInfo_t framebufferInfo);
void (*_gnDestroyFramebuffer)(struct gnFramebuffer_t* framebuffer); void (*_gnDestroyFramebuffer)(struct gnFramebuffer_t* framebuffer);
gnReturnCode (*_gnCreateCommandPool)(struct gnCommandPool_t* commandPool, struct gnOutputDevice_t* device, struct gnCommandPoolInfo_t info);
void (*_gnDestroyCommandPool)(struct gnCommandPool_t* commandPool);
} gnDeviceFunctions; } gnDeviceFunctions;

View File

@@ -79,4 +79,6 @@ void gnLoadDeviceFunctions(struct gnDynamicLibrary_t* lib, struct gnDeviceFuncti
gnLoadDLLFunction(lib, functions->_gnDestroyGraphicsPipeline, "gnDestroyGraphicsPipelineFn"); gnLoadDLLFunction(lib, functions->_gnDestroyGraphicsPipeline, "gnDestroyGraphicsPipelineFn");
gnLoadDLLFunction(lib, functions->_gnCreateFramebuffer, "gnCreateFramebufferFn"); gnLoadDLLFunction(lib, functions->_gnCreateFramebuffer, "gnCreateFramebufferFn");
gnLoadDLLFunction(lib, functions->_gnDestroyFramebuffer, "gnDestroyFramebufferFn"); gnLoadDLLFunction(lib, functions->_gnDestroyFramebuffer, "gnDestroyFramebufferFn");
gnLoadDLLFunction(lib, functions->_gnCreateCommandPool, "gnCreateCommandPoolFn");
gnLoadDLLFunction(lib, functions->_gnDestroyCommandPool, "gnDestroyCommandPoolFn");
} }

View File

@@ -26,7 +26,8 @@ typedef enum gnReturnCode_t {
GN_UNSUPPORTED_SHADER_MODULE, GN_UNSUPPORTED_SHADER_MODULE,
GN_UNKNOWN_SUBPASS, GN_UNKNOWN_SUBPASS,
GN_FAILED_TO_CREATE_FRAMEBUFFER, GN_FAILED_TO_CREATE_FRAMEBUFFER,
GN_DIVERGENT_RENDERPASS GN_DIVERGENT_RENDERPASS,
GN_FAILED_TO_CREATE_COMMAND_POOL
} gnReturnCode; } gnReturnCode;
typedef gnReturnCode gnErrorCode; typedef gnReturnCode gnErrorCode;
@@ -58,5 +59,6 @@ static const char* gnErrorCodeToCString(enum gnReturnCode_t returnCode) {
case GN_UNKNOWN_SUBPASS: return "GN_UNKNOWN_SUBPASS"; case GN_UNKNOWN_SUBPASS: return "GN_UNKNOWN_SUBPASS";
case GN_FAILED_TO_CREATE_FRAMEBUFFER: return "GN_FAILED_TO_CREATE_FRAMEBUFFER"; case GN_FAILED_TO_CREATE_FRAMEBUFFER: return "GN_FAILED_TO_CREATE_FRAMEBUFFER";
case GN_DIVERGENT_RENDERPASS: return "GN_DIVERGENT_RENDERPASS"; case GN_DIVERGENT_RENDERPASS: return "GN_DIVERGENT_RENDERPASS";
case GN_FAILED_TO_CREATE_COMMAND_POOL: return "GN_FAILED_TO_CREATE_COMMAND_POOL";
} }
} }