// ============================================= // Aster: physical_device.cpp // Copyright (c) 2020-2024 Anish Bhobe // ============================================= #include "physical_device.h" QueueFamilyIndices PhysicalDevice::get_queue_families(const Window *_window, const vk::raii::PhysicalDevice *_device) { QueueFamilyIndices indices; auto queue_families_ = _device->getQueueFamilyProperties(); u32 family_index = 0; for (const auto &queueFamily : queue_families_) { u32 this_family_count = 0; VERBOSE(std::fmt("Queue(%i): %s", family_index, to_string(queueFamily.queueFlags).data())); if (queueFamily.queueCount <= 0) { ++family_index; continue; // Skip families with no queues } if (!indices.has_graphics() && (queueFamily.queueFlags & vk::QueueFlagBits::eGraphics)) { if (queueFamily.queueCount > this_family_count) { indices.graphics_idx = family_index; ++this_family_count; } else { continue; } } if (!indices.has_compute() && (queueFamily.queueFlags & vk::QueueFlagBits::eCompute)) { if (queueFamily.queueCount > this_family_count) { indices.compute_idx = family_index; ++this_family_count; } else { continue; } } if (!indices.has_transfer() && (queueFamily.queueFlags & vk::QueueFlagBits::eTransfer)) { if (queueFamily.queueCount > this_family_count) { indices.transfer_idx = family_index; ++this_family_count; } else { continue; } } try { if (!indices.has_present() && _device->getSurfaceSupportKHR(family_index, *_window->surface)) { if (queueFamily.queueCount > this_family_count) { indices.present_idx = family_index; ++this_family_count; } else { continue; } } } catch (const std::exception& err) { ERROR("Failure in finding surface support, all possibilities fatal. Failed with "s + err.what()); throw err; } ++family_index; } return indices; }