finally redo physical device creation
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
#include "vulkan_result_converter.h"
|
||||
#include "string.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
gnReturnCode createVulkanOutputDevice(gnInstanceHandle instance, gnOutputDeviceHandle device, gnOutputDeviceInfo deviceInfo) {
|
||||
device->outputDevice = malloc(sizeof(gnPlatformOutputDevice));
|
||||
device->outputDevice->physicalDevice = (VkPhysicalDevice)deviceInfo.physicalDevice;
|
||||
@@ -18,7 +20,6 @@ gnReturnCode createVulkanOutputDevice(gnInstanceHandle instance, gnOutputDeviceH
|
||||
if (!instance->enabledExtensions[GN_EXT_QUEUES]) {
|
||||
uint32_t neededQueueCount;
|
||||
vulkanNeededQueue* neededQueues = vulkanLoadNeededQueues(deviceInfo.physicalDevice, &neededQueueCount);
|
||||
|
||||
queueCreateInfos = malloc(sizeof(VkDeviceQueueCreateInfo) * neededQueueCount);
|
||||
createQueueCount = neededQueueCount;
|
||||
float queuePriority = 1.0f;
|
||||
@@ -68,7 +69,6 @@ gnReturnCode createVulkanOutputDevice(gnInstanceHandle instance, gnOutputDeviceH
|
||||
deviceCreateInfo.enabledLayerCount = 1;
|
||||
deviceCreateInfo.ppEnabledLayerNames = validation_layers;
|
||||
}
|
||||
|
||||
VkResult result = vkCreateDevice((VkPhysicalDevice)deviceInfo.physicalDevice, &deviceCreateInfo, NULL, &device->outputDevice->device);
|
||||
if (result != VK_SUCCESS)
|
||||
return VkResultToGnReturnCode(result);
|
||||
@@ -76,6 +76,7 @@ gnReturnCode createVulkanOutputDevice(gnInstanceHandle instance, gnOutputDeviceH
|
||||
device->outputDevice->queues = malloc(sizeof(vulkanQueue) * createQueueCount);
|
||||
uint32_t transferQueue = 0;
|
||||
gnBool foundTransferQueue = GN_FALSE, foundGraphicsQueue = GN_FALSE;
|
||||
|
||||
for (uint32_t i = 0; i < createQueueCount; i++) {
|
||||
vkGetDeviceQueue(device->outputDevice->device, queueCreateInfos[i].queueFamilyIndex, 0, &device->outputDevice->queues[i].queue);
|
||||
if ((device->outputDevice->queues[i].queueInfo.createFlags & VK_QUEUE_TRANSFER_BIT) == VK_QUEUE_TRANSFER_BIT && !foundTransferQueue) {
|
||||
@@ -88,7 +89,12 @@ gnReturnCode createVulkanOutputDevice(gnInstanceHandle instance, gnOutputDeviceH
|
||||
device->outputDevice->graphicsQueueIndex = i;
|
||||
foundGraphicsQueue = GN_FALSE;
|
||||
}
|
||||
if ((device->outputDevice->queues[i].queueInfo.createFlags & VK_QUEUE_GRAPHICS_BIT) == VK_QUEUE_GRAPHICS_BIT && !foundGraphicsQueue) {
|
||||
device->outputDevice->graphicsQueueIndex = i;
|
||||
foundGraphicsQueue = GN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VkCommandPoolCreateInfo poolInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
|
||||
|
@@ -147,13 +147,22 @@ vulkanNeededQueue* vulkanLoadNeededQueues(gnPhysicalDevice physicalDevice, uint3
|
||||
vkGetPhysicalDeviceQueueFamilyProperties(device, &queueFamilyCount, NULL);
|
||||
VkQueueFamilyProperties* queueFamilies = malloc(sizeof(VkQueueFamilyProperties) * queueFamilyCount);
|
||||
vkGetPhysicalDeviceQueueFamilyProperties(device, &queueFamilyCount, queueFamilies);
|
||||
*neededQueueCount = 0;
|
||||
|
||||
gnBool foundGraphicsQueue = GN_FALSE, foundTransferQueue = GN_FALSE;
|
||||
vulkanNeededQueue* neededQueues = malloc(sizeof(vulkanNeededQueue) * queueFamilyCount);
|
||||
|
||||
|
||||
for (uint32_t c = 0; c < queueFamilyCount; c++) {
|
||||
gnBool hasNeededQueue = GN_FALSE;
|
||||
if ((queueFamilies[c].queueFlags & VK_QUEUE_GRAPHICS_BIT) == VK_QUEUE_GRAPHICS_BIT)
|
||||
if ((queueFamilies[c].queueFlags & VK_QUEUE_GRAPHICS_BIT) == VK_QUEUE_GRAPHICS_BIT && !foundGraphicsQueue) {
|
||||
hasNeededQueue = GN_TRUE;
|
||||
if ((queueFamilies[c].queueFlags & VK_QUEUE_TRANSFER_BIT) == VK_QUEUE_TRANSFER_BIT)
|
||||
foundGraphicsQueue = GN_TRUE;
|
||||
}
|
||||
if ((queueFamilies[c].queueFlags & VK_QUEUE_TRANSFER_BIT) == VK_QUEUE_TRANSFER_BIT && !foundTransferQueue) {
|
||||
hasNeededQueue = GN_TRUE;
|
||||
foundTransferQueue = GN_TRUE;
|
||||
}
|
||||
|
||||
if (hasNeededQueue) {
|
||||
vulkanNeededQueue neededQueue = {
|
||||
@@ -169,6 +178,7 @@ vulkanNeededQueue* vulkanLoadNeededQueues(gnPhysicalDevice physicalDevice, uint3
|
||||
}
|
||||
}
|
||||
free(queueFamilies);
|
||||
neededQueues = realloc(neededQueues, sizeof(vulkanNeededQueue) * *neededQueueCount);
|
||||
return neededQueues;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user