73{
74 vk::Instance vk_instance(instance);
75 auto devices = vk_instance.enumeratePhysicalDevices();
76
77 if (devices.empty()) {
79 std::source_location::current(),
80 "Failed to find GPUs with Vulkan support!");
81 }
82
83 for (const auto& device : devices) {
85
86 if (indices.graphics_family.has_value()) {
87 auto available_extensions = device.enumerateDeviceExtensionProperties();
88 bool supports_swapchain = false;
89 bool supports_mesh_shader = false;
90
91 for (const auto& ext : available_extensions) {
92 if (strcmp(ext.extensionName, VK_KHR_SWAPCHAIN_EXTENSION_NAME) == 0) {
93 supports_swapchain = true;
94 }
95 if (strcmp(ext.extensionName, VK_EXT_MESH_SHADER_EXTENSION_NAME) == 0) {
96 supports_mesh_shader = true;
97 }
98 }
99
100 if (!supports_swapchain) {
102 "Physical device {} does not support VK_KHR_swapchain - skipping",
103 device.getProperties().deviceName.data());
104 continue;
105 }
106
107 if (!supports_mesh_shader) {
109 "Physical device {} does not support VK_EXT_mesh_shader - "
110 "mesh shading features will be unavailable",
111 device.getProperties().deviceName.data());
112 } else {
113 vk::PhysicalDeviceMeshShaderFeaturesEXT mesh_features;
114 vk::PhysicalDeviceFeatures2 temp_features;
115 temp_features.pNext = &mesh_features;
116 device.getFeatures2(&temp_features);
117
118 if (mesh_features.meshShader == VK_FALSE || mesh_features.taskShader == VK_FALSE) {
120 "Physical device {} supports VK_EXT_mesh_shader extension but features disabled",
121 device.getProperties().deviceName.data());
122 supports_mesh_shader = false;
123 }
124 }
125
129
130 vk::PhysicalDeviceProperties props = device.getProperties();
132 "Selected GPU: {}", props.deviceName.data());
133 return true;
134 }
135 }
136
138 std::source_location::current(),
139 "Failed to find a suitable GPU!");
140 return false;
141}
#define MF_INFO(comp, ctx,...)
#define MF_PRINT(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
bool m_supports_mesh_shaders
Whether the device supports mesh shaders.
vk::PhysicalDevice m_physical_device
Selected physical device (GPU)
QueueFamilyIndices find_queue_families(vk::PhysicalDevice device, vk::SurfaceKHR surface=nullptr)
Find queue families on the given physical device.
QueueFamilyIndices m_queue_families
Indices of required queue families.
@ GraphicsBackend
Graphics/visual rendering backend (Vulkan, OpenGL)
@ Core
Core engine, backend, subsystems.