glad_vulkan.c 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <glad/vulkan.h>
  5. #ifndef GLAD_IMPL_UTIL_C_
  6. #define GLAD_IMPL_UTIL_C_
  7. #ifdef _MSC_VER
  8. #define GLAD_IMPL_UTIL_SSCANF sscanf_s
  9. #else
  10. #define GLAD_IMPL_UTIL_SSCANF sscanf
  11. #endif
  12. #endif /* GLAD_IMPL_UTIL_C_ */
  13. int GLAD_VK_VERSION_1_0 = 0;
  14. int GLAD_VK_VERSION_1_1 = 0;
  15. int GLAD_VK_EXT_debug_report = 0;
  16. int GLAD_VK_KHR_surface = 0;
  17. int GLAD_VK_KHR_swapchain = 0;
  18. PFN_vkAcquireNextImage2KHR glad_vkAcquireNextImage2KHR = NULL;
  19. PFN_vkAcquireNextImageKHR glad_vkAcquireNextImageKHR = NULL;
  20. PFN_vkAllocateCommandBuffers glad_vkAllocateCommandBuffers = NULL;
  21. PFN_vkAllocateDescriptorSets glad_vkAllocateDescriptorSets = NULL;
  22. PFN_vkAllocateMemory glad_vkAllocateMemory = NULL;
  23. PFN_vkBeginCommandBuffer glad_vkBeginCommandBuffer = NULL;
  24. PFN_vkBindBufferMemory glad_vkBindBufferMemory = NULL;
  25. PFN_vkBindBufferMemory2 glad_vkBindBufferMemory2 = NULL;
  26. PFN_vkBindImageMemory glad_vkBindImageMemory = NULL;
  27. PFN_vkBindImageMemory2 glad_vkBindImageMemory2 = NULL;
  28. PFN_vkCmdBeginQuery glad_vkCmdBeginQuery = NULL;
  29. PFN_vkCmdBeginRenderPass glad_vkCmdBeginRenderPass = NULL;
  30. PFN_vkCmdBindDescriptorSets glad_vkCmdBindDescriptorSets = NULL;
  31. PFN_vkCmdBindIndexBuffer glad_vkCmdBindIndexBuffer = NULL;
  32. PFN_vkCmdBindPipeline glad_vkCmdBindPipeline = NULL;
  33. PFN_vkCmdBindVertexBuffers glad_vkCmdBindVertexBuffers = NULL;
  34. PFN_vkCmdBlitImage glad_vkCmdBlitImage = NULL;
  35. PFN_vkCmdClearAttachments glad_vkCmdClearAttachments = NULL;
  36. PFN_vkCmdClearColorImage glad_vkCmdClearColorImage = NULL;
  37. PFN_vkCmdClearDepthStencilImage glad_vkCmdClearDepthStencilImage = NULL;
  38. PFN_vkCmdCopyBuffer glad_vkCmdCopyBuffer = NULL;
  39. PFN_vkCmdCopyBufferToImage glad_vkCmdCopyBufferToImage = NULL;
  40. PFN_vkCmdCopyImage glad_vkCmdCopyImage = NULL;
  41. PFN_vkCmdCopyImageToBuffer glad_vkCmdCopyImageToBuffer = NULL;
  42. PFN_vkCmdCopyQueryPoolResults glad_vkCmdCopyQueryPoolResults = NULL;
  43. PFN_vkCmdDispatch glad_vkCmdDispatch = NULL;
  44. PFN_vkCmdDispatchBase glad_vkCmdDispatchBase = NULL;
  45. PFN_vkCmdDispatchIndirect glad_vkCmdDispatchIndirect = NULL;
  46. PFN_vkCmdDraw glad_vkCmdDraw = NULL;
  47. PFN_vkCmdDrawIndexed glad_vkCmdDrawIndexed = NULL;
  48. PFN_vkCmdDrawIndexedIndirect glad_vkCmdDrawIndexedIndirect = NULL;
  49. PFN_vkCmdDrawIndirect glad_vkCmdDrawIndirect = NULL;
  50. PFN_vkCmdEndQuery glad_vkCmdEndQuery = NULL;
  51. PFN_vkCmdEndRenderPass glad_vkCmdEndRenderPass = NULL;
  52. PFN_vkCmdExecuteCommands glad_vkCmdExecuteCommands = NULL;
  53. PFN_vkCmdFillBuffer glad_vkCmdFillBuffer = NULL;
  54. PFN_vkCmdNextSubpass glad_vkCmdNextSubpass = NULL;
  55. PFN_vkCmdPipelineBarrier glad_vkCmdPipelineBarrier = NULL;
  56. PFN_vkCmdPushConstants glad_vkCmdPushConstants = NULL;
  57. PFN_vkCmdResetEvent glad_vkCmdResetEvent = NULL;
  58. PFN_vkCmdResetQueryPool glad_vkCmdResetQueryPool = NULL;
  59. PFN_vkCmdResolveImage glad_vkCmdResolveImage = NULL;
  60. PFN_vkCmdSetBlendConstants glad_vkCmdSetBlendConstants = NULL;
  61. PFN_vkCmdSetDepthBias glad_vkCmdSetDepthBias = NULL;
  62. PFN_vkCmdSetDepthBounds glad_vkCmdSetDepthBounds = NULL;
  63. PFN_vkCmdSetDeviceMask glad_vkCmdSetDeviceMask = NULL;
  64. PFN_vkCmdSetEvent glad_vkCmdSetEvent = NULL;
  65. PFN_vkCmdSetLineWidth glad_vkCmdSetLineWidth = NULL;
  66. PFN_vkCmdSetScissor glad_vkCmdSetScissor = NULL;
  67. PFN_vkCmdSetStencilCompareMask glad_vkCmdSetStencilCompareMask = NULL;
  68. PFN_vkCmdSetStencilReference glad_vkCmdSetStencilReference = NULL;
  69. PFN_vkCmdSetStencilWriteMask glad_vkCmdSetStencilWriteMask = NULL;
  70. PFN_vkCmdSetViewport glad_vkCmdSetViewport = NULL;
  71. PFN_vkCmdUpdateBuffer glad_vkCmdUpdateBuffer = NULL;
  72. PFN_vkCmdWaitEvents glad_vkCmdWaitEvents = NULL;
  73. PFN_vkCmdWriteTimestamp glad_vkCmdWriteTimestamp = NULL;
  74. PFN_vkCreateBuffer glad_vkCreateBuffer = NULL;
  75. PFN_vkCreateBufferView glad_vkCreateBufferView = NULL;
  76. PFN_vkCreateCommandPool glad_vkCreateCommandPool = NULL;
  77. PFN_vkCreateComputePipelines glad_vkCreateComputePipelines = NULL;
  78. PFN_vkCreateDebugReportCallbackEXT glad_vkCreateDebugReportCallbackEXT = NULL;
  79. PFN_vkCreateDescriptorPool glad_vkCreateDescriptorPool = NULL;
  80. PFN_vkCreateDescriptorSetLayout glad_vkCreateDescriptorSetLayout = NULL;
  81. PFN_vkCreateDescriptorUpdateTemplate glad_vkCreateDescriptorUpdateTemplate = NULL;
  82. PFN_vkCreateDevice glad_vkCreateDevice = NULL;
  83. PFN_vkCreateEvent glad_vkCreateEvent = NULL;
  84. PFN_vkCreateFence glad_vkCreateFence = NULL;
  85. PFN_vkCreateFramebuffer glad_vkCreateFramebuffer = NULL;
  86. PFN_vkCreateGraphicsPipelines glad_vkCreateGraphicsPipelines = NULL;
  87. PFN_vkCreateImage glad_vkCreateImage = NULL;
  88. PFN_vkCreateImageView glad_vkCreateImageView = NULL;
  89. PFN_vkCreateInstance glad_vkCreateInstance = NULL;
  90. PFN_vkCreatePipelineCache glad_vkCreatePipelineCache = NULL;
  91. PFN_vkCreatePipelineLayout glad_vkCreatePipelineLayout = NULL;
  92. PFN_vkCreateQueryPool glad_vkCreateQueryPool = NULL;
  93. PFN_vkCreateRenderPass glad_vkCreateRenderPass = NULL;
  94. PFN_vkCreateSampler glad_vkCreateSampler = NULL;
  95. PFN_vkCreateSamplerYcbcrConversion glad_vkCreateSamplerYcbcrConversion = NULL;
  96. PFN_vkCreateSemaphore glad_vkCreateSemaphore = NULL;
  97. PFN_vkCreateShaderModule glad_vkCreateShaderModule = NULL;
  98. PFN_vkCreateSwapchainKHR glad_vkCreateSwapchainKHR = NULL;
  99. PFN_vkDebugReportMessageEXT glad_vkDebugReportMessageEXT = NULL;
  100. PFN_vkDestroyBuffer glad_vkDestroyBuffer = NULL;
  101. PFN_vkDestroyBufferView glad_vkDestroyBufferView = NULL;
  102. PFN_vkDestroyCommandPool glad_vkDestroyCommandPool = NULL;
  103. PFN_vkDestroyDebugReportCallbackEXT glad_vkDestroyDebugReportCallbackEXT = NULL;
  104. PFN_vkDestroyDescriptorPool glad_vkDestroyDescriptorPool = NULL;
  105. PFN_vkDestroyDescriptorSetLayout glad_vkDestroyDescriptorSetLayout = NULL;
  106. PFN_vkDestroyDescriptorUpdateTemplate glad_vkDestroyDescriptorUpdateTemplate = NULL;
  107. PFN_vkDestroyDevice glad_vkDestroyDevice = NULL;
  108. PFN_vkDestroyEvent glad_vkDestroyEvent = NULL;
  109. PFN_vkDestroyFence glad_vkDestroyFence = NULL;
  110. PFN_vkDestroyFramebuffer glad_vkDestroyFramebuffer = NULL;
  111. PFN_vkDestroyImage glad_vkDestroyImage = NULL;
  112. PFN_vkDestroyImageView glad_vkDestroyImageView = NULL;
  113. PFN_vkDestroyInstance glad_vkDestroyInstance = NULL;
  114. PFN_vkDestroyPipeline glad_vkDestroyPipeline = NULL;
  115. PFN_vkDestroyPipelineCache glad_vkDestroyPipelineCache = NULL;
  116. PFN_vkDestroyPipelineLayout glad_vkDestroyPipelineLayout = NULL;
  117. PFN_vkDestroyQueryPool glad_vkDestroyQueryPool = NULL;
  118. PFN_vkDestroyRenderPass glad_vkDestroyRenderPass = NULL;
  119. PFN_vkDestroySampler glad_vkDestroySampler = NULL;
  120. PFN_vkDestroySamplerYcbcrConversion glad_vkDestroySamplerYcbcrConversion = NULL;
  121. PFN_vkDestroySemaphore glad_vkDestroySemaphore = NULL;
  122. PFN_vkDestroyShaderModule glad_vkDestroyShaderModule = NULL;
  123. PFN_vkDestroySurfaceKHR glad_vkDestroySurfaceKHR = NULL;
  124. PFN_vkDestroySwapchainKHR glad_vkDestroySwapchainKHR = NULL;
  125. PFN_vkDeviceWaitIdle glad_vkDeviceWaitIdle = NULL;
  126. PFN_vkEndCommandBuffer glad_vkEndCommandBuffer = NULL;
  127. PFN_vkEnumerateDeviceExtensionProperties glad_vkEnumerateDeviceExtensionProperties = NULL;
  128. PFN_vkEnumerateDeviceLayerProperties glad_vkEnumerateDeviceLayerProperties = NULL;
  129. PFN_vkEnumerateInstanceExtensionProperties glad_vkEnumerateInstanceExtensionProperties = NULL;
  130. PFN_vkEnumerateInstanceLayerProperties glad_vkEnumerateInstanceLayerProperties = NULL;
  131. PFN_vkEnumerateInstanceVersion glad_vkEnumerateInstanceVersion = NULL;
  132. PFN_vkEnumeratePhysicalDeviceGroups glad_vkEnumeratePhysicalDeviceGroups = NULL;
  133. PFN_vkEnumeratePhysicalDevices glad_vkEnumeratePhysicalDevices = NULL;
  134. PFN_vkFlushMappedMemoryRanges glad_vkFlushMappedMemoryRanges = NULL;
  135. PFN_vkFreeCommandBuffers glad_vkFreeCommandBuffers = NULL;
  136. PFN_vkFreeDescriptorSets glad_vkFreeDescriptorSets = NULL;
  137. PFN_vkFreeMemory glad_vkFreeMemory = NULL;
  138. PFN_vkGetBufferMemoryRequirements glad_vkGetBufferMemoryRequirements = NULL;
  139. PFN_vkGetBufferMemoryRequirements2 glad_vkGetBufferMemoryRequirements2 = NULL;
  140. PFN_vkGetDescriptorSetLayoutSupport glad_vkGetDescriptorSetLayoutSupport = NULL;
  141. PFN_vkGetDeviceGroupPeerMemoryFeatures glad_vkGetDeviceGroupPeerMemoryFeatures = NULL;
  142. PFN_vkGetDeviceGroupPresentCapabilitiesKHR glad_vkGetDeviceGroupPresentCapabilitiesKHR = NULL;
  143. PFN_vkGetDeviceGroupSurfacePresentModesKHR glad_vkGetDeviceGroupSurfacePresentModesKHR = NULL;
  144. PFN_vkGetDeviceMemoryCommitment glad_vkGetDeviceMemoryCommitment = NULL;
  145. PFN_vkGetDeviceProcAddr glad_vkGetDeviceProcAddr = NULL;
  146. PFN_vkGetDeviceQueue glad_vkGetDeviceQueue = NULL;
  147. PFN_vkGetDeviceQueue2 glad_vkGetDeviceQueue2 = NULL;
  148. PFN_vkGetEventStatus glad_vkGetEventStatus = NULL;
  149. PFN_vkGetFenceStatus glad_vkGetFenceStatus = NULL;
  150. PFN_vkGetImageMemoryRequirements glad_vkGetImageMemoryRequirements = NULL;
  151. PFN_vkGetImageMemoryRequirements2 glad_vkGetImageMemoryRequirements2 = NULL;
  152. PFN_vkGetImageSparseMemoryRequirements glad_vkGetImageSparseMemoryRequirements = NULL;
  153. PFN_vkGetImageSparseMemoryRequirements2 glad_vkGetImageSparseMemoryRequirements2 = NULL;
  154. PFN_vkGetImageSubresourceLayout glad_vkGetImageSubresourceLayout = NULL;
  155. PFN_vkGetInstanceProcAddr glad_vkGetInstanceProcAddr = NULL;
  156. PFN_vkGetPhysicalDeviceExternalBufferProperties glad_vkGetPhysicalDeviceExternalBufferProperties = NULL;
  157. PFN_vkGetPhysicalDeviceExternalFenceProperties glad_vkGetPhysicalDeviceExternalFenceProperties = NULL;
  158. PFN_vkGetPhysicalDeviceExternalSemaphoreProperties glad_vkGetPhysicalDeviceExternalSemaphoreProperties = NULL;
  159. PFN_vkGetPhysicalDeviceFeatures glad_vkGetPhysicalDeviceFeatures = NULL;
  160. PFN_vkGetPhysicalDeviceFeatures2 glad_vkGetPhysicalDeviceFeatures2 = NULL;
  161. PFN_vkGetPhysicalDeviceFormatProperties glad_vkGetPhysicalDeviceFormatProperties = NULL;
  162. PFN_vkGetPhysicalDeviceFormatProperties2 glad_vkGetPhysicalDeviceFormatProperties2 = NULL;
  163. PFN_vkGetPhysicalDeviceImageFormatProperties glad_vkGetPhysicalDeviceImageFormatProperties = NULL;
  164. PFN_vkGetPhysicalDeviceImageFormatProperties2 glad_vkGetPhysicalDeviceImageFormatProperties2 = NULL;
  165. PFN_vkGetPhysicalDeviceMemoryProperties glad_vkGetPhysicalDeviceMemoryProperties = NULL;
  166. PFN_vkGetPhysicalDeviceMemoryProperties2 glad_vkGetPhysicalDeviceMemoryProperties2 = NULL;
  167. PFN_vkGetPhysicalDevicePresentRectanglesKHR glad_vkGetPhysicalDevicePresentRectanglesKHR = NULL;
  168. PFN_vkGetPhysicalDeviceProperties glad_vkGetPhysicalDeviceProperties = NULL;
  169. PFN_vkGetPhysicalDeviceProperties2 glad_vkGetPhysicalDeviceProperties2 = NULL;
  170. PFN_vkGetPhysicalDeviceQueueFamilyProperties glad_vkGetPhysicalDeviceQueueFamilyProperties = NULL;
  171. PFN_vkGetPhysicalDeviceQueueFamilyProperties2 glad_vkGetPhysicalDeviceQueueFamilyProperties2 = NULL;
  172. PFN_vkGetPhysicalDeviceSparseImageFormatProperties glad_vkGetPhysicalDeviceSparseImageFormatProperties = NULL;
  173. PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 glad_vkGetPhysicalDeviceSparseImageFormatProperties2 = NULL;
  174. PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR glad_vkGetPhysicalDeviceSurfaceCapabilitiesKHR = NULL;
  175. PFN_vkGetPhysicalDeviceSurfaceFormatsKHR glad_vkGetPhysicalDeviceSurfaceFormatsKHR = NULL;
  176. PFN_vkGetPhysicalDeviceSurfacePresentModesKHR glad_vkGetPhysicalDeviceSurfacePresentModesKHR = NULL;
  177. PFN_vkGetPhysicalDeviceSurfaceSupportKHR glad_vkGetPhysicalDeviceSurfaceSupportKHR = NULL;
  178. PFN_vkGetPipelineCacheData glad_vkGetPipelineCacheData = NULL;
  179. PFN_vkGetQueryPoolResults glad_vkGetQueryPoolResults = NULL;
  180. PFN_vkGetRenderAreaGranularity glad_vkGetRenderAreaGranularity = NULL;
  181. PFN_vkGetSwapchainImagesKHR glad_vkGetSwapchainImagesKHR = NULL;
  182. PFN_vkInvalidateMappedMemoryRanges glad_vkInvalidateMappedMemoryRanges = NULL;
  183. PFN_vkMapMemory glad_vkMapMemory = NULL;
  184. PFN_vkMergePipelineCaches glad_vkMergePipelineCaches = NULL;
  185. PFN_vkQueueBindSparse glad_vkQueueBindSparse = NULL;
  186. PFN_vkQueuePresentKHR glad_vkQueuePresentKHR = NULL;
  187. PFN_vkQueueSubmit glad_vkQueueSubmit = NULL;
  188. PFN_vkQueueWaitIdle glad_vkQueueWaitIdle = NULL;
  189. PFN_vkResetCommandBuffer glad_vkResetCommandBuffer = NULL;
  190. PFN_vkResetCommandPool glad_vkResetCommandPool = NULL;
  191. PFN_vkResetDescriptorPool glad_vkResetDescriptorPool = NULL;
  192. PFN_vkResetEvent glad_vkResetEvent = NULL;
  193. PFN_vkResetFences glad_vkResetFences = NULL;
  194. PFN_vkSetEvent glad_vkSetEvent = NULL;
  195. PFN_vkTrimCommandPool glad_vkTrimCommandPool = NULL;
  196. PFN_vkUnmapMemory glad_vkUnmapMemory = NULL;
  197. PFN_vkUpdateDescriptorSetWithTemplate glad_vkUpdateDescriptorSetWithTemplate = NULL;
  198. PFN_vkUpdateDescriptorSets glad_vkUpdateDescriptorSets = NULL;
  199. PFN_vkWaitForFences glad_vkWaitForFences = NULL;
  200. static void glad_vk_load_VK_VERSION_1_0( GLADuserptrloadfunc load, void* userptr) {
  201. if(!GLAD_VK_VERSION_1_0) return;
  202. vkAllocateCommandBuffers = (PFN_vkAllocateCommandBuffers) load("vkAllocateCommandBuffers", userptr);
  203. vkAllocateDescriptorSets = (PFN_vkAllocateDescriptorSets) load("vkAllocateDescriptorSets", userptr);
  204. vkAllocateMemory = (PFN_vkAllocateMemory) load("vkAllocateMemory", userptr);
  205. vkBeginCommandBuffer = (PFN_vkBeginCommandBuffer) load("vkBeginCommandBuffer", userptr);
  206. vkBindBufferMemory = (PFN_vkBindBufferMemory) load("vkBindBufferMemory", userptr);
  207. vkBindImageMemory = (PFN_vkBindImageMemory) load("vkBindImageMemory", userptr);
  208. vkCmdBeginQuery = (PFN_vkCmdBeginQuery) load("vkCmdBeginQuery", userptr);
  209. vkCmdBeginRenderPass = (PFN_vkCmdBeginRenderPass) load("vkCmdBeginRenderPass", userptr);
  210. vkCmdBindDescriptorSets = (PFN_vkCmdBindDescriptorSets) load("vkCmdBindDescriptorSets", userptr);
  211. vkCmdBindIndexBuffer = (PFN_vkCmdBindIndexBuffer) load("vkCmdBindIndexBuffer", userptr);
  212. vkCmdBindPipeline = (PFN_vkCmdBindPipeline) load("vkCmdBindPipeline", userptr);
  213. vkCmdBindVertexBuffers = (PFN_vkCmdBindVertexBuffers) load("vkCmdBindVertexBuffers", userptr);
  214. vkCmdBlitImage = (PFN_vkCmdBlitImage) load("vkCmdBlitImage", userptr);
  215. vkCmdClearAttachments = (PFN_vkCmdClearAttachments) load("vkCmdClearAttachments", userptr);
  216. vkCmdClearColorImage = (PFN_vkCmdClearColorImage) load("vkCmdClearColorImage", userptr);
  217. vkCmdClearDepthStencilImage = (PFN_vkCmdClearDepthStencilImage) load("vkCmdClearDepthStencilImage", userptr);
  218. vkCmdCopyBuffer = (PFN_vkCmdCopyBuffer) load("vkCmdCopyBuffer", userptr);
  219. vkCmdCopyBufferToImage = (PFN_vkCmdCopyBufferToImage) load("vkCmdCopyBufferToImage", userptr);
  220. vkCmdCopyImage = (PFN_vkCmdCopyImage) load("vkCmdCopyImage", userptr);
  221. vkCmdCopyImageToBuffer = (PFN_vkCmdCopyImageToBuffer) load("vkCmdCopyImageToBuffer", userptr);
  222. vkCmdCopyQueryPoolResults = (PFN_vkCmdCopyQueryPoolResults) load("vkCmdCopyQueryPoolResults", userptr);
  223. vkCmdDispatch = (PFN_vkCmdDispatch) load("vkCmdDispatch", userptr);
  224. vkCmdDispatchIndirect = (PFN_vkCmdDispatchIndirect) load("vkCmdDispatchIndirect", userptr);
  225. vkCmdDraw = (PFN_vkCmdDraw) load("vkCmdDraw", userptr);
  226. vkCmdDrawIndexed = (PFN_vkCmdDrawIndexed) load("vkCmdDrawIndexed", userptr);
  227. vkCmdDrawIndexedIndirect = (PFN_vkCmdDrawIndexedIndirect) load("vkCmdDrawIndexedIndirect", userptr);
  228. vkCmdDrawIndirect = (PFN_vkCmdDrawIndirect) load("vkCmdDrawIndirect", userptr);
  229. vkCmdEndQuery = (PFN_vkCmdEndQuery) load("vkCmdEndQuery", userptr);
  230. vkCmdEndRenderPass = (PFN_vkCmdEndRenderPass) load("vkCmdEndRenderPass", userptr);
  231. vkCmdExecuteCommands = (PFN_vkCmdExecuteCommands) load("vkCmdExecuteCommands", userptr);
  232. vkCmdFillBuffer = (PFN_vkCmdFillBuffer) load("vkCmdFillBuffer", userptr);
  233. vkCmdNextSubpass = (PFN_vkCmdNextSubpass) load("vkCmdNextSubpass", userptr);
  234. vkCmdPipelineBarrier = (PFN_vkCmdPipelineBarrier) load("vkCmdPipelineBarrier", userptr);
  235. vkCmdPushConstants = (PFN_vkCmdPushConstants) load("vkCmdPushConstants", userptr);
  236. vkCmdResetEvent = (PFN_vkCmdResetEvent) load("vkCmdResetEvent", userptr);
  237. vkCmdResetQueryPool = (PFN_vkCmdResetQueryPool) load("vkCmdResetQueryPool", userptr);
  238. vkCmdResolveImage = (PFN_vkCmdResolveImage) load("vkCmdResolveImage", userptr);
  239. vkCmdSetBlendConstants = (PFN_vkCmdSetBlendConstants) load("vkCmdSetBlendConstants", userptr);
  240. vkCmdSetDepthBias = (PFN_vkCmdSetDepthBias) load("vkCmdSetDepthBias", userptr);
  241. vkCmdSetDepthBounds = (PFN_vkCmdSetDepthBounds) load("vkCmdSetDepthBounds", userptr);
  242. vkCmdSetEvent = (PFN_vkCmdSetEvent) load("vkCmdSetEvent", userptr);
  243. vkCmdSetLineWidth = (PFN_vkCmdSetLineWidth) load("vkCmdSetLineWidth", userptr);
  244. vkCmdSetScissor = (PFN_vkCmdSetScissor) load("vkCmdSetScissor", userptr);
  245. vkCmdSetStencilCompareMask = (PFN_vkCmdSetStencilCompareMask) load("vkCmdSetStencilCompareMask", userptr);
  246. vkCmdSetStencilReference = (PFN_vkCmdSetStencilReference) load("vkCmdSetStencilReference", userptr);
  247. vkCmdSetStencilWriteMask = (PFN_vkCmdSetStencilWriteMask) load("vkCmdSetStencilWriteMask", userptr);
  248. vkCmdSetViewport = (PFN_vkCmdSetViewport) load("vkCmdSetViewport", userptr);
  249. vkCmdUpdateBuffer = (PFN_vkCmdUpdateBuffer) load("vkCmdUpdateBuffer", userptr);
  250. vkCmdWaitEvents = (PFN_vkCmdWaitEvents) load("vkCmdWaitEvents", userptr);
  251. vkCmdWriteTimestamp = (PFN_vkCmdWriteTimestamp) load("vkCmdWriteTimestamp", userptr);
  252. vkCreateBuffer = (PFN_vkCreateBuffer) load("vkCreateBuffer", userptr);
  253. vkCreateBufferView = (PFN_vkCreateBufferView) load("vkCreateBufferView", userptr);
  254. vkCreateCommandPool = (PFN_vkCreateCommandPool) load("vkCreateCommandPool", userptr);
  255. vkCreateComputePipelines = (PFN_vkCreateComputePipelines) load("vkCreateComputePipelines", userptr);
  256. vkCreateDescriptorPool = (PFN_vkCreateDescriptorPool) load("vkCreateDescriptorPool", userptr);
  257. vkCreateDescriptorSetLayout = (PFN_vkCreateDescriptorSetLayout) load("vkCreateDescriptorSetLayout", userptr);
  258. vkCreateDevice = (PFN_vkCreateDevice) load("vkCreateDevice", userptr);
  259. vkCreateEvent = (PFN_vkCreateEvent) load("vkCreateEvent", userptr);
  260. vkCreateFence = (PFN_vkCreateFence) load("vkCreateFence", userptr);
  261. vkCreateFramebuffer = (PFN_vkCreateFramebuffer) load("vkCreateFramebuffer", userptr);
  262. vkCreateGraphicsPipelines = (PFN_vkCreateGraphicsPipelines) load("vkCreateGraphicsPipelines", userptr);
  263. vkCreateImage = (PFN_vkCreateImage) load("vkCreateImage", userptr);
  264. vkCreateImageView = (PFN_vkCreateImageView) load("vkCreateImageView", userptr);
  265. vkCreateInstance = (PFN_vkCreateInstance) load("vkCreateInstance", userptr);
  266. vkCreatePipelineCache = (PFN_vkCreatePipelineCache) load("vkCreatePipelineCache", userptr);
  267. vkCreatePipelineLayout = (PFN_vkCreatePipelineLayout) load("vkCreatePipelineLayout", userptr);
  268. vkCreateQueryPool = (PFN_vkCreateQueryPool) load("vkCreateQueryPool", userptr);
  269. vkCreateRenderPass = (PFN_vkCreateRenderPass) load("vkCreateRenderPass", userptr);
  270. vkCreateSampler = (PFN_vkCreateSampler) load("vkCreateSampler", userptr);
  271. vkCreateSemaphore = (PFN_vkCreateSemaphore) load("vkCreateSemaphore", userptr);
  272. vkCreateShaderModule = (PFN_vkCreateShaderModule) load("vkCreateShaderModule", userptr);
  273. vkDestroyBuffer = (PFN_vkDestroyBuffer) load("vkDestroyBuffer", userptr);
  274. vkDestroyBufferView = (PFN_vkDestroyBufferView) load("vkDestroyBufferView", userptr);
  275. vkDestroyCommandPool = (PFN_vkDestroyCommandPool) load("vkDestroyCommandPool", userptr);
  276. vkDestroyDescriptorPool = (PFN_vkDestroyDescriptorPool) load("vkDestroyDescriptorPool", userptr);
  277. vkDestroyDescriptorSetLayout = (PFN_vkDestroyDescriptorSetLayout) load("vkDestroyDescriptorSetLayout", userptr);
  278. vkDestroyDevice = (PFN_vkDestroyDevice) load("vkDestroyDevice", userptr);
  279. vkDestroyEvent = (PFN_vkDestroyEvent) load("vkDestroyEvent", userptr);
  280. vkDestroyFence = (PFN_vkDestroyFence) load("vkDestroyFence", userptr);
  281. vkDestroyFramebuffer = (PFN_vkDestroyFramebuffer) load("vkDestroyFramebuffer", userptr);
  282. vkDestroyImage = (PFN_vkDestroyImage) load("vkDestroyImage", userptr);
  283. vkDestroyImageView = (PFN_vkDestroyImageView) load("vkDestroyImageView", userptr);
  284. vkDestroyInstance = (PFN_vkDestroyInstance) load("vkDestroyInstance", userptr);
  285. vkDestroyPipeline = (PFN_vkDestroyPipeline) load("vkDestroyPipeline", userptr);
  286. vkDestroyPipelineCache = (PFN_vkDestroyPipelineCache) load("vkDestroyPipelineCache", userptr);
  287. vkDestroyPipelineLayout = (PFN_vkDestroyPipelineLayout) load("vkDestroyPipelineLayout", userptr);
  288. vkDestroyQueryPool = (PFN_vkDestroyQueryPool) load("vkDestroyQueryPool", userptr);
  289. vkDestroyRenderPass = (PFN_vkDestroyRenderPass) load("vkDestroyRenderPass", userptr);
  290. vkDestroySampler = (PFN_vkDestroySampler) load("vkDestroySampler", userptr);
  291. vkDestroySemaphore = (PFN_vkDestroySemaphore) load("vkDestroySemaphore", userptr);
  292. vkDestroyShaderModule = (PFN_vkDestroyShaderModule) load("vkDestroyShaderModule", userptr);
  293. vkDeviceWaitIdle = (PFN_vkDeviceWaitIdle) load("vkDeviceWaitIdle", userptr);
  294. vkEndCommandBuffer = (PFN_vkEndCommandBuffer) load("vkEndCommandBuffer", userptr);
  295. vkEnumerateDeviceExtensionProperties = (PFN_vkEnumerateDeviceExtensionProperties) load("vkEnumerateDeviceExtensionProperties", userptr);
  296. vkEnumerateDeviceLayerProperties = (PFN_vkEnumerateDeviceLayerProperties) load("vkEnumerateDeviceLayerProperties", userptr);
  297. vkEnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties) load("vkEnumerateInstanceExtensionProperties", userptr);
  298. vkEnumerateInstanceLayerProperties = (PFN_vkEnumerateInstanceLayerProperties) load("vkEnumerateInstanceLayerProperties", userptr);
  299. vkEnumeratePhysicalDevices = (PFN_vkEnumeratePhysicalDevices) load("vkEnumeratePhysicalDevices", userptr);
  300. vkFlushMappedMemoryRanges = (PFN_vkFlushMappedMemoryRanges) load("vkFlushMappedMemoryRanges", userptr);
  301. vkFreeCommandBuffers = (PFN_vkFreeCommandBuffers) load("vkFreeCommandBuffers", userptr);
  302. vkFreeDescriptorSets = (PFN_vkFreeDescriptorSets) load("vkFreeDescriptorSets", userptr);
  303. vkFreeMemory = (PFN_vkFreeMemory) load("vkFreeMemory", userptr);
  304. vkGetBufferMemoryRequirements = (PFN_vkGetBufferMemoryRequirements) load("vkGetBufferMemoryRequirements", userptr);
  305. vkGetDeviceMemoryCommitment = (PFN_vkGetDeviceMemoryCommitment) load("vkGetDeviceMemoryCommitment", userptr);
  306. vkGetDeviceProcAddr = (PFN_vkGetDeviceProcAddr) load("vkGetDeviceProcAddr", userptr);
  307. vkGetDeviceQueue = (PFN_vkGetDeviceQueue) load("vkGetDeviceQueue", userptr);
  308. vkGetEventStatus = (PFN_vkGetEventStatus) load("vkGetEventStatus", userptr);
  309. vkGetFenceStatus = (PFN_vkGetFenceStatus) load("vkGetFenceStatus", userptr);
  310. vkGetImageMemoryRequirements = (PFN_vkGetImageMemoryRequirements) load("vkGetImageMemoryRequirements", userptr);
  311. vkGetImageSparseMemoryRequirements = (PFN_vkGetImageSparseMemoryRequirements) load("vkGetImageSparseMemoryRequirements", userptr);
  312. vkGetImageSubresourceLayout = (PFN_vkGetImageSubresourceLayout) load("vkGetImageSubresourceLayout", userptr);
  313. vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) load("vkGetInstanceProcAddr", userptr);
  314. vkGetPhysicalDeviceFeatures = (PFN_vkGetPhysicalDeviceFeatures) load("vkGetPhysicalDeviceFeatures", userptr);
  315. vkGetPhysicalDeviceFormatProperties = (PFN_vkGetPhysicalDeviceFormatProperties) load("vkGetPhysicalDeviceFormatProperties", userptr);
  316. vkGetPhysicalDeviceImageFormatProperties = (PFN_vkGetPhysicalDeviceImageFormatProperties) load("vkGetPhysicalDeviceImageFormatProperties", userptr);
  317. vkGetPhysicalDeviceMemoryProperties = (PFN_vkGetPhysicalDeviceMemoryProperties) load("vkGetPhysicalDeviceMemoryProperties", userptr);
  318. vkGetPhysicalDeviceProperties = (PFN_vkGetPhysicalDeviceProperties) load("vkGetPhysicalDeviceProperties", userptr);
  319. vkGetPhysicalDeviceQueueFamilyProperties = (PFN_vkGetPhysicalDeviceQueueFamilyProperties) load("vkGetPhysicalDeviceQueueFamilyProperties", userptr);
  320. vkGetPhysicalDeviceSparseImageFormatProperties = (PFN_vkGetPhysicalDeviceSparseImageFormatProperties) load("vkGetPhysicalDeviceSparseImageFormatProperties", userptr);
  321. vkGetPipelineCacheData = (PFN_vkGetPipelineCacheData) load("vkGetPipelineCacheData", userptr);
  322. vkGetQueryPoolResults = (PFN_vkGetQueryPoolResults) load("vkGetQueryPoolResults", userptr);
  323. vkGetRenderAreaGranularity = (PFN_vkGetRenderAreaGranularity) load("vkGetRenderAreaGranularity", userptr);
  324. vkInvalidateMappedMemoryRanges = (PFN_vkInvalidateMappedMemoryRanges) load("vkInvalidateMappedMemoryRanges", userptr);
  325. vkMapMemory = (PFN_vkMapMemory) load("vkMapMemory", userptr);
  326. vkMergePipelineCaches = (PFN_vkMergePipelineCaches) load("vkMergePipelineCaches", userptr);
  327. vkQueueBindSparse = (PFN_vkQueueBindSparse) load("vkQueueBindSparse", userptr);
  328. vkQueueSubmit = (PFN_vkQueueSubmit) load("vkQueueSubmit", userptr);
  329. vkQueueWaitIdle = (PFN_vkQueueWaitIdle) load("vkQueueWaitIdle", userptr);
  330. vkResetCommandBuffer = (PFN_vkResetCommandBuffer) load("vkResetCommandBuffer", userptr);
  331. vkResetCommandPool = (PFN_vkResetCommandPool) load("vkResetCommandPool", userptr);
  332. vkResetDescriptorPool = (PFN_vkResetDescriptorPool) load("vkResetDescriptorPool", userptr);
  333. vkResetEvent = (PFN_vkResetEvent) load("vkResetEvent", userptr);
  334. vkResetFences = (PFN_vkResetFences) load("vkResetFences", userptr);
  335. vkSetEvent = (PFN_vkSetEvent) load("vkSetEvent", userptr);
  336. vkUnmapMemory = (PFN_vkUnmapMemory) load("vkUnmapMemory", userptr);
  337. vkUpdateDescriptorSets = (PFN_vkUpdateDescriptorSets) load("vkUpdateDescriptorSets", userptr);
  338. vkWaitForFences = (PFN_vkWaitForFences) load("vkWaitForFences", userptr);
  339. }
  340. static void glad_vk_load_VK_VERSION_1_1( GLADuserptrloadfunc load, void* userptr) {
  341. if(!GLAD_VK_VERSION_1_1) return;
  342. vkBindBufferMemory2 = (PFN_vkBindBufferMemory2) load("vkBindBufferMemory2", userptr);
  343. vkBindImageMemory2 = (PFN_vkBindImageMemory2) load("vkBindImageMemory2", userptr);
  344. vkCmdDispatchBase = (PFN_vkCmdDispatchBase) load("vkCmdDispatchBase", userptr);
  345. vkCmdSetDeviceMask = (PFN_vkCmdSetDeviceMask) load("vkCmdSetDeviceMask", userptr);
  346. vkCreateDescriptorUpdateTemplate = (PFN_vkCreateDescriptorUpdateTemplate) load("vkCreateDescriptorUpdateTemplate", userptr);
  347. vkCreateSamplerYcbcrConversion = (PFN_vkCreateSamplerYcbcrConversion) load("vkCreateSamplerYcbcrConversion", userptr);
  348. vkDestroyDescriptorUpdateTemplate = (PFN_vkDestroyDescriptorUpdateTemplate) load("vkDestroyDescriptorUpdateTemplate", userptr);
  349. vkDestroySamplerYcbcrConversion = (PFN_vkDestroySamplerYcbcrConversion) load("vkDestroySamplerYcbcrConversion", userptr);
  350. vkEnumerateInstanceVersion = (PFN_vkEnumerateInstanceVersion) load("vkEnumerateInstanceVersion", userptr);
  351. vkEnumeratePhysicalDeviceGroups = (PFN_vkEnumeratePhysicalDeviceGroups) load("vkEnumeratePhysicalDeviceGroups", userptr);
  352. vkGetBufferMemoryRequirements2 = (PFN_vkGetBufferMemoryRequirements2) load("vkGetBufferMemoryRequirements2", userptr);
  353. vkGetDescriptorSetLayoutSupport = (PFN_vkGetDescriptorSetLayoutSupport) load("vkGetDescriptorSetLayoutSupport", userptr);
  354. vkGetDeviceGroupPeerMemoryFeatures = (PFN_vkGetDeviceGroupPeerMemoryFeatures) load("vkGetDeviceGroupPeerMemoryFeatures", userptr);
  355. vkGetDeviceQueue2 = (PFN_vkGetDeviceQueue2) load("vkGetDeviceQueue2", userptr);
  356. vkGetImageMemoryRequirements2 = (PFN_vkGetImageMemoryRequirements2) load("vkGetImageMemoryRequirements2", userptr);
  357. vkGetImageSparseMemoryRequirements2 = (PFN_vkGetImageSparseMemoryRequirements2) load("vkGetImageSparseMemoryRequirements2", userptr);
  358. vkGetPhysicalDeviceExternalBufferProperties = (PFN_vkGetPhysicalDeviceExternalBufferProperties) load("vkGetPhysicalDeviceExternalBufferProperties", userptr);
  359. vkGetPhysicalDeviceExternalFenceProperties = (PFN_vkGetPhysicalDeviceExternalFenceProperties) load("vkGetPhysicalDeviceExternalFenceProperties", userptr);
  360. vkGetPhysicalDeviceExternalSemaphoreProperties = (PFN_vkGetPhysicalDeviceExternalSemaphoreProperties) load("vkGetPhysicalDeviceExternalSemaphoreProperties", userptr);
  361. vkGetPhysicalDeviceFeatures2 = (PFN_vkGetPhysicalDeviceFeatures2) load("vkGetPhysicalDeviceFeatures2", userptr);
  362. vkGetPhysicalDeviceFormatProperties2 = (PFN_vkGetPhysicalDeviceFormatProperties2) load("vkGetPhysicalDeviceFormatProperties2", userptr);
  363. vkGetPhysicalDeviceImageFormatProperties2 = (PFN_vkGetPhysicalDeviceImageFormatProperties2) load("vkGetPhysicalDeviceImageFormatProperties2", userptr);
  364. vkGetPhysicalDeviceMemoryProperties2 = (PFN_vkGetPhysicalDeviceMemoryProperties2) load("vkGetPhysicalDeviceMemoryProperties2", userptr);
  365. vkGetPhysicalDeviceProperties2 = (PFN_vkGetPhysicalDeviceProperties2) load("vkGetPhysicalDeviceProperties2", userptr);
  366. vkGetPhysicalDeviceQueueFamilyProperties2 = (PFN_vkGetPhysicalDeviceQueueFamilyProperties2) load("vkGetPhysicalDeviceQueueFamilyProperties2", userptr);
  367. vkGetPhysicalDeviceSparseImageFormatProperties2 = (PFN_vkGetPhysicalDeviceSparseImageFormatProperties2) load("vkGetPhysicalDeviceSparseImageFormatProperties2", userptr);
  368. vkTrimCommandPool = (PFN_vkTrimCommandPool) load("vkTrimCommandPool", userptr);
  369. vkUpdateDescriptorSetWithTemplate = (PFN_vkUpdateDescriptorSetWithTemplate) load("vkUpdateDescriptorSetWithTemplate", userptr);
  370. }
  371. static void glad_vk_load_VK_EXT_debug_report( GLADuserptrloadfunc load, void* userptr) {
  372. if(!GLAD_VK_EXT_debug_report) return;
  373. vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT) load("vkCreateDebugReportCallbackEXT", userptr);
  374. vkDebugReportMessageEXT = (PFN_vkDebugReportMessageEXT) load("vkDebugReportMessageEXT", userptr);
  375. vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT) load("vkDestroyDebugReportCallbackEXT", userptr);
  376. }
  377. static void glad_vk_load_VK_KHR_surface( GLADuserptrloadfunc load, void* userptr) {
  378. if(!GLAD_VK_KHR_surface) return;
  379. vkDestroySurfaceKHR = (PFN_vkDestroySurfaceKHR) load("vkDestroySurfaceKHR", userptr);
  380. vkGetPhysicalDeviceSurfaceCapabilitiesKHR = (PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR) load("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", userptr);
  381. vkGetPhysicalDeviceSurfaceFormatsKHR = (PFN_vkGetPhysicalDeviceSurfaceFormatsKHR) load("vkGetPhysicalDeviceSurfaceFormatsKHR", userptr);
  382. vkGetPhysicalDeviceSurfacePresentModesKHR = (PFN_vkGetPhysicalDeviceSurfacePresentModesKHR) load("vkGetPhysicalDeviceSurfacePresentModesKHR", userptr);
  383. vkGetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR) load("vkGetPhysicalDeviceSurfaceSupportKHR", userptr);
  384. }
  385. static void glad_vk_load_VK_KHR_swapchain( GLADuserptrloadfunc load, void* userptr) {
  386. if(!GLAD_VK_KHR_swapchain) return;
  387. vkAcquireNextImage2KHR = (PFN_vkAcquireNextImage2KHR) load("vkAcquireNextImage2KHR", userptr);
  388. vkAcquireNextImageKHR = (PFN_vkAcquireNextImageKHR) load("vkAcquireNextImageKHR", userptr);
  389. vkCreateSwapchainKHR = (PFN_vkCreateSwapchainKHR) load("vkCreateSwapchainKHR", userptr);
  390. vkDestroySwapchainKHR = (PFN_vkDestroySwapchainKHR) load("vkDestroySwapchainKHR", userptr);
  391. vkGetDeviceGroupPresentCapabilitiesKHR = (PFN_vkGetDeviceGroupPresentCapabilitiesKHR) load("vkGetDeviceGroupPresentCapabilitiesKHR", userptr);
  392. vkGetDeviceGroupSurfacePresentModesKHR = (PFN_vkGetDeviceGroupSurfacePresentModesKHR) load("vkGetDeviceGroupSurfacePresentModesKHR", userptr);
  393. vkGetPhysicalDevicePresentRectanglesKHR = (PFN_vkGetPhysicalDevicePresentRectanglesKHR) load("vkGetPhysicalDevicePresentRectanglesKHR", userptr);
  394. vkGetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR) load("vkGetSwapchainImagesKHR", userptr);
  395. vkQueuePresentKHR = (PFN_vkQueuePresentKHR) load("vkQueuePresentKHR", userptr);
  396. }
  397. static int glad_vk_get_extensions( VkPhysicalDevice physical_device, uint32_t *out_extension_count, char ***out_extensions) {
  398. uint32_t i;
  399. uint32_t instance_extension_count = 0;
  400. uint32_t device_extension_count = 0;
  401. uint32_t max_extension_count;
  402. uint32_t total_extension_count;
  403. char **extensions;
  404. VkExtensionProperties *ext_properties;
  405. VkResult result;
  406. if (vkEnumerateInstanceExtensionProperties == NULL || (physical_device != NULL && vkEnumerateDeviceExtensionProperties == NULL)) {
  407. return 0;
  408. }
  409. result = vkEnumerateInstanceExtensionProperties(NULL, &instance_extension_count, NULL);
  410. if (result != VK_SUCCESS) {
  411. return 0;
  412. }
  413. if (physical_device != NULL) {
  414. result = vkEnumerateDeviceExtensionProperties(physical_device, NULL, &device_extension_count, NULL);
  415. if (result != VK_SUCCESS) {
  416. return 0;
  417. }
  418. }
  419. total_extension_count = instance_extension_count + device_extension_count;
  420. max_extension_count = instance_extension_count > device_extension_count
  421. ? instance_extension_count : device_extension_count;
  422. ext_properties = (VkExtensionProperties*) malloc(max_extension_count * sizeof(VkExtensionProperties));
  423. if (ext_properties == NULL) {
  424. return 0;
  425. }
  426. result = vkEnumerateInstanceExtensionProperties(NULL, &instance_extension_count, ext_properties);
  427. if (result != VK_SUCCESS) {
  428. free((void*) ext_properties);
  429. return 0;
  430. }
  431. extensions = (char**) calloc(total_extension_count, sizeof(char*));
  432. if (extensions == NULL) {
  433. free((void*) ext_properties);
  434. return 0;
  435. }
  436. for (i = 0; i < instance_extension_count; ++i) {
  437. VkExtensionProperties ext = ext_properties[i];
  438. size_t extension_name_length = strlen(ext.extensionName) + 1;
  439. extensions[i] = (char*) malloc(extension_name_length * sizeof(char));
  440. memcpy(extensions[i], ext.extensionName, extension_name_length * sizeof(char));
  441. }
  442. if (physical_device != NULL) {
  443. result = vkEnumerateDeviceExtensionProperties(physical_device, NULL, &device_extension_count, ext_properties);
  444. if (result != VK_SUCCESS) {
  445. for (i = 0; i < instance_extension_count; ++i) {
  446. free((void*) extensions[i]);
  447. }
  448. free(extensions);
  449. return 0;
  450. }
  451. for (i = 0; i < device_extension_count; ++i) {
  452. VkExtensionProperties ext = ext_properties[i];
  453. size_t extension_name_length = strlen(ext.extensionName) + 1;
  454. extensions[instance_extension_count + i] = (char*) malloc(extension_name_length * sizeof(char));
  455. memcpy(extensions[instance_extension_count + i], ext.extensionName, extension_name_length * sizeof(char));
  456. }
  457. }
  458. free((void*) ext_properties);
  459. *out_extension_count = total_extension_count;
  460. *out_extensions = extensions;
  461. return 1;
  462. }
  463. static void glad_vk_free_extensions(uint32_t extension_count, char **extensions) {
  464. uint32_t i;
  465. for(i = 0; i < extension_count ; ++i) {
  466. free((void*) (extensions[i]));
  467. }
  468. free((void*) extensions);
  469. }
  470. static int glad_vk_has_extension(const char *name, uint32_t extension_count, char **extensions) {
  471. uint32_t i;
  472. for (i = 0; i < extension_count; ++i) {
  473. if(strcmp(name, extensions[i]) == 0) {
  474. return 1;
  475. }
  476. }
  477. return 0;
  478. }
  479. static GLADapiproc glad_vk_get_proc_from_userptr(const char* name, void *userptr) {
  480. return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name);
  481. }
  482. static int glad_vk_find_extensions_vulkan( VkPhysicalDevice physical_device) {
  483. uint32_t extension_count = 0;
  484. char **extensions = NULL;
  485. if (!glad_vk_get_extensions(physical_device, &extension_count, &extensions)) return 0;
  486. GLAD_VK_EXT_debug_report = glad_vk_has_extension("VK_EXT_debug_report", extension_count, extensions);
  487. GLAD_VK_KHR_surface = glad_vk_has_extension("VK_KHR_surface", extension_count, extensions);
  488. GLAD_VK_KHR_swapchain = glad_vk_has_extension("VK_KHR_swapchain", extension_count, extensions);
  489. glad_vk_free_extensions(extension_count, extensions);
  490. return 1;
  491. }
  492. static int glad_vk_find_core_vulkan( VkPhysicalDevice physical_device) {
  493. int major = 1;
  494. int minor = 0;
  495. #ifdef VK_VERSION_1_1
  496. if (vkEnumerateInstanceVersion != NULL) {
  497. uint32_t version;
  498. VkResult result;
  499. result = vkEnumerateInstanceVersion(&version);
  500. if (result == VK_SUCCESS) {
  501. major = (int) VK_VERSION_MAJOR(version);
  502. minor = (int) VK_VERSION_MINOR(version);
  503. }
  504. }
  505. #endif
  506. if (physical_device != NULL && vkGetPhysicalDeviceProperties != NULL) {
  507. VkPhysicalDeviceProperties properties;
  508. vkGetPhysicalDeviceProperties(physical_device, &properties);
  509. major = (int) VK_VERSION_MAJOR(properties.apiVersion);
  510. minor = (int) VK_VERSION_MINOR(properties.apiVersion);
  511. }
  512. GLAD_VK_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1;
  513. GLAD_VK_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1;
  514. return GLAD_MAKE_VERSION(major, minor);
  515. }
  516. int gladLoadVulkanUserPtr( VkPhysicalDevice physical_device, GLADuserptrloadfunc load, void *userptr) {
  517. int version;
  518. #ifdef VK_VERSION_1_1
  519. vkEnumerateInstanceVersion = (PFN_vkEnumerateInstanceVersion) load("vkEnumerateInstanceVersion", userptr);
  520. #endif
  521. version = glad_vk_find_core_vulkan( physical_device);
  522. if (!version) {
  523. return 0;
  524. }
  525. glad_vk_load_VK_VERSION_1_0(load, userptr);
  526. glad_vk_load_VK_VERSION_1_1(load, userptr);
  527. if (!glad_vk_find_extensions_vulkan( physical_device)) return 0;
  528. glad_vk_load_VK_EXT_debug_report(load, userptr);
  529. glad_vk_load_VK_KHR_surface(load, userptr);
  530. glad_vk_load_VK_KHR_swapchain(load, userptr);
  531. return version;
  532. }
  533. int gladLoadVulkan( VkPhysicalDevice physical_device, GLADloadfunc load) {
  534. return gladLoadVulkanUserPtr( physical_device, glad_vk_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load);
  535. }