Vulkan/Device: Update queue handling
Former-commit-id: 72f6af81a54e73b3e49a7a2ca1abeae2dfcb3754 [formerly 8932248d5e816bfa294f0ad9f955ded7b5078c83] Former-commit-id: c8d2543428a0b1226bee28bda6141c2af4d82c77
This commit is contained in:
parent
a57b1781b6
commit
bae3034a61
|
|
@ -28,6 +28,7 @@ namespace Nz
|
|||
{
|
||||
public:
|
||||
struct QueueFamilyInfo;
|
||||
struct QueueInfo;
|
||||
|
||||
inline Device(Instance& instance);
|
||||
Device(const Device&) = delete;
|
||||
|
|
@ -191,9 +192,18 @@ namespace Nz
|
|||
|
||||
#undef NAZARA_VULKAN_DEVICE_FUNCTION
|
||||
|
||||
struct QueueFamilyInfo
|
||||
struct QueueInfo
|
||||
{
|
||||
std::vector<float> queues;
|
||||
QueueFamilyInfo* familyInfo;
|
||||
Queue queue;
|
||||
float priority;
|
||||
};
|
||||
|
||||
using QueueList = std::vector<QueueInfo>;
|
||||
|
||||
struct QueueFamilyInfoi
|
||||
{
|
||||
QueueList queues;
|
||||
VkExtent3D minImageTransferGranularity;
|
||||
VkQueueFlags flags;
|
||||
UInt32 familyIndex;
|
||||
|
|
|
|||
|
|
@ -27,38 +27,15 @@ namespace Nz
|
|||
return false;
|
||||
}
|
||||
|
||||
m_physicalDevice = device;
|
||||
|
||||
// Store the allocator to access them when needed
|
||||
if (allocator)
|
||||
m_allocator = *allocator;
|
||||
else
|
||||
m_allocator.pfnAllocation = nullptr;
|
||||
|
||||
// Parse extensions and layers
|
||||
for (UInt32 i = 0; i < createInfo.enabledExtensionCount; ++i)
|
||||
m_loadedExtensions.insert(createInfo.ppEnabledExtensionNames[i]);
|
||||
|
||||
for (UInt32 i = 0; i < createInfo.enabledLayerCount; ++i)
|
||||
m_loadedLayers.insert(createInfo.ppEnabledLayerNames[i]);
|
||||
|
||||
// And retains informations about queues
|
||||
m_enabledQueuesInfos.resize(createInfo.queueCreateInfoCount);
|
||||
for (UInt32 i = 0; i < createInfo.queueCreateInfoCount; ++i)
|
||||
{
|
||||
const VkDeviceQueueCreateInfo& queueCreateInfo = createInfo.pQueueCreateInfos[i];
|
||||
QueueFamilyInfo& info = m_enabledQueuesInfos[i];
|
||||
|
||||
info.familyIndex = queueCreateInfo.queueFamilyIndex;
|
||||
|
||||
const VkQueueFamilyProperties& queueProperties = queuesProperties[info.familyIndex];
|
||||
info.flags = queueProperties.queueFlags;
|
||||
info.minImageTransferGranularity = queueProperties.minImageTransferGranularity;
|
||||
info.timestampValidBits = queueProperties.timestampValidBits;
|
||||
|
||||
info.queues.resize(queueCreateInfo.queueCount);
|
||||
for (UInt32 queueCount = 0; queueCount < queueCreateInfo.queueCount; ++queueCount)
|
||||
info.queues[queueCount] = queueCreateInfo.pQueuePriorities[queueCount];
|
||||
}
|
||||
|
||||
// Load all device-related functions
|
||||
#define NAZARA_VULKAN_LOAD_DEVICE(func) func = reinterpret_cast<PFN_##func>(GetProcAddr(#func))
|
||||
|
||||
try
|
||||
|
|
@ -200,6 +177,40 @@ namespace Nz
|
|||
|
||||
#undef NAZARA_VULKAN_LOAD_DEVICE
|
||||
|
||||
// Parse extensions and layers
|
||||
for (UInt32 i = 0; i < createInfo.enabledExtensionCount; ++i)
|
||||
m_loadedExtensions.insert(createInfo.ppEnabledExtensionNames[i]);
|
||||
|
||||
for (UInt32 i = 0; i < createInfo.enabledLayerCount; ++i)
|
||||
m_loadedLayers.insert(createInfo.ppEnabledLayerNames[i]);
|
||||
|
||||
// And retains informations about queues
|
||||
UInt32 maxFamilyIndex = 0;
|
||||
m_enabledQueuesInfos.resize(createInfo.queueCreateInfoCount);
|
||||
for (UInt32 i = 0; i < createInfo.queueCreateInfoCount; ++i)
|
||||
{
|
||||
const VkDeviceQueueCreateInfo& queueCreateInfo = createInfo.pQueueCreateInfos[i];
|
||||
QueueFamilyInfo& info = m_enabledQueuesInfos[i];
|
||||
|
||||
info.familyIndex = queueCreateInfo.queueFamilyIndex;
|
||||
if (info.familyIndex > maxFamilyIndex)
|
||||
maxFamilyIndex = info.familyIndex;
|
||||
|
||||
const VkQueueFamilyProperties& queueProperties = queuesProperties[info.familyIndex];
|
||||
info.flags = queueProperties.queueFlags;
|
||||
info.minImageTransferGranularity = queueProperties.minImageTransferGranularity;
|
||||
info.timestampValidBits = queueProperties.timestampValidBits;
|
||||
|
||||
info.queues.resize(queueCreateInfo.queueCount);
|
||||
for (UInt32 queueIndex = 0; queueIndex < queueCreateInfo.queueCount; ++queueIndex)
|
||||
{
|
||||
QueueInfo queueInfo;
|
||||
queueInfo.familyInfo = &info;
|
||||
queueInfo.priority = queueCreateInfo.pQueuePriorities[queueIndex];
|
||||
queueInfo.queue = GetQueue(info.familyIndex, queueIndex);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue