first device functions loaded

This commit is contained in:
Gregory Wells
2025-06-24 13:49:00 -04:00
parent 8d2c58b0e9
commit cdf8dd46d2
3 changed files with 56 additions and 4 deletions

View File

@@ -1,7 +1,55 @@
#include "vulkan_loader.h"
#include <presentation_queue/vulkan_presentation_queue.h>
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);
};
}

View File

@@ -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);

View File

@@ -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);