• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // File: vk_layer.h
3 //
4 /*
5  * Copyright (c) 2015-2016 The Khronos Group Inc.
6  * Copyright (c) 2015-2016 Valve Corporation
7  * Copyright (c) 2015-2016 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 
23 /* Need to define dispatch table
24  * Core struct can then have ptr to dispatch table at the top
25  * Along with object ptrs for current and next OBJ
26  */
27 #pragma once
28 
29 #include "vulkan.h"
30 #if defined(__GNUC__) && __GNUC__ >= 4
31 #define VK_LAYER_EXPORT __attribute__((visibility("default")))
32 #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
33 #define VK_LAYER_EXPORT __attribute__((visibility("default")))
34 #else
35 #define VK_LAYER_EXPORT
36 #endif
37 
38 typedef struct VkLayerDispatchTable_ {
39     PFN_vkGetDeviceProcAddr GetDeviceProcAddr;
40     PFN_vkDestroyDevice DestroyDevice;
41     PFN_vkGetDeviceQueue GetDeviceQueue;
42     PFN_vkQueueSubmit QueueSubmit;
43     PFN_vkQueueWaitIdle QueueWaitIdle;
44     PFN_vkDeviceWaitIdle DeviceWaitIdle;
45     PFN_vkAllocateMemory AllocateMemory;
46     PFN_vkFreeMemory FreeMemory;
47     PFN_vkMapMemory MapMemory;
48     PFN_vkUnmapMemory UnmapMemory;
49     PFN_vkFlushMappedMemoryRanges FlushMappedMemoryRanges;
50     PFN_vkInvalidateMappedMemoryRanges InvalidateMappedMemoryRanges;
51     PFN_vkGetDeviceMemoryCommitment GetDeviceMemoryCommitment;
52     PFN_vkGetImageSparseMemoryRequirements GetImageSparseMemoryRequirements;
53     PFN_vkGetImageMemoryRequirements GetImageMemoryRequirements;
54     PFN_vkGetBufferMemoryRequirements GetBufferMemoryRequirements;
55     PFN_vkBindImageMemory BindImageMemory;
56     PFN_vkBindBufferMemory BindBufferMemory;
57     PFN_vkQueueBindSparse QueueBindSparse;
58     PFN_vkCreateFence CreateFence;
59     PFN_vkDestroyFence DestroyFence;
60     PFN_vkGetFenceStatus GetFenceStatus;
61     PFN_vkResetFences ResetFences;
62     PFN_vkWaitForFences WaitForFences;
63     PFN_vkCreateSemaphore CreateSemaphore;
64     PFN_vkDestroySemaphore DestroySemaphore;
65     PFN_vkCreateEvent CreateEvent;
66     PFN_vkDestroyEvent DestroyEvent;
67     PFN_vkGetEventStatus GetEventStatus;
68     PFN_vkSetEvent SetEvent;
69     PFN_vkResetEvent ResetEvent;
70     PFN_vkCreateQueryPool CreateQueryPool;
71     PFN_vkDestroyQueryPool DestroyQueryPool;
72     PFN_vkGetQueryPoolResults GetQueryPoolResults;
73     PFN_vkCreateBuffer CreateBuffer;
74     PFN_vkDestroyBuffer DestroyBuffer;
75     PFN_vkCreateBufferView CreateBufferView;
76     PFN_vkDestroyBufferView DestroyBufferView;
77     PFN_vkCreateImage CreateImage;
78     PFN_vkDestroyImage DestroyImage;
79     PFN_vkGetImageSubresourceLayout GetImageSubresourceLayout;
80     PFN_vkCreateImageView CreateImageView;
81     PFN_vkDestroyImageView DestroyImageView;
82     PFN_vkCreateShaderModule CreateShaderModule;
83     PFN_vkDestroyShaderModule DestroyShaderModule;
84     PFN_vkCreatePipelineCache CreatePipelineCache;
85     PFN_vkDestroyPipelineCache DestroyPipelineCache;
86     PFN_vkGetPipelineCacheData GetPipelineCacheData;
87     PFN_vkMergePipelineCaches MergePipelineCaches;
88     PFN_vkCreateGraphicsPipelines CreateGraphicsPipelines;
89     PFN_vkCreateComputePipelines CreateComputePipelines;
90     PFN_vkDestroyPipeline DestroyPipeline;
91     PFN_vkCreatePipelineLayout CreatePipelineLayout;
92     PFN_vkDestroyPipelineLayout DestroyPipelineLayout;
93     PFN_vkCreateSampler CreateSampler;
94     PFN_vkDestroySampler DestroySampler;
95     PFN_vkCreateDescriptorSetLayout CreateDescriptorSetLayout;
96     PFN_vkDestroyDescriptorSetLayout DestroyDescriptorSetLayout;
97     PFN_vkCreateDescriptorPool CreateDescriptorPool;
98     PFN_vkDestroyDescriptorPool DestroyDescriptorPool;
99     PFN_vkResetDescriptorPool ResetDescriptorPool;
100     PFN_vkAllocateDescriptorSets AllocateDescriptorSets;
101     PFN_vkFreeDescriptorSets FreeDescriptorSets;
102     PFN_vkUpdateDescriptorSets UpdateDescriptorSets;
103     PFN_vkCreateFramebuffer CreateFramebuffer;
104     PFN_vkDestroyFramebuffer DestroyFramebuffer;
105     PFN_vkCreateRenderPass CreateRenderPass;
106     PFN_vkDestroyRenderPass DestroyRenderPass;
107     PFN_vkGetRenderAreaGranularity GetRenderAreaGranularity;
108     PFN_vkCreateCommandPool CreateCommandPool;
109     PFN_vkDestroyCommandPool DestroyCommandPool;
110     PFN_vkResetCommandPool ResetCommandPool;
111     PFN_vkAllocateCommandBuffers AllocateCommandBuffers;
112     PFN_vkFreeCommandBuffers FreeCommandBuffers;
113     PFN_vkBeginCommandBuffer BeginCommandBuffer;
114     PFN_vkEndCommandBuffer EndCommandBuffer;
115     PFN_vkResetCommandBuffer ResetCommandBuffer;
116     PFN_vkCmdBindPipeline CmdBindPipeline;
117     PFN_vkCmdBindDescriptorSets CmdBindDescriptorSets;
118     PFN_vkCmdBindVertexBuffers CmdBindVertexBuffers;
119     PFN_vkCmdBindIndexBuffer CmdBindIndexBuffer;
120     PFN_vkCmdSetViewport CmdSetViewport;
121     PFN_vkCmdSetScissor CmdSetScissor;
122     PFN_vkCmdSetLineWidth CmdSetLineWidth;
123     PFN_vkCmdSetDepthBias CmdSetDepthBias;
124     PFN_vkCmdSetBlendConstants CmdSetBlendConstants;
125     PFN_vkCmdSetDepthBounds CmdSetDepthBounds;
126     PFN_vkCmdSetStencilCompareMask CmdSetStencilCompareMask;
127     PFN_vkCmdSetStencilWriteMask CmdSetStencilWriteMask;
128     PFN_vkCmdSetStencilReference CmdSetStencilReference;
129     PFN_vkCmdDraw CmdDraw;
130     PFN_vkCmdDrawIndexed CmdDrawIndexed;
131     PFN_vkCmdDrawIndirect CmdDrawIndirect;
132     PFN_vkCmdDrawIndexedIndirect CmdDrawIndexedIndirect;
133     PFN_vkCmdDispatch CmdDispatch;
134     PFN_vkCmdDispatchIndirect CmdDispatchIndirect;
135     PFN_vkCmdCopyBuffer CmdCopyBuffer;
136     PFN_vkCmdCopyImage CmdCopyImage;
137     PFN_vkCmdBlitImage CmdBlitImage;
138     PFN_vkCmdCopyBufferToImage CmdCopyBufferToImage;
139     PFN_vkCmdCopyImageToBuffer CmdCopyImageToBuffer;
140     PFN_vkCmdUpdateBuffer CmdUpdateBuffer;
141     PFN_vkCmdFillBuffer CmdFillBuffer;
142     PFN_vkCmdClearColorImage CmdClearColorImage;
143     PFN_vkCmdClearDepthStencilImage CmdClearDepthStencilImage;
144     PFN_vkCmdClearAttachments CmdClearAttachments;
145     PFN_vkCmdResolveImage CmdResolveImage;
146     PFN_vkCmdSetEvent CmdSetEvent;
147     PFN_vkCmdResetEvent CmdResetEvent;
148     PFN_vkCmdWaitEvents CmdWaitEvents;
149     PFN_vkCmdPipelineBarrier CmdPipelineBarrier;
150     PFN_vkCmdBeginQuery CmdBeginQuery;
151     PFN_vkCmdEndQuery CmdEndQuery;
152     PFN_vkCmdResetQueryPool CmdResetQueryPool;
153     PFN_vkCmdWriteTimestamp CmdWriteTimestamp;
154     PFN_vkCmdCopyQueryPoolResults CmdCopyQueryPoolResults;
155     PFN_vkCmdPushConstants CmdPushConstants;
156     PFN_vkCmdBeginRenderPass CmdBeginRenderPass;
157     PFN_vkCmdNextSubpass CmdNextSubpass;
158     PFN_vkCmdEndRenderPass CmdEndRenderPass;
159     PFN_vkCmdExecuteCommands CmdExecuteCommands;
160     PFN_vkCreateSwapchainKHR CreateSwapchainKHR;
161     PFN_vkDestroySwapchainKHR DestroySwapchainKHR;
162     PFN_vkGetSwapchainImagesKHR GetSwapchainImagesKHR;
163     PFN_vkAcquireNextImageKHR AcquireNextImageKHR;
164     PFN_vkQueuePresentKHR QueuePresentKHR;
165     PFN_vkCmdDrawIndirectCountAMD CmdDrawIndirectCountAMD;
166     PFN_vkCmdDrawIndexedIndirectCountAMD CmdDrawIndexedIndirectCountAMD;
167 #ifdef VK_USE_PLATFORM_WIN32_KHR
168     PFN_vkGetMemoryWin32HandleNV GetMemoryWin32HandleNV;
169 #endif
170     PFN_vkCreateSharedSwapchainsKHR CreateSharedSwapchainsKHR;
171     PFN_vkDebugMarkerSetObjectTagEXT DebugMarkerSetObjectTagEXT;
172     PFN_vkDebugMarkerSetObjectNameEXT DebugMarkerSetObjectNameEXT;
173     PFN_vkCmdDebugMarkerBeginEXT CmdDebugMarkerBeginEXT;
174     PFN_vkCmdDebugMarkerEndEXT CmdDebugMarkerEndEXT;
175     PFN_vkCmdDebugMarkerInsertEXT CmdDebugMarkerInsertEXT;
176 } VkLayerDispatchTable;
177 
178 typedef struct VkLayerInstanceDispatchTable_ {
179     PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
180     PFN_vkDestroyInstance DestroyInstance;
181     PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices;
182     PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures;
183     PFN_vkGetPhysicalDeviceImageFormatProperties
184         GetPhysicalDeviceImageFormatProperties;
185     PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties;
186     PFN_vkGetPhysicalDeviceSparseImageFormatProperties
187         GetPhysicalDeviceSparseImageFormatProperties;
188     PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties;
189     PFN_vkGetPhysicalDeviceQueueFamilyProperties
190         GetPhysicalDeviceQueueFamilyProperties;
191     PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties;
192     PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties;
193     PFN_vkEnumerateDeviceLayerProperties EnumerateDeviceLayerProperties;
194     PFN_vkDestroySurfaceKHR DestroySurfaceKHR;
195     PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR;
196     PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR
197         GetPhysicalDeviceSurfaceCapabilitiesKHR;
198     PFN_vkGetPhysicalDeviceSurfaceFormatsKHR GetPhysicalDeviceSurfaceFormatsKHR;
199     PFN_vkGetPhysicalDeviceSurfacePresentModesKHR
200         GetPhysicalDeviceSurfacePresentModesKHR;
201     PFN_vkCreateDebugReportCallbackEXT CreateDebugReportCallbackEXT;
202     PFN_vkDestroyDebugReportCallbackEXT DestroyDebugReportCallbackEXT;
203     PFN_vkDebugReportMessageEXT DebugReportMessageEXT;
204 #ifdef VK_USE_PLATFORM_MIR_KHR
205     PFN_vkCreateMirSurfaceKHR CreateMirSurfaceKHR;
206     PFN_vkGetPhysicalDeviceMirPresentationSupportKHR
207         GetPhysicalDeviceMirPresentationSupportKHR;
208 #endif
209 #ifdef VK_USE_PLATFORM_WAYLAND_KHR
210     PFN_vkCreateWaylandSurfaceKHR CreateWaylandSurfaceKHR;
211     PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR
212         GetPhysicalDeviceWaylandPresentationSupportKHR;
213 #endif
214 #ifdef VK_USE_PLATFORM_WIN32_KHR
215     PFN_vkCreateWin32SurfaceKHR CreateWin32SurfaceKHR;
216     PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR
217         GetPhysicalDeviceWin32PresentationSupportKHR;
218 #endif
219 #ifdef VK_USE_PLATFORM_XCB_KHR
220     PFN_vkCreateXcbSurfaceKHR CreateXcbSurfaceKHR;
221     PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR
222         GetPhysicalDeviceXcbPresentationSupportKHR;
223 #endif
224 #ifdef VK_USE_PLATFORM_XLIB_KHR
225     PFN_vkCreateXlibSurfaceKHR CreateXlibSurfaceKHR;
226     PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR
227         GetPhysicalDeviceXlibPresentationSupportKHR;
228 #endif
229 #ifdef VK_USE_PLATFORM_ANDROID_KHR
230     PFN_vkCreateAndroidSurfaceKHR CreateAndroidSurfaceKHR;
231 #endif
232     PFN_vkGetPhysicalDeviceDisplayPropertiesKHR
233         GetPhysicalDeviceDisplayPropertiesKHR;
234     PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR
235         GetPhysicalDeviceDisplayPlanePropertiesKHR;
236     PFN_vkGetDisplayPlaneSupportedDisplaysKHR
237         GetDisplayPlaneSupportedDisplaysKHR;
238     PFN_vkGetDisplayModePropertiesKHR
239         GetDisplayModePropertiesKHR;
240     PFN_vkCreateDisplayModeKHR
241         CreateDisplayModeKHR;
242     PFN_vkGetDisplayPlaneCapabilitiesKHR
243         GetDisplayPlaneCapabilitiesKHR;
244     PFN_vkCreateDisplayPlaneSurfaceKHR
245         CreateDisplayPlaneSurfaceKHR;
246     PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV
247         GetPhysicalDeviceExternalImageFormatPropertiesNV;
248 } VkLayerInstanceDispatchTable;
249 
250 // ------------------------------------------------------------------------------------------------
251 // CreateInstance and CreateDevice support structures
252 
253 /* Sub type of structure for instance and device loader ext of CreateInfo.
254  * When sType == VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO
255  * or sType == VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO
256  * then VkLayerFunction indicates struct type pointed to by pNext
257  */
258 typedef enum VkLayerFunction_ {
259     VK_LAYER_LINK_INFO = 0,
260     VK_LOADER_DATA_CALLBACK = 1
261 } VkLayerFunction;
262 
263 typedef struct VkLayerInstanceLink_ {
264     struct VkLayerInstanceLink_ *pNext;
265     PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr;
266 } VkLayerInstanceLink;
267 
268 /*
269  * When creating the device chain the loader needs to pass
270  * down information about it's device structure needed at
271  * the end of the chain. Passing the data via the
272  * VkLayerDeviceInfo avoids issues with finding the
273  * exact instance being used.
274  */
275 typedef struct VkLayerDeviceInfo_ {
276     void *device_info;
277     PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr;
278 } VkLayerDeviceInfo;
279 
280 typedef VkResult (VKAPI_PTR *PFN_vkSetInstanceLoaderData)(VkInstance instance,
281         void *object);
282 typedef VkResult (VKAPI_PTR *PFN_vkSetDeviceLoaderData)(VkDevice device,
283         void *object);
284 
285 typedef struct {
286     VkStructureType sType; // VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO
287     const void *pNext;
288     VkLayerFunction function;
289     union {
290         VkLayerInstanceLink *pLayerInfo;
291         PFN_vkSetInstanceLoaderData pfnSetInstanceLoaderData;
292     } u;
293 } VkLayerInstanceCreateInfo;
294 
295 typedef struct VkLayerDeviceLink_ {
296     struct VkLayerDeviceLink_ *pNext;
297     PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr;
298     PFN_vkGetDeviceProcAddr pfnNextGetDeviceProcAddr;
299 } VkLayerDeviceLink;
300 
301 typedef struct {
302     VkStructureType sType; // VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO
303     const void *pNext;
304     VkLayerFunction function;
305     union {
306         VkLayerDeviceLink *pLayerInfo;
307         PFN_vkSetDeviceLoaderData pfnSetDeviceLoaderData;
308     } u;
309 } VkLayerDeviceCreateInfo;
310 
311