From 96234613be56b0a8bfbe94d93af6124f3c94edbd Mon Sep 17 00:00:00 2001 From: Bam4d Date: Sat, 30 Dec 2023 12:36:44 +0000 Subject: [PATCH] only enable the portability subset if its available --- .../Core/Observers/Vulkan/VulkanDevice.cpp | 24 +++++++++++++++---- .../Core/Observers/Vulkan/VulkanDevice.hpp | 1 + 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/Griddly/Core/Observers/Vulkan/VulkanDevice.cpp b/src/Griddly/Core/Observers/Vulkan/VulkanDevice.cpp index c11a7f630..39e6c4044 100644 --- a/src/Griddly/Core/Observers/Vulkan/VulkanDevice.cpp +++ b/src/Griddly/Core/Observers/Vulkan/VulkanDevice.cpp @@ -124,14 +124,28 @@ void VulkanDevice::initDevice(bool useGPU) { auto graphicsQueueFamilyIndex = physicalDeviceInfo->queueFamilyIndices.graphicsIndices; auto computeQueueFamilyIndex = physicalDeviceInfo->queueFamilyIndices.computeIndices; - const char* ppEnabledExtensionNames[] = { - "VK_KHR_portability_subset" - }; + // Get the device extensions + uint32_t deviceExtensionCount; + vkEnumerateDeviceExtensionProperties(physicalDeviceInfo->physicalDevice, nullptr, &deviceExtensionCount, nullptr); + std::vector deviceExtensions(deviceExtensionCount); + vkEnumerateDeviceExtensionProperties(physicalDeviceInfo->physicalDevice, nullptr, &deviceExtensionCount, deviceExtensions.data()); + + std::vector deviceExtensionNames; + for (auto& extension : deviceExtensions) { + deviceExtensionNames.push_back(extension.extensionName); + } + + //if portable subset is available, enable it + std::vector enabledExtensions; + if (std::find(deviceExtensionNames.begin(), deviceExtensionNames.end(), VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME) != deviceExtensionNames.end()) { + enabledExtensions.push_back(VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME); + } + auto deviceQueueCreateInfo = vk::initializers::deviceQueueCreateInfo(graphicsQueueFamilyIndex, 1.0f); auto deviceCreateInfo = vk::initializers::deviceCreateInfo(deviceQueueCreateInfo); - deviceCreateInfo.enabledExtensionCount = 1; - deviceCreateInfo.ppEnabledExtensionNames = ppEnabledExtensionNames; + deviceCreateInfo.enabledExtensionCount = enabledExtensions.size(); + deviceCreateInfo.ppEnabledExtensionNames = enabledExtensions.data(); physicalDevice_ = physicalDeviceInfo->physicalDevice; spdlog::debug("Creating physical device."); diff --git a/src/Griddly/Core/Observers/Vulkan/VulkanDevice.hpp b/src/Griddly/Core/Observers/Vulkan/VulkanDevice.hpp index a5c85dc06..2bd769a86 100644 --- a/src/Griddly/Core/Observers/Vulkan/VulkanDevice.hpp +++ b/src/Griddly/Core/Observers/Vulkan/VulkanDevice.hpp @@ -1,6 +1,7 @@ #pragma once #include +#define VK_ENABLE_BETA_EXTENSIONS #include #include