From 29a2818643dde8e505d4b63b14b2ef5028cddd00 Mon Sep 17 00:00:00 2001 From: Greg Wells Date: Wed, 16 Jul 2025 19:52:12 -0400 Subject: [PATCH] GN_EXT_QUEUES done, untested --- projects/apis/vulkan/loader/vulkan_queue_loader.c | 5 ++++- projects/apis/vulkan/src/present/vulkan_present.c | 15 +++++++++++---- projects/apis/vulkan/src/present/vulkan_present.h | 2 ++ projects/extensions/queues/gryphn_queue_present.h | 6 ++++++ projects/extensions/queues/queues_functions.h | 5 +++++ .../commands/gryphn_sync_present.h | 1 - 6 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 projects/extensions/queues/gryphn_queue_present.h diff --git a/projects/apis/vulkan/loader/vulkan_queue_loader.c b/projects/apis/vulkan/loader/vulkan_queue_loader.c index d424f35..a120ed0 100644 --- a/projects/apis/vulkan/loader/vulkan_queue_loader.c +++ b/projects/apis/vulkan/loader/vulkan_queue_loader.c @@ -1,12 +1,15 @@ #include "vulkan_loader.h" #include "extensions/queues/vulkan_device_queues.h" #include +#include gnQueueExtFunctions loadVulkanQueueFunctions() { return (gnQueueExtFunctions) { ._gnGetPhysicalDeviceQueueProperties = vulkanPhysicalDeviceQueueProperties, ._gnQueueSubmit = vulkanSubmitQueue, ._gnQueueSubmitSync = vulkanSubmitSyncQueue, - ._gnGetDeviceQueue = getVulkanDeviceQueue + ._gnGetDeviceQueue = getVulkanDeviceQueue, + ._gnQueuePresent = vulkanQueuePresent, + ._gnQueuePresentSync = vulkanQueuePresentSync }; } diff --git a/projects/apis/vulkan/src/present/vulkan_present.c b/projects/apis/vulkan/src/present/vulkan_present.c index 059bba0..9d87d06 100644 --- a/projects/apis/vulkan/src/present/vulkan_present.c +++ b/projects/apis/vulkan/src/present/vulkan_present.c @@ -2,7 +2,7 @@ #include "extensions/synchronization/commands/gryphn_sync_present.h" #include "vulkan_surface/vulkan_surface.h" -gnReturnCode vulkanPresentSync(gnDevice device, gnPresentSyncInfo info) { +gnReturnCode vulkanQueuePresentSync(gnDevice device, gnQueue queue, gnPresentSyncInfo info) { VkSemaphore* waitSemaphores = malloc(sizeof(VkSemaphore) * info.waitCount); for (int i = 0; i < info.waitCount; i++) waitSemaphores[i] = info.waitSemaphores[i]->semaphore->semaphore; @@ -18,14 +18,17 @@ gnReturnCode vulkanPresentSync(gnDevice device, gnPresentSyncInfo info) { .pImageIndices = info.imageIndices }; - VkResult result = vkQueuePresentKHR(device->outputDevice->queues[info.presentationQueues[0]->info.surface->windowSurface->presentQueueIndex].queue, &presentInfo); + VkResult result = vkQueuePresentKHR((VkQueue)queue, &presentInfo); if (result == VK_ERROR_OUT_OF_DATE_KHR) return GN_OUT_OF_DATE_PRESENTATION_QUEUE; if (result == VK_SUBOPTIMAL_KHR) return GN_SUBOPTIMAL_PRESENTATION_QUEUE; return GN_SUCCESS; } +gnReturnCode vulkanPresentSync(gnDevice device, gnPresentSyncInfo info) { + return vulkanQueuePresentSync(device, (gnQueue)device->outputDevice->queues[info.presentationQueues[0]->info.surface->windowSurface->presentQueueIndex].queue, info); +} -gnReturnCode vulkanPresent(gnDevice device, gnPresentInfo info) { +gnReturnCode vulkanQueuePresent(gnDevice device, gnQueue queue, gnPresentInfo info) { VkSwapchainKHR* swapchains = malloc(sizeof(VkSwapchainKHR) * info.presentationQueueCount); for (int i = 0; i < info.presentationQueueCount; i++) swapchains[i] = info.presentationQueues[i]->presentationQueue->swapChain; @@ -38,8 +41,12 @@ gnReturnCode vulkanPresent(gnDevice device, gnPresentInfo info) { .pImageIndices = info.imageIndices }; - VkResult result = vkQueuePresentKHR(device->outputDevice->queues[info.presentationQueues[0]->info.surface->windowSurface->presentQueueIndex].queue, &presentInfo); + VkResult result = vkQueuePresentKHR((VkQueue)queue, &presentInfo); if (result == VK_ERROR_OUT_OF_DATE_KHR) return GN_OUT_OF_DATE_PRESENTATION_QUEUE; if (result == VK_SUBOPTIMAL_KHR) return GN_SUBOPTIMAL_PRESENTATION_QUEUE; return GN_SUCCESS; } + +gnReturnCode vulkanPresent(gnDevice device, gnPresentInfo info) { + return vulkanQueuePresent(device, (gnQueue)device->outputDevice->queues[info.presentationQueues[0]->info.surface->windowSurface->presentQueueIndex].queue, info); +} diff --git a/projects/apis/vulkan/src/present/vulkan_present.h b/projects/apis/vulkan/src/present/vulkan_present.h index ce72090..98afd81 100644 --- a/projects/apis/vulkan/src/present/vulkan_present.h +++ b/projects/apis/vulkan/src/present/vulkan_present.h @@ -4,4 +4,6 @@ #include gnReturnCode vulkanPresentSync(gnDevice device, gnPresentSyncInfo info); +gnReturnCode vulkanQueuePresentSync(gnDevice device, gnQueue queue, gnPresentSyncInfo info); gnReturnCode vulkanPresent(gnDevice device, gnPresentInfo info); +gnReturnCode vulkanQueuePresent(gnOutputDevice device, gnQueue queue, gnPresentInfo info); diff --git a/projects/extensions/queues/gryphn_queue_present.h b/projects/extensions/queues/gryphn_queue_present.h new file mode 100644 index 0000000..7353824 --- /dev/null +++ b/projects/extensions/queues/gryphn_queue_present.h @@ -0,0 +1,6 @@ +#pragma once +#include +#include + +gnReturnCode gnQueuePresent(gnDevice device, gnQueue queue, gnPresentInfo info); +gnReturnCode gnQueuePresentSync(gnDevice device, gnQueue queue, gnPresentSyncInfo info); diff --git a/projects/extensions/queues/queues_functions.h b/projects/extensions/queues/queues_functions.h index 689fd3b..43f8e06 100644 --- a/projects/extensions/queues/queues_functions.h +++ b/projects/extensions/queues/queues_functions.h @@ -6,6 +6,8 @@ typedef struct gnQueueFamilyProperties gnQueueFamilyProperties; typedef struct gnSubmitInfo gnSubmitInfo; typedef struct gnSubmitSyncInfo gnSubmitSyncInfo; +typedef struct gnPresentInfo gnPresentInfo; +typedef struct gnPresentSyncInfo gnPresentSyncInfo; typedef struct gnQueueExtFunctions { gnReturnCode (*_gnGetPhysicalDeviceQueueProperties)(gnPhysicalOutputDeviceHandle device, uint32_t queueCount, gnQueueFamilyProperties* queues); @@ -13,4 +15,7 @@ typedef struct gnQueueExtFunctions { gnReturnCode (*_gnQueueSubmit)(gnOutputDevice device, gnQueue queue, gnSubmitInfo info); gnReturnCode (*_gnQueueSubmitSync)(gnOutputDevice device, gnQueue queue, gnSubmitSyncInfo info); + + gnReturnCode (*_gnQueuePresent)(gnDevice device, gnQueue queue, gnPresentInfo info); + gnReturnCode (*_gnQueuePresentSync)(gnDevice device, gnQueue queue, gnPresentSyncInfo info); } gnQueueExtFunctions; diff --git a/projects/extensions/synchronization/commands/gryphn_sync_present.h b/projects/extensions/synchronization/commands/gryphn_sync_present.h index 602195a..874eee4 100644 --- a/projects/extensions/synchronization/commands/gryphn_sync_present.h +++ b/projects/extensions/synchronization/commands/gryphn_sync_present.h @@ -2,7 +2,6 @@ #include "stdint.h" #include "utils/gryphn_error_code.h" #include "gryphn_handles.h" -#include "extensions/synchronization/semaphore/gryphn_semaphore.h" typedef struct gnPresentSyncInfo { uint32_t waitCount;