• 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  * Permission is hereby granted, free of charge, to any person obtaining a copy
10  * of this software and/or associated documentation files (the "Materials"), to
11  * deal in the Materials without restriction, including without limitation the
12  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
13  * sell copies of the Materials, and to permit persons to whom the Materials are
14  * furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice(s) and this permission notice shall be included in
17  * all copies or substantial portions of the Materials.
18  *
19  * THE MATERIALS ARE 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 AND NONINFRINGEMENT.
22  *
23  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
24  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
25  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE
26  * USE OR OTHER DEALINGS IN THE MATERIALS.
27  *
28  */
29 
30 /* Need to define dispatch table
31  * Core struct can then have ptr to dispatch table at the top
32  * Along with object ptrs for current and next OBJ
33  */
34 #pragma once
35 
36 #include "vulkan.h"
37 #if defined(__GNUC__) && __GNUC__ >= 4
38 #define VK_LAYER_EXPORT __attribute__((visibility("default")))
39 #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
40 #define VK_LAYER_EXPORT __attribute__((visibility("default")))
41 #else
42 #define VK_LAYER_EXPORT
43 #endif
44 
45 typedef struct VkLayerDispatchTable_ {
46     PFN_vkGetDeviceProcAddr GetDeviceProcAddr;
47     PFN_vkDestroyDevice DestroyDevice;
48     PFN_vkGetDeviceQueue GetDeviceQueue;
49     PFN_vkQueueSubmit QueueSubmit;
50     PFN_vkQueueWaitIdle QueueWaitIdle;
51     PFN_vkDeviceWaitIdle DeviceWaitIdle;
52     PFN_vkAllocateMemory AllocateMemory;
53     PFN_vkFreeMemory FreeMemory;
54     PFN_vkMapMemory MapMemory;
55     PFN_vkUnmapMemory UnmapMemory;
56     PFN_vkFlushMappedMemoryRanges FlushMappedMemoryRanges;
57     PFN_vkInvalidateMappedMemoryRanges InvalidateMappedMemoryRanges;
58     PFN_vkGetDeviceMemoryCommitment GetDeviceMemoryCommitment;
59     PFN_vkGetImageSparseMemoryRequirements GetImageSparseMemoryRequirements;
60     PFN_vkGetImageMemoryRequirements GetImageMemoryRequirements;
61     PFN_vkGetBufferMemoryRequirements GetBufferMemoryRequirements;
62     PFN_vkBindImageMemory BindImageMemory;
63     PFN_vkBindBufferMemory BindBufferMemory;
64     PFN_vkQueueBindSparse QueueBindSparse;
65     PFN_vkCreateFence CreateFence;
66     PFN_vkDestroyFence DestroyFence;
67     PFN_vkGetFenceStatus GetFenceStatus;
68     PFN_vkResetFences ResetFences;
69     PFN_vkWaitForFences WaitForFences;
70     PFN_vkCreateSemaphore CreateSemaphore;
71     PFN_vkDestroySemaphore DestroySemaphore;
72     PFN_vkCreateEvent CreateEvent;
73     PFN_vkDestroyEvent DestroyEvent;
74     PFN_vkGetEventStatus GetEventStatus;
75     PFN_vkSetEvent SetEvent;
76     PFN_vkResetEvent ResetEvent;
77     PFN_vkCreateQueryPool CreateQueryPool;
78     PFN_vkDestroyQueryPool DestroyQueryPool;
79     PFN_vkGetQueryPoolResults GetQueryPoolResults;
80     PFN_vkCreateBuffer CreateBuffer;
81     PFN_vkDestroyBuffer DestroyBuffer;
82     PFN_vkCreateBufferView CreateBufferView;
83     PFN_vkDestroyBufferView DestroyBufferView;
84     PFN_vkCreateImage CreateImage;
85     PFN_vkDestroyImage DestroyImage;
86     PFN_vkGetImageSubresourceLayout GetImageSubresourceLayout;
87     PFN_vkCreateImageView CreateImageView;
88     PFN_vkDestroyImageView DestroyImageView;
89     PFN_vkCreateShaderModule CreateShaderModule;
90     PFN_vkDestroyShaderModule DestroyShaderModule;
91     PFN_vkCreatePipelineCache CreatePipelineCache;
92     PFN_vkDestroyPipelineCache DestroyPipelineCache;
93     PFN_vkGetPipelineCacheData GetPipelineCacheData;
94     PFN_vkMergePipelineCaches MergePipelineCaches;
95     PFN_vkCreateGraphicsPipelines CreateGraphicsPipelines;
96     PFN_vkCreateComputePipelines CreateComputePipelines;
97     PFN_vkDestroyPipeline DestroyPipeline;
98     PFN_vkCreatePipelineLayout CreatePipelineLayout;
99     PFN_vkDestroyPipelineLayout DestroyPipelineLayout;
100     PFN_vkCreateSampler CreateSampler;
101     PFN_vkDestroySampler DestroySampler;
102     PFN_vkCreateDescriptorSetLayout CreateDescriptorSetLayout;
103     PFN_vkDestroyDescriptorSetLayout DestroyDescriptorSetLayout;
104     PFN_vkCreateDescriptorPool CreateDescriptorPool;
105     PFN_vkDestroyDescriptorPool DestroyDescriptorPool;
106     PFN_vkResetDescriptorPool ResetDescriptorPool;
107     PFN_vkAllocateDescriptorSets AllocateDescriptorSets;
108     PFN_vkFreeDescriptorSets FreeDescriptorSets;
109     PFN_vkUpdateDescriptorSets UpdateDescriptorSets;
110     PFN_vkCreateFramebuffer CreateFramebuffer;
111     PFN_vkDestroyFramebuffer DestroyFramebuffer;
112     PFN_vkCreateRenderPass CreateRenderPass;
113     PFN_vkDestroyRenderPass DestroyRenderPass;
114     PFN_vkGetRenderAreaGranularity GetRenderAreaGranularity;
115     PFN_vkCreateCommandPool CreateCommandPool;
116     PFN_vkDestroyCommandPool DestroyCommandPool;
117     PFN_vkResetCommandPool ResetCommandPool;
118     PFN_vkAllocateCommandBuffers AllocateCommandBuffers;
119     PFN_vkFreeCommandBuffers FreeCommandBuffers;
120     PFN_vkBeginCommandBuffer BeginCommandBuffer;
121     PFN_vkEndCommandBuffer EndCommandBuffer;
122     PFN_vkResetCommandBuffer ResetCommandBuffer;
123     PFN_vkCmdBindPipeline CmdBindPipeline;
124     PFN_vkCmdBindDescriptorSets CmdBindDescriptorSets;
125     PFN_vkCmdBindVertexBuffers CmdBindVertexBuffers;
126     PFN_vkCmdBindIndexBuffer CmdBindIndexBuffer;
127     PFN_vkCmdSetViewport CmdSetViewport;
128     PFN_vkCmdSetScissor CmdSetScissor;
129     PFN_vkCmdSetLineWidth CmdSetLineWidth;
130     PFN_vkCmdSetDepthBias CmdSetDepthBias;
131     PFN_vkCmdSetBlendConstants CmdSetBlendConstants;
132     PFN_vkCmdSetDepthBounds CmdSetDepthBounds;
133     PFN_vkCmdSetStencilCompareMask CmdSetStencilCompareMask;
134     PFN_vkCmdSetStencilWriteMask CmdSetStencilWriteMask;
135     PFN_vkCmdSetStencilReference CmdSetStencilReference;
136     PFN_vkCmdDraw CmdDraw;
137     PFN_vkCmdDrawIndexed CmdDrawIndexed;
138     PFN_vkCmdDrawIndirect CmdDrawIndirect;
139     PFN_vkCmdDrawIndexedIndirect CmdDrawIndexedIndirect;
140     PFN_vkCmdDispatch CmdDispatch;
141     PFN_vkCmdDispatchIndirect CmdDispatchIndirect;
142     PFN_vkCmdCopyBuffer CmdCopyBuffer;
143     PFN_vkCmdCopyImage CmdCopyImage;
144     PFN_vkCmdBlitImage CmdBlitImage;
145     PFN_vkCmdCopyBufferToImage CmdCopyBufferToImage;
146     PFN_vkCmdCopyImageToBuffer CmdCopyImageToBuffer;
147     PFN_vkCmdUpdateBuffer CmdUpdateBuffer;
148     PFN_vkCmdFillBuffer CmdFillBuffer;
149     PFN_vkCmdClearColorImage CmdClearColorImage;
150     PFN_vkCmdClearDepthStencilImage CmdClearDepthStencilImage;
151     PFN_vkCmdClearAttachments CmdClearAttachments;
152     PFN_vkCmdResolveImage CmdResolveImage;
153     PFN_vkCmdSetEvent CmdSetEvent;
154     PFN_vkCmdResetEvent CmdResetEvent;
155     PFN_vkCmdWaitEvents CmdWaitEvents;
156     PFN_vkCmdPipelineBarrier CmdPipelineBarrier;
157     PFN_vkCmdBeginQuery CmdBeginQuery;
158     PFN_vkCmdEndQuery CmdEndQuery;
159     PFN_vkCmdResetQueryPool CmdResetQueryPool;
160     PFN_vkCmdWriteTimestamp CmdWriteTimestamp;
161     PFN_vkCmdCopyQueryPoolResults CmdCopyQueryPoolResults;
162     PFN_vkCmdPushConstants CmdPushConstants;
163     PFN_vkCmdBeginRenderPass CmdBeginRenderPass;
164     PFN_vkCmdNextSubpass CmdNextSubpass;
165     PFN_vkCmdEndRenderPass CmdEndRenderPass;
166     PFN_vkCmdExecuteCommands CmdExecuteCommands;
167     PFN_vkCreateSwapchainKHR CreateSwapchainKHR;
168     PFN_vkDestroySwapchainKHR DestroySwapchainKHR;
169     PFN_vkGetSwapchainImagesKHR GetSwapchainImagesKHR;
170     PFN_vkAcquireNextImageKHR AcquireNextImageKHR;
171     PFN_vkQueuePresentKHR QueuePresentKHR;
172 } VkLayerDispatchTable;
173 
174 typedef struct VkLayerInstanceDispatchTable_ {
175     PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
176     PFN_vkDestroyInstance DestroyInstance;
177     PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices;
178     PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures;
179     PFN_vkGetPhysicalDeviceImageFormatProperties
180         GetPhysicalDeviceImageFormatProperties;
181     PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties;
182     PFN_vkGetPhysicalDeviceSparseImageFormatProperties
183         GetPhysicalDeviceSparseImageFormatProperties;
184     PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties;
185     PFN_vkGetPhysicalDeviceQueueFamilyProperties
186         GetPhysicalDeviceQueueFamilyProperties;
187     PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties;
188     PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties;
189     PFN_vkEnumerateDeviceLayerProperties EnumerateDeviceLayerProperties;
190     PFN_vkDestroySurfaceKHR DestroySurfaceKHR;
191     PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR;
192     PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR
193         GetPhysicalDeviceSurfaceCapabilitiesKHR;
194     PFN_vkGetPhysicalDeviceSurfaceFormatsKHR GetPhysicalDeviceSurfaceFormatsKHR;
195     PFN_vkGetPhysicalDeviceSurfacePresentModesKHR
196         GetPhysicalDeviceSurfacePresentModesKHR;
197     PFN_vkCreateDebugReportCallbackEXT CreateDebugReportCallbackEXT;
198     PFN_vkDestroyDebugReportCallbackEXT DestroyDebugReportCallbackEXT;
199     PFN_vkDebugReportMessageEXT DebugReportMessageEXT;
200 #ifdef VK_USE_PLATFORM_MIR_KHR
201     PFN_vkCreateMirSurfaceKHR CreateMirSurfaceKHR;
202     PFN_vkGetPhysicalDeviceMirPresentationSupportKHR
203         GetPhysicalDeviceMirPresentationSupportKHR;
204 #endif
205 #ifdef VK_USE_PLATFORM_WAYLAND_KHR
206     PFN_vkCreateWaylandSurfaceKHR CreateWaylandSurfaceKHR;
207     PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR
208         GetPhysicalDeviceWaylandPresentationSupportKHR;
209 #endif
210 #ifdef VK_USE_PLATFORM_WIN32_KHR
211     PFN_vkCreateWin32SurfaceKHR CreateWin32SurfaceKHR;
212     PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR
213         GetPhysicalDeviceWin32PresentationSupportKHR;
214 #endif
215 #ifdef VK_USE_PLATFORM_XCB_KHR
216     PFN_vkCreateXcbSurfaceKHR CreateXcbSurfaceKHR;
217     PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR
218         GetPhysicalDeviceXcbPresentationSupportKHR;
219 #endif
220 #ifdef VK_USE_PLATFORM_XLIB_KHR
221     PFN_vkCreateXlibSurfaceKHR CreateXlibSurfaceKHR;
222     PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR
223         GetPhysicalDeviceXlibPresentationSupportKHR;
224 #endif
225 #ifdef VK_USE_PLATFORM_ANDROID_KHR
226     PFN_vkCreateAndroidSurfaceKHR CreateAndroidSurfaceKHR;
227 #endif
228     PFN_vkGetPhysicalDeviceDisplayPropertiesKHR
229         GetPhysicalDeviceDisplayPropertiesKHR;
230     PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR
231         GetPhysicalDeviceDisplayPlanePropertiesKHR;
232     PFN_vkGetDisplayPlaneSupportedDisplaysKHR
233         GetDisplayPlaneSupportedDisplaysKHR;
234     PFN_vkGetDisplayModePropertiesKHR
235         GetDisplayModePropertiesKHR;
236     PFN_vkCreateDisplayModeKHR
237         CreateDisplayModeKHR;
238     PFN_vkGetDisplayPlaneCapabilitiesKHR
239         GetDisplayPlaneCapabilitiesKHR;
240     PFN_vkCreateDisplayPlaneSurfaceKHR
241         CreateDisplayPlaneSurfaceKHR;
242 } VkLayerInstanceDispatchTable;
243 
244 // LL node for tree of dbg callback functions
245 typedef struct VkLayerDbgFunctionNode_ {
246     VkDebugReportCallbackEXT msgCallback;
247     PFN_vkDebugReportCallbackEXT pfnMsgCallback;
248     VkFlags msgFlags;
249     void *pUserData;
250     struct VkLayerDbgFunctionNode_ *pNext;
251 } VkLayerDbgFunctionNode;
252 
253 typedef enum VkLayerDbgAction_ {
254     VK_DBG_LAYER_ACTION_IGNORE = 0x0,
255     VK_DBG_LAYER_ACTION_CALLBACK = 0x1,
256     VK_DBG_LAYER_ACTION_LOG_MSG = 0x2,
257     VK_DBG_LAYER_ACTION_BREAK = 0x4,
258     VK_DBG_LAYER_ACTION_DEBUG_OUTPUT = 0x8,
259 } VkLayerDbgAction;
260 
261 // ------------------------------------------------------------------------------------------------
262 // CreateInstance and CreateDevice support structures
263 
264 typedef enum VkLayerFunction_ {
265     VK_LAYER_LINK_INFO = 0,
266     VK_LAYER_DEVICE_INFO = 1,
267     VK_LAYER_INSTANCE_INFO = 2
268 } VkLayerFunction;
269 
270 /*
271  * When creating the device chain the loader needs to pass
272  * down information about it's device structure needed at
273  * the end of the chain. Passing the data via the
274  * VkLayerInstanceInfo avoids issues with finding the
275  * exact instance being used.
276  */
277 typedef struct VkLayerInstanceInfo_ {
278     void *instance_info;
279     PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr;
280 } VkLayerInstanceInfo;
281 
282 typedef struct VkLayerInstanceLink_ {
283     struct VkLayerInstanceLink_ *pNext;
284     PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr;
285 } VkLayerInstanceLink;
286 
287 /*
288  * When creating the device chain the loader needs to pass
289  * down information about it's device structure needed at
290  * the end of the chain. Passing the data via the
291  * VkLayerDeviceInfo avoids issues with finding the
292  * exact instance being used.
293  */
294 typedef struct VkLayerDeviceInfo_ {
295     void *device_info;
296     PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr;
297 } VkLayerDeviceInfo;
298 
299 typedef struct {
300     VkStructureType sType; // VK_STRUCTURE_TYPE_LAYER_INSTANCE_CREATE_INFO
301     const void *pNext;
302     VkLayerFunction function;
303     union {
304         VkLayerInstanceLink *pLayerInfo;
305         VkLayerInstanceInfo instanceInfo;
306     } u;
307 } VkLayerInstanceCreateInfo;
308 
309 typedef struct VkLayerDeviceLink_ {
310     struct VkLayerDeviceLink_ *pNext;
311     PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr;
312     PFN_vkGetDeviceProcAddr pfnNextGetDeviceProcAddr;
313 } VkLayerDeviceLink;
314 
315 typedef struct {
316     VkStructureType sType; // VK_STRUCTURE_TYPE_LAYER_DEVICE_CREATE_INFO
317     const void *pNext;
318     VkLayerFunction function;
319     union {
320         VkLayerDeviceLink *pLayerInfo;
321         VkLayerDeviceInfo deviceInfo;
322     } u;
323 } VkLayerDeviceCreateInfo;
324 
325 // ------------------------------------------------------------------------------------------------
326 // API functions
327