vulkan command pools
This commit is contained in:
@@ -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);
|
||||
}
|
@@ -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;
|
11
src/core/command/command_pool/gryphn_command_pool.c
Normal file
11
src/core/command/command_pool/gryphn_command_pool.c
Normal 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);
|
||||
}
|
15
src/core/command/command_pool/gryphn_command_pool.h
Normal file
15
src/core/command/command_pool/gryphn_command_pool.h
Normal 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);
|
@@ -11,6 +11,7 @@
|
||||
#include "renderpass/gryphn_render_pass_descriptor.h"
|
||||
#include "pipelines/graphics_pipeline/gryphn_graphics_pipeline.h"
|
||||
#include "framebuffer/gryphn_framebuffer.h"
|
||||
#include "command/command_pool/gryphn_command_pool.h"
|
||||
|
||||
typedef struct gnFunctions_t {
|
||||
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);
|
||||
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;
|
||||
|
@@ -79,4 +79,6 @@ void gnLoadDeviceFunctions(struct gnDynamicLibrary_t* lib, struct gnDeviceFuncti
|
||||
gnLoadDLLFunction(lib, functions->_gnDestroyGraphicsPipeline, "gnDestroyGraphicsPipelineFn");
|
||||
gnLoadDLLFunction(lib, functions->_gnCreateFramebuffer, "gnCreateFramebufferFn");
|
||||
gnLoadDLLFunction(lib, functions->_gnDestroyFramebuffer, "gnDestroyFramebufferFn");
|
||||
gnLoadDLLFunction(lib, functions->_gnCreateCommandPool, "gnCreateCommandPoolFn");
|
||||
gnLoadDLLFunction(lib, functions->_gnDestroyCommandPool, "gnDestroyCommandPoolFn");
|
||||
}
|
||||
|
@@ -26,7 +26,8 @@ typedef enum gnReturnCode_t {
|
||||
GN_UNSUPPORTED_SHADER_MODULE,
|
||||
GN_UNKNOWN_SUBPASS,
|
||||
GN_FAILED_TO_CREATE_FRAMEBUFFER,
|
||||
GN_DIVERGENT_RENDERPASS
|
||||
GN_DIVERGENT_RENDERPASS,
|
||||
GN_FAILED_TO_CREATE_COMMAND_POOL
|
||||
} gnReturnCode;
|
||||
|
||||
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_FAILED_TO_CREATE_FRAMEBUFFER: return "GN_FAILED_TO_CREATE_FRAMEBUFFER";
|
||||
case GN_DIVERGENT_RENDERPASS: return "GN_DIVERGENT_RENDERPASS";
|
||||
case GN_FAILED_TO_CREATE_COMMAND_POOL: return "GN_FAILED_TO_CREATE_COMMAND_POOL";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user