Jesse Hall | d02edcb | 2015-09-08 07:44:48 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 17 | #ifndef LIBVULKAN_LOADER_H |
| 18 | #define LIBVULKAN_LOADER_H 1 |
| 19 | |
| 20 | #define VK_PROTOTYPES |
| 21 | #include <vulkan/vulkan.h> |
| 22 | |
| 23 | namespace vulkan { |
| 24 | |
| 25 | struct InstanceVtbl { |
| 26 | // clang-format off |
| 27 | VkInstance instance; |
| 28 | |
| 29 | PFN_vkCreateInstance CreateInstance; |
| 30 | PFN_vkDestroyInstance DestroyInstance; |
| 31 | PFN_vkGetInstanceProcAddr GetInstanceProcAddr; |
| 32 | PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices; |
| 33 | |
| 34 | PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures; |
| 35 | PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties; |
| 36 | PFN_vkGetPhysicalDeviceImageFormatProperties GetPhysicalDeviceImageFormatProperties; |
| 37 | PFN_vkGetPhysicalDeviceLimits GetPhysicalDeviceLimits; |
| 38 | PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties; |
| 39 | PFN_vkGetPhysicalDeviceQueueCount GetPhysicalDeviceQueueCount; |
| 40 | PFN_vkGetPhysicalDeviceQueueProperties GetPhysicalDeviceQueueProperties; |
| 41 | PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties; |
| 42 | PFN_vkCreateDevice CreateDevice; |
| 43 | PFN_vkGetPhysicalDeviceExtensionProperties GetPhysicalDeviceExtensionProperties; |
| 44 | PFN_vkGetPhysicalDeviceLayerProperties GetPhysicalDeviceLayerProperties; |
| 45 | PFN_vkGetPhysicalDeviceSparseImageFormatProperties GetPhysicalDeviceSparseImageFormatProperties; |
| 46 | // clang-format on |
| 47 | }; |
| 48 | |
| 49 | struct DeviceVtbl { |
| 50 | void* device; |
| 51 | |
| 52 | PFN_vkGetDeviceProcAddr GetDeviceProcAddr; |
| 53 | PFN_vkDestroyDevice DestroyDevice; |
| 54 | PFN_vkGetDeviceQueue GetDeviceQueue; |
| 55 | PFN_vkDeviceWaitIdle DeviceWaitIdle; |
| 56 | PFN_vkAllocMemory AllocMemory; |
| 57 | PFN_vkFreeMemory FreeMemory; |
| 58 | PFN_vkMapMemory MapMemory; |
| 59 | PFN_vkUnmapMemory UnmapMemory; |
| 60 | PFN_vkFlushMappedMemoryRanges FlushMappedMemoryRanges; |
| 61 | PFN_vkInvalidateMappedMemoryRanges InvalidateMappedMemoryRanges; |
| 62 | PFN_vkGetDeviceMemoryCommitment GetDeviceMemoryCommitment; |
| 63 | PFN_vkBindBufferMemory BindBufferMemory; |
| 64 | PFN_vkBindImageMemory BindImageMemory; |
| 65 | PFN_vkGetBufferMemoryRequirements GetBufferMemoryRequirements; |
| 66 | PFN_vkGetImageMemoryRequirements GetImageMemoryRequirements; |
| 67 | PFN_vkGetImageSparseMemoryRequirements GetImageSparseMemoryRequirements; |
| 68 | PFN_vkCreateFence CreateFence; |
| 69 | PFN_vkDestroyFence DestroyFence; |
| 70 | PFN_vkResetFences ResetFences; |
| 71 | PFN_vkGetFenceStatus GetFenceStatus; |
| 72 | PFN_vkWaitForFences WaitForFences; |
| 73 | PFN_vkCreateSemaphore CreateSemaphore; |
| 74 | PFN_vkDestroySemaphore DestroySemaphore; |
| 75 | PFN_vkCreateEvent CreateEvent; |
| 76 | PFN_vkDestroyEvent DestroyEvent; |
| 77 | PFN_vkGetEventStatus GetEventStatus; |
| 78 | PFN_vkSetEvent SetEvent; |
| 79 | PFN_vkResetEvent ResetEvent; |
| 80 | PFN_vkCreateQueryPool CreateQueryPool; |
| 81 | PFN_vkDestroyQueryPool DestroyQueryPool; |
| 82 | PFN_vkGetQueryPoolResults GetQueryPoolResults; |
| 83 | PFN_vkCreateBuffer CreateBuffer; |
| 84 | PFN_vkDestroyBuffer DestroyBuffer; |
| 85 | PFN_vkCreateBufferView CreateBufferView; |
| 86 | PFN_vkDestroyBufferView DestroyBufferView; |
| 87 | PFN_vkCreateImage CreateImage; |
| 88 | PFN_vkDestroyImage DestroyImage; |
| 89 | PFN_vkGetImageSubresourceLayout GetImageSubresourceLayout; |
| 90 | PFN_vkCreateImageView CreateImageView; |
| 91 | PFN_vkDestroyImageView DestroyImageView; |
| 92 | PFN_vkCreateAttachmentView CreateAttachmentView; |
| 93 | PFN_vkDestroyAttachmentView DestroyAttachmentView; |
| 94 | PFN_vkCreateShaderModule CreateShaderModule; |
| 95 | PFN_vkDestroyShaderModule DestroyShaderModule; |
| 96 | PFN_vkCreateShader CreateShader; |
| 97 | PFN_vkDestroyShader DestroyShader; |
| 98 | PFN_vkCreatePipelineCache CreatePipelineCache; |
| 99 | PFN_vkDestroyPipelineCache DestroyPipelineCache; |
| 100 | PFN_vkGetPipelineCacheSize GetPipelineCacheSize; |
| 101 | PFN_vkGetPipelineCacheData GetPipelineCacheData; |
| 102 | PFN_vkMergePipelineCaches MergePipelineCaches; |
| 103 | PFN_vkCreateGraphicsPipelines CreateGraphicsPipelines; |
| 104 | PFN_vkCreateComputePipelines CreateComputePipelines; |
| 105 | PFN_vkDestroyPipeline DestroyPipeline; |
| 106 | PFN_vkCreatePipelineLayout CreatePipelineLayout; |
| 107 | PFN_vkDestroyPipelineLayout DestroyPipelineLayout; |
| 108 | PFN_vkCreateSampler CreateSampler; |
| 109 | PFN_vkDestroySampler DestroySampler; |
| 110 | PFN_vkCreateDescriptorSetLayout CreateDescriptorSetLayout; |
| 111 | PFN_vkDestroyDescriptorSetLayout DestroyDescriptorSetLayout; |
| 112 | PFN_vkCreateDescriptorPool CreateDescriptorPool; |
| 113 | PFN_vkDestroyDescriptorPool DestroyDescriptorPool; |
| 114 | PFN_vkResetDescriptorPool ResetDescriptorPool; |
| 115 | PFN_vkAllocDescriptorSets AllocDescriptorSets; |
| 116 | PFN_vkFreeDescriptorSets FreeDescriptorSets; |
| 117 | PFN_vkUpdateDescriptorSets UpdateDescriptorSets; |
| 118 | PFN_vkCreateDynamicViewportState CreateDynamicViewportState; |
| 119 | PFN_vkDestroyDynamicViewportState DestroyDynamicViewportState; |
| 120 | PFN_vkCreateDynamicRasterState CreateDynamicRasterState; |
| 121 | PFN_vkDestroyDynamicRasterState DestroyDynamicRasterState; |
| 122 | PFN_vkCreateDynamicColorBlendState CreateDynamicColorBlendState; |
| 123 | PFN_vkDestroyDynamicColorBlendState DestroyDynamicColorBlendState; |
| 124 | PFN_vkCreateDynamicDepthStencilState CreateDynamicDepthStencilState; |
| 125 | PFN_vkDestroyDynamicDepthStencilState DestroyDynamicDepthStencilState; |
| 126 | PFN_vkCreateFramebuffer CreateFramebuffer; |
| 127 | PFN_vkDestroyFramebuffer DestroyFramebuffer; |
| 128 | PFN_vkCreateRenderPass CreateRenderPass; |
| 129 | PFN_vkDestroyRenderPass DestroyRenderPass; |
| 130 | PFN_vkGetRenderAreaGranularity GetRenderAreaGranularity; |
| 131 | PFN_vkCreateCommandPool CreateCommandPool; |
| 132 | PFN_vkDestroyCommandPool DestroyCommandPool; |
| 133 | PFN_vkResetCommandPool ResetCommandPool; |
| 134 | PFN_vkCreateCommandBuffer CreateCommandBuffer; |
| 135 | PFN_vkDestroyCommandBuffer DestroyCommandBuffer; |
| 136 | |
| 137 | PFN_vkQueueSubmit QueueSubmit; |
| 138 | PFN_vkQueueWaitIdle QueueWaitIdle; |
| 139 | PFN_vkQueueBindSparseBufferMemory QueueBindSparseBufferMemory; |
| 140 | PFN_vkQueueBindSparseImageOpaqueMemory QueueBindSparseImageOpaqueMemory; |
| 141 | PFN_vkQueueBindSparseImageMemory QueueBindSparseImageMemory; |
| 142 | PFN_vkQueueSignalSemaphore QueueSignalSemaphore; |
| 143 | PFN_vkQueueWaitSemaphore QueueWaitSemaphore; |
| 144 | |
| 145 | PFN_vkBeginCommandBuffer BeginCommandBuffer; |
| 146 | PFN_vkEndCommandBuffer EndCommandBuffer; |
| 147 | PFN_vkResetCommandBuffer ResetCommandBuffer; |
| 148 | PFN_vkCmdBindPipeline CmdBindPipeline; |
| 149 | PFN_vkCmdBindDynamicViewportState CmdBindDynamicViewportState; |
| 150 | PFN_vkCmdBindDynamicRasterState CmdBindDynamicRasterState; |
| 151 | PFN_vkCmdBindDynamicColorBlendState CmdBindDynamicColorBlendState; |
| 152 | PFN_vkCmdBindDynamicDepthStencilState CmdBindDynamicDepthStencilState; |
| 153 | PFN_vkCmdBindDescriptorSets CmdBindDescriptorSets; |
| 154 | PFN_vkCmdBindIndexBuffer CmdBindIndexBuffer; |
| 155 | PFN_vkCmdBindVertexBuffers CmdBindVertexBuffers; |
| 156 | PFN_vkCmdDraw CmdDraw; |
| 157 | PFN_vkCmdDrawIndexed CmdDrawIndexed; |
| 158 | PFN_vkCmdDrawIndirect CmdDrawIndirect; |
| 159 | PFN_vkCmdDrawIndexedIndirect CmdDrawIndexedIndirect; |
| 160 | PFN_vkCmdDispatch CmdDispatch; |
| 161 | PFN_vkCmdDispatchIndirect CmdDispatchIndirect; |
| 162 | PFN_vkCmdCopyBuffer CmdCopyBuffer; |
| 163 | PFN_vkCmdCopyImage CmdCopyImage; |
| 164 | PFN_vkCmdBlitImage CmdBlitImage; |
| 165 | PFN_vkCmdCopyBufferToImage CmdCopyBufferToImage; |
| 166 | PFN_vkCmdCopyImageToBuffer CmdCopyImageToBuffer; |
| 167 | PFN_vkCmdUpdateBuffer CmdUpdateBuffer; |
| 168 | PFN_vkCmdFillBuffer CmdFillBuffer; |
| 169 | PFN_vkCmdClearColorImage CmdClearColorImage; |
| 170 | PFN_vkCmdClearDepthStencilImage CmdClearDepthStencilImage; |
| 171 | PFN_vkCmdClearColorAttachment CmdClearColorAttachment; |
| 172 | PFN_vkCmdClearDepthStencilAttachment CmdClearDepthStencilAttachment; |
| 173 | PFN_vkCmdResolveImage CmdResolveImage; |
| 174 | PFN_vkCmdSetEvent CmdSetEvent; |
| 175 | PFN_vkCmdResetEvent CmdResetEvent; |
| 176 | PFN_vkCmdWaitEvents CmdWaitEvents; |
| 177 | PFN_vkCmdPipelineBarrier CmdPipelineBarrier; |
| 178 | PFN_vkCmdBeginQuery CmdBeginQuery; |
| 179 | PFN_vkCmdEndQuery CmdEndQuery; |
| 180 | PFN_vkCmdResetQueryPool CmdResetQueryPool; |
| 181 | PFN_vkCmdWriteTimestamp CmdWriteTimestamp; |
| 182 | PFN_vkCmdCopyQueryPoolResults CmdCopyQueryPoolResults; |
| 183 | PFN_vkCmdPushConstants CmdPushConstants; |
| 184 | PFN_vkCmdBeginRenderPass CmdBeginRenderPass; |
| 185 | PFN_vkCmdNextSubpass CmdNextSubpass; |
| 186 | PFN_vkCmdEndRenderPass CmdEndRenderPass; |
| 187 | PFN_vkCmdExecuteCommands CmdExecuteCommands; |
| 188 | }; |
| 189 | |
| 190 | // ----------------------------------------------------------------------------- |
| 191 | // loader.cpp |
| 192 | |
| 193 | VkResult GetGlobalExtensionProperties(const char* layer_name, |
| 194 | uint32_t* count, |
| 195 | VkExtensionProperties* properties); |
| 196 | VkResult GetGlobalLayerProperties(uint32_t* count, |
| 197 | VkLayerProperties* properties); |
| 198 | VkResult CreateInstance(const VkInstanceCreateInfo* create_info, |
| 199 | VkInstance* instance); |
| 200 | PFN_vkVoidFunction GetInstanceProcAddr(VkInstance instance, const char* name); |
| 201 | PFN_vkVoidFunction GetDeviceProcAddr(VkDevice drv_device, const char* name); |
| 202 | VkResult GetDeviceQueue(VkDevice drv_device, |
| 203 | uint32_t family, |
| 204 | uint32_t index, |
| 205 | VkQueue* out_queue); |
Jesse Hall | c7a6eb5 | 2015-08-31 12:52:03 -0700 | [diff] [blame] | 206 | VkResult CreateCommandBuffer(VkDevice device, |
| 207 | const VkCmdBufferCreateInfo* create_info, |
| 208 | VkCmdBuffer* out_cmdbuf); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 209 | VkResult DestroyDevice(VkDevice drv_device); |
| 210 | |
| 211 | // ----------------------------------------------------------------------------- |
| 212 | // get_proc_addr.cpp |
| 213 | |
| 214 | PFN_vkVoidFunction GetGlobalInstanceProcAddr(const char* name); |
| 215 | PFN_vkVoidFunction GetGlobalDeviceProcAddr(const char* name); |
| 216 | PFN_vkVoidFunction GetSpecificInstanceProcAddr(const InstanceVtbl* vtbl, |
| 217 | const char* name); |
| 218 | PFN_vkVoidFunction GetSpecificDeviceProcAddr(const DeviceVtbl* vtbl, |
| 219 | const char* name); |
| 220 | |
| 221 | bool LoadInstanceVtbl(VkInstance instance, |
| 222 | PFN_vkGetInstanceProcAddr get_proc_addr, |
| 223 | InstanceVtbl& vtbl); |
| 224 | bool LoadDeviceVtbl(VkDevice device, |
| 225 | PFN_vkGetDeviceProcAddr get_proc_addr, |
| 226 | DeviceVtbl& vtbl); |
| 227 | |
| 228 | } // namespace vulkan |
| 229 | |
| 230 | #endif // LIBVULKAN_LOADER_H |