From cdf8dd46d2dde0705ecf636c398e2409a6547d26 Mon Sep 17 00:00:00 2001 From: Gregory Wells Date: Tue, 24 Jun 2025 13:49:00 -0400 Subject: [PATCH] first device functions loaded --- .../apis/vulkan/loader/vulkan_device_loader.c | 50 ++++++++++++++++++- .../vulkan_presentation_queue.c | 6 +-- .../vulkan_presentation_queue.h | 4 ++ 3 files changed, 56 insertions(+), 4 deletions(-) diff --git a/projects/apis/vulkan/loader/vulkan_device_loader.c b/projects/apis/vulkan/loader/vulkan_device_loader.c index 3cce394..ca89751 100644 --- a/projects/apis/vulkan/loader/vulkan_device_loader.c +++ b/projects/apis/vulkan/loader/vulkan_device_loader.c @@ -1,7 +1,55 @@ #include "vulkan_loader.h" +#include gnDeviceFunctions loadVulkanDeviceFunctions() { return (gnDeviceFunctions){ - NULL + ._gnCreatePresentationQueue = createPresentationQueue, + ._gnPresentationQueueGetImage = getPresentQueueImage, + ._gnDestroyPresentationQueue = destroyPresentationQueue + + // gnReturnCode (*_gnCreateShaderModule)(gnShaderModuleHandle module, gnOutputDeviceHandle device, gnShaderModuleInfo shaderModuleInfo); + // void (*_gnDestroyShaderModule)(gnShaderModuleHandle module); + + // gnReturnCode (*_gnCreateRenderPassDescriptor)(gnRenderPassDescriptorHandle renderPass, gnOutputDeviceHandle device, gnRenderPassDescriptorInfo info); + // void (*_gnDestroyRenderPassDescriptor)(gnRenderPassDescriptorHandle renderPass); + + // gnReturnCode (*_gnCreateGraphicsPipeline)(gnGraphicsPipelineHandle pipeline, gnOutputDeviceHandle device, gnGraphicsPipelineInfo pipelineInfo); + // void (*_gnDestroyGraphicsPipeline)(gnGraphicsPipelineHandle pipeline); + + // gnReturnCode (*_gnCreateFramebuffer)(gnFramebuffer framebuffer, gnOutputDeviceHandle device, gnFramebufferInfo framebufferInfo); + // void (*_gnDestroyFramebuffer)(gnFramebuffer framebuffer); + + // gnReturnCode (*_gnCreateCommandPool)(gnCommandPoolHandle commandPool, gnOutputDeviceHandle device, gnCommandPoolInfo info); + // void (*_gnDestroyCommandPool)(gnCommandPoolHandle commandPool); + + // gnReturnCode (*_gnCreateSemaphore)(gnSemaphoreHandle semaphore, gnOutputDeviceHandle device); + // void (*_gnDestroySemaphore)(gnSemaphoreHandle semaphore); + + // gnReturnCode (*_gnCreateBuffer)(gnBufferHandle buffer, gnDeviceHandle device, gnBufferInfo info); + // void (*_gnBufferData)(gnBufferHandle buffer, size_t size, void* data); + // void* (*_gnMapBuffer)(gnBufferHandle buffer); + // void (*_gnDestroyBuffer)(gnBufferHandle buffer); + + // gnReturnCode (*_gnCreateUniformPool)(gnUniformPool pool, gnDeviceHandle device); + // gnUniform* (*_gnUniformPoolAllocateUniforms)(gnUniformPool pool, gnUniformAllocationInfo allocInfo); + // void (*_gnDestroyUniformPool)(gnUniformPool pool); + + // 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); + + // gnReturnCode (*_gnCreateFence)(gnFenceHandle fence, gnOutputDeviceHandle device); + // void (*_gnSignalFence)(gnFenceHandle fence); + // void (*_gnWaitForFence)(gnFenceHandle fence, uint64_t timeout); + // void (*_gnResetFence)(gnFenceHandle fence); + // void (*_gnDestroyFence)(gnFenceHandle fence); + + // gnReturnCode (*_gnSubmit)(gnOutputDeviceHandle device, gnSubmitInfo submit); + // gnReturnCode (*_gnPresent)(gnOutputDeviceHandle device, gnPresentInfo info); + + // void (*_gnWaitForDevice)(gnOutputDeviceHandle device); }; } diff --git a/projects/apis/vulkan/src/presentation_queue/vulkan_presentation_queue.c b/projects/apis/vulkan/src/presentation_queue/vulkan_presentation_queue.c index fd22a1e..c3a65e3 100644 --- a/projects/apis/vulkan/src/presentation_queue/vulkan_presentation_queue.c +++ b/projects/apis/vulkan/src/presentation_queue/vulkan_presentation_queue.c @@ -7,7 +7,7 @@ #include "sync/semaphore/vulkan_semaphore.h" #include "stdio.h" -gnReturnCode gnCreatePresentationQueueFn(gnPresentationQueueHandle presentationQueue, const gnDevice device, gnPresentationQueueInfo presentationInfo) { +gnReturnCode createPresentationQueue(gnPresentationQueueHandle presentationQueue, const gnDevice device, gnPresentationQueueInfo presentationInfo) { presentationQueue->presentationQueue = malloc(sizeof(struct gnPlatformPresentationQueue_t)); vkSwapchainSupportDetails details = vkGetSwapchainSupport(device->physicalDevice.physicalDevice->device, presentationInfo.surface->windowSurface->surface); @@ -123,7 +123,7 @@ gnReturnCode gnCreatePresentationQueueFn(gnPresentationQueueHandle presentationQ return GN_SUCCESS; } -gnReturnCode gnPresentationQueueGetImageFn(gnPresentationQueueHandle presentationQueue, uint64_t timeout, struct gnSemaphore_t* semaphore, uint32_t* imageIndex) { +gnReturnCode getPresentQueueImage(gnPresentationQueueHandle presentationQueue, uint64_t timeout, gnSemaphore semaphore, uint32_t* imageIndex) { VkResult result = vkAcquireNextImageKHR( presentationQueue->outputDevice->outputDevice->device, presentationQueue->presentationQueue->swapChain, @@ -135,7 +135,7 @@ gnReturnCode gnPresentationQueueGetImageFn(gnPresentationQueueHandle presentatio return GN_SUCCESS; } -void gnDestroyPresentationQueueFn(gnPresentationQueueHandle queue) { +void destroyPresentationQueue(gnPresentationQueueHandle queue) { for (int i = 0; i < queue->imageCount; i++) vkDestroyImageView(queue->outputDevice->outputDevice->device, queue->presentationQueue->swapChainImageViews[i], NULL); vkDestroySwapchainKHR(queue->outputDevice->outputDevice->device, queue->presentationQueue->swapChain, NULL); diff --git a/projects/apis/vulkan/src/presentation_queue/vulkan_presentation_queue.h b/projects/apis/vulkan/src/presentation_queue/vulkan_presentation_queue.h index 3b6b2a0..f3ebe40 100644 --- a/projects/apis/vulkan/src/presentation_queue/vulkan_presentation_queue.h +++ b/projects/apis/vulkan/src/presentation_queue/vulkan_presentation_queue.h @@ -8,3 +8,7 @@ typedef struct gnPlatformPresentationQueue_t { VkImage* swapChainImages; VkImageView* swapChainImageViews; } gnPlatformPresentationQueue; + +gnReturnCode createPresentationQueue(gnPresentationQueueHandle presentationQueue, const gnDevice device, gnPresentationQueueInfo presentationInfo); +gnReturnCode getPresentQueueImage(gnPresentationQueueHandle presentationQueue, uint64_t timeout, gnSemaphore semaphore, uint32_t* imageIndex); +void destroyPresentationQueue(gnPresentationQueueHandle queue);