vulkan remove queue API
This commit is contained in:
@@ -2,5 +2,6 @@
|
|||||||
|
|
||||||
gnBool metalIsExtensionSupported(gnExtension extension) {
|
gnBool metalIsExtensionSupported(gnExtension extension) {
|
||||||
if (extension == GN_EXT_SYNCHRONIZATION) return gnTrue;
|
if (extension == GN_EXT_SYNCHRONIZATION) return gnTrue;
|
||||||
|
if (extension == GN_EXT_QUEUES) return gnTrue;
|
||||||
return gnFalse;
|
return gnFalse;
|
||||||
}
|
}
|
||||||
|
@@ -2,5 +2,6 @@
|
|||||||
|
|
||||||
gnBool vulkanIsExtensionSupported(gnExtension extension){
|
gnBool vulkanIsExtensionSupported(gnExtension extension){
|
||||||
if (extension == GN_EXT_SYNCHRONIZATION) return gnTrue;
|
if (extension == GN_EXT_SYNCHRONIZATION) return gnTrue;
|
||||||
|
if (extension == GN_EXT_QUEUES) return gnTrue;
|
||||||
return gnFalse;
|
return gnFalse;
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,7 @@ 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 = info.queueIndex,
|
.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) {
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
#include "vulkan_instance.h"
|
#include "vulkan_instance.h"
|
||||||
#include <debugger/vulkan_debugger.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
typedef struct vkUserData {
|
typedef struct vkUserData {
|
||||||
|
@@ -8,13 +8,13 @@
|
|||||||
gnReturnCode createOutputDevice(gnOutputDeviceHandle outputDevice, gnInstanceHandle instance, gnOutputDeviceInfo deviceInfo) {
|
gnReturnCode createOutputDevice(gnOutputDeviceHandle outputDevice, gnInstanceHandle instance, gnOutputDeviceInfo deviceInfo) {
|
||||||
outputDevice->outputDevice = malloc(sizeof(gnPlatformOutputDevice));
|
outputDevice->outputDevice = malloc(sizeof(gnPlatformOutputDevice));
|
||||||
|
|
||||||
VkDeviceQueueCreateInfo* queueCreateInfos = malloc(sizeof(VkDeviceQueueCreateInfo) * deviceInfo.queueInfoCount);
|
VkDeviceQueueCreateInfo* queueCreateInfos = malloc(sizeof(VkDeviceQueueCreateInfo) * deviceInfo.physicalDevice->physicalDevice->neededQueueCount);
|
||||||
float queuePriority = 1.0f;
|
float queuePriority = 1.0f;
|
||||||
for (int i = 0; i < deviceInfo.queueInfoCount; i++) {
|
for (int i = 0; i < deviceInfo.physicalDevice->physicalDevice->neededQueueCount; i++) {
|
||||||
queueCreateInfos[i].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
|
queueCreateInfos[i].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
|
||||||
queueCreateInfos[i].flags = 0;
|
queueCreateInfos[i].flags = 0;
|
||||||
queueCreateInfos[i].queueFamilyIndex = deviceInfo.queueInfos[i].queueIndex;
|
queueCreateInfos[i].queueFamilyIndex = deviceInfo.physicalDevice->physicalDevice->neededQueues[i].queueIndex;
|
||||||
queueCreateInfos[i].queueCount = deviceInfo.queueInfos[i].queueCount;
|
queueCreateInfos[i].queueCount = 1;
|
||||||
queueCreateInfos[i].pQueuePriorities = &queuePriority;
|
queueCreateInfos[i].pQueuePriorities = &queuePriority;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ gnReturnCode createOutputDevice(gnOutputDeviceHandle outputDevice, gnInstanceHan
|
|||||||
|
|
||||||
VkDeviceCreateInfo deviceCreateInfo = {
|
VkDeviceCreateInfo deviceCreateInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
|
||||||
.queueCreateInfoCount = deviceInfo.queueInfoCount,
|
.queueCreateInfoCount = deviceInfo.physicalDevice->physicalDevice->neededQueueCount,
|
||||||
.pQueueCreateInfos = queueCreateInfos,
|
.pQueueCreateInfos = queueCreateInfos,
|
||||||
.pEnabledFeatures = &deviceFeatures
|
.pEnabledFeatures = &deviceFeatures
|
||||||
};
|
};
|
||||||
@@ -45,9 +45,20 @@ gnReturnCode createOutputDevice(gnOutputDeviceHandle outputDevice, gnInstanceHan
|
|||||||
if (vkCreateDevice(deviceInfo.physicalDevice->physicalDevice->device, &deviceCreateInfo, NULL, &outputDevice->outputDevice->device) != VK_SUCCESS)
|
if (vkCreateDevice(deviceInfo.physicalDevice->physicalDevice->device, &deviceCreateInfo, NULL, &outputDevice->outputDevice->device) != VK_SUCCESS)
|
||||||
return GN_FAILED_TO_CREATE_DEVICE;
|
return GN_FAILED_TO_CREATE_DEVICE;
|
||||||
|
|
||||||
outputDevice->outputDevice->queues = malloc(sizeof(VkQueue) * deviceInfo.queueInfoCount);
|
outputDevice->outputDevice->queues = malloc(sizeof(VkQueue) * deviceInfo.physicalDevice->physicalDevice->neededQueueCount);
|
||||||
for (int i = 0; i < deviceInfo.queueInfoCount; i++) {
|
uint32_t transferQueue = 0;
|
||||||
vkGetDeviceQueue(outputDevice->outputDevice->device, deviceInfo.queueInfos[i].queueIndex, 0, &outputDevice->outputDevice->queues[i]);
|
for (int i = 0; i < deviceInfo.physicalDevice->physicalDevice->neededQueueCount; i++) {
|
||||||
|
outputDevice->outputDevice->queues[i].queueInfo = deviceInfo.physicalDevice->physicalDevice->neededQueues[i];
|
||||||
|
|
||||||
|
vkGetDeviceQueue(outputDevice->outputDevice->device, deviceInfo.physicalDevice->physicalDevice->neededQueues[i].queueIndex, 0, &outputDevice->outputDevice->queues[i].queue);
|
||||||
|
if ((outputDevice->outputDevice->queues[i].queueInfo.createFlags & VK_QUEUE_TRANSFER_BIT) == VK_QUEUE_TRANSFER_BIT) {
|
||||||
|
outputDevice->outputDevice->transferQueueIndex = i;
|
||||||
|
transferQueue = outputDevice->outputDevice->queues[i].queueInfo.queueIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((outputDevice->outputDevice->queues[i].queueInfo.createFlags & VK_QUEUE_GRAPHICS_BIT) == VK_QUEUE_GRAPHICS_BIT) {
|
||||||
|
outputDevice->outputDevice->graphicsQueueIndex = i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t queueCount = 0;
|
uint32_t queueCount = 0;
|
||||||
@@ -64,19 +75,10 @@ gnReturnCode createOutputDevice(gnOutputDeviceHandle outputDevice, gnInstanceHan
|
|||||||
queueFamilies
|
queueFamilies
|
||||||
);
|
);
|
||||||
|
|
||||||
uint32_t transferQueueIndex = 0;
|
|
||||||
for (int i = 0; i < queueCount; i++) {
|
|
||||||
if ((queueFamilies[i].queueFlags & VK_QUEUE_TRANSFER_BIT) == VK_QUEUE_TRANSFER_BIT) {
|
|
||||||
transferQueueIndex = i;
|
|
||||||
vkGetDeviceQueue(outputDevice->outputDevice->device, deviceInfo.queueInfos[i].queueIndex, 0, &outputDevice->outputDevice->transferQueue);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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 = transferQueueIndex
|
.queueFamilyIndex = transferQueue
|
||||||
};
|
};
|
||||||
|
|
||||||
if (vkCreateCommandPool(outputDevice->outputDevice->device, &poolInfo, NULL, &outputDevice->outputDevice->transferCommandPool) != VK_SUCCESS)
|
if (vkCreateCommandPool(outputDevice->outputDevice->device, &poolInfo, NULL, &outputDevice->outputDevice->transferCommandPool) != VK_SUCCESS)
|
||||||
@@ -116,5 +118,5 @@ VkCommandBuffer gnBeginVulkanTransferOperation(gnDevice device) {
|
|||||||
return VkBeginTransferOperation(device->outputDevice->device, device->outputDevice->transferCommandPool);
|
return VkBeginTransferOperation(device->outputDevice->device, device->outputDevice->transferCommandPool);
|
||||||
}
|
}
|
||||||
void gnEndVulkanTransferOperation(gnDevice device, VkCommandBuffer buffer) {
|
void gnEndVulkanTransferOperation(gnDevice device, VkCommandBuffer buffer) {
|
||||||
VkEndTransferOperation(buffer, device->outputDevice->transferCommandPool, device->outputDevice->transferQueue, device->outputDevice->device);
|
VkEndTransferOperation(buffer, device->outputDevice->transferCommandPool, device->outputDevice->queues[device->outputDevice->transferQueueIndex].queue, device->outputDevice->device);
|
||||||
}
|
}
|
||||||
|
@@ -2,20 +2,26 @@
|
|||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <output_device/gryphn_output_device.h>
|
#include <output_device/gryphn_output_device.h>
|
||||||
#include "buffers/vulkan_buffer.h"
|
#include "buffers/vulkan_buffer.h"
|
||||||
|
#include "vulkan_physical_device.h"
|
||||||
|
|
||||||
|
typedef struct vulkanQueue {
|
||||||
|
VkQueue queue;
|
||||||
|
vulkanNeededQueue queueInfo;
|
||||||
|
} vulkanQueue;
|
||||||
|
|
||||||
typedef struct gnPlatformOutputDevice_t {
|
typedef struct gnPlatformOutputDevice_t {
|
||||||
VkDevice device;
|
VkDevice device;
|
||||||
uint32_t queueCount;
|
|
||||||
VkQueue* queues;
|
|
||||||
|
|
||||||
VkQueue transferQueue;
|
uint32_t transferQueueIndex, graphicsQueueIndex;
|
||||||
|
uint32_t queueCount;
|
||||||
|
vulkanQueue* queues;
|
||||||
|
|
||||||
VkCommandPool transferCommandPool;
|
VkCommandPool transferCommandPool;
|
||||||
|
|
||||||
VkGryphnBuffer stagingBuffer;
|
VkGryphnBuffer stagingBuffer;
|
||||||
VkDeviceSize stagingBufferSize;
|
VkDeviceSize stagingBufferSize;
|
||||||
|
|
||||||
VkFence barrierFence;
|
VkFence barrierFence;
|
||||||
|
|
||||||
gnBool enabledOversizedDescriptorPools;
|
gnBool enabledOversizedDescriptorPools;
|
||||||
} gnPlatformOutputDevice;
|
} gnPlatformOutputDevice;
|
||||||
|
|
||||||
|
@@ -56,20 +56,37 @@ gnPhysicalDevice* getPhysicalDevices(gnInstanceHandle instance, uint32_t* device
|
|||||||
case VK_PHYSICAL_DEVICE_TYPE_MAX_ENUM: outputDevices[i]->properties.deviceType = GN_INTEGRATED_DEVICE;
|
case VK_PHYSICAL_DEVICE_TYPE_MAX_ENUM: outputDevices[i]->properties.deviceType = GN_INTEGRATED_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
vkGetPhysicalDeviceQueueFamilyProperties(physicalDevices[i], &outputDevices[i]->queueProperties.queueCount, NULL);
|
uint32_t queueFamilyCount = 0;
|
||||||
|
vkGetPhysicalDeviceQueueFamilyProperties(physicalDevices[i], &queueFamilyCount, NULL);
|
||||||
|
VkQueueFamilyProperties* queueFamilies = malloc(sizeof(VkQueueFamilyProperties) * queueFamilyCount);
|
||||||
|
vkGetPhysicalDeviceQueueFamilyProperties(physicalDevices[i], &queueFamilyCount, queueFamilies);
|
||||||
|
|
||||||
VkQueueFamilyProperties* queueFamilies = malloc(sizeof(VkQueueFamilyProperties) * outputDevices[i]->queueProperties.queueCount);
|
outputDevices[i]->physicalDevice->neededQueues = malloc(sizeof(vulkanNeededQueue) * queueFamilyCount);
|
||||||
outputDevices[i]->queueProperties.queueProperties = malloc(sizeof(gnQueueProperties) * outputDevices[i]->queueProperties.queueCount);
|
gnBool foundGraphicsQueueFamily = gnFalse, foundTransferQueueFamily = gnFalse;
|
||||||
vkGetPhysicalDeviceQueueFamilyProperties(physicalDevices[i], &outputDevices[i]->queueProperties.queueCount, queueFamilies);
|
for (int c = 0; c < queueFamilyCount; c++) {
|
||||||
for (int c = 0; c < outputDevices[i]->queueProperties.queueCount; c++) {
|
gnBool hasNeededQueue = gnFalse;
|
||||||
outputDevices[i]->queueProperties.queueProperties[i].queueCount = queueFamilies[i].queueCount;
|
|
||||||
|
|
||||||
gnQueueTypeFlags finalQueueType = 0;
|
if ((queueFamilies[c].queueFlags & VK_QUEUE_GRAPHICS_BIT) == VK_QUEUE_GRAPHICS_BIT) {
|
||||||
if (queueFamilies[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) finalQueueType |= GN_QUEUE_GRAPHICS;
|
foundGraphicsQueueFamily = true;
|
||||||
if (queueFamilies[i].queueFlags & VK_QUEUE_COMPUTE_BIT) finalQueueType |= GN_QUEUE_COMPUTE;
|
hasNeededQueue = gnTrue;
|
||||||
if (queueFamilies[i].queueFlags & VK_QUEUE_TRANSFER_BIT) finalQueueType |= GN_QUEUE_TRANSFER;
|
}
|
||||||
if (queueFamilies[i].queueFlags & VK_QUEUE_SPARSE_BINDING_BIT) finalQueueType |= GN_QUEUE_SPARSE_BINDING;
|
if ((queueFamilies[c].queueFlags & VK_QUEUE_TRANSFER_BIT) == VK_QUEUE_TRANSFER_BIT) {
|
||||||
outputDevices[i]->queueProperties.queueProperties[i].queueType = finalQueueType;
|
foundTransferQueueFamily = true;
|
||||||
|
hasNeededQueue = gnTrue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasNeededQueue) {
|
||||||
|
vulkanNeededQueue neededQueue = {
|
||||||
|
.queueIndex = c,
|
||||||
|
.createFlags = 0,
|
||||||
|
.usedForPresent = gnFalse
|
||||||
|
};
|
||||||
|
if ((queueFamilies[c].queueFlags & VK_QUEUE_GRAPHICS_BIT)) neededQueue.createFlags |= VK_QUEUE_GRAPHICS_BIT;
|
||||||
|
if ((queueFamilies[c].queueFlags & VK_QUEUE_TRANSFER_BIT)) neededQueue.createFlags |= VK_QUEUE_TRANSFER_BIT;
|
||||||
|
|
||||||
|
outputDevices[i]->physicalDevice->neededQueues[outputDevices[i]->physicalDevice->neededQueueCount] = neededQueue;
|
||||||
|
outputDevices[i]->physicalDevice->neededQueueCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VkPhysicalDeviceProperties physicalDeviceProperties;
|
VkPhysicalDeviceProperties physicalDeviceProperties;
|
||||||
@@ -78,16 +95,55 @@ gnPhysicalDevice* getPhysicalDevices(gnInstanceHandle instance, uint32_t* device
|
|||||||
outputDevices[i]->features.maxDepthSamples = vkSampleCountToGryphn(physicalDeviceProperties.limits.framebufferDepthSampleCounts);
|
outputDevices[i]->features.maxDepthSamples = vkSampleCountToGryphn(physicalDeviceProperties.limits.framebufferDepthSampleCounts);
|
||||||
outputDevices[i]->features.maxMemoryAllocations = physicalDeviceProperties.limits.maxMemoryAllocationCount;
|
outputDevices[i]->features.maxMemoryAllocations = physicalDeviceProperties.limits.maxMemoryAllocationCount;
|
||||||
outputDevices[i]->features.maxPushConstantSize = physicalDeviceProperties.limits.maxPushConstantsSize;
|
outputDevices[i]->features.maxPushConstantSize = physicalDeviceProperties.limits.maxPushConstantsSize;
|
||||||
|
|
||||||
|
free(queueFamilies);
|
||||||
}
|
}
|
||||||
free(physicalDevices);
|
free(physicalDevices);
|
||||||
|
|
||||||
return outputDevices;
|
return outputDevices;
|
||||||
}
|
}
|
||||||
|
|
||||||
gnBool queueCanPresentToSurface(gnPhysicalDevice device, uint32_t queueIndex, gnWindowSurfaceHandle windowSurface) {
|
gnBool deviceCanPresentToSurface(gnPhysicalDevice device, gnWindowSurface surface) {
|
||||||
|
gnBool foundQueue = gnFalse;
|
||||||
|
for (int i = 0; i < device->physicalDevice->neededQueueCount; i++) {
|
||||||
VkBool32 supportsPresent = VK_FALSE;
|
VkBool32 supportsPresent = VK_FALSE;
|
||||||
vkGetPhysicalDeviceSurfaceSupportKHR(device->physicalDevice->device, queueIndex, windowSurface->windowSurface->surface, &supportsPresent);
|
vkGetPhysicalDeviceSurfaceSupportKHR(device->physicalDevice->device, device->physicalDevice->neededQueues[i].queueIndex, surface->windowSurface->surface, &supportsPresent);
|
||||||
if (supportsPresent)
|
if (supportsPresent) {
|
||||||
return gnTrue;
|
device->physicalDevice->neededQueues[i].usedForPresent = gnTrue;
|
||||||
return gnFalse;
|
foundQueue = gnTrue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
surface->windowSurface->presentQueueIndex = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!foundQueue) {
|
||||||
|
uint32_t queueFamilyCount = 0;
|
||||||
|
vkGetPhysicalDeviceQueueFamilyProperties(device->physicalDevice->device, &queueFamilyCount, NULL);
|
||||||
|
|
||||||
|
for (int i = 0; i < queueFamilyCount; i++) {
|
||||||
|
VkBool32 supportsPresent = VK_FALSE;
|
||||||
|
vkGetPhysicalDeviceSurfaceSupportKHR(device->physicalDevice->device, i, surface->windowSurface->surface, &supportsPresent);
|
||||||
|
if (supportsPresent) {
|
||||||
|
device->physicalDevice->neededQueues[device->physicalDevice->neededQueueCount] = (vulkanNeededQueue){
|
||||||
|
.queueIndex = i,
|
||||||
|
.createFlags = 0,
|
||||||
|
.usedForPresent = gnTrue
|
||||||
|
};
|
||||||
|
foundQueue = gnTrue;
|
||||||
|
surface->windowSurface->presentQueueIndex = device->physicalDevice->neededQueueCount;
|
||||||
|
device->physicalDevice->neededQueueCount++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return foundQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// gnBool queueCanPresentToSurface(gnPhysicalDevice device, uint32_t queueIndex, gnWindowSurfaceHandle windowSurface) {
|
||||||
|
// VkBool32 supportsPresent = VK_FALSE;
|
||||||
|
// vkGetPhysicalDeviceSurfaceSupportKHR(device->physicalDevice->device, queueIndex, windowSurface->windowSurface->surface, &supportsPresent);
|
||||||
|
// if (supportsPresent)
|
||||||
|
// return gnTrue;
|
||||||
|
// return gnFalse;
|
||||||
|
// }
|
||||||
|
@@ -2,8 +2,17 @@
|
|||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <output_device/gryphn_physical_output_device.h>
|
#include <output_device/gryphn_physical_output_device.h>
|
||||||
|
|
||||||
|
typedef struct vulkanNeededQueue {
|
||||||
|
VkQueueFlags createFlags;
|
||||||
|
gnBool usedForPresent;
|
||||||
|
uint32_t queueIndex;
|
||||||
|
} vulkanNeededQueue;
|
||||||
|
|
||||||
typedef struct gnPlatformPhysicalDevice_t {
|
typedef struct gnPlatformPhysicalDevice_t {
|
||||||
VkPhysicalDevice device;
|
VkPhysicalDevice device;
|
||||||
|
uint32_t neededQueueCount;
|
||||||
|
vulkanNeededQueue* neededQueues;
|
||||||
|
|
||||||
} gnPlatformPhysicalDevice;
|
} gnPlatformPhysicalDevice;
|
||||||
|
|
||||||
gnPhysicalDevice* getPhysicalDevices(gnInstanceHandle instance, uint32_t* deviceCount);
|
gnPhysicalDevice* getPhysicalDevices(gnInstanceHandle instance, uint32_t* deviceCount);
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
#include "vulkan_present.h"
|
#include "vulkan_present.h"
|
||||||
#include "extensions/synchronization/commands/gryphn_sync_present.h"
|
#include "extensions/synchronization/commands/gryphn_sync_present.h"
|
||||||
|
#include "vulkan_surface/vulkan_surface.h"
|
||||||
|
|
||||||
gnReturnCode vulkanPresentSync(gnDevice device, gnPresentSyncInfo info) {
|
gnReturnCode vulkanPresentSync(gnDevice device, gnPresentSyncInfo info) {
|
||||||
VkSemaphore* waitSemaphores = malloc(sizeof(VkSemaphore) * info.waitCount);
|
VkSemaphore* waitSemaphores = malloc(sizeof(VkSemaphore) * info.waitCount);
|
||||||
@@ -17,10 +18,7 @@ gnReturnCode vulkanPresentSync(gnDevice device, gnPresentSyncInfo info) {
|
|||||||
.pImageIndices = info.imageIndices
|
.pImageIndices = info.imageIndices
|
||||||
};
|
};
|
||||||
|
|
||||||
VkQueue queue;
|
VkResult result = vkQueuePresentKHR(device->outputDevice->queues[info.presentationQueues[0]->info.surface->windowSurface->presentQueueIndex].queue, &presentInfo);
|
||||||
vkGetDeviceQueue(device->outputDevice->device, info.queueIndex, 0, &queue);
|
|
||||||
|
|
||||||
VkResult result = vkQueuePresentKHR(queue, &presentInfo);
|
|
||||||
if (result == VK_ERROR_OUT_OF_DATE_KHR) return GN_OUT_OF_DATE_PRESENTATION_QUEUE;
|
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;
|
if (result == VK_SUBOPTIMAL_KHR) return GN_SUBOPTIMAL_PRESENTATION_QUEUE;
|
||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
@@ -40,10 +38,7 @@ gnReturnCode vulkanPresent(gnDevice device, gnPresentInfo info) {
|
|||||||
.pImageIndices = info.imageIndices
|
.pImageIndices = info.imageIndices
|
||||||
};
|
};
|
||||||
|
|
||||||
VkQueue queue;
|
VkResult result = vkQueuePresentKHR(device->outputDevice->queues[info.presentationQueues[0]->info.surface->windowSurface->presentQueueIndex].queue, &presentInfo);
|
||||||
vkGetDeviceQueue(device->outputDevice->device, info.queueIndex, 0, &queue);
|
|
||||||
|
|
||||||
VkResult result = vkQueuePresentKHR(queue, &presentInfo);
|
|
||||||
if (result == VK_ERROR_OUT_OF_DATE_KHR) return GN_OUT_OF_DATE_PRESENTATION_QUEUE;
|
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;
|
if (result == VK_SUBOPTIMAL_KHR) return GN_SUBOPTIMAL_PRESENTATION_QUEUE;
|
||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
|
@@ -34,8 +34,8 @@ gnReturnCode createPresentationQueue(gnPresentationQueueHandle presentationQueue
|
|||||||
createInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
createInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||||
else
|
else
|
||||||
createInfo.imageSharingMode = VK_SHARING_MODE_CONCURRENT;
|
createInfo.imageSharingMode = VK_SHARING_MODE_CONCURRENT;
|
||||||
createInfo.queueFamilyIndexCount = presentationInfo.queueFamilyCount;
|
createInfo.queueFamilyIndexCount = 1;
|
||||||
createInfo.pQueueFamilyIndices = presentationInfo.queueFamilies;
|
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;
|
||||||
createInfo.presentMode = presentMode;
|
createInfo.presentMode = presentMode;
|
||||||
|
@@ -26,7 +26,7 @@ gnReturnCode vulkanSubmitSync(gnDevice device, gnSubmitSyncInfo info) {
|
|||||||
VkQueue queue;
|
VkQueue queue;
|
||||||
vkGetDeviceQueue(device->outputDevice->device, info.queueIndex, 0, &queue);
|
vkGetDeviceQueue(device->outputDevice->device, info.queueIndex, 0, &queue);
|
||||||
|
|
||||||
if (vkQueueSubmit(queue, 1, &submitInfo, info.fence->fence->fence) != VK_SUCCESS) {
|
if (vkQueueSubmit(device->outputDevice->queues[device->outputDevice->graphicsQueueIndex].queue, 1, &submitInfo, info.fence->fence->fence) != VK_SUCCESS) {
|
||||||
free(waitSemaphores);
|
free(waitSemaphores);
|
||||||
free(waitStages);
|
free(waitStages);
|
||||||
free(commandBuffers);
|
free(commandBuffers);
|
||||||
@@ -55,11 +55,8 @@ gnReturnCode vulkanSubmit(gnDevice device, gnSubmitInfo info) {
|
|||||||
.pSignalSemaphores = NULL
|
.pSignalSemaphores = NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
VkQueue queue;
|
|
||||||
vkGetDeviceQueue(device->outputDevice->device, info.queueIndex, 0, &queue);
|
|
||||||
|
|
||||||
vkResetFences(device->outputDevice->device, 1, &device->outputDevice->barrierFence);
|
vkResetFences(device->outputDevice->device, 1, &device->outputDevice->barrierFence);
|
||||||
if (vkQueueSubmit(queue, 1, &submitInfo, device->outputDevice->barrierFence) != VK_SUCCESS)
|
if (vkQueueSubmit(device->outputDevice->queues[device->outputDevice->graphicsQueueIndex].queue, 1, &submitInfo, device->outputDevice->barrierFence) != VK_SUCCESS)
|
||||||
return GN_FAILED_TO_SUBMIT_COMMAND_BUFFER;
|
return GN_FAILED_TO_SUBMIT_COMMAND_BUFFER;
|
||||||
vkWaitForFences(device->outputDevice->device, 1, &device->outputDevice->barrierFence, VK_TRUE, UINT64_MAX);
|
vkWaitForFences(device->outputDevice->device, 1, &device->outputDevice->barrierFence, VK_TRUE, UINT64_MAX);
|
||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
typedef struct gnPlatformWindowSurface_t {
|
typedef struct gnPlatformWindowSurface_t {
|
||||||
VkSurfaceKHR surface;
|
VkSurfaceKHR surface;
|
||||||
|
uint32_t presentQueueIndex;
|
||||||
} gnPlatformWindowSurface;
|
} gnPlatformWindowSurface;
|
||||||
|
|
||||||
VkFormat vkGryphnFormatToVulkanFormat(gnImageFormat format);
|
VkFormat vkGryphnFormatToVulkanFormat(gnImageFormat format);
|
||||||
|
@@ -3,3 +3,4 @@
|
|||||||
|
|
||||||
typedef uint32_t gnExtension;
|
typedef uint32_t gnExtension;
|
||||||
#define GN_EXT_SYNCHRONIZATION 0
|
#define GN_EXT_SYNCHRONIZATION 0
|
||||||
|
#define GN_EXT_QUEUES 1
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "stdint.h"
|
// #include "stdint.h"
|
||||||
#include <utils/gryphn_error_code.h>
|
#include <utils/gryphn_error_code.h>
|
||||||
#include "gryphn_handles.h"
|
#include "gryphn_handles.h"
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ typedef enum gnCommandPoolFlags {
|
|||||||
} gnCommandPoolFlags;
|
} gnCommandPoolFlags;
|
||||||
|
|
||||||
typedef struct gnCommandPoolInfo {
|
typedef struct gnCommandPoolInfo {
|
||||||
uint32_t queueIndex;
|
// uint32_t queueIndex;
|
||||||
gnCommandPoolFlags flags;
|
gnCommandPoolFlags flags;
|
||||||
} gnCommandPoolInfo;
|
} gnCommandPoolInfo;
|
||||||
|
|
||||||
|
@@ -2,15 +2,15 @@
|
|||||||
#include <output_device/gryphn_physical_output_device.h>
|
#include <output_device/gryphn_physical_output_device.h>
|
||||||
#include <utils/gryphn_error_code.h>
|
#include <utils/gryphn_error_code.h>
|
||||||
|
|
||||||
typedef struct gnDeviceQueueInfo {
|
// typedef struct gnDeviceQueueInfo {
|
||||||
int queueIndex;
|
// int queueIndex;
|
||||||
int queueCount;
|
// int queueCount;
|
||||||
// float* queuePriority;
|
// // float* queuePriority;
|
||||||
} gnDeviceQueueInfo;
|
// } gnDeviceQueueInfo;
|
||||||
|
|
||||||
typedef struct gnOutputDeviceInfo {
|
typedef struct gnOutputDeviceInfo {
|
||||||
uint32_t queueInfoCount;
|
// uint32_t queueInfoCount;
|
||||||
gnDeviceQueueInfo* queueInfos;
|
// gnDeviceQueueInfo* queueInfos;
|
||||||
gnPhysicalDeviceFeatures enabledFeatures;
|
gnPhysicalDeviceFeatures enabledFeatures;
|
||||||
gnPhysicalDevice physicalDevice;
|
gnPhysicalDevice physicalDevice;
|
||||||
} gnOutputDeviceInfo;
|
} gnOutputDeviceInfo;
|
||||||
|
@@ -59,4 +59,4 @@ int gnGetPresentQueueIndex(gnPhysicalDevice device, gnWindowSurfaceHandle window
|
|||||||
|
|
||||||
gnPhysicalDeviceProperties gnGetPhysicalDeviceProperties(gnPhysicalOutputDeviceHandle device) { return device->properties; }
|
gnPhysicalDeviceProperties gnGetPhysicalDeviceProperties(gnPhysicalOutputDeviceHandle device) { return device->properties; }
|
||||||
gnPhysicalDeviceFeatures gnGetPhysicalDeviceFeatures(gnPhysicalOutputDeviceHandle device) { return device->features; }
|
gnPhysicalDeviceFeatures gnGetPhysicalDeviceFeatures(gnPhysicalOutputDeviceHandle device) { return device->features; }
|
||||||
gnPhysicalDeviceQueueProperties gnGetPhysicalDeviceQueueProperties(gnPhysicalOutputDeviceHandle device) { return device->queueProperties; }
|
// gnPhysicalDeviceQueueProperties gnGetPhysicalDeviceQueueProperties(gnPhysicalOutputDeviceHandle device) { return device->queueProperties; }
|
||||||
|
@@ -28,29 +28,29 @@ typedef struct gnPhysicalDeviceFeatures {
|
|||||||
uint32_t maxPushConstantSize;
|
uint32_t maxPushConstantSize;
|
||||||
} gnPhysicalDeviceFeatures;
|
} gnPhysicalDeviceFeatures;
|
||||||
|
|
||||||
typedef enum gnQueueTypeFlags {
|
// typedef enum gnQueueTypeFlags {
|
||||||
GN_QUEUE_GRAPHICS = 1 << 0,
|
// GN_QUEUE_GRAPHICS = 1 << 0,
|
||||||
GN_QUEUE_COMPUTE = 1 << 1,
|
// GN_QUEUE_COMPUTE = 1 << 1,
|
||||||
GN_QUEUE_TRANSFER = 1 << 2,
|
// GN_QUEUE_TRANSFER = 1 << 2,
|
||||||
GN_QUEUE_SPARSE_BINDING = 1 << 3
|
// GN_QUEUE_SPARSE_BINDING = 1 << 3
|
||||||
} gnQueueTypeFlags;
|
// } gnQueueTypeFlags;
|
||||||
|
|
||||||
typedef struct gnQueueProperties {
|
// typedef struct gnQueueProperties {
|
||||||
uint32_t queueCount;
|
// uint32_t queueCount;
|
||||||
gnQueueTypeFlags queueType;
|
// gnQueueTypeFlags queueType;
|
||||||
} gnQueueProperties;
|
// } gnQueueProperties;
|
||||||
|
|
||||||
typedef struct gnPhysicalDeviceQueueProperties {
|
// typedef struct gnPhysicalDeviceQueueProperties {
|
||||||
uint32_t queueCount;
|
// uint32_t queueCount;
|
||||||
gnQueueProperties* queueProperties;
|
// gnQueueProperties* queueProperties;
|
||||||
} gnPhysicalDeviceQueueProperties;
|
// } gnPhysicalDeviceQueueProperties;
|
||||||
|
|
||||||
#ifdef GN_REVEAL_IMPL
|
#ifdef GN_REVEAL_IMPL
|
||||||
typedef struct gnPhysicalOutputDevice_t {
|
typedef struct gnPhysicalOutputDevice_t {
|
||||||
struct gnPlatformPhysicalDevice_t* physicalDevice;
|
struct gnPlatformPhysicalDevice_t* physicalDevice;
|
||||||
gnPhysicalDeviceProperties properties;
|
gnPhysicalDeviceProperties properties;
|
||||||
gnPhysicalDeviceFeatures features;
|
gnPhysicalDeviceFeatures features;
|
||||||
gnPhysicalDeviceQueueProperties queueProperties;
|
// gnPhysicalDeviceQueueProperties queueProperties;
|
||||||
|
|
||||||
gnInstanceHandle instance;
|
gnInstanceHandle instance;
|
||||||
} gnPhysicalOutputDevice_t;
|
} gnPhysicalOutputDevice_t;
|
||||||
@@ -61,7 +61,7 @@ gnBool gnQueueCanPresentToSurface(gnPhysicalOutputDeviceHandle device, uint32_t
|
|||||||
|
|
||||||
gnPhysicalDeviceProperties gnGetPhysicalDeviceProperties(gnPhysicalOutputDeviceHandle device);
|
gnPhysicalDeviceProperties gnGetPhysicalDeviceProperties(gnPhysicalOutputDeviceHandle device);
|
||||||
gnPhysicalDeviceFeatures gnGetPhysicalDeviceFeatures(gnPhysicalOutputDeviceHandle device);
|
gnPhysicalDeviceFeatures gnGetPhysicalDeviceFeatures(gnPhysicalOutputDeviceHandle device);
|
||||||
gnPhysicalDeviceQueueProperties gnGetPhysicalDeviceQueueProperties(gnPhysicalOutputDeviceHandle device);
|
// gnPhysicalDeviceQueueProperties gnGetPhysicalDeviceQueueProperties(gnPhysicalOutputDeviceHandle device);
|
||||||
|
|
||||||
gnBool gnHasGraphicsQueue(gnPhysicalOutputDeviceHandle device);
|
gnBool gnHasGraphicsQueue(gnPhysicalOutputDeviceHandle device);
|
||||||
gnBool gnHasPresentQueue(gnPhysicalOutputDeviceHandle device, gnWindowSurfaceHandle windowSurface);
|
gnBool gnHasPresentQueue(gnPhysicalOutputDeviceHandle device, gnWindowSurfaceHandle windowSurface);
|
||||||
|
@@ -7,7 +7,7 @@ typedef struct gnPresentInfo {
|
|||||||
uint32_t presentationQueueCount;
|
uint32_t presentationQueueCount;
|
||||||
gnPresentationQueueHandle* presentationQueues;
|
gnPresentationQueueHandle* presentationQueues;
|
||||||
uint32_t* imageIndices;
|
uint32_t* imageIndices;
|
||||||
uint32_t queueIndex;
|
// uint32_t queueIndex;
|
||||||
} gnPresentInfo;
|
} gnPresentInfo;
|
||||||
|
|
||||||
gnReturnCode gnPresent(gnOutputDeviceHandle device, gnPresentInfo info);
|
gnReturnCode gnPresent(gnOutputDeviceHandle device, gnPresentInfo info);
|
||||||
|
@@ -10,8 +10,8 @@ typedef struct gnPresentationQueueInfo {
|
|||||||
gnWindowSurfaceHandle surface;
|
gnWindowSurfaceHandle surface;
|
||||||
gnSurfaceFormat format;
|
gnSurfaceFormat format;
|
||||||
gnImageSharingMode imageSharingMode;
|
gnImageSharingMode imageSharingMode;
|
||||||
uint32_t queueFamilyCount;
|
// uint32_t queueFamilyCount;
|
||||||
uint32_t* queueFamilies;
|
// uint32_t* queueFamilies;
|
||||||
} gnPresentationQueueInfo;
|
} gnPresentationQueueInfo;
|
||||||
|
|
||||||
struct gnPlatformPresentationQueue_t;
|
struct gnPlatformPresentationQueue_t;
|
||||||
|
@@ -6,6 +6,6 @@
|
|||||||
typedef struct gnSubmitInfo {
|
typedef struct gnSubmitInfo {
|
||||||
uint32_t commandBufferCount;
|
uint32_t commandBufferCount;
|
||||||
gnCommandBufferHandle* commandBuffers;
|
gnCommandBufferHandle* commandBuffers;
|
||||||
uint32_t queueIndex;
|
// uint32_t queueIndex;
|
||||||
} gnSubmitInfo;
|
} gnSubmitInfo;
|
||||||
gnReturnCode gnSubmit(gnOutputDevice device, gnSubmitInfo info);
|
gnReturnCode gnSubmit(gnOutputDevice device, gnSubmitInfo info);
|
||||||
|
@@ -2,7 +2,6 @@
|
|||||||
#include <gryphn_platform_include.h>
|
#include <gryphn_platform_include.h>
|
||||||
#include <utils/gryphn_image_format.h>
|
#include <utils/gryphn_image_format.h>
|
||||||
#include <instance/gryphn_instance.h>
|
#include <instance/gryphn_instance.h>
|
||||||
#include "output_device/gryphn_physical_output_device.h"
|
|
||||||
#include "utils/math/gryphn_vec2.h"
|
#include "utils/math/gryphn_vec2.h"
|
||||||
|
|
||||||
typedef struct gnSurfaceFormat {
|
typedef struct gnSurfaceFormat {
|
||||||
|
Reference in New Issue
Block a user