From ff916e1934565ffc5be21f1aaf623daef4dbbab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 13 Dec 2020 01:53:01 +0100 Subject: [PATCH] Vk: internal helper for checking both extension and its core version. Not exactly sure about the semantics yet, so keeping it private. In particular, if this should be the default behavior for isExtensionEnabled() (would make sense probably?), or for isExtensionSupported(), and what should be the API that separates the version from the extension so we can decide which function pointer to fetch. --- src/Magnum/Vk/DeviceProperties.cpp | 9 +++++++-- src/Magnum/Vk/DeviceProperties.h | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Magnum/Vk/DeviceProperties.cpp b/src/Magnum/Vk/DeviceProperties.cpp index 2794993da..d9cf5952d 100644 --- a/src/Magnum/Vk/DeviceProperties.cpp +++ b/src/Magnum/Vk/DeviceProperties.cpp @@ -193,8 +193,8 @@ const VkPhysicalDeviceProperties2& DeviceProperties::properties() { Containers::Reference next = _state->properties.pNext; /* Fetch driver properties, if supported */ - if(isVersionSupported(Version::Vk12) || extensionPropertiesInternal().isSupported()) - connect(next, _state->driverProperties, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES); + if(isOrVersionSupportedInternal()) + Implementation::structureConnect(next, _state->driverProperties, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES); _state->getPropertiesImplementation(*this, _state->properties); } @@ -231,6 +231,11 @@ const ExtensionProperties& DeviceProperties::extensionPropertiesInternal() { return *_state->extensions; } +template bool DeviceProperties::isOrVersionSupportedInternal() { + if(isVersionSupported(E::coreVersion())) return true; + return extensionPropertiesInternal().isSupported(); +} + Containers::ArrayView DeviceProperties::queueFamilyProperties() { if(!_state) _state.emplace(*_instance, _handle); diff --git a/src/Magnum/Vk/DeviceProperties.h b/src/Magnum/Vk/DeviceProperties.h index cd7a94457..2b7e7153c 100644 --- a/src/Magnum/Vk/DeviceProperties.h +++ b/src/Magnum/Vk/DeviceProperties.h @@ -631,6 +631,11 @@ class MAGNUM_VK_EXPORT DeviceProperties { function. */ MAGNUM_VK_LOCAL const ExtensionProperties& extensionPropertiesInternal(); + /* Combines isVersionSupported(E::coreVersion()) and + ExtensionProperties::isSupported(). Used internally to avoid + accidents with incorrectly specified extension core version. */ + template MAGNUM_VK_LOCAL bool isOrVersionSupportedInternal(); + MAGNUM_VK_LOCAL static void getPropertiesImplementationDefault(DeviceProperties& self, VkPhysicalDeviceProperties2& properties); MAGNUM_VK_LOCAL static void getPropertiesImplementationKHR(DeviceProperties& self, VkPhysicalDeviceProperties2& properties); MAGNUM_VK_LOCAL static void getPropertiesImplementation11(DeviceProperties& self, VkPhysicalDeviceProperties2& properties);