From 7e724da698ed2091c044f588796b7a71b3258f8b Mon Sep 17 00:00:00 2001 From: Greg Wells Date: Wed, 16 Jul 2025 19:19:03 -0400 Subject: [PATCH] more GN_EXT_QUEUES business --- .../command_pool/vulkan_command_pool.c | 7 ++--- .../vulkan_presentation_queue.c | 26 ++++++++++++------- .../command_pool/gryphn_command_pool.h | 1 + .../gryphn_presentation_queue.h | 8 +++--- 4 files changed, 26 insertions(+), 16 deletions(-) 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 0576b0a..2ee9c37 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,5 +1,6 @@ #include "vulkan_command_pool.h" #include "output_device/vulkan_output_devices.h" +#include "instance/gryphn_instance.h" gnReturnCode createCommandPool(gnCommandPool commandPool, gnDevice device, gnCommandPoolInfo info) { commandPool->commandPool = malloc(sizeof(gnPlatformCommandPool)); @@ -7,12 +8,12 @@ gnReturnCode createCommandPool(gnCommandPool commandPool, gnDevice device, gnCom VkCommandPoolCreateInfo poolInfo = { .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, .flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, - .queueFamilyIndex = device->outputDevice->queues[device->outputDevice->graphicsQueueIndex].queueInfo.queueIndex, + .queueFamilyIndex = info.queueFamilyIndex, }; + if (!device->instance->enabledExtensions[GN_EXT_QUEUES]) poolInfo.queueFamilyIndex = device->outputDevice->queues[device->outputDevice->graphicsQueueIndex].queueInfo.queueIndex; - if (vkCreateCommandPool(device->outputDevice->device, &poolInfo, NULL, &commandPool->commandPool->commandPool) != VK_SUCCESS) { + if (vkCreateCommandPool(device->outputDevice->device, &poolInfo, NULL, &commandPool->commandPool->commandPool) != VK_SUCCESS) return GN_FAILED_TO_CREATE_COMMAND_POOL; - } return GN_SUCCESS; } 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 ed9b9d2..96936b5 100644 --- a/projects/apis/vulkan/src/presentation_queue/vulkan_presentation_queue.c +++ b/projects/apis/vulkan/src/presentation_queue/vulkan_presentation_queue.c @@ -30,17 +30,23 @@ gnReturnCode createPresentationQueue(gnPresentationQueueHandle presentationQueue createInfo.imageArrayLayers = 1; createInfo.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; - if (presentationInfo.surface->windowSurface->presentQueueIndex != device->outputDevice->graphicsQueueIndex) { - createInfo.imageSharingMode = VK_SHARING_MODE_CONCURRENT; - createInfo.queueFamilyIndexCount = 2; - createInfo.pQueueFamilyIndices = (uint32_t[]){ - device->outputDevice->queues[presentationInfo.surface->windowSurface->presentQueueIndex].queueInfo.queueIndex, - device->outputDevice->queues[device->outputDevice->graphicsQueueIndex].queueInfo.queueIndex - }; + if (device->instance->enabledExtensions[GN_EXT_QUEUES]) { + createInfo.imageSharingMode = (presentationInfo.imageSharingMode == GN_SHARING_MODE_CONCURRENT) ? VK_SHARING_MODE_CONCURRENT : VK_SHARING_MODE_EXCLUSIVE; + createInfo.queueFamilyIndexCount = presentationInfo.queueFamilyCount; + createInfo.pQueueFamilyIndices = presentationInfo.queueFamilies; } else { - createInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; - createInfo.queueFamilyIndexCount = 1; - createInfo.pQueueFamilyIndices = &device->outputDevice->queues[presentationInfo.surface->windowSurface->presentQueueIndex].queueInfo.queueIndex; + if (presentationInfo.surface->windowSurface->presentQueueIndex != device->outputDevice->graphicsQueueIndex) { + createInfo.imageSharingMode = VK_SHARING_MODE_CONCURRENT; + createInfo.queueFamilyIndexCount = 2; + createInfo.pQueueFamilyIndices = (uint32_t[]){ + device->outputDevice->queues[presentationInfo.surface->windowSurface->presentQueueIndex].queueInfo.queueIndex, + device->outputDevice->queues[device->outputDevice->graphicsQueueIndex].queueInfo.queueIndex + }; + } else { + createInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; + createInfo.queueFamilyIndexCount = 1; + createInfo.pQueueFamilyIndices = &device->outputDevice->queues[presentationInfo.surface->windowSurface->presentQueueIndex].queueInfo.queueIndex; + } } createInfo.preTransform = details.capabilities.currentTransform; createInfo.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR; diff --git a/projects/core/src/command/command_pool/gryphn_command_pool.h b/projects/core/src/command/command_pool/gryphn_command_pool.h index 015f4f0..9797a51 100644 --- a/projects/core/src/command/command_pool/gryphn_command_pool.h +++ b/projects/core/src/command/command_pool/gryphn_command_pool.h @@ -11,6 +11,7 @@ typedef gnFlags gnCommandPoolFlags; typedef struct gnCommandPoolInfo { gnCommandPoolFlags flags; + uint32_t queueFamilyIndex; // ignored unless GN_EXT_QUEUES is enabled } gnCommandPoolInfo; #ifdef GN_REVEAL_IMPL diff --git a/projects/core/src/presentation_queue/gryphn_presentation_queue.h b/projects/core/src/presentation_queue/gryphn_presentation_queue.h index 39756a9..3327046 100644 --- a/projects/core/src/presentation_queue/gryphn_presentation_queue.h +++ b/projects/core/src/presentation_queue/gryphn_presentation_queue.h @@ -9,9 +9,11 @@ typedef struct gnPresentationQueueInfo { gnUInt2 imageSize; gnWindowSurfaceHandle surface; gnSurfaceFormat format; - // gnImageSharingMode imageSharingMode; - // uint32_t queueFamilyCount; - // uint32_t* queueFamilies; + + // ignored unless GN_EXT_QUEUES is enabled + gnImageSharingMode imageSharingMode; + uint32_t queueFamilyCount; + uint32_t* queueFamilies; } gnPresentationQueueInfo; struct gnPlatformPresentationQueue_t;