load up until command pool creation

This commit is contained in:
Gregory Wells
2025-06-24 14:04:58 -04:00
parent cdf8dd46d2
commit 4ec3d62146
15 changed files with 66 additions and 34 deletions

View File

@@ -1,26 +1,34 @@
#include "vulkan_loader.h" #include "vulkan_loader.h"
#include <presentation_queue/vulkan_presentation_queue.h> #include <presentation_queue/vulkan_presentation_queue.h>
#include <shader_module/vulkan_shader_module.h>
#include <renderpass/vulkan_render_pass_descriptor.h>
#include <pipelines/graphics_pipeline/vulkan_graphics_pipeline.h>
#include <framebuffers/vulkan_framebuffer.h>
#include <textures/vulkan_texture.h>
#include <uniforms/vulkan_uniform_pool.h>
#include <commands/command_pool/vulkan_command_pool.h>
#include <output_device/vulkan_output_devices.h>
gnDeviceFunctions loadVulkanDeviceFunctions() { gnDeviceFunctions loadVulkanDeviceFunctions() {
return (gnDeviceFunctions){ return (gnDeviceFunctions){
._gnCreatePresentationQueue = createPresentationQueue, ._gnCreatePresentationQueue = createPresentationQueue,
._gnPresentationQueueGetImage = getPresentQueueImage, ._gnPresentationQueueGetImage = getPresentQueueImage,
._gnDestroyPresentationQueue = destroyPresentationQueue ._gnDestroyPresentationQueue = destroyPresentationQueue,
// gnReturnCode (*_gnCreateShaderModule)(gnShaderModuleHandle module, gnOutputDeviceHandle device, gnShaderModuleInfo shaderModuleInfo); ._gnCreateShaderModule = createShaderModule,
// void (*_gnDestroyShaderModule)(gnShaderModuleHandle module); ._gnDestroyShaderModule = destroyShaderModule,
// gnReturnCode (*_gnCreateRenderPassDescriptor)(gnRenderPassDescriptorHandle renderPass, gnOutputDeviceHandle device, gnRenderPassDescriptorInfo info); ._gnCreateRenderPassDescriptor = createRenderPass,
// void (*_gnDestroyRenderPassDescriptor)(gnRenderPassDescriptorHandle renderPass); ._gnDestroyRenderPassDescriptor = destroyRenderPass,
// gnReturnCode (*_gnCreateGraphicsPipeline)(gnGraphicsPipelineHandle pipeline, gnOutputDeviceHandle device, gnGraphicsPipelineInfo pipelineInfo); ._gnCreateGraphicsPipeline = createGraphicsPipeline,
// void (*_gnDestroyGraphicsPipeline)(gnGraphicsPipelineHandle pipeline); ._gnDestroyGraphicsPipeline = destroyGraphicsPipeline,
// gnReturnCode (*_gnCreateFramebuffer)(gnFramebuffer framebuffer, gnOutputDeviceHandle device, gnFramebufferInfo framebufferInfo); ._gnCreateFramebuffer = createFramebuffer,
// void (*_gnDestroyFramebuffer)(gnFramebuffer framebuffer); ._gnDestroyFramebuffer = destroyFramebuffer,
// gnReturnCode (*_gnCreateCommandPool)(gnCommandPoolHandle commandPool, gnOutputDeviceHandle device, gnCommandPoolInfo info); ._gnCreateCommandPool = createCommandPool,
// void (*_gnDestroyCommandPool)(gnCommandPoolHandle commandPool); ._gnDestroyCommandPool = destroyCommandPool,
// gnReturnCode (*_gnCreateSemaphore)(gnSemaphoreHandle semaphore, gnOutputDeviceHandle device); // gnReturnCode (*_gnCreateSemaphore)(gnSemaphoreHandle semaphore, gnOutputDeviceHandle device);
// void (*_gnDestroySemaphore)(gnSemaphoreHandle semaphore); // void (*_gnDestroySemaphore)(gnSemaphoreHandle semaphore);
@@ -30,16 +38,16 @@ gnDeviceFunctions loadVulkanDeviceFunctions() {
// void* (*_gnMapBuffer)(gnBufferHandle buffer); // void* (*_gnMapBuffer)(gnBufferHandle buffer);
// void (*_gnDestroyBuffer)(gnBufferHandle buffer); // void (*_gnDestroyBuffer)(gnBufferHandle buffer);
// gnReturnCode (*_gnCreateUniformPool)(gnUniformPool pool, gnDeviceHandle device); ._gnCreateUniformPool = createUniformPool,
// gnUniform* (*_gnUniformPoolAllocateUniforms)(gnUniformPool pool, gnUniformAllocationInfo allocInfo); ._gnUniformPoolAllocateUniforms = allocateUniforms,
// void (*_gnDestroyUniformPool)(gnUniformPool pool); ._gnDestroyUniformPool = destroyUniformPool,
// void (*_gnUpdateBufferUniform)(gnUniform uniform, gnBufferUniformInfo* bufferInfo); // void (*_gnUpdateBufferUniform)(gnUniform uniform, gnBufferUniformInfo* bufferInfo);
// void (*_gnUpdateImageUniform)(gnUniform uniform, gnImageUniformInfo* imageInfo); // void (*_gnUpdateImageUniform)(gnUniform uniform, gnImageUniformInfo* imageInfo);
// gnReturnCode (*_gnCreateTexture)(gnTexture texture, gnDevice device, const gnTextureInfo info); ._gnCreateTexture = createTexture,
// void (*_gnTextureData)(gnTextureHandle texture, void* pixelData); ._gnTextureData = textureData,
// void (*_gnDestroyTexture)(gnTexture texture); ._gnDestroyTexture = destroyTexture,
// gnReturnCode (*_gnCreateFence)(gnFenceHandle fence, gnOutputDeviceHandle device); // gnReturnCode (*_gnCreateFence)(gnFenceHandle fence, gnOutputDeviceHandle device);
// void (*_gnSignalFence)(gnFenceHandle fence); // void (*_gnSignalFence)(gnFenceHandle fence);
@@ -50,6 +58,6 @@ gnDeviceFunctions loadVulkanDeviceFunctions() {
// gnReturnCode (*_gnSubmit)(gnOutputDeviceHandle device, gnSubmitInfo submit); // gnReturnCode (*_gnSubmit)(gnOutputDeviceHandle device, gnSubmitInfo submit);
// gnReturnCode (*_gnPresent)(gnOutputDeviceHandle device, gnPresentInfo info); // gnReturnCode (*_gnPresent)(gnOutputDeviceHandle device, gnPresentInfo info);
// void (*_gnWaitForDevice)(gnOutputDeviceHandle device); ._gnWaitForDevice = waitForDevice
}; };
} }

View File

@@ -1,7 +1,7 @@
#include "vulkan_command_pool.h" #include "vulkan_command_pool.h"
#include "output_device/vulkan_output_devices.h" #include "output_device/vulkan_output_devices.h"
gnReturnCode gnCreateCommandPoolFn(struct gnCommandPool_t* commandPool, struct gnOutputDevice_t* device, gnCommandPoolInfo info) { gnReturnCode createCommandPool(gnCommandPool commandPool, gnDevice device, gnCommandPoolInfo info) {
commandPool->commandPool = malloc(sizeof(gnPlatformCommandPool)); commandPool->commandPool = malloc(sizeof(gnPlatformCommandPool));
VkCommandPoolCreateInfo poolInfo = { VkCommandPoolCreateInfo poolInfo = {
@@ -17,7 +17,7 @@ gnReturnCode gnCreateCommandPoolFn(struct gnCommandPool_t* commandPool, struct g
return GN_SUCCESS; return GN_SUCCESS;
} }
void gnDestroyCommandPoolFn(struct gnCommandPool_t* commandPool) { void destroyCommandPool(gnCommandPool commandPool) {
vkDestroyCommandPool(commandPool->device->outputDevice->device, commandPool->commandPool->commandPool, NULL); vkDestroyCommandPool(commandPool->device->outputDevice->device, commandPool->commandPool->commandPool, NULL);
free(commandPool->commandPool); free(commandPool->commandPool);
} }

View File

@@ -5,3 +5,6 @@
typedef struct gnPlatformCommandPool_t { typedef struct gnPlatformCommandPool_t {
VkCommandPool commandPool; VkCommandPool commandPool;
} gnPlatformCommandPool; } gnPlatformCommandPool;
gnReturnCode createCommandPool(gnCommandPool commandPool, gnDevice device, gnCommandPoolInfo info);
void destroyCommandPool(gnCommandPool commandPool);

View File

@@ -3,7 +3,7 @@
#include "renderpass/vulkan_render_pass_descriptor.h" #include "renderpass/vulkan_render_pass_descriptor.h"
#include "output_device/vulkan_output_devices.h" #include "output_device/vulkan_output_devices.h"
gnReturnCode gnCreateFramebufferFn(gnFramebuffer framebuffer, gnDevice device, gnFramebufferInfo info) { gnReturnCode createFramebuffer(gnFramebuffer framebuffer, gnDevice device, gnFramebufferInfo info) {
framebuffer->framebuffer = malloc(sizeof(struct gnPlatformFramebuffer_t)); framebuffer->framebuffer = malloc(sizeof(struct gnPlatformFramebuffer_t));
VkImageView* attachments = malloc(sizeof(VkImageView) * info.attachmentCount); VkImageView* attachments = malloc(sizeof(VkImageView) * info.attachmentCount);
@@ -28,7 +28,7 @@ gnReturnCode gnCreateFramebufferFn(gnFramebuffer framebuffer, gnDevice device, g
return GN_SUCCESS; return GN_SUCCESS;
} }
void gnDestroyFramebufferFn(gnFramebuffer framebuffer) { void destroyFramebuffer(gnFramebuffer framebuffer) {
vkDestroyFramebuffer(framebuffer->device->outputDevice->device, framebuffer->framebuffer->framebuffer, NULL); vkDestroyFramebuffer(framebuffer->device->outputDevice->device, framebuffer->framebuffer->framebuffer, NULL);
free(framebuffer->framebuffer); free(framebuffer->framebuffer);
} }

View File

@@ -5,3 +5,6 @@
typedef struct gnPlatformFramebuffer_t { typedef struct gnPlatformFramebuffer_t {
VkFramebuffer framebuffer; VkFramebuffer framebuffer;
} gnPlatformFramebuffer; } gnPlatformFramebuffer;
gnReturnCode createFramebuffer(gnFramebuffer framebuffer, gnDevice device, gnFramebufferInfo info);
void destroyFramebuffer(gnFramebuffer framebuffer);

View File

@@ -87,7 +87,7 @@ VkStencilOp vkGryphnStencilOperation(gnStencilOperation operation) {
} }
} }
gnReturnCode gnCreateGraphicsPipelineFn(gnGraphicsPipeline graphicsPipeline, gnDevice device, gnGraphicsPipelineInfo info) { gnReturnCode createGraphicsPipeline(gnGraphicsPipeline graphicsPipeline, gnDevice device, gnGraphicsPipelineInfo info) {
graphicsPipeline->graphicsPipeline = malloc(sizeof(gnPlatformGraphicsPipeline)); graphicsPipeline->graphicsPipeline = malloc(sizeof(gnPlatformGraphicsPipeline));
for (int i = 0; i < GN_DYNAMIC_STATE_MAX; i++) graphicsPipeline->graphicsPipeline->isDynamic[i] = gnFalse; for (int i = 0; i < GN_DYNAMIC_STATE_MAX; i++) graphicsPipeline->graphicsPipeline->isDynamic[i] = gnFalse;
@@ -288,7 +288,7 @@ gnReturnCode gnCreateGraphicsPipelineFn(gnGraphicsPipeline graphicsPipeline, gnD
return GN_SUCCESS; return GN_SUCCESS;
} }
void gnDestroyGraphicsPipelineFn(struct gnGraphicsPipeline_t *graphicsPipeline) { void destroyGraphicsPipeline(gnGraphicsPipeline graphicsPipeline) {
free(graphicsPipeline->graphicsPipeline->dynamicStates); free(graphicsPipeline->graphicsPipeline->dynamicStates);
free(graphicsPipeline->graphicsPipeline->bindingDescriptions); free(graphicsPipeline->graphicsPipeline->bindingDescriptions);
free(graphicsPipeline->graphicsPipeline->attributeDescriptions); free(graphicsPipeline->graphicsPipeline->attributeDescriptions);

View File

@@ -33,3 +33,6 @@ typedef struct gnPlatformGraphicsPipeline_t {
VkPipelineShaderStageCreateInfo* modules; VkPipelineShaderStageCreateInfo* modules;
VkPushConstantRange* ranges; VkPushConstantRange* ranges;
} gnPlatformGraphicsPipeline; } gnPlatformGraphicsPipeline;
void destroyGraphicsPipeline(gnGraphicsPipeline graphicsPipeline);
gnReturnCode createGraphicsPipeline(gnGraphicsPipeline graphicsPipeline, gnDevice device, gnGraphicsPipelineInfo info);

View File

@@ -42,7 +42,7 @@ VkAccessFlags vkGryphnRenderPassAccess(gnRenderPassAccess access) {
return flags; return flags;
} }
gnReturnCode gnCreateRenderPassDescriptorFn(struct gnRenderPassDescriptor_t* renderPass, struct gnOutputDevice_t* device, gnRenderPassDescriptorInfo info) { gnReturnCode createRenderPass(gnRenderPassDescriptor renderPass, gnDevice device, gnRenderPassDescriptorInfo info) {
renderPass->renderPassDescriptor = malloc(sizeof(gnPlatformRenderPassDescriptor)); renderPass->renderPassDescriptor = malloc(sizeof(gnPlatformRenderPassDescriptor));
renderPass->renderPassDescriptor->attachmentCount = info.attachmentCount; renderPass->renderPassDescriptor->attachmentCount = info.attachmentCount;
@@ -124,7 +124,7 @@ gnReturnCode gnCreateRenderPassDescriptorFn(struct gnRenderPassDescriptor_t* ren
} }
void gnDestroyRenderPassDescriptorFn(gnRenderPassDescriptor renderPass) { void destroyRenderPass(gnRenderPassDescriptor renderPass) {
vkDestroyRenderPass(renderPass->device->outputDevice->device, renderPass->renderPassDescriptor->renderPass, NULL); vkDestroyRenderPass(renderPass->device->outputDevice->device, renderPass->renderPassDescriptor->renderPass, NULL);

View File

@@ -17,3 +17,6 @@ typedef struct gnPlatformRenderPassDescriptor_t {
} gnPlatformRenderPassDescriptor; } gnPlatformRenderPassDescriptor;
VkPipelineStageFlags vkGryphnRenderPassStage(gnRenderPassStage stage); VkPipelineStageFlags vkGryphnRenderPassStage(gnRenderPassStage stage);
gnReturnCode createRenderPass(gnRenderPassDescriptor renderPass, gnDevice device, gnRenderPassDescriptorInfo info);
void destroyRenderPass(gnRenderPassDescriptor renderPass);

View File

@@ -12,7 +12,7 @@ VkShaderStageFlagBits vkGryphnShaderModuleStage(gnShaderModuleStage stage) {
return outStage; return outStage;
} }
gnReturnCode gnCreateShaderModuleFn(gnShaderModule module, gnDevice device, gnShaderModuleInfo shaderModuleInfo) { gnReturnCode createShaderModule(gnShaderModule module, gnDevice device, gnShaderModuleInfo shaderModuleInfo) {
module->shaderModule = malloc(sizeof(struct gnPlatformShaderModule_t)); module->shaderModule = malloc(sizeof(struct gnPlatformShaderModule_t));
VkShaderModuleCreateInfo createInfo = { VkShaderModuleCreateInfo createInfo = {
@@ -34,6 +34,6 @@ gnReturnCode gnCreateShaderModuleFn(gnShaderModule module, gnDevice device, gnSh
return GN_SUCCESS; return GN_SUCCESS;
} }
void gnDestroyShaderModuleFn(struct gnShaderModule_t* module) { void destroyShaderModule(gnShaderModule module) {
vkDestroyShaderModule(module->device->outputDevice->device, module->shaderModule->shaderModule, NULL); vkDestroyShaderModule(module->device->outputDevice->device, module->shaderModule->shaderModule, NULL);
} }

View File

@@ -8,3 +8,7 @@ typedef struct gnPlatformShaderModule_t {
} gnPlatformShaderModule; } gnPlatformShaderModule;
VkShaderStageFlagBits vkGryphnShaderModuleStage(gnShaderModuleStage stage); VkShaderStageFlagBits vkGryphnShaderModuleStage(gnShaderModuleStage stage);
gnReturnCode createShaderModule(gnShaderModule module, gnDevice device, gnShaderModuleInfo shaderModuleInfo);
void destroyShaderModule(gnShaderModule module);

View File

@@ -128,7 +128,7 @@ void VkCopyBufferToImage(VkGryphnBuffer buffer, VkGryphnImage image, uint32_t wi
#include "stdio.h" #include "stdio.h"
gnReturnCode gnCreateTextureFn(gnTexture texture, gnDevice device, const gnTextureInfo info) { gnReturnCode createTexture(gnTexture texture, gnDevice device, const gnTextureInfo info) {
texture->texture = malloc(sizeof(struct gnPlatformTexture_t)); texture->texture = malloc(sizeof(struct gnPlatformTexture_t));
size_t imageSize = info.width * info.height; size_t imageSize = info.width * info.height;
@@ -239,7 +239,7 @@ gnReturnCode gnCreateTextureFn(gnTexture texture, gnDevice device, const gnTextu
return GN_SUCCESS; return GN_SUCCESS;
} }
void gnTextureDataFn(gnTextureHandle texture, void* pixelData) { void textureData(gnTextureHandle texture, void* pixelData) {
void* data; void* data;
vkMapMemory(texture->device->outputDevice->device, texture->texture->buffer.memory, 0, texture->texture->size, 0, &data); vkMapMemory(texture->device->outputDevice->device, texture->texture->buffer.memory, 0, texture->texture->size, 0, &data);
memcpy(data, pixelData, texture->texture->size); memcpy(data, pixelData, texture->texture->size);
@@ -265,7 +265,7 @@ void gnDestroyVulkanImage(VkGryphnImage* image, VkDevice device) {
vkFreeMemory(device, image->memory, NULL); vkFreeMemory(device, image->memory, NULL);
} }
void gnDestroyTextureFn(gnTexture texture) { void destroyTexture(gnTexture texture) {
vkDestroySampler(texture->device->outputDevice->device, texture->texture->sampler, NULL); vkDestroySampler(texture->device->outputDevice->device, texture->texture->sampler, NULL);
gnDestroyVulkanBuffer(&texture->texture->buffer, texture->device->outputDevice->device); gnDestroyVulkanBuffer(&texture->texture->buffer, texture->device->outputDevice->device);

View File

@@ -19,3 +19,7 @@ typedef struct gnPlatformTexture_t {
uint32_t width, height; uint32_t width, height;
gnBool beenWrittenToo; gnBool beenWrittenToo;
} gnPlatformTexture; } gnPlatformTexture;
gnReturnCode createTexture(gnTexture texture, gnDevice device, const gnTextureInfo info);
void textureData(gnTextureHandle texture, void* pixelData);
void destroyTexture(gnTexture texture);

View File

@@ -8,7 +8,7 @@
VkGryphnUniformPool* GetLastUniformPool(VkGryphnUniformPoolArrayList* list) { return &list->data[list->count - 1]; } VkGryphnUniformPool* GetLastUniformPool(VkGryphnUniformPoolArrayList* list) { return &list->data[list->count - 1]; }
gnReturnCode gnCreateUniformPoolFn(gnUniformPool pool, gnDeviceHandle device) { gnReturnCode createUniformPool(gnUniformPool pool, gnDeviceHandle device) {
pool->uniformPool = malloc(sizeof(struct gnPlatformUniformPool_t)); pool->uniformPool = malloc(sizeof(struct gnPlatformUniformPool_t));
pool->uniformPool->pools = VkGryphnUniformPoolArrayListCreate(); pool->uniformPool->pools = VkGryphnUniformPoolArrayListCreate();
@@ -40,7 +40,7 @@ gnReturnCode gnCreateUniformPoolFn(gnUniformPool pool, gnDeviceHandle device) {
return GN_SUCCESS; return GN_SUCCESS;
} }
gnUniform* gnUniformPoolAllocateUniformsFn(gnUniformPool pool, gnUniformAllocationInfo allocInfo) { gnUniform* allocateUniforms(gnUniformPool pool, gnUniformAllocationInfo allocInfo) {
gnBool fixedAllocation = !pool->device->outputDevice->enabledOversizedDescriptorPools; gnBool fixedAllocation = !pool->device->outputDevice->enabledOversizedDescriptorPools;
if (fixedAllocation) { if (fixedAllocation) {
VkGryphnUniformPool newPool = { VkGryphnUniformPool newPool = {
@@ -127,7 +127,7 @@ gnUniform* gnUniformPoolAllocateUniformsFn(gnUniformPool pool, gnUniformAllocati
return uniforms; return uniforms;
} }
void gnDestroyUniformPoolFn(gnUniformPool pool) { void destroyUniformPool(gnUniformPool pool) {
for (int k = 0; k < pool->uniformPool->pools.count; k++) { for (int k = 0; k < pool->uniformPool->pools.count; k++) {
vkDestroyDescriptorPool(pool->device->outputDevice->device, pool->uniformPool->pools.data[k].pool, NULL); vkDestroyDescriptorPool(pool->device->outputDevice->device, pool->uniformPool->pools.data[k].pool, NULL);
for (int i = 0; i < pool->uniformPool->pools.data[k].layouts.count; i++) for (int i = 0; i < pool->uniformPool->pools.data[k].layouts.count; i++)

View File

@@ -13,3 +13,7 @@ GN_ARRAY_LIST(VkGryphnUniformPool);
struct gnPlatformUniformPool_t { struct gnPlatformUniformPool_t {
VkGryphnUniformPoolArrayList pools; VkGryphnUniformPoolArrayList pools;
}; };
gnReturnCode createUniformPool(gnUniformPool pool, gnDeviceHandle device);
gnUniform* allocateUniforms(gnUniformPool pool, gnUniformAllocationInfo allocInfo);
void destroyUniformPool(gnUniformPool pool);