SpiecsEngine
 
Loading...
Searching...
No Matches

◆ SelectPhysicalDevice()

bool Spices::VulkanDevice::SelectPhysicalDevice ( const VkInstance & instance,
const VkSurfaceKHR & surface,
GLFWwindow * window )
private

select a suitable physical device.

Parameters
[in]instanceVkInstance.
[in]surfaceVkSurfaceKHR.
[in]windowThe row pointer of GLFW window.
Returns
Returns true if select one successfully.
Todo
multiple physical device support.

Get all physical device num this computer.

This software requires there must be at least one physical device.

@breif Get all physical device this computer.

Iter all physical and select one suitable.

All this condition need satisfied.

Set Selected physical device.

Query physicaldevice's SwapChainSupport.

Get all physical device num this computer.

This software requires there must be at least one physical device.

@breif Get all physical device this computer.

Iter all physical and select one suitable.

All this condition need satisfied.

Set Selected physical device.

Query physicaldevice's SwapChainSupport.

Definition at line 296 of file VulkanDevice.cpp.

297 {
299
303 uint32_t deviceCount = 0;
304 vkEnumeratePhysicalDevices(instance, &deviceCount, nullptr);
305
309 if (deviceCount == 0)
310 {
311 SPICES_CORE_WARN("Failed to find GPUs with Vulkan support!")
312 return false;
313 }
314
318 std::vector<VkPhysicalDevice> PhysicalDevices(deviceCount);
319 vkEnumeratePhysicalDevices(instance, &deviceCount, PhysicalDevices.data());
320
324 for (const auto& physicalDevice : PhysicalDevices)
325 {
329 if (IsExtensionMeetDemand(physicalDevice) &&
330 IsPropertyMeetDemand(physicalDevice) &&
331 IsFeatureMeetDemand(physicalDevice) &&
332 IsQueueMeetDemand(physicalDevice, surface)
333 )
334 {
338 m_VulkanState.m_PhysicalDevice = physicalDevice;
339
343 m_SwapChainSupportDetails = QuerySwapChainSupport(physicalDevice, surface, window);
344
345 SPICES_CORE_INFO("VkPhysicalDevice Selected!!!")
346 return true;
347 }
348 }
349
350 return false;
351 }
#define SPICES_PROFILE_ZONE
bool IsQueueMeetDemand(const VkPhysicalDevice &device, const VkSurfaceKHR &surface)
Check all Queue we need meet;.
static SwapChainSupportDetails QuerySwapChainSupport(const VkPhysicalDevice &device, const VkSurfaceKHR &surface, GLFWwindow *window)
Query physical device's SwapChainSupport.
bool IsPropertyMeetDemand(const VkPhysicalDevice &device)
Check all Property we need meet.
bool IsFeatureMeetDemand(const VkPhysicalDevice &device)
Check all Feature we need meet.
SwapChainSupportDetails m_SwapChainSupportDetails
SwapChainSupportDetails.
bool IsExtensionMeetDemand(const VkPhysicalDevice &device)
Check all Extension we need meet;.
VulkanState & m_VulkanState
The global VulkanState Referenced from VulkanRenderBackend.
STL namespace.
VkPhysicalDevice m_PhysicalDevice
Definition VulkanUtils.h:95