diff --git a/projects/apis/vulkan/loader/vulkan_device_loader.c b/projects/apis/vulkan/loader/vulkan_device_loader.c index ca89751..e0bfeb5 100644 --- a/projects/apis/vulkan/loader/vulkan_device_loader.c +++ b/projects/apis/vulkan/loader/vulkan_device_loader.c @@ -1,26 +1,34 @@ #include "vulkan_loader.h" #include +#include +#include +#include +#include +#include +#include +#include +#include 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 }; } diff --git a/projects/apis/vulkan/src/commands/command_pool/vulkan_command_pool.c b/projects/apis/vulkan/src/commands/command_pool/vulkan_command_pool.c index 7ab713d..59121b4 100644 --- a/projects/apis/vulkan/src/commands/command_pool/vulkan_command_pool.c +++ b/projects/apis/vulkan/src/commands/command_pool/vulkan_command_pool.c @@ -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); } diff --git a/projects/apis/vulkan/src/commands/command_pool/vulkan_command_pool.h b/projects/apis/vulkan/src/commands/command_pool/vulkan_command_pool.h index 8fcc2d7..db57eb8 100644 --- a/projects/apis/vulkan/src/commands/command_pool/vulkan_command_pool.h +++ b/projects/apis/vulkan/src/commands/command_pool/vulkan_command_pool.h @@ -5,3 +5,6 @@ typedef struct gnPlatformCommandPool_t { VkCommandPool commandPool; } gnPlatformCommandPool; + +gnReturnCode createCommandPool(gnCommandPool commandPool, gnDevice device, gnCommandPoolInfo info); +void destroyCommandPool(gnCommandPool commandPool); diff --git a/projects/apis/vulkan/src/framebuffers/vulkan_framebuffer.c b/projects/apis/vulkan/src/framebuffers/vulkan_framebuffer.c index 1154d76..aeff40c 100644 --- a/projects/apis/vulkan/src/framebuffers/vulkan_framebuffer.c +++ b/projects/apis/vulkan/src/framebuffers/vulkan_framebuffer.c @@ -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); } diff --git a/projects/apis/vulkan/src/framebuffers/vulkan_framebuffer.h b/projects/apis/vulkan/src/framebuffers/vulkan_framebuffer.h index 672c045..05cfbef 100644 --- a/projects/apis/vulkan/src/framebuffers/vulkan_framebuffer.h +++ b/projects/apis/vulkan/src/framebuffers/vulkan_framebuffer.h @@ -5,3 +5,6 @@ typedef struct gnPlatformFramebuffer_t { VkFramebuffer framebuffer; } gnPlatformFramebuffer; + +gnReturnCode createFramebuffer(gnFramebuffer framebuffer, gnDevice device, gnFramebufferInfo info); +void destroyFramebuffer(gnFramebuffer framebuffer); diff --git a/projects/apis/vulkan/src/pipelines/graphics_pipeline/vulkan_graphics_pipeline.c b/projects/apis/vulkan/src/pipelines/graphics_pipeline/vulkan_graphics_pipeline.c index b97579d..a4cc0e7 100644 --- a/projects/apis/vulkan/src/pipelines/graphics_pipeline/vulkan_graphics_pipeline.c +++ b/projects/apis/vulkan/src/pipelines/graphics_pipeline/vulkan_graphics_pipeline.c @@ -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); diff --git a/projects/apis/vulkan/src/pipelines/graphics_pipeline/vulkan_graphics_pipeline.h b/projects/apis/vulkan/src/pipelines/graphics_pipeline/vulkan_graphics_pipeline.h index 57d7288..3cda1c3 100644 --- a/projects/apis/vulkan/src/pipelines/graphics_pipeline/vulkan_graphics_pipeline.h +++ b/projects/apis/vulkan/src/pipelines/graphics_pipeline/vulkan_graphics_pipeline.h @@ -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); diff --git a/projects/apis/vulkan/src/renderpass/vulkan_render_pass_descriptor.c b/projects/apis/vulkan/src/renderpass/vulkan_render_pass_descriptor.c index 51a5a17..bc15294 100644 --- a/projects/apis/vulkan/src/renderpass/vulkan_render_pass_descriptor.c +++ b/projects/apis/vulkan/src/renderpass/vulkan_render_pass_descriptor.c @@ -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); diff --git a/projects/apis/vulkan/src/renderpass/vulkan_render_pass_descriptor.h b/projects/apis/vulkan/src/renderpass/vulkan_render_pass_descriptor.h index 5da1874..6ba1cfe 100644 --- a/projects/apis/vulkan/src/renderpass/vulkan_render_pass_descriptor.h +++ b/projects/apis/vulkan/src/renderpass/vulkan_render_pass_descriptor.h @@ -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); diff --git a/projects/apis/vulkan/src/shader_module/vulkan_shader_module.c b/projects/apis/vulkan/src/shader_module/vulkan_shader_module.c index b2c80a0..519b236 100644 --- a/projects/apis/vulkan/src/shader_module/vulkan_shader_module.c +++ b/projects/apis/vulkan/src/shader_module/vulkan_shader_module.c @@ -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); } diff --git a/projects/apis/vulkan/src/shader_module/vulkan_shader_module.h b/projects/apis/vulkan/src/shader_module/vulkan_shader_module.h index fdbe516..61183f5 100644 --- a/projects/apis/vulkan/src/shader_module/vulkan_shader_module.h +++ b/projects/apis/vulkan/src/shader_module/vulkan_shader_module.h @@ -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); diff --git a/projects/apis/vulkan/src/textures/vulkan_texture.c b/projects/apis/vulkan/src/textures/vulkan_texture.c index 578bae7..fbd29d7 100644 --- a/projects/apis/vulkan/src/textures/vulkan_texture.c +++ b/projects/apis/vulkan/src/textures/vulkan_texture.c @@ -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); diff --git a/projects/apis/vulkan/src/textures/vulkan_texture.h b/projects/apis/vulkan/src/textures/vulkan_texture.h index 6ef0f43..307546b 100644 --- a/projects/apis/vulkan/src/textures/vulkan_texture.h +++ b/projects/apis/vulkan/src/textures/vulkan_texture.h @@ -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); diff --git a/projects/apis/vulkan/src/uniforms/vulkan_uniform_pool.c b/projects/apis/vulkan/src/uniforms/vulkan_uniform_pool.c index a32fbce..627d3d5 100644 --- a/projects/apis/vulkan/src/uniforms/vulkan_uniform_pool.c +++ b/projects/apis/vulkan/src/uniforms/vulkan_uniform_pool.c @@ -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++) diff --git a/projects/apis/vulkan/src/uniforms/vulkan_uniform_pool.h b/projects/apis/vulkan/src/uniforms/vulkan_uniform_pool.h index 94ed5ce..d78ab1d 100644 --- a/projects/apis/vulkan/src/uniforms/vulkan_uniform_pool.h +++ b/projects/apis/vulkan/src/uniforms/vulkan_uniform_pool.h @@ -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);