Browse Source

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.
pull/491/head
Vladimír Vondruš 5 years ago
parent
commit
ff916e1934
  1. 9
      src/Magnum/Vk/DeviceProperties.cpp
  2. 5
      src/Magnum/Vk/DeviceProperties.h

9
src/Magnum/Vk/DeviceProperties.cpp

@ -193,8 +193,8 @@ const VkPhysicalDeviceProperties2& DeviceProperties::properties() {
Containers::Reference<void*> next = _state->properties.pNext; Containers::Reference<void*> next = _state->properties.pNext;
/* Fetch driver properties, if supported */ /* Fetch driver properties, if supported */
if(isVersionSupported(Version::Vk12) || extensionPropertiesInternal().isSupported<Extensions::KHR::driver_properties>()) if(isOrVersionSupportedInternal<Extensions::KHR::driver_properties>())
connect(next, _state->driverProperties, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES); Implementation::structureConnect(next, _state->driverProperties, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES);
_state->getPropertiesImplementation(*this, _state->properties); _state->getPropertiesImplementation(*this, _state->properties);
} }
@ -231,6 +231,11 @@ const ExtensionProperties& DeviceProperties::extensionPropertiesInternal() {
return *_state->extensions; return *_state->extensions;
} }
template<class E> bool DeviceProperties::isOrVersionSupportedInternal() {
if(isVersionSupported(E::coreVersion())) return true;
return extensionPropertiesInternal().isSupported<E>();
}
Containers::ArrayView<const VkQueueFamilyProperties2> DeviceProperties::queueFamilyProperties() { Containers::ArrayView<const VkQueueFamilyProperties2> DeviceProperties::queueFamilyProperties() {
if(!_state) _state.emplace(*_instance, _handle); if(!_state) _state.emplace(*_instance, _handle);

5
src/Magnum/Vk/DeviceProperties.h

@ -631,6 +631,11 @@ class MAGNUM_VK_EXPORT DeviceProperties {
function. */ function. */
MAGNUM_VK_LOCAL const ExtensionProperties& extensionPropertiesInternal(); MAGNUM_VK_LOCAL const ExtensionProperties& extensionPropertiesInternal();
/* Combines isVersionSupported(E::coreVersion()) and
ExtensionProperties::isSupported<E>(). Used internally to avoid
accidents with incorrectly specified extension core version. */
template<class E> MAGNUM_VK_LOCAL bool isOrVersionSupportedInternal();
MAGNUM_VK_LOCAL static void getPropertiesImplementationDefault(DeviceProperties& self, VkPhysicalDeviceProperties2& properties); 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 getPropertiesImplementationKHR(DeviceProperties& self, VkPhysicalDeviceProperties2& properties);
MAGNUM_VK_LOCAL static void getPropertiesImplementation11(DeviceProperties& self, VkPhysicalDeviceProperties2& properties); MAGNUM_VK_LOCAL static void getPropertiesImplementation11(DeviceProperties& self, VkPhysicalDeviceProperties2& properties);

Loading…
Cancel
Save