more GN_EXT_QUEUES business

This commit is contained in:
Greg Wells
2025-07-16 19:19:03 -04:00
parent b3f72c94ae
commit 7e724da698
4 changed files with 26 additions and 16 deletions

View File

@@ -1,5 +1,6 @@
#include "vulkan_command_pool.h" #include "vulkan_command_pool.h"
#include "output_device/vulkan_output_devices.h" #include "output_device/vulkan_output_devices.h"
#include "instance/gryphn_instance.h"
gnReturnCode createCommandPool(gnCommandPool commandPool, gnDevice device, gnCommandPoolInfo info) { gnReturnCode createCommandPool(gnCommandPool commandPool, gnDevice device, gnCommandPoolInfo info) {
commandPool->commandPool = malloc(sizeof(gnPlatformCommandPool)); commandPool->commandPool = malloc(sizeof(gnPlatformCommandPool));
@@ -7,12 +8,12 @@ gnReturnCode createCommandPool(gnCommandPool commandPool, gnDevice device, gnCom
VkCommandPoolCreateInfo poolInfo = { VkCommandPoolCreateInfo poolInfo = {
.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, .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_FAILED_TO_CREATE_COMMAND_POOL;
}
return GN_SUCCESS; return GN_SUCCESS;
} }

View File

@@ -30,17 +30,23 @@ gnReturnCode createPresentationQueue(gnPresentationQueueHandle presentationQueue
createInfo.imageArrayLayers = 1; createInfo.imageArrayLayers = 1;
createInfo.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; createInfo.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
if (presentationInfo.surface->windowSurface->presentQueueIndex != device->outputDevice->graphicsQueueIndex) { if (device->instance->enabledExtensions[GN_EXT_QUEUES]) {
createInfo.imageSharingMode = VK_SHARING_MODE_CONCURRENT; createInfo.imageSharingMode = (presentationInfo.imageSharingMode == GN_SHARING_MODE_CONCURRENT) ? VK_SHARING_MODE_CONCURRENT : VK_SHARING_MODE_EXCLUSIVE;
createInfo.queueFamilyIndexCount = 2; createInfo.queueFamilyIndexCount = presentationInfo.queueFamilyCount;
createInfo.pQueueFamilyIndices = (uint32_t[]){ createInfo.pQueueFamilyIndices = presentationInfo.queueFamilies;
device->outputDevice->queues[presentationInfo.surface->windowSurface->presentQueueIndex].queueInfo.queueIndex,
device->outputDevice->queues[device->outputDevice->graphicsQueueIndex].queueInfo.queueIndex
};
} else { } else {
createInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; if (presentationInfo.surface->windowSurface->presentQueueIndex != device->outputDevice->graphicsQueueIndex) {
createInfo.queueFamilyIndexCount = 1; createInfo.imageSharingMode = VK_SHARING_MODE_CONCURRENT;
createInfo.pQueueFamilyIndices = &device->outputDevice->queues[presentationInfo.surface->windowSurface->presentQueueIndex].queueInfo.queueIndex; 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.preTransform = details.capabilities.currentTransform;
createInfo.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR; createInfo.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;

View File

@@ -11,6 +11,7 @@ typedef gnFlags gnCommandPoolFlags;
typedef struct gnCommandPoolInfo { typedef struct gnCommandPoolInfo {
gnCommandPoolFlags flags; gnCommandPoolFlags flags;
uint32_t queueFamilyIndex; // ignored unless GN_EXT_QUEUES is enabled
} gnCommandPoolInfo; } gnCommandPoolInfo;
#ifdef GN_REVEAL_IMPL #ifdef GN_REVEAL_IMPL

View File

@@ -9,9 +9,11 @@ typedef struct gnPresentationQueueInfo {
gnUInt2 imageSize; gnUInt2 imageSize;
gnWindowSurfaceHandle surface; gnWindowSurfaceHandle surface;
gnSurfaceFormat format; gnSurfaceFormat format;
// gnImageSharingMode imageSharingMode;
// uint32_t queueFamilyCount; // ignored unless GN_EXT_QUEUES is enabled
// uint32_t* queueFamilies; gnImageSharingMode imageSharingMode;
uint32_t queueFamilyCount;
uint32_t* queueFamilies;
} gnPresentationQueueInfo; } gnPresentationQueueInfo;
struct gnPlatformPresentationQueue_t; struct gnPlatformPresentationQueue_t;