From 40f13fc770bc714235c0545248d72aab967ba314 Mon Sep 17 00:00:00 2001 From: saschawillems Date: Wed, 17 Feb 2016 18:37:36 +0100 Subject: [PATCH] Fix for physical device enumeration --- base/vulkanexamplebase.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index 5f22de6e..8163be12 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -469,14 +469,25 @@ void VulkanExampleBase::initVulkan(bool enableValidation) } // Physical device - // Note : This example will always use the first physical device reported - uint32_t gpuCount; - err = vkEnumeratePhysicalDevices(instance, &gpuCount, &physicalDevice); + uint32_t gpuCount = 0; + // Get number of available physical devices + err = vkEnumeratePhysicalDevices(instance, &gpuCount, nullptr); + assert(!err); + assert(gpuCount > 0); + // Enumerate devices + std::vector physicalDevices(gpuCount); + err = vkEnumeratePhysicalDevices(instance, &gpuCount, physicalDevices.data()); if (err) { vkTools::exitFatal("Could not enumerate phyiscal devices : \n" + vkTools::errorString(err), "Fatal error"); } + // Note : + // This example will always use the first physical device reported, + // change the vector index if you have multiple Vulkan devices installed + // and want to use another one + physicalDevice = physicalDevices[0]; + // Find a queue that supports graphics operations uint32_t graphicsQueueIndex = 0; uint32_t queueCount;