- pick the first device that supports our required features

This commit is contained in:
Magnus Norddahl 2019-03-08 22:53:32 +01:00
parent aa1ff58353
commit 389469c604
2 changed files with 13 additions and 1 deletions

View file

@ -272,6 +272,16 @@ void VulkanDevice::createSurface()
} }
} }
bool VulkanDevice::checkFeatures(const VkPhysicalDeviceFeatures &f)
{
return
f.samplerAnisotropy == VK_TRUE &&
f.shaderClipDistance == VK_TRUE &&
f.fragmentStoresAndAtomics == VK_TRUE &&
f.depthClamp == VK_TRUE &&
f.shaderClipDistance == VK_TRUE;
}
void VulkanDevice::selectPhysicalDevice() void VulkanDevice::selectPhysicalDevice()
{ {
VkResult result; VkResult result;
@ -293,7 +303,7 @@ void VulkanDevice::selectPhysicalDevice()
vkGetPhysicalDeviceProperties(device, &deviceProperties); vkGetPhysicalDeviceProperties(device, &deviceProperties);
vkGetPhysicalDeviceFeatures(device, &deviceFeatures); vkGetPhysicalDeviceFeatures(device, &deviceFeatures);
bool isUsableDevice = deviceProperties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU && deviceFeatures.geometryShader && deviceFeatures.samplerAnisotropy; bool isUsableDevice = /*deviceProperties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU &&*/ checkFeatures(deviceFeatures);
if (!isUsableDevice) if (!isUsableDevice)
continue; continue;

View file

@ -61,6 +61,8 @@ private:
void createSemaphores(); void createSemaphores();
void releaseResources(); void releaseResources();
static bool checkFeatures(const VkPhysicalDeviceFeatures &f);
VkDebugUtilsMessengerEXT debugMessenger = VK_NULL_HANDLE; VkDebugUtilsMessengerEXT debugMessenger = VK_NULL_HANDLE;
static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, void* pUserData); static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, void* pUserData);