1 /*
2 
3 Boost Software License - Version 1.0 - August 17th, 2003
4 
5 Permission is hereby granted, free of charge, to any person or organization
6 obtaining a copy of the software and accompanying documentation covered by
7 this license (the "Software") to use, reproduce, display, distribute,
8 execute, and transmit the Software, and to prepare derivative works of the
9 Software, and to permit third-parties to whom the Software is furnished to
10 do so, all subject to the following:
11 
12 The copyright notices in the Software and this entire statement, including
13 the above license grant, this restriction and the following disclaimer,
14 must be included in all copies of the Software, in whole or in part, and
15 all derivative works of the Software, unless such copies or derivative
16 works are solely in the form of machine-executable object code generated by
17 a source language processor.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
22 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
23 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
24 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 DEALINGS IN THE SOFTWARE.
26 
27 */
28 module derelict.vulkan;
29 
30 public {
31 	import derelict.vulkan.system;
32 	import derelict.vulkan.types;
33 	import derelict.vulkan.functions;
34 }
35 
36 private {
37 	import derelict.util.loader;
38 	import derelict.util.system;
39 }
40 
41 static if (libNames.length == 0) {
42   pragma(msg, "Library names are not specified for this system, "
43             , "please specify them when loading the library. "
44             , "Example: DerelictVulkan.load(\"libvulkan.so\");");
45 }
46 
47 class DerelictVulkanLoader : SharedLibLoader {
48 	protected {
49 		override void loadSymbols() {
50 			bindFunc(cast(void**)&vkAcquireNextImageKHR, "vkAcquireNextImageKHR");
51 			bindFunc(cast(void**)&vkAllocateCommandBuffers, "vkAllocateCommandBuffers");
52 			bindFunc(cast(void**)&vkAllocateDescriptorSets, "vkAllocateDescriptorSets");
53 			bindFunc(cast(void**)&vkAllocateMemory, "vkAllocateMemory");
54 			bindFunc(cast(void**)&vkBeginCommandBuffer, "vkBeginCommandBuffer");
55 			bindFunc(cast(void**)&vkBindBufferMemory, "vkBindBufferMemory");
56 			bindFunc(cast(void**)&vkBindImageMemory, "vkBindImageMemory");
57 			bindFunc(cast(void**)&vkCmdBeginQuery, "vkCmdBeginQuery");
58 			bindFunc(cast(void**)&vkCmdBeginRenderPass, "vkCmdBeginRenderPass");
59 			bindFunc(cast(void**)&vkCmdBindDescriptorSets, "vkCmdBindDescriptorSets");
60 			bindFunc(cast(void**)&vkCmdBindIndexBuffer, "vkCmdBindIndexBuffer");
61 			bindFunc(cast(void**)&vkCmdBindPipeline, "vkCmdBindPipeline");
62 			bindFunc(cast(void**)&vkCmdBindVertexBuffers, "vkCmdBindVertexBuffers");
63 			bindFunc(cast(void**)&vkCmdBlitImage, "vkCmdBlitImage");
64 			bindFunc(cast(void**)&vkCmdClearAttachments, "vkCmdClearAttachments");
65 			bindFunc(cast(void**)&vkCmdClearColorImage, "vkCmdClearColorImage");
66 			bindFunc(cast(void**)&vkCmdClearDepthStencilImage, "vkCmdClearDepthStencilImage");
67 			bindFunc(cast(void**)&vkCmdCopyBuffer, "vkCmdCopyBuffer");
68 			bindFunc(cast(void**)&vkCmdCopyBufferToImage, "vkCmdCopyBufferToImage");
69 			bindFunc(cast(void**)&vkCmdCopyImage, "vkCmdCopyImage");
70 			bindFunc(cast(void**)&vkCmdCopyImageToBuffer, "vkCmdCopyImageToBuffer");
71 			bindFunc(cast(void**)&vkCmdCopyQueryPoolResults, "vkCmdCopyQueryPoolResults");
72 			bindFunc(cast(void**)&vkCmdDispatch, "vkCmdDispatch");
73 			bindFunc(cast(void**)&vkCmdDispatchIndirect, "vkCmdDispatchIndirect");
74 			bindFunc(cast(void**)&vkCmdDraw, "vkCmdDraw");
75 			bindFunc(cast(void**)&vkCmdDrawIndexed, "vkCmdDrawIndexed");
76 			bindFunc(cast(void**)&vkCmdDrawIndexedIndirect, "vkCmdDrawIndexedIndirect");
77 			bindFunc(cast(void**)&vkCmdDrawIndirect, "vkCmdDrawIndirect");
78 			bindFunc(cast(void**)&vkCmdEndQuery, "vkCmdEndQuery");
79 			bindFunc(cast(void**)&vkCmdEndRenderPass, "vkCmdEndRenderPass");
80 			bindFunc(cast(void**)&vkCmdExecuteCommands, "vkCmdExecuteCommands");
81 			bindFunc(cast(void**)&vkCmdFillBuffer, "vkCmdFillBuffer");
82 			bindFunc(cast(void**)&vkCmdNextSubpass, "vkCmdNextSubpass");
83 			bindFunc(cast(void**)&vkCmdPipelineBarrier, "vkCmdPipelineBarrier");
84 			bindFunc(cast(void**)&vkCmdPushConstants, "vkCmdPushConstants");
85 			bindFunc(cast(void**)&vkCmdResetEvent, "vkCmdResetEvent");
86 			bindFunc(cast(void**)&vkCmdResetQueryPool, "vkCmdResetQueryPool");
87 			bindFunc(cast(void**)&vkCmdResolveImage, "vkCmdResolveImage");
88 			bindFunc(cast(void**)&vkCmdSetBlendConstants, "vkCmdSetBlendConstants");
89 			bindFunc(cast(void**)&vkCmdSetDepthBias, "vkCmdSetDepthBias");
90 			bindFunc(cast(void**)&vkCmdSetDepthBounds, "vkCmdSetDepthBounds");
91 			bindFunc(cast(void**)&vkCmdSetEvent, "vkCmdSetEvent");
92 			bindFunc(cast(void**)&vkCmdSetLineWidth, "vkCmdSetLineWidth");
93 			bindFunc(cast(void**)&vkCmdSetScissor, "vkCmdSetScissor");
94 			bindFunc(cast(void**)&vkCmdSetStencilCompareMask, "vkCmdSetStencilCompareMask");
95 			bindFunc(cast(void**)&vkCmdSetStencilReference, "vkCmdSetStencilReference");
96 			bindFunc(cast(void**)&vkCmdSetStencilWriteMask, "vkCmdSetStencilWriteMask");
97 			bindFunc(cast(void**)&vkCmdSetViewport, "vkCmdSetViewport");
98 			bindFunc(cast(void**)&vkCmdUpdateBuffer, "vkCmdUpdateBuffer");
99 			bindFunc(cast(void**)&vkCmdWaitEvents, "vkCmdWaitEvents");
100 			bindFunc(cast(void**)&vkCmdWriteTimestamp, "vkCmdWriteTimestamp");
101 			bindFunc(cast(void**)&vkCreateBuffer, "vkCreateBuffer");
102 			bindFunc(cast(void**)&vkCreateBufferView, "vkCreateBufferView");
103 			bindFunc(cast(void**)&vkCreateCommandPool, "vkCreateCommandPool");
104 			bindFunc(cast(void**)&vkCreateComputePipelines, "vkCreateComputePipelines");
105 			bindFunc(cast(void**)&vkCreateDescriptorPool, "vkCreateDescriptorPool");
106 			bindFunc(cast(void**)&vkCreateDescriptorSetLayout, "vkCreateDescriptorSetLayout");
107 			bindFunc(cast(void**)&vkCreateDevice, "vkCreateDevice");
108 			bindFunc(cast(void**)&vkCreateEvent, "vkCreateEvent");
109 			bindFunc(cast(void**)&vkCreateFence, "vkCreateFence");
110 			bindFunc(cast(void**)&vkCreateFramebuffer, "vkCreateFramebuffer");
111 			bindFunc(cast(void**)&vkCreateGraphicsPipelines, "vkCreateGraphicsPipelines");
112 			bindFunc(cast(void**)&vkCreateImage, "vkCreateImage");
113 			bindFunc(cast(void**)&vkCreateImageView, "vkCreateImageView");
114 			bindFunc(cast(void**)&vkCreateInstance, "vkCreateInstance");
115 			bindFunc(cast(void**)&vkCreatePipelineCache, "vkCreatePipelineCache");
116 			bindFunc(cast(void**)&vkCreatePipelineLayout, "vkCreatePipelineLayout");
117 			bindFunc(cast(void**)&vkCreateQueryPool, "vkCreateQueryPool");
118 			bindFunc(cast(void**)&vkCreateRenderPass, "vkCreateRenderPass");
119 			bindFunc(cast(void**)&vkCreateSampler, "vkCreateSampler");
120 			bindFunc(cast(void**)&vkCreateSemaphore, "vkCreateSemaphore");
121 			bindFunc(cast(void**)&vkCreateShaderModule, "vkCreateShaderModule");
122 			bindFunc(cast(void**)&vkCreateSwapchainKHR, "vkCreateSwapchainKHR");
123 			bindFunc(cast(void**)&vkDestroyBuffer, "vkDestroyBuffer");
124 			bindFunc(cast(void**)&vkDestroyBufferView, "vkDestroyBufferView");
125 			bindFunc(cast(void**)&vkDestroyCommandPool, "vkDestroyCommandPool");
126 			bindFunc(cast(void**)&vkDestroyDescriptorPool, "vkDestroyDescriptorPool");
127 			bindFunc(cast(void**)&vkDestroyDescriptorSetLayout, "vkDestroyDescriptorSetLayout");
128 			bindFunc(cast(void**)&vkDestroyDevice, "vkDestroyDevice");
129 			bindFunc(cast(void**)&vkDestroyEvent, "vkDestroyEvent");
130 			bindFunc(cast(void**)&vkDestroyFence, "vkDestroyFence");
131 			bindFunc(cast(void**)&vkDestroyFramebuffer, "vkDestroyFramebuffer");
132 			bindFunc(cast(void**)&vkDestroyImage, "vkDestroyImage");
133 			bindFunc(cast(void**)&vkDestroyImageView, "vkDestroyImageView");
134 			bindFunc(cast(void**)&vkDestroyInstance, "vkDestroyInstance");
135 			bindFunc(cast(void**)&vkDestroyPipeline, "vkDestroyPipeline");
136 			bindFunc(cast(void**)&vkDestroyPipelineCache, "vkDestroyPipelineCache");
137 			bindFunc(cast(void**)&vkDestroyPipelineLayout, "vkDestroyPipelineLayout");
138 			bindFunc(cast(void**)&vkDestroyQueryPool, "vkDestroyQueryPool");
139 			bindFunc(cast(void**)&vkDestroyRenderPass, "vkDestroyRenderPass");
140 			bindFunc(cast(void**)&vkDestroySampler, "vkDestroySampler");
141 			bindFunc(cast(void**)&vkDestroySemaphore, "vkDestroySemaphore");
142 			bindFunc(cast(void**)&vkDestroyShaderModule, "vkDestroyShaderModule");
143 			bindFunc(cast(void**)&vkDestroySurfaceKHR, "vkDestroySurfaceKHR");
144 			bindFunc(cast(void**)&vkDestroySwapchainKHR, "vkDestroySwapchainKHR");
145 			bindFunc(cast(void**)&vkDeviceWaitIdle, "vkDeviceWaitIdle");
146 			bindFunc(cast(void**)&vkEndCommandBuffer, "vkEndCommandBuffer");
147 			bindFunc(cast(void**)&vkEnumerateDeviceExtensionProperties, "vkEnumerateDeviceExtensionProperties");
148 			bindFunc(cast(void**)&vkEnumerateDeviceLayerProperties, "vkEnumerateDeviceLayerProperties");
149 			bindFunc(cast(void**)&vkEnumerateInstanceExtensionProperties, "vkEnumerateInstanceExtensionProperties");
150 			bindFunc(cast(void**)&vkEnumerateInstanceLayerProperties, "vkEnumerateInstanceLayerProperties");
151 			bindFunc(cast(void**)&vkEnumeratePhysicalDevices, "vkEnumeratePhysicalDevices");
152 			bindFunc(cast(void**)&vkFlushMappedMemoryRanges, "vkFlushMappedMemoryRanges");
153 			bindFunc(cast(void**)&vkFreeCommandBuffers, "vkFreeCommandBuffers");
154 			bindFunc(cast(void**)&vkFreeDescriptorSets, "vkFreeDescriptorSets");
155 			bindFunc(cast(void**)&vkFreeMemory, "vkFreeMemory");
156 			bindFunc(cast(void**)&vkGetBufferMemoryRequirements, "vkGetBufferMemoryRequirements");
157 			bindFunc(cast(void**)&vkGetDeviceMemoryCommitment, "vkGetDeviceMemoryCommitment");
158 			bindFunc(cast(void**)&vkGetDeviceProcAddr, "vkGetDeviceProcAddr");
159 			bindFunc(cast(void**)&vkGetDeviceQueue, "vkGetDeviceQueue");
160 			bindFunc(cast(void**)&vkGetEventStatus, "vkGetEventStatus");
161 			bindFunc(cast(void**)&vkGetFenceStatus, "vkGetFenceStatus");
162 			bindFunc(cast(void**)&vkGetImageMemoryRequirements, "vkGetImageMemoryRequirements");
163 			bindFunc(cast(void**)&vkGetImageSparseMemoryRequirements, "vkGetImageSparseMemoryRequirements");
164 			bindFunc(cast(void**)&vkGetImageSubresourceLayout, "vkGetImageSubresourceLayout");
165 			bindFunc(cast(void**)&vkGetInstanceProcAddr, "vkGetInstanceProcAddr");
166 			bindFunc(cast(void**)&vkGetPhysicalDeviceFeatures, "vkGetPhysicalDeviceFeatures");
167 			bindFunc(cast(void**)&vkGetPhysicalDeviceFormatProperties, "vkGetPhysicalDeviceFormatProperties");
168 			bindFunc(cast(void**)&vkGetPhysicalDeviceImageFormatProperties, "vkGetPhysicalDeviceImageFormatProperties");
169 			bindFunc(cast(void**)&vkGetPhysicalDeviceMemoryProperties, "vkGetPhysicalDeviceMemoryProperties");
170 			bindFunc(cast(void**)&vkGetPhysicalDeviceProperties, "vkGetPhysicalDeviceProperties");
171 			bindFunc(cast(void**)&vkGetPhysicalDeviceQueueFamilyProperties, "vkGetPhysicalDeviceQueueFamilyProperties");
172 			bindFunc(cast(void**)&vkGetPhysicalDeviceSparseImageFormatProperties, "vkGetPhysicalDeviceSparseImageFormatProperties");
173 			bindFunc(cast(void**)&vkGetPhysicalDeviceSurfaceCapabilitiesKHR, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR");
174 			bindFunc(cast(void**)&vkGetPhysicalDeviceSurfaceFormatsKHR, "vkGetPhysicalDeviceSurfaceFormatsKHR");
175 			bindFunc(cast(void**)&vkGetPhysicalDeviceSurfacePresentModesKHR, "vkGetPhysicalDeviceSurfacePresentModesKHR");
176 			bindFunc(cast(void**)&vkGetPhysicalDeviceSurfaceSupportKHR, "vkGetPhysicalDeviceSurfaceSupportKHR");
177 			bindFunc(cast(void**)&vkGetPipelineCacheData, "vkGetPipelineCacheData");
178 			bindFunc(cast(void**)&vkGetQueryPoolResults, "vkGetQueryPoolResults");
179 			bindFunc(cast(void**)&vkGetRenderAreaGranularity, "vkGetRenderAreaGranularity");
180 			bindFunc(cast(void**)&vkGetSwapchainImagesKHR, "vkGetSwapchainImagesKHR");
181 			bindFunc(cast(void**)&vkInvalidateMappedMemoryRanges, "vkInvalidateMappedMemoryRanges");
182 			bindFunc(cast(void**)&vkMapMemory, "vkMapMemory");
183 			bindFunc(cast(void**)&vkMergePipelineCaches, "vkMergePipelineCaches");
184 			bindFunc(cast(void**)&vkQueueBindSparse, "vkQueueBindSparse");
185 			bindFunc(cast(void**)&vkQueuePresentKHR, "vkQueuePresentKHR");
186 			bindFunc(cast(void**)&vkQueueSubmit, "vkQueueSubmit");
187 			bindFunc(cast(void**)&vkQueueWaitIdle, "vkQueueWaitIdle");
188 			bindFunc(cast(void**)&vkResetCommandBuffer, "vkResetCommandBuffer");
189 			bindFunc(cast(void**)&vkResetCommandPool, "vkResetCommandPool");
190 			bindFunc(cast(void**)&vkResetDescriptorPool, "vkResetDescriptorPool");
191 			bindFunc(cast(void**)&vkResetEvent, "vkResetEvent");
192 			bindFunc(cast(void**)&vkResetFences, "vkResetFences");
193 			bindFunc(cast(void**)&vkSetEvent, "vkSetEvent");
194 			bindFunc(cast(void**)&vkUnmapMemory, "vkUnmapMemory");
195 			bindFunc(cast(void**)&vkUpdateDescriptorSets, "vkUpdateDescriptorSets");
196 			bindFunc(cast(void**)&vkWaitForFences, "vkWaitForFences");
197 
198 			bindFunctions!((void** ptr, string funcName) => bindFunc(ptr, funcName));
199 		}
200 	}
201 	public {
202 		this() {
203 			super(libNames);
204 		}
205 	}
206 }
207 
208 __gshared DerelictVulkanLoader DerelictVulkan;
209 
210 shared static this() {
211 	DerelictVulkan = new DerelictVulkanLoader();
212 }
213 
214 shared static ~this() {
215 	DerelictVulkan.unload();
216 }