|
|
@ -122,10 +122,22 @@ static void SetupVulkan(const char** extensions, uint32_t extensions_count) |
|
|
|
err = vkEnumeratePhysicalDevices(g_Instance, &gpu_count, gpus); |
|
|
|
err = vkEnumeratePhysicalDevices(g_Instance, &gpu_count, gpus); |
|
|
|
check_vk_result(err); |
|
|
|
check_vk_result(err); |
|
|
|
|
|
|
|
|
|
|
|
// If a number >1 of GPUs got reported, you should find the best fit GPU for your purpose
|
|
|
|
// If a number >1 of GPUs got reported, find discrete GPU if present, or use first one available. This covers
|
|
|
|
// e.g. VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU if available, or with the greatest memory available, etc.
|
|
|
|
// most common cases (multi-gpu/integrated+dedicated graphics). Handling more complicated setups (multiple
|
|
|
|
// for sake of simplicity we'll just take the first one, assuming it has a graphics queue family.
|
|
|
|
// dedicated GPUs) is out of scope of this sample.
|
|
|
|
g_PhysicalDevice = gpus[0]; |
|
|
|
int use_gpu = 0; |
|
|
|
|
|
|
|
for (int i = 0; i < (int)gpu_count; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
VkPhysicalDeviceProperties properties; |
|
|
|
|
|
|
|
vkGetPhysicalDeviceProperties(gpus[i], &properties); |
|
|
|
|
|
|
|
if (properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
use_gpu = i; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
g_PhysicalDevice = gpus[use_gpu]; |
|
|
|
free(gpus); |
|
|
|
free(gpus); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|