Вынес управление VkDevice в отдельный класс
This commit is contained in:
@@ -58,27 +58,29 @@ VkObjects::PhysicalDevice::QueueFamilyIndices VkObjects::PhysicalDevice::find_qu
|
||||
vkGetPhysicalDeviceQueueFamilyProperties(physical_device, &queueFamilyCount, family_properties.data());
|
||||
|
||||
// Find graphics
|
||||
bool is_find_graphics_family = false;
|
||||
for(uint32_t i = 0; i < family_properties.size(); ++i)
|
||||
{
|
||||
if (family_properties[i].queueFlags & VK_QUEUE_GRAPHICS_BIT)
|
||||
{
|
||||
queue_family_indices.graphics_family = i;
|
||||
queue_family_indices.is_find_graphics_family = true;
|
||||
is_find_graphics_family = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (queue_family_indices.is_find_graphics_family == false)
|
||||
if (is_find_graphics_family == false)
|
||||
throw std::runtime_error("Failed to find a graphics queue family");
|
||||
|
||||
// Find present
|
||||
VkBool32 present_support = false;
|
||||
VK_CHECK(vkGetPhysicalDeviceSurfaceSupportKHR(physical_device, queue_family_indices.graphics_family, surface, &present_support))
|
||||
// Если графическая очередь поддерживет презентацию кадров, то используем её
|
||||
bool is_find_present_family = false;
|
||||
if (present_support == VK_TRUE)
|
||||
{
|
||||
queue_family_indices.present_family = queue_family_indices.graphics_family;
|
||||
queue_family_indices.is_find_present_family = true;
|
||||
is_find_present_family = true;
|
||||
}
|
||||
// иначе ищем другую подходящую очередь
|
||||
else
|
||||
@@ -90,17 +92,18 @@ VkObjects::PhysicalDevice::QueueFamilyIndices VkObjects::PhysicalDevice::find_qu
|
||||
if (present_support == VK_TRUE)
|
||||
{
|
||||
queue_family_indices.present_family = i;
|
||||
queue_family_indices.is_find_present_family = true;
|
||||
is_find_present_family = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (queue_family_indices.is_find_present_family == false)
|
||||
if (is_find_present_family == false)
|
||||
throw std::runtime_error("Failed to find a present queue family");
|
||||
|
||||
// С начала пытаемся найти очередь специалезированную
|
||||
// для копирования отличную от графической
|
||||
bool is_find_transfer_family = false;
|
||||
for(uint32_t i = 0; i < family_properties.size(); ++i)
|
||||
{
|
||||
if (i == queue_family_indices.graphics_family)
|
||||
@@ -108,14 +111,13 @@ VkObjects::PhysicalDevice::QueueFamilyIndices VkObjects::PhysicalDevice::find_qu
|
||||
if (family_properties[i].queueFlags & VK_QUEUE_TRANSFER_BIT)
|
||||
{
|
||||
queue_family_indices.transfer_family = i;
|
||||
queue_family_indices.is_find_transfer_family = true;
|
||||
is_find_transfer_family = true;
|
||||
}
|
||||
}
|
||||
// Если не находим, то используем графическую
|
||||
if (queue_family_indices.is_find_transfer_family == false)
|
||||
if (is_find_transfer_family == false)
|
||||
{
|
||||
queue_family_indices.transfer_family = queue_family_indices.graphics_family;
|
||||
queue_family_indices.is_find_transfer_family = true;
|
||||
}
|
||||
return queue_family_indices;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user