Skip to content

Commit

Permalink
Vulkan: If there are no GPUs available, fail properly instead of asse…
Browse files Browse the repository at this point in the history
…rting.

Seen on an obscure x86-64 android device when running 32-bit binaries
  • Loading branch information
hrydgard committed Oct 2, 2017
1 parent 6867265 commit 356b25e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Common/Vulkan/VulkanContext.cpp
Expand Up @@ -123,11 +123,20 @@ VkResult VulkanContext::CreateInstance(const char *app_name, int app_ver, uint32

uint32_t gpu_count = 1;
res = vkEnumeratePhysicalDevices(instance_, &gpu_count, nullptr);
if (gpu_count <= 0) {
ELOG("Vulkan driver found but no supported GPU is available");
init_error_ = "No Vulkan physical devices found";
vkDestroyInstance(instance_, nullptr);
instance_ = nullptr;
return VK_ERROR_INITIALIZATION_FAILED;
}

assert(gpu_count > 0);
physical_devices_.resize(gpu_count);
res = vkEnumeratePhysicalDevices(instance_, &gpu_count, physical_devices_.data());
if (res != VK_SUCCESS) {
init_error_ = "Failed to enumerate physical devices";
vkDestroyInstance(instance_, nullptr);
return res;
}

Expand Down

0 comments on commit 356b25e

Please sign in to comment.