Make Vk::Device store a reference to Vk::PhysicalDevice info

This commit is contained in:
Lynix
2020-03-08 18:10:12 +01:00
parent 0e27c2315f
commit 28cf4ed6e3
4 changed files with 17 additions and 17 deletions

View File

@@ -429,7 +429,7 @@ namespace Nz
};
std::shared_ptr<VulkanDevice> device = std::make_shared<VulkanDevice>(s_instance);
if (!device->Create(gpu, createInfo))
if (!device->Create(GetPhysicalDeviceInfo(gpu), createInfo))
{
NazaraError("Failed to create Vulkan Device: " + TranslateVulkanError(device->GetLastErrorCode()));
return {};

View File

@@ -12,23 +12,16 @@ namespace Nz
{
namespace Vk
{
bool Device::Create(VkPhysicalDevice device, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator)
bool Device::Create(const Vk::PhysicalDevice& deviceInfo, 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(deviceInfo.device, &createInfo, allocator, &m_device);
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("Failed to create Vulkan device");
return false;
}
m_physicalDevice = device;
m_physicalDevice = &deviceInfo;
// Store the allocator to access them when needed
if (allocator)
@@ -76,7 +69,7 @@ namespace Nz
if (info.familyIndex > maxFamilyIndex)
maxFamilyIndex = info.familyIndex;
const VkQueueFamilyProperties& queueProperties = queuesProperties[info.familyIndex];
const VkQueueFamilyProperties& queueProperties = deviceInfo.queues[info.familyIndex];
info.flags = queueProperties.queueFlags;
info.minImageTransferGranularity = queueProperties.minImageTransferGranularity;
info.timestampValidBits = queueProperties.timestampValidBits;