Vulkan/Device: Add queue infos
Former-commit-id: 36a260b1efa0f443b1c22c21060adbc7ff23a10f [formerly a9c073dfae57cde2c3b175c5f70e2fa47976bd82] Former-commit-id: a14c9a5283579dff978fffcca660e4974bf8e58d
This commit is contained in:
parent
c0d8beb11b
commit
c28995bc88
|
|
@ -27,6 +27,8 @@ namespace Nz
|
||||||
class NAZARA_VULKAN_API Device : public HandledObject<Device>
|
class NAZARA_VULKAN_API Device : public HandledObject<Device>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
struct QueueFamilyInfo;
|
||||||
|
|
||||||
inline Device(Instance& instance);
|
inline Device(Instance& instance);
|
||||||
Device(const Device&) = delete;
|
Device(const Device&) = delete;
|
||||||
Device(Device&&) = delete;
|
Device(Device&&) = delete;
|
||||||
|
|
@ -35,6 +37,7 @@ namespace Nz
|
||||||
bool Create(VkPhysicalDevice device, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr);
|
bool Create(VkPhysicalDevice device, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr);
|
||||||
inline void Destroy();
|
inline void Destroy();
|
||||||
|
|
||||||
|
inline const std::vector<QueueFamilyInfo>& GetEnabledQueues() const;
|
||||||
inline Queue GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex);
|
inline Queue GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex);
|
||||||
inline Instance& GetInstance();
|
inline Instance& GetInstance();
|
||||||
inline const Instance& GetInstance() const;
|
inline const Instance& GetInstance() const;
|
||||||
|
|
@ -184,6 +187,15 @@ namespace Nz
|
||||||
|
|
||||||
#undef NAZARA_VULKAN_DEVICE_FUNCTION
|
#undef NAZARA_VULKAN_DEVICE_FUNCTION
|
||||||
|
|
||||||
|
struct QueueFamilyInfo
|
||||||
|
{
|
||||||
|
std::vector<float> queues;
|
||||||
|
VkExtent3D minImageTransferGranularity;
|
||||||
|
VkQueueFlags flags;
|
||||||
|
UInt32 familyIndex;
|
||||||
|
UInt32 timestampValidBits;
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline PFN_vkVoidFunction GetProcAddr(const char* name);
|
inline PFN_vkVoidFunction GetProcAddr(const char* name);
|
||||||
|
|
||||||
|
|
@ -193,6 +205,7 @@ namespace Nz
|
||||||
VkResult m_lastErrorCode;
|
VkResult m_lastErrorCode;
|
||||||
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;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,11 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline const std::vector<Device::QueueFamilyInfo>& Device::GetEnabledQueues() const
|
||||||
|
{
|
||||||
|
return m_enabledQueuesInfos;
|
||||||
|
}
|
||||||
|
|
||||||
inline Queue Device::GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex)
|
inline Queue Device::GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex)
|
||||||
{
|
{
|
||||||
VkQueue queue;
|
VkQueue queue;
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,13 @@ namespace Nz
|
||||||
{
|
{
|
||||||
bool Device::Create(VkPhysicalDevice device, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator)
|
bool Device::Create(VkPhysicalDevice device, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator)
|
||||||
{
|
{
|
||||||
|
std::vector<VkQueueFamilyProperties> queuesProperties;
|
||||||
|
if (!m_instance.GetPhysicalDeviceQueueFamilyProperties(device, &queuesProperties))
|
||||||
|
{
|
||||||
|
NazaraError("Failed to query queue family properties");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
m_lastErrorCode = m_instance.vkCreateDevice(device, &createInfo, allocator, &m_device);
|
m_lastErrorCode = m_instance.vkCreateDevice(device, &createInfo, allocator, &m_device);
|
||||||
if (m_lastErrorCode != VkResult::VK_SUCCESS)
|
if (m_lastErrorCode != VkResult::VK_SUCCESS)
|
||||||
{
|
{
|
||||||
|
|
@ -33,6 +40,25 @@ namespace Nz
|
||||||
for (UInt32 i = 0; i < createInfo.enabledLayerCount; ++i)
|
for (UInt32 i = 0; i < createInfo.enabledLayerCount; ++i)
|
||||||
m_loadedLayers.insert(createInfo.ppEnabledLayerNames[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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue