Create vulkan command pools

This commit is contained in:
2021-08-12 21:31:20 -07:00
parent 3fff761bca
commit 9bc30e6937
2 changed files with 24 additions and 0 deletions

View File

@@ -785,6 +785,8 @@ KRContext::destroyDeviceContexts()
{ {
for (auto itr = m_devices.begin(); itr != m_devices.end(); itr++) { for (auto itr = m_devices.begin(); itr != m_devices.end(); itr++) {
DeviceInfo* deviceInfo = &(*itr).second; DeviceInfo* deviceInfo = &(*itr).second;
vkDestroyCommandPool(deviceInfo->logicalDevice, deviceInfo->graphicsCommandPool, nullptr);
vkDestroyCommandPool(deviceInfo->logicalDevice, deviceInfo->computeCommandPool, nullptr);
vkDestroyDevice(deviceInfo->logicalDevice, nullptr); vkDestroyDevice(deviceInfo->logicalDevice, nullptr);
} }
@@ -1311,6 +1313,26 @@ void KRContext::createDevices()
} }
vkGetDeviceQueue(info.logicalDevice, info.graphicsFamilyQueueIndex, 0, &info.graphicsQueue); vkGetDeviceQueue(info.logicalDevice, info.graphicsFamilyQueueIndex, 0, &info.graphicsQueue);
vkGetDeviceQueue(info.logicalDevice, info.computeFamilyQueueIndex, 0, &info.computeQueue); vkGetDeviceQueue(info.logicalDevice, info.computeFamilyQueueIndex, 0, &info.computeQueue);
VkCommandPoolCreateInfo poolInfo{};
poolInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
poolInfo.queueFamilyIndex = info.graphicsFamilyQueueIndex;
poolInfo.flags = 0;
if (vkCreateCommandPool(info.logicalDevice, &poolInfo, nullptr, &info.graphicsCommandPool) != VK_SUCCESS) {
vkDestroyDevice(info.logicalDevice, nullptr);
// TODO - Log a warning...
continue;
}
poolInfo.queueFamilyIndex = info.computeFamilyQueueIndex;
if (vkCreateCommandPool(info.logicalDevice, &poolInfo, nullptr, &info.computeCommandPool) != VK_SUCCESS) {
vkDestroyCommandPool(info.logicalDevice, info.graphicsCommandPool, nullptr);
vkDestroyDevice(info.logicalDevice, nullptr);
// TODO - Log a warning...
continue;
}
m_devices[++m_topDeviceHandle] = info; m_devices[++m_topDeviceHandle] = info;
} }
} }

View File

@@ -139,6 +139,8 @@ public:
VkQueue graphicsQueue; VkQueue graphicsQueue;
uint32_t computeFamilyQueueIndex; uint32_t computeFamilyQueueIndex;
VkQueue computeQueue; VkQueue computeQueue;
VkCommandPool graphicsCommandPool;
VkCommandPool computeCommandPool;
} DeviceInfo; } DeviceInfo;
typedef struct { typedef struct {