Demo application that renders a triangle using Vulkan on the Pixel 3A.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. //
  2. // File: vk_layer.h
  3. //
  4. /*
  5. * Copyright (c) 2015-2017 The Khronos Group Inc.
  6. * Copyright (c) 2015-2017 Valve Corporation
  7. * Copyright (c) 2015-2017 LunarG, Inc.
  8. *
  9. * Licensed under the Apache License, Version 2.0 (the "License");
  10. * you may not use this file except in compliance with the License.
  11. * You may obtain a copy of the License at
  12. *
  13. * http://www.apache.org/licenses/LICENSE-2.0
  14. *
  15. * Unless required by applicable law or agreed to in writing, software
  16. * distributed under the License is distributed on an "AS IS" BASIS,
  17. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18. * See the License for the specific language governing permissions and
  19. * limitations under the License.
  20. *
  21. */
  22. /* Need to define dispatch table
  23. * Core struct can then have ptr to dispatch table at the top
  24. * Along with object ptrs for current and next OBJ
  25. */
  26. #pragma once
  27. #include "vulkan.h"
  28. #if defined(__GNUC__) && __GNUC__ >= 4
  29. #define VK_LAYER_EXPORT __attribute__((visibility("default")))
  30. #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
  31. #define VK_LAYER_EXPORT __attribute__((visibility("default")))
  32. #else
  33. #define VK_LAYER_EXPORT
  34. #endif
  35. #define MAX_NUM_UNKNOWN_EXTS 250
  36. // Loader-Layer version negotiation API. Versions add the following features:
  37. // Versions 0/1 - Initial. Doesn't support vk_layerGetPhysicalDeviceProcAddr
  38. // or vk_icdNegotiateLoaderLayerInterfaceVersion.
  39. // Version 2 - Add support for vk_layerGetPhysicalDeviceProcAddr and
  40. // vk_icdNegotiateLoaderLayerInterfaceVersion.
  41. #define CURRENT_LOADER_LAYER_INTERFACE_VERSION 2
  42. #define MIN_SUPPORTED_LOADER_LAYER_INTERFACE_VERSION 1
  43. #define VK_CURRENT_CHAIN_VERSION 1
  44. // Typedef for use in the interfaces below
  45. typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char* pName);
  46. // Version negotiation values
  47. typedef enum VkNegotiateLayerStructType {
  48. LAYER_NEGOTIATE_UNINTIALIZED = 0,
  49. LAYER_NEGOTIATE_INTERFACE_STRUCT = 1,
  50. } VkNegotiateLayerStructType;
  51. // Version negotiation structures
  52. typedef struct VkNegotiateLayerInterface {
  53. VkNegotiateLayerStructType sType;
  54. void *pNext;
  55. uint32_t loaderLayerInterfaceVersion;
  56. PFN_vkGetInstanceProcAddr pfnGetInstanceProcAddr;
  57. PFN_vkGetDeviceProcAddr pfnGetDeviceProcAddr;
  58. PFN_GetPhysicalDeviceProcAddr pfnGetPhysicalDeviceProcAddr;
  59. } VkNegotiateLayerInterface;
  60. // Version negotiation functions
  61. typedef VkResult (VKAPI_PTR *PFN_vkNegotiateLoaderLayerInterfaceVersion)(VkNegotiateLayerInterface *pVersionStruct);
  62. // Function prototype for unknown physical device extension command
  63. typedef VkResult(VKAPI_PTR *PFN_PhysDevExt)(VkPhysicalDevice phys_device);
  64. // ------------------------------------------------------------------------------------------------
  65. // CreateInstance and CreateDevice support structures
  66. /* Sub type of structure for instance and device loader ext of CreateInfo.
  67. * When sType == VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO
  68. * or sType == VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO
  69. * then VkLayerFunction indicates struct type pointed to by pNext
  70. */
  71. typedef enum VkLayerFunction_ {
  72. VK_LAYER_LINK_INFO = 0,
  73. VK_LOADER_DATA_CALLBACK = 1,
  74. VK_LOADER_LAYER_CREATE_DEVICE_CALLBACK = 2
  75. } VkLayerFunction;
  76. typedef struct VkLayerInstanceLink_ {
  77. struct VkLayerInstanceLink_ *pNext;
  78. PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr;
  79. PFN_GetPhysicalDeviceProcAddr pfnNextGetPhysicalDeviceProcAddr;
  80. } VkLayerInstanceLink;
  81. /*
  82. * When creating the device chain the loader needs to pass
  83. * down information about it's device structure needed at
  84. * the end of the chain. Passing the data via the
  85. * VkLayerDeviceInfo avoids issues with finding the
  86. * exact instance being used.
  87. */
  88. typedef struct VkLayerDeviceInfo_ {
  89. void *device_info;
  90. PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr;
  91. } VkLayerDeviceInfo;
  92. typedef VkResult (VKAPI_PTR *PFN_vkSetInstanceLoaderData)(VkInstance instance,
  93. void *object);
  94. typedef VkResult (VKAPI_PTR *PFN_vkSetDeviceLoaderData)(VkDevice device,
  95. void *object);
  96. typedef VkResult (VKAPI_PTR *PFN_vkLayerCreateDevice)(VkInstance instance, VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
  97. const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, PFN_vkGetInstanceProcAddr layerGIPA, PFN_vkGetDeviceProcAddr *nextGDPA);
  98. typedef void (VKAPI_PTR *PFN_vkLayerDestroyDevice)(VkDevice physicalDevice, const VkAllocationCallbacks *pAllocator, PFN_vkDestroyDevice destroyFunction);
  99. typedef struct {
  100. VkStructureType sType; // VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO
  101. const void *pNext;
  102. VkLayerFunction function;
  103. union {
  104. VkLayerInstanceLink *pLayerInfo;
  105. PFN_vkSetInstanceLoaderData pfnSetInstanceLoaderData;
  106. struct {
  107. PFN_vkLayerCreateDevice pfnLayerCreateDevice;
  108. PFN_vkLayerDestroyDevice pfnLayerDestroyDevice;
  109. } layerDevice;
  110. } u;
  111. } VkLayerInstanceCreateInfo;
  112. typedef struct VkLayerDeviceLink_ {
  113. struct VkLayerDeviceLink_ *pNext;
  114. PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr;
  115. PFN_vkGetDeviceProcAddr pfnNextGetDeviceProcAddr;
  116. } VkLayerDeviceLink;
  117. typedef struct {
  118. VkStructureType sType; // VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO
  119. const void *pNext;
  120. VkLayerFunction function;
  121. union {
  122. VkLayerDeviceLink *pLayerInfo;
  123. PFN_vkSetDeviceLoaderData pfnSetDeviceLoaderData;
  124. } u;
  125. } VkLayerDeviceCreateInfo;
  126. #ifdef __cplusplus
  127. extern "C" {
  128. #endif
  129. VKAPI_ATTR VkResult VKAPI_CALL vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *pVersionStruct);
  130. typedef enum VkChainType {
  131. VK_CHAIN_TYPE_UNKNOWN = 0,
  132. VK_CHAIN_TYPE_ENUMERATE_INSTANCE_EXTENSION_PROPERTIES = 1,
  133. VK_CHAIN_TYPE_ENUMERATE_INSTANCE_LAYER_PROPERTIES = 2,
  134. VK_CHAIN_TYPE_ENUMERATE_INSTANCE_VERSION = 3,
  135. } VkChainType;
  136. typedef struct VkChainHeader {
  137. VkChainType type;
  138. uint32_t version;
  139. uint32_t size;
  140. } VkChainHeader;
  141. typedef struct VkEnumerateInstanceExtensionPropertiesChain {
  142. VkChainHeader header;
  143. VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceExtensionPropertiesChain *, const char *, uint32_t *,
  144. VkExtensionProperties *);
  145. const struct VkEnumerateInstanceExtensionPropertiesChain *pNextLink;
  146. #if defined(__cplusplus)
  147. inline VkResult CallDown(const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties) const {
  148. return pfnNextLayer(pNextLink, pLayerName, pPropertyCount, pProperties);
  149. }
  150. #endif
  151. } VkEnumerateInstanceExtensionPropertiesChain;
  152. typedef struct VkEnumerateInstanceLayerPropertiesChain {
  153. VkChainHeader header;
  154. VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceLayerPropertiesChain *, uint32_t *, VkLayerProperties *);
  155. const struct VkEnumerateInstanceLayerPropertiesChain *pNextLink;
  156. #if defined(__cplusplus)
  157. inline VkResult CallDown(uint32_t *pPropertyCount, VkLayerProperties *pProperties) const {
  158. return pfnNextLayer(pNextLink, pPropertyCount, pProperties);
  159. }
  160. #endif
  161. } VkEnumerateInstanceLayerPropertiesChain;
  162. typedef struct VkEnumerateInstanceVersionChain {
  163. VkChainHeader header;
  164. VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceVersionChain *, uint32_t *);
  165. const struct VkEnumerateInstanceVersionChain *pNextLink;
  166. #if defined(__cplusplus)
  167. inline VkResult CallDown(uint32_t *pApiVersion) const {
  168. return pfnNextLayer(pNextLink, pApiVersion);
  169. }
  170. #endif
  171. } VkEnumerateInstanceVersionChain;
  172. #ifdef __cplusplus
  173. }
  174. #endif