From bf989e55c693b83fc3e10838b04d89fd97921a6c Mon Sep 17 00:00:00 2001 From: bailwillharr Date: Sun, 25 Sep 2022 14:52:05 +0100 Subject: [PATCH] Check for device surface support --- src/gfx_device_vulkan.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gfx_device_vulkan.cpp b/src/gfx_device_vulkan.cpp index d122471..f1d1002 100644 --- a/src/gfx_device_vulkan.cpp +++ b/src/gfx_device_vulkan.cpp @@ -492,6 +492,13 @@ namespace engine::gfx { queueCreateInfos.push_back(queueCreateInfo); } + VkBool32 supported; + res = vkGetPhysicalDeviceSurfaceSupportKHR(physicalDevice, graphicsFamilyIndex.value(), m_surface->getHandle(), &supported); + assert(res == VK_SUCCESS); + if (supported != VK_TRUE) { + throw std::runtime_error("The selected physical device and queue family do not support this surface"); + } + VkDeviceCreateInfo deviceCreateInfo{ .sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, .pNext = nullptr, @@ -561,7 +568,7 @@ namespace engine::gfx { { VkResult res; - auto supportDetails = device->getSupportDetails(); + auto supportDetails = m_device->getSupportDetails(); VkSurfaceFormatKHR chosenSurfaceFormat = supportDetails.formats[0];