Vulkan/Device: Fix Queue stuff
Former-commit-id: 124691546da9e4ce867df931c97b828efef237ca [formerly 9ce524972a4ca15755b9b575560046251a8063f7] Former-commit-id: 2ac3db1c0c11573e3ea6439cb3bb8f8c8dec9451
This commit is contained in:
parent
f6b683eae2
commit
296680d32a
|
|
@ -29,6 +29,7 @@ namespace Nz
|
||||||
public:
|
public:
|
||||||
struct QueueFamilyInfo;
|
struct QueueFamilyInfo;
|
||||||
struct QueueInfo;
|
struct QueueInfo;
|
||||||
|
using QueueList = std::vector<QueueInfo>;
|
||||||
|
|
||||||
inline Device(Instance& instance);
|
inline Device(Instance& instance);
|
||||||
Device(const Device&) = delete;
|
Device(const Device&) = delete;
|
||||||
|
|
@ -39,6 +40,7 @@ namespace Nz
|
||||||
inline void Destroy();
|
inline void Destroy();
|
||||||
|
|
||||||
inline const std::vector<QueueFamilyInfo>& GetEnabledQueues() const;
|
inline const std::vector<QueueFamilyInfo>& GetEnabledQueues() const;
|
||||||
|
inline const QueueList& GetEnabledQueues(UInt32 familyQueue) const;
|
||||||
|
|
||||||
inline Queue GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex);
|
inline Queue GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex);
|
||||||
inline Instance& GetInstance();
|
inline Instance& GetInstance();
|
||||||
|
|
@ -195,13 +197,11 @@ namespace Nz
|
||||||
struct QueueInfo
|
struct QueueInfo
|
||||||
{
|
{
|
||||||
QueueFamilyInfo* familyInfo;
|
QueueFamilyInfo* familyInfo;
|
||||||
Queue queue;
|
VkQueue queue;
|
||||||
float priority;
|
float priority;
|
||||||
};
|
};
|
||||||
|
|
||||||
using QueueList = std::vector<QueueInfo>;
|
struct QueueFamilyInfo
|
||||||
|
|
||||||
struct QueueFamilyInfoi
|
|
||||||
{
|
{
|
||||||
QueueList queues;
|
QueueList queues;
|
||||||
VkExtent3D minImageTransferGranularity;
|
VkExtent3D minImageTransferGranularity;
|
||||||
|
|
@ -221,6 +221,7 @@ namespace Nz
|
||||||
std::unordered_set<String> m_loadedExtensions;
|
std::unordered_set<String> m_loadedExtensions;
|
||||||
std::unordered_set<String> m_loadedLayers;
|
std::unordered_set<String> m_loadedLayers;
|
||||||
std::vector<QueueFamilyInfo> m_enabledQueuesInfos;
|
std::vector<QueueFamilyInfo> m_enabledQueuesInfos;
|
||||||
|
std::vector<const QueueList*> m_queuesByFamily;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,13 @@ namespace Nz
|
||||||
return m_enabledQueuesInfos;
|
return m_enabledQueuesInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline const Device::QueueList& Device::GetEnabledQueues(UInt32 familyQueue) const
|
||||||
|
{
|
||||||
|
NazaraAssert(familyQueue < m_enabledQueuesInfos.size(), "Invalid family queue");
|
||||||
|
|
||||||
|
return *m_queuesByFamily[familyQueue];
|
||||||
|
}
|
||||||
|
|
||||||
inline Queue Device::GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex)
|
inline Queue Device::GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex)
|
||||||
{
|
{
|
||||||
VkQueue queue;
|
VkQueue queue;
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,13 @@ namespace Nz
|
||||||
else
|
else
|
||||||
m_allocator.pfnAllocation = nullptr;
|
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]);
|
||||||
|
|
||||||
// Load all device-related functions
|
// Load all device-related functions
|
||||||
#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))
|
||||||
|
|
||||||
|
|
@ -177,13 +184,6 @@ 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
|
// And retains informations about queues
|
||||||
UInt32 maxFamilyIndex = 0;
|
UInt32 maxFamilyIndex = 0;
|
||||||
m_enabledQueuesInfos.resize(createInfo.queueCreateInfoCount);
|
m_enabledQueuesInfos.resize(createInfo.queueCreateInfoCount);
|
||||||
|
|
@ -204,13 +204,17 @@ namespace Nz
|
||||||
info.queues.resize(queueCreateInfo.queueCount);
|
info.queues.resize(queueCreateInfo.queueCount);
|
||||||
for (UInt32 queueIndex = 0; queueIndex < queueCreateInfo.queueCount; ++queueIndex)
|
for (UInt32 queueIndex = 0; queueIndex < queueCreateInfo.queueCount; ++queueIndex)
|
||||||
{
|
{
|
||||||
QueueInfo queueInfo;
|
QueueInfo& queueInfo = info.queues[queueIndex];
|
||||||
queueInfo.familyInfo = &info;
|
queueInfo.familyInfo = &info;
|
||||||
queueInfo.priority = queueCreateInfo.pQueuePriorities[queueIndex];
|
queueInfo.priority = queueCreateInfo.pQueuePriorities[queueIndex];
|
||||||
queueInfo.queue = GetQueue(info.familyIndex, queueIndex);
|
vkGetDeviceQueue(m_device, info.familyIndex, queueIndex, &queueInfo.queue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_queuesByFamily.resize(maxFamilyIndex + 1);
|
||||||
|
for (const QueueFamilyInfo& familyInfo : m_enabledQueuesInfos)
|
||||||
|
m_queuesByFamily[familyInfo.familyIndex] = &familyInfo.queues;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue