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:
|
public:
|
||||||
struct QueueFamilyInfo;
|
struct QueueFamilyInfo;
|
||||||
|
struct QueueInfo;
|
||||||
|
|
||||||
inline Device(Instance& instance);
|
inline Device(Instance& instance);
|
||||||
Device(const Device&) = delete;
|
Device(const Device&) = delete;
|
||||||
|
|
@ -191,9 +192,18 @@ namespace Nz
|
||||||
|
|
||||||
#undef NAZARA_VULKAN_DEVICE_FUNCTION
|
#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;
|
VkExtent3D minImageTransferGranularity;
|
||||||
VkQueueFlags flags;
|
VkQueueFlags flags;
|
||||||
UInt32 familyIndex;
|
UInt32 familyIndex;
|
||||||
|
|
|
||||||
|
|
@ -27,38 +27,15 @@ namespace Nz
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_physicalDevice = device;
|
||||||
|
|
||||||
// Store the allocator to access them when needed
|
// Store the allocator to access them when needed
|
||||||
if (allocator)
|
if (allocator)
|
||||||
m_allocator = *allocator;
|
m_allocator = *allocator;
|
||||||
else
|
else
|
||||||
m_allocator.pfnAllocation = nullptr;
|
m_allocator.pfnAllocation = nullptr;
|
||||||
|
|
||||||
// Parse extensions and layers
|
// Load all device-related functions
|
||||||
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];
|
|
||||||
}
|
|
||||||
|
|
||||||
#define NAZARA_VULKAN_LOAD_DEVICE(func) func = reinterpret_cast<PFN_##func>(GetProcAddr(#func))
|
#define NAZARA_VULKAN_LOAD_DEVICE(func) func = reinterpret_cast<PFN_##func>(GetProcAddr(#func))
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
@ -200,6 +177,40 @@ namespace Nz
|
||||||
|
|
||||||
#undef NAZARA_VULKAN_LOAD_DEVICE
|
#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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue