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 <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() {
return (gnDeviceFunctions){
._gnCreatePresentationQueue = createPresentationQueue,
._gnPresentationQueueGetImage = getPresentQueueImage,
._gnDestroyPresentationQueue = destroyPresentationQueue
._gnDestroyPresentationQueue = destroyPresentationQueue,
// gnReturnCode (*_gnCreateShaderModule)(gnShaderModuleHandle module, gnOutputDeviceHandle device, gnShaderModuleInfo shaderModuleInfo);
// void (*_gnDestroyShaderModule)(gnShaderModuleHandle module);
._gnCreateShaderModule = createShaderModule,
._gnDestroyShaderModule = destroyShaderModule,
// gnReturnCode (*_gnCreateRenderPassDescriptor)(gnRenderPassDescriptorHandle renderPass, gnOutputDeviceHandle device, gnRenderPassDescriptorInfo info);
// void (*_gnDestroyRenderPassDescriptor)(gnRenderPassDescriptorHandle renderPass);
._gnCreateRenderPassDescriptor = createRenderPass,
._gnDestroyRenderPassDescriptor = destroyRenderPass,
// gnReturnCode (*_gnCreateGraphicsPipeline)(gnGraphicsPipelineHandle pipeline, gnOutputDeviceHandle device, gnGraphicsPipelineInfo pipelineInfo);
// void (*_gnDestroyGraphicsPipeline)(gnGraphicsPipelineHandle pipeline);
._gnCreateGraphicsPipeline = createGraphicsPipeline,
._gnDestroyGraphicsPipeline = destroyGraphicsPipeline,
// gnReturnCode (*_gnCreateFramebuffer)(gnFramebuffer framebuffer, gnOutputDeviceHandle device, gnFramebufferInfo framebufferInfo);
// void (*_gnDestroyFramebuffer)(gnFramebuffer framebuffer);
._gnCreateFramebuffer = createFramebuffer,
._gnDestroyFramebuffer = destroyFramebuffer,
// gnReturnCode (*_gnCreateCommandPool)(gnCommandPoolHandle commandPool, gnOutputDeviceHandle device, gnCommandPoolInfo info);
// void (*_gnDestroyCommandPool)(gnCommandPoolHandle commandPool);
._gnCreateCommandPool = createCommandPool,
._gnDestroyCommandPool = destroyCommandPool,
// gnReturnCode (*_gnCreateSemaphore)(gnSemaphoreHandle semaphore, gnOutputDeviceHandle device);
// void (*_gnDestroySemaphore)(gnSemaphoreHandle semaphore);
@@ -30,16 +38,16 @@ gnDeviceFunctions loadVulkanDeviceFunctions() {
// void* (*_gnMapBuffer)(gnBufferHandle buffer);
// void (*_gnDestroyBuffer)(gnBufferHandle buffer);
// gnReturnCode (*_gnCreateUniformPool)(gnUniformPool pool, gnDeviceHandle device);
// gnUniform* (*_gnUniformPoolAllocateUniforms)(gnUniformPool pool, gnUniformAllocationInfo allocInfo);
// void (*_gnDestroyUniformPool)(gnUniformPool pool);
._gnCreateUniformPool = createUniformPool,
._gnUniformPoolAllocateUniforms = allocateUniforms,
._gnDestroyUniformPool = destroyUniformPool,
// void (*_gnUpdateBufferUniform)(gnUniform uniform, gnBufferUniformInfo* bufferInfo);
// void (*_gnUpdateImageUniform)(gnUniform uniform, gnImageUniformInfo* imageInfo);
// gnReturnCode (*_gnCreateTexture)(gnTexture texture, gnDevice device, const gnTextureInfo info);
// void (*_gnTextureData)(gnTextureHandle texture, void* pixelData);
// void (*_gnDestroyTexture)(gnTexture texture);
._gnCreateTexture = createTexture,
._gnTextureData = textureData,
._gnDestroyTexture = destroyTexture,
// gnReturnCode (*_gnCreateFence)(gnFenceHandle fence, gnOutputDeviceHandle device);
// void (*_gnSignalFence)(gnFenceHandle fence);
@@ -50,6 +58,6 @@ gnDeviceFunctions loadVulkanDeviceFunctions() {
// gnReturnCode (*_gnSubmit)(gnOutputDeviceHandle device, gnSubmitInfo submit);
// gnReturnCode (*_gnPresent)(gnOutputDeviceHandle device, gnPresentInfo info);
// void (*_gnWaitForDevice)(gnOutputDeviceHandle device);
._gnWaitForDevice = waitForDevice
};
}

View File

@@ -1,7 +1,7 @@
#include "vulkan_command_pool.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));
VkCommandPoolCreateInfo poolInfo = {
@@ -17,7 +17,7 @@ gnReturnCode gnCreateCommandPoolFn(struct gnCommandPool_t* commandPool, struct g
return GN_SUCCESS;
}
void gnDestroyCommandPoolFn(struct gnCommandPool_t* commandPool) {
void destroyCommandPool(gnCommandPool commandPool) {
vkDestroyCommandPool(commandPool->device->outputDevice->device, commandPool->commandPool->commandPool, NULL);
free(commandPool->commandPool);
}

View File

@@ -5,3 +5,6 @@
typedef struct gnPlatformCommandPool_t {
VkCommandPool commandPool;
} 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 "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));
VkImageView* attachments = malloc(sizeof(VkImageView) * info.attachmentCount);
@@ -28,7 +28,7 @@ gnReturnCode gnCreateFramebufferFn(gnFramebuffer framebuffer, gnDevice device, g
return GN_SUCCESS;
}
void gnDestroyFramebufferFn(gnFramebuffer framebuffer) {
void destroyFramebuffer(gnFramebuffer framebuffer) {
vkDestroyFramebuffer(framebuffer->device->outputDevice->device, framebuffer->framebuffer->framebuffer, NULL);
free(framebuffer->framebuffer);
}

View File

@@ -5,3 +5,6 @@
typedef struct gnPlatformFramebuffer_t {
VkFramebuffer framebuffer;
} 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));
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;
}
void gnDestroyGraphicsPipelineFn(struct gnGraphicsPipeline_t *graphicsPipeline) {
void destroyGraphicsPipeline(gnGraphicsPipeline graphicsPipeline) {
free(graphicsPipeline->graphicsPipeline->dynamicStates);
free(graphicsPipeline->graphicsPipeline->bindingDescriptions);
free(graphicsPipeline->graphicsPipeline->attributeDescriptions);

View File

@@ -33,3 +33,6 @@ typedef struct gnPlatformGraphicsPipeline_t {
VkPipelineShaderStageCreateInfo* modules;
VkPushConstantRange* ranges;
} 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;
}
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->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);

View File

@@ -17,3 +17,6 @@ typedef struct gnPlatformRenderPassDescriptor_t {
} gnPlatformRenderPassDescriptor;
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;
}
gnReturnCode gnCreateShaderModuleFn(gnShaderModule module, gnDevice device, gnShaderModuleInfo shaderModuleInfo) {
gnReturnCode createShaderModule(gnShaderModule module, gnDevice device, gnShaderModuleInfo shaderModuleInfo) {
module->shaderModule = malloc(sizeof(struct gnPlatformShaderModule_t));
VkShaderModuleCreateInfo createInfo = {
@@ -34,6 +34,6 @@ gnReturnCode gnCreateShaderModuleFn(gnShaderModule module, gnDevice device, gnSh
return GN_SUCCESS;
}
void gnDestroyShaderModuleFn(struct gnShaderModule_t* module) {
void destroyShaderModule(gnShaderModule module) {
vkDestroyShaderModule(module->device->outputDevice->device, module->shaderModule->shaderModule, NULL);
}

View File

@@ -8,3 +8,7 @@ typedef struct gnPlatformShaderModule_t {
} gnPlatformShaderModule;
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"
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));
size_t imageSize = info.width * info.height;
@@ -239,7 +239,7 @@ gnReturnCode gnCreateTextureFn(gnTexture texture, gnDevice device, const gnTextu
return GN_SUCCESS;
}
void gnTextureDataFn(gnTextureHandle texture, void* pixelData) {
void textureData(gnTextureHandle texture, void* pixelData) {
void* data;
vkMapMemory(texture->device->outputDevice->device, texture->texture->buffer.memory, 0, texture->texture->size, 0, &data);
memcpy(data, pixelData, texture->texture->size);
@@ -265,7 +265,7 @@ void gnDestroyVulkanImage(VkGryphnImage* image, VkDevice device) {
vkFreeMemory(device, image->memory, NULL);
}
void gnDestroyTextureFn(gnTexture texture) {
void destroyTexture(gnTexture texture) {
vkDestroySampler(texture->device->outputDevice->device, texture->texture->sampler, NULL);
gnDestroyVulkanBuffer(&texture->texture->buffer, texture->device->outputDevice->device);

View File

@@ -19,3 +19,7 @@ typedef struct gnPlatformTexture_t {
uint32_t width, height;
gnBool beenWrittenToo;
} 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]; }
gnReturnCode gnCreateUniformPoolFn(gnUniformPool pool, gnDeviceHandle device) {
gnReturnCode createUniformPool(gnUniformPool pool, gnDeviceHandle device) {
pool->uniformPool = malloc(sizeof(struct gnPlatformUniformPool_t));
pool->uniformPool->pools = VkGryphnUniformPoolArrayListCreate();
@@ -40,7 +40,7 @@ gnReturnCode gnCreateUniformPoolFn(gnUniformPool pool, gnDeviceHandle device) {
return GN_SUCCESS;
}
gnUniform* gnUniformPoolAllocateUniformsFn(gnUniformPool pool, gnUniformAllocationInfo allocInfo) {
gnUniform* allocateUniforms(gnUniformPool pool, gnUniformAllocationInfo allocInfo) {
gnBool fixedAllocation = !pool->device->outputDevice->enabledOversizedDescriptorPools;
if (fixedAllocation) {
VkGryphnUniformPool newPool = {
@@ -127,7 +127,7 @@ gnUniform* gnUniformPoolAllocateUniformsFn(gnUniformPool pool, gnUniformAllocati
return uniforms;
}
void gnDestroyUniformPoolFn(gnUniformPool pool) {
void destroyUniformPool(gnUniformPool pool) {
for (int k = 0; k < pool->uniformPool->pools.count; k++) {
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++)

View File

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