Extending Vulkan


New functionality may be added to Vulkan via either new extensions or new versions of the core, or new versions of an extension in some cases.

This chapter describes how Vulkan is versioned, how compatibility is affected between different versions, and compatibility rules that are followed by the Vulkan Working Group.

Instance and Device Functionality

Core Versions

Version Numbers

#define VK_API_VERSION_VARIANT(version) ((uint32_t)(version) >> 29)

#define VK_API_VERSION_MAJOR(version) (((uint32_t)(version) >> 22) & 0x7FU)

#define VK_VERSION_MAJOR(version) ((uint32_t)(version) >> 22)

#define VK_API_VERSION_MINOR(version) (((uint32_t)(version) >> 12) & 0x3FFU)

#define VK_VERSION_MINOR(version) (((uint32_t)(version) >> 12) & 0x3FFU)

#define VK_API_VERSION_PATCH(version) ((uint32_t)(version) & 0xFFFU)

#define VK_VERSION_PATCH(version) ((uint32_t)(version) & 0xFFFU)

#define VK_MAKE_API_VERSION(variant, major, minor, patch) \ ((((uint32_t)(variant)) << 29) | (((uint32_t)(major)) << 22) | (((uint32_t)(minor)) << 12) | ((uint32_t)(patch)))

#define VK_MAKE_VERSION(major, minor, patch) \ ((((uint32_t)(major)) << 22) | (((uint32_t)(minor)) << 12) | ((uint32_t)(patch)))

#define VK_API_VERSION_1_0 VK_MAKE_API_VERSION(0, 1, 0, 0)// Patch version should always be set to 0

#define VK_API_VERSION_1_1 VK_MAKE_API_VERSION(0, 1, 1, 0)// Patch version should always be set to 0

#define VK_API_VERSION_1_2 VK_MAKE_API_VERSION(0, 1, 2, 0)// Patch version should always be set to 0

#define VK_API_VERSION_1_3 VK_MAKE_API_VERSION(0, 1, 3, 0)// Patch version should always be set to 0

Querying Version Support

The version of instance-level functionality can be queried by calling vkEnumerateInstanceVersion.

The version of device-level functionality can be queried by calling vkGetPhysicalDeviceProperties or vkGetPhysicalDeviceProperties2, and is returned in VkPhysicalDeviceProperties::apiVersion, encoded as described in Version Numbers.

Layers

When a layer is enabled, it inserts itself into the call chain for Vulkan commands the layer is interested in. Layers can be used for a variety of tasks that extend the base behavior of Vulkan beyond what is required by the specification - such as call logging, tracing, validation, or providing additional extensions.

VkResult vkEnumerateInstanceLayerProperties( uint32_t* pPropertyCount, VkLayerProperties* pProperties);

void FVulkanDynamicRHI::GetInstanceLayersAndExtensions(TArray<.const ANSICHAR*>& OutInstanceExtensions, TArray<.const ANSICHAR*>& OutInstanceLayers, bool& bOutDebugUtils)

VkResult vkEnumerateDeviceLayerProperties( VkPhysicalDevice uint32_t* VkLayerProperties* physicalDevice, pPropertyCount, pProperties);

void FVulkanDevice::GetDeviceExtensionsAndLayers(VkPhysicalDevice Gpu, EGpuVendorId VendorId, TArray& OutDeviceExtensions, TArray& OutDeviceLayers, TArray& OutAllDeviceExtensions, TArray& OutAllDeviceLayers, bool& bOutDebugMarkers)

Extensions may define new Vulkan commands, structures, and enumerants. For compilation purposes, the interfaces defined by registered extensions, including new structures and enumerants as well as function pointer types for new commands, are defined in the Khronos- supplied vulkan_core.h together with the core API. However, commands defined by extensions may not be available for static linking - in which case function pointers to these commands should be queried at runtime as described in Command Function Pointers. Extensions may be provided by layers as well as by a Vulkan implementation.

VkResult vkEnumerateInstanceExtensionProperties( const char* uint32_t* VkExtensionProperties* pLayerName, pPropertyCount, pProperties);

static inline void EnumerateInstanceExtensionProperties(const ANSICHAR* LayerName, FLayerExtension& OutLayer)

void FVulkanDynamicRHI::CreateInstance()

VkResult vkEnumerateDeviceExtensionProperties( VkPhysicalDevice const char* uint32_t* physicalDevice, pLayerName, pPropertyCount, pProperties);

static inline void EnumerateDeviceExtensionProperties(VkPhysicalDevice Device, const ANSICHAR* LayerName, FLayerExtension& OutLayer)

Extension Dependencies

Compatibility Guarantees (Informative)

Core Versions

Extensions

本节教程就到此结束,希望大家继续阅读我之后的教程。

谢谢大家,再见!


原创技术文章,撰写不易,转载请注明出处:电子设备中的画家|王烁 于 2021 年 5 月 10 日发表,原文链接(http://geekfaner.com/shineengine/blog20_Vulkanv1.2_6.html)