Jon Ashburn | d55a394 | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Vulkan |
| 3 | * |
| 4 | * Copyright (C) 2014 LunarG, Inc. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included |
| 14 | * in all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | * DEALINGS IN THE SOFTWARE. |
| 23 | */ |
| 24 | |
| 25 | #include <vulkan.h> |
Tobin Ehlis | 0c6f9ee | 2015-07-03 09:42:57 -0600 | [diff] [blame] | 26 | #include <vk_layer.h> |
Jon Ashburn | d55a394 | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 27 | #include <string.h> |
Jon Ashburn | 27cd584 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 28 | #include "loader.h" |
Tobin Ehlis | b835d1b | 2015-07-03 10:34:49 -0600 | [diff] [blame] | 29 | #include "vk_loader_platform.h" |
Jon Ashburn | d55a394 | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 30 | |
Jon Ashburn | fbb4e25 | 2015-05-04 16:27:53 -0600 | [diff] [blame] | 31 | static inline void loader_init_device_dispatch_table(VkLayerDispatchTable *table, |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 32 | PFN_vkGetDeviceProcAddr gpa, |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 33 | VkDevice dev_next, |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 34 | VkDevice dev) |
Jon Ashburn | d55a394 | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 35 | { |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 36 | // If layer is next, this will trigger layers to initialize their dispatch tables |
| 37 | //then use the gpa in their dispatch for subsequent layers in the chain |
| 38 | table->GetDeviceProcAddr = (PFN_vkGetDeviceProcAddr) gpa(dev_next, "vkGetDeviceProcAddr"); |
| 39 | |
Courtney Goeltzenleuchter | ca173b8 | 2015-06-25 18:01:43 -0600 | [diff] [blame] | 40 | table->CreateDevice = (PFN_vkCreateDevice) gpa(dev, "vkCreateDevice"); |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 41 | table->DestroyDevice = (PFN_vkDestroyDevice) gpa(dev, "vkDestroyDevice"); |
| 42 | table->GetDeviceQueue = (PFN_vkGetDeviceQueue) gpa(dev, "vkGetDeviceQueue"); |
| 43 | table->QueueSubmit = (PFN_vkQueueSubmit) gpa(dev, "vkQueueSubmit"); |
| 44 | table->QueueWaitIdle = (PFN_vkQueueWaitIdle) gpa(dev, "vkQueueWaitIdle"); |
| 45 | table->DeviceWaitIdle = (PFN_vkDeviceWaitIdle) gpa(dev, "vkDeviceWaitIdle"); |
| 46 | table->AllocMemory = (PFN_vkAllocMemory) gpa(dev, "vkAllocMemory"); |
| 47 | table->FreeMemory = (PFN_vkFreeMemory) gpa(dev, "vkFreeMemory"); |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 48 | table->MapMemory = (PFN_vkMapMemory) gpa(dev, "vkMapMemory"); |
| 49 | table->UnmapMemory = (PFN_vkUnmapMemory) gpa(dev, "vkUnmapMemory"); |
| 50 | table->FlushMappedMemoryRanges = (PFN_vkFlushMappedMemoryRanges) gpa(dev, "vkFlushMappedMemoryRanges"); |
| 51 | table->InvalidateMappedMemoryRanges = (PFN_vkInvalidateMappedMemoryRanges) gpa(dev, "vkInvalidateMappedMemoryRanges"); |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 52 | table->DestroyObject = (PFN_vkDestroyObject) gpa(dev, "vkDestroyObject"); |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 53 | table->GetObjectMemoryRequirements = (PFN_vkGetObjectMemoryRequirements) gpa(dev, "vkGetObjectMemoryRequirements"); |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 54 | table->BindObjectMemory = (PFN_vkBindObjectMemory) gpa(dev, "vkBindObjectMemory"); |
| 55 | table->QueueBindSparseBufferMemory = (PFN_vkQueueBindSparseBufferMemory) gpa(dev, "vkQueueBindSparseBufferMemory"); |
| 56 | table->QueueBindSparseImageMemory = (PFN_vkQueueBindSparseImageMemory) gpa(dev, "vkQueueBindSparseImageMemory"); |
| 57 | table->CreateFence = (PFN_vkCreateFence) gpa(dev, "vkCreateFence"); |
| 58 | table->ResetFences = (PFN_vkResetFences) gpa(dev, "vkResetFences"); |
| 59 | table->GetFenceStatus = (PFN_vkGetFenceStatus) gpa(dev, "vkGetFenceStatus"); |
| 60 | table->WaitForFences = (PFN_vkWaitForFences) gpa(dev, "vkWaitForFences"); |
| 61 | table->CreateSemaphore = (PFN_vkCreateSemaphore) gpa(dev, "vkCreateSemaphore"); |
| 62 | table->QueueSignalSemaphore = (PFN_vkQueueSignalSemaphore) gpa(dev, "vkQueueSignalSemaphore"); |
| 63 | table->QueueWaitSemaphore = (PFN_vkQueueWaitSemaphore) gpa(dev, "vkQueueWaitSemaphore"); |
| 64 | table->CreateEvent = (PFN_vkCreateEvent) gpa(dev, "vkCreateEvent"); |
| 65 | table->GetEventStatus = (PFN_vkGetEventStatus) gpa(dev, "vkGetEventStatus"); |
| 66 | table->SetEvent = (PFN_vkSetEvent) gpa(dev, "vkSetEvent"); |
| 67 | table->ResetEvent = (PFN_vkResetEvent) gpa(dev, "vkResetEvent"); |
| 68 | table->CreateQueryPool = (PFN_vkCreateQueryPool) gpa(dev, "vkCreateQueryPool"); |
| 69 | table->GetQueryPoolResults = (PFN_vkGetQueryPoolResults) gpa(dev, "vkGetQueryPoolResults"); |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 70 | table->CreateBuffer = (PFN_vkCreateBuffer) gpa(dev, "vkCreateBuffer"); |
| 71 | table->CreateBufferView = (PFN_vkCreateBufferView) gpa(dev, "vkCreateBufferView"); |
| 72 | table->CreateImage = (PFN_vkCreateImage) gpa(dev, "vkCreateImage"); |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 73 | table->GetImageSubresourceLayout = (PFN_vkGetImageSubresourceLayout) gpa(dev, "vkGetImageSubresourceLayout"); |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 74 | table->CreateImageView = (PFN_vkCreateImageView) gpa(dev, "vkCreateImageView"); |
| 75 | table->CreateColorAttachmentView = (PFN_vkCreateColorAttachmentView) gpa(dev, "vkCreateColorAttachmentView"); |
| 76 | table->CreateDepthStencilView = (PFN_vkCreateDepthStencilView) gpa(dev, "vkCreateDepthStencilView"); |
Courtney Goeltzenleuchter | 2d2cb68 | 2015-06-24 18:24:19 -0600 | [diff] [blame] | 77 | table->CreateShaderModule = (PFN_vkCreateShaderModule) gpa(dev, "vkCreateShaderModule"); |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 78 | table->CreateShader = (PFN_vkCreateShader) gpa(dev, "vkCreateShader"); |
| 79 | table->CreateGraphicsPipeline = (PFN_vkCreateGraphicsPipeline) gpa(dev, "vkCreateGraphicsPipeline"); |
| 80 | table->CreateGraphicsPipelineDerivative = (PFN_vkCreateGraphicsPipelineDerivative) gpa(dev, "vkCreateGraphicsPipelineDerivative"); |
| 81 | table->CreateComputePipeline = (PFN_vkCreateComputePipeline) gpa(dev, "vkCreateComputePipeline"); |
| 82 | table->StorePipeline = (PFN_vkStorePipeline) gpa(dev, "vkStorePipeline"); |
| 83 | table->LoadPipeline = (PFN_vkLoadPipeline) gpa(dev, "vkLoadPipeline"); |
| 84 | table->LoadPipelineDerivative = (PFN_vkLoadPipelineDerivative) gpa(dev, "vkLoadPipelineDerivative"); |
| 85 | table->CreatePipelineLayout = (PFN_vkCreatePipelineLayout) gpa(dev, "vkCreatePipelineLayout"); |
| 86 | table->CreateSampler = (PFN_vkCreateSampler) gpa(dev, "vkCreateSampler"); |
| 87 | table->CreateDescriptorSetLayout = (PFN_vkCreateDescriptorSetLayout) gpa(dev, "vkCreateDescriptorSetLayout"); |
| 88 | table->CreateDescriptorPool = (PFN_vkCreateDescriptorPool) gpa(dev, "vkCreateDescriptorPool"); |
| 89 | table->ResetDescriptorPool = (PFN_vkResetDescriptorPool) gpa(dev, "vkResetDescriptorPool"); |
| 90 | table->AllocDescriptorSets = (PFN_vkAllocDescriptorSets) gpa(dev, "vkAllocDescriptorSets"); |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 91 | table->UpdateDescriptorSets = (PFN_vkUpdateDescriptorSets) gpa(dev, "vkUpdateDescriptorSets"); |
| 92 | table->CreateDynamicViewportState = (PFN_vkCreateDynamicViewportState) gpa(dev, "vkCreateDynamicViewportState"); |
| 93 | table->CreateDynamicRasterState = (PFN_vkCreateDynamicRasterState) gpa(dev, "vkCreateDynamicRasterState"); |
| 94 | table->CreateDynamicColorBlendState = (PFN_vkCreateDynamicColorBlendState) gpa(dev, "vkCreateDynamicColorBlendState"); |
| 95 | table->CreateDynamicDepthStencilState = (PFN_vkCreateDynamicDepthStencilState) gpa(dev, "vkCreateDynamicDepthStencilState"); |
| 96 | table->CreateCommandBuffer = (PFN_vkCreateCommandBuffer) gpa(dev, "vkCreateCommandBuffer"); |
| 97 | table->BeginCommandBuffer = (PFN_vkBeginCommandBuffer) gpa(dev, "vkBeginCommandBuffer"); |
| 98 | table->EndCommandBuffer = (PFN_vkEndCommandBuffer) gpa(dev, "vkEndCommandBuffer"); |
| 99 | table->ResetCommandBuffer = (PFN_vkResetCommandBuffer) gpa(dev, "vkResetCommandBuffer"); |
| 100 | table->CmdBindPipeline = (PFN_vkCmdBindPipeline) gpa(dev, "vkCmdBindPipeline"); |
| 101 | table->CmdBindDynamicStateObject = (PFN_vkCmdBindDynamicStateObject) gpa(dev, "vkCmdBindDynamicStateObject"); |
| 102 | table->CmdBindDescriptorSets = (PFN_vkCmdBindDescriptorSets) gpa(dev, "vkCmdBindDescriptorSets"); |
| 103 | table->CmdBindVertexBuffers = (PFN_vkCmdBindVertexBuffers) gpa(dev, "vkCmdBindVertexBuffers"); |
| 104 | table->CmdBindIndexBuffer = (PFN_vkCmdBindIndexBuffer) gpa(dev, "vkCmdBindIndexBuffer"); |
| 105 | table->CmdDraw = (PFN_vkCmdDraw) gpa(dev, "vkCmdDraw"); |
| 106 | table->CmdDrawIndexed = (PFN_vkCmdDrawIndexed) gpa(dev, "vkCmdDrawIndexed"); |
| 107 | table->CmdDrawIndirect = (PFN_vkCmdDrawIndirect) gpa(dev, "vkCmdDrawIndirect"); |
| 108 | table->CmdDrawIndexedIndirect = (PFN_vkCmdDrawIndexedIndirect) gpa(dev, "vkCmdDrawIndexedIndirect"); |
| 109 | table->CmdDispatch = (PFN_vkCmdDispatch) gpa(dev, "vkCmdDispatch"); |
| 110 | table->CmdDispatchIndirect = (PFN_vkCmdDispatchIndirect) gpa(dev, "vkCmdDispatchIndirect"); |
| 111 | table->CmdCopyBuffer = (PFN_vkCmdCopyBuffer) gpa(dev, "vkCmdCopyBuffer"); |
| 112 | table->CmdCopyImage = (PFN_vkCmdCopyImage) gpa(dev, "vkCmdCopyImage"); |
| 113 | table->CmdBlitImage = (PFN_vkCmdBlitImage) gpa(dev, "vkCmdBlitImage"); |
| 114 | table->CmdCopyBufferToImage = (PFN_vkCmdCopyBufferToImage) gpa(dev, "vkCmdCopyBufferToImage"); |
| 115 | table->CmdCopyImageToBuffer = (PFN_vkCmdCopyImageToBuffer) gpa(dev, "vkCmdCopyImageToBuffer"); |
| 116 | table->CmdUpdateBuffer = (PFN_vkCmdUpdateBuffer) gpa(dev, "vkCmdUpdateBuffer"); |
| 117 | table->CmdFillBuffer = (PFN_vkCmdFillBuffer) gpa(dev, "vkCmdFillBuffer"); |
| 118 | table->CmdClearColorImage = (PFN_vkCmdClearColorImage) gpa(dev, "vkCmdClearColorImage"); |
Chris Forbes | d9be82b | 2015-06-22 17:21:59 +1200 | [diff] [blame] | 119 | table->CmdClearDepthStencilImage = (PFN_vkCmdClearDepthStencilImage) gpa(dev, "vkCmdClearDepthStencilImage"); |
| 120 | table->CmdClearColorAttachment = (PFN_vkCmdClearColorAttachment) gpa(dev, "vkCmdClearColorAttachment"); |
| 121 | table->CmdClearDepthStencilAttachment = (PFN_vkCmdClearDepthStencilAttachment) gpa(dev, "vkCmdClearDepthStencilAttachment"); |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 122 | table->CmdResolveImage = (PFN_vkCmdResolveImage) gpa(dev, "vkCmdResolveImage"); |
| 123 | table->CmdSetEvent = (PFN_vkCmdSetEvent) gpa(dev, "vkCmdSetEvent"); |
| 124 | table->CmdResetEvent = (PFN_vkCmdResetEvent) gpa(dev, "vkCmdResetEvent"); |
| 125 | table->CmdWaitEvents = (PFN_vkCmdWaitEvents) gpa(dev, "vkCmdWaitEvents"); |
| 126 | table->CmdPipelineBarrier = (PFN_vkCmdPipelineBarrier) gpa(dev, "vkCmdPipelineBarrier"); |
| 127 | table->CmdBeginQuery = (PFN_vkCmdBeginQuery) gpa(dev, "vkCmdBeginQuery"); |
| 128 | table->CmdEndQuery = (PFN_vkCmdEndQuery) gpa(dev, "vkCmdEndQuery"); |
| 129 | table->CmdResetQueryPool = (PFN_vkCmdResetQueryPool) gpa(dev, "vkCmdResetQueryPool"); |
| 130 | table->CmdWriteTimestamp = (PFN_vkCmdWriteTimestamp) gpa(dev, "vkCmdWriteTimestamp"); |
| 131 | table->CmdCopyQueryPoolResults = (PFN_vkCmdCopyQueryPoolResults) gpa(dev, "vkCmdCopyQueryPoolResults"); |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 132 | table->CreateFramebuffer = (PFN_vkCreateFramebuffer) gpa(dev, "vkCreateFramebuffer"); |
| 133 | table->CreateRenderPass = (PFN_vkCreateRenderPass) gpa(dev, "vkCreateRenderPass"); |
| 134 | table->CmdBeginRenderPass = (PFN_vkCmdBeginRenderPass) gpa(dev, "vkCmdBeginRenderPass"); |
| 135 | table->CmdEndRenderPass = (PFN_vkCmdEndRenderPass) gpa(dev, "vkCmdEndRenderPass"); |
Chia-I Wu | 0b50a1c | 2015-06-26 15:34:39 +0800 | [diff] [blame] | 136 | table->CmdExecuteCommands = (PFN_vkCmdExecuteCommands) gpa(dev, "vkCmdExecuteCommands"); |
Jon Ashburn | 07daee7 | 2015-05-21 18:13:33 -0600 | [diff] [blame] | 137 | //TODO move into it's own table |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 138 | //TODO also consider dropping trampoline code for these device level extensions entirely |
| 139 | // then don't need loader to know about these at all but then not queryable via GIPA |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 140 | table->CreateSwapChainWSI = (PFN_vkCreateSwapChainWSI) gpa(dev, "vkCreateSwapChainWSI"); |
| 141 | table->DestroySwapChainWSI = (PFN_vkDestroySwapChainWSI) gpa(dev, "vkDestroySwapChainWSI"); |
| 142 | table->GetSwapChainInfoWSI = (PFN_vkGetSwapChainInfoWSI) gpa(dev, "vkGetSwapChainInfoWSI"); |
| 143 | table->QueuePresentWSI = (PFN_vkQueuePresentWSI) gpa(dev, "vkQueuePresentWSI"); |
Jon Ashburn | d55a394 | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 144 | } |
| 145 | |
Jon Ashburn | 27cd584 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 146 | static inline void *loader_lookup_device_dispatch_table( |
| 147 | const VkLayerDispatchTable *table, |
| 148 | const char *name) |
Jon Ashburn | d55a394 | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 149 | { |
| 150 | if (!name || name[0] != 'v' || name[1] != 'k') |
| 151 | return NULL; |
| 152 | |
| 153 | name += 2; |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 154 | if (!strcmp(name, "GetDeviceProcAddr")) |
| 155 | return (void *) table->GetDeviceProcAddr; |
Courtney Goeltzenleuchter | ca173b8 | 2015-06-25 18:01:43 -0600 | [diff] [blame] | 156 | if (!strcmp(name, "CreateDevice")) |
| 157 | return (void *) table->CreateDevice; |
Jon Ashburn | d55a394 | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 158 | if (!strcmp(name, "DestroyDevice")) |
| 159 | return (void *) table->DestroyDevice; |
Jon Ashburn | d55a394 | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 160 | if (!strcmp(name, "GetDeviceQueue")) |
| 161 | return (void *) table->GetDeviceQueue; |
| 162 | if (!strcmp(name, "QueueSubmit")) |
| 163 | return (void *) table->QueueSubmit; |
| 164 | if (!strcmp(name, "QueueWaitIdle")) |
| 165 | return (void *) table->QueueWaitIdle; |
| 166 | if (!strcmp(name, "DeviceWaitIdle")) |
| 167 | return (void *) table->DeviceWaitIdle; |
| 168 | if (!strcmp(name, "AllocMemory")) |
| 169 | return (void *) table->AllocMemory; |
| 170 | if (!strcmp(name, "FreeMemory")) |
| 171 | return (void *) table->FreeMemory; |
Jon Ashburn | d55a394 | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 172 | if (!strcmp(name, "MapMemory")) |
| 173 | return (void *) table->MapMemory; |
| 174 | if (!strcmp(name, "UnmapMemory")) |
| 175 | return (void *) table->UnmapMemory; |
| 176 | if (!strcmp(name, "FlushMappedMemoryRanges")) |
| 177 | return (void *) table->FlushMappedMemoryRanges; |
| 178 | if (!strcmp(name, "InvalidateMappedMemoryRanges")) |
| 179 | return (void *) table->InvalidateMappedMemoryRanges; |
Jon Ashburn | d55a394 | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 180 | if (!strcmp(name, "DestroyObject")) |
| 181 | return (void *) table->DestroyObject; |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 182 | if (!strcmp(name, "GetObjectMemoryRequirements")) |
| 183 | return (void *) table->GetObjectMemoryRequirements; |
Mark Lobodzinski | 942b172 | 2015-05-11 17:21:15 -0500 | [diff] [blame] | 184 | if (!strcmp(name, "BindObjectMemory")) |
| 185 | return (void *) table->BindObjectMemory; |
| 186 | if (!strcmp(name, "QueueBindSparseBufferMemory")) |
| 187 | return (void *) table->QueueBindSparseBufferMemory; |
| 188 | if (!strcmp(name, "QueueBindSparseImageMemory")) |
| 189 | return (void *) table->QueueBindSparseImageMemory; |
Jon Ashburn | d55a394 | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 190 | if (!strcmp(name, "CreateFence")) |
| 191 | return (void *) table->CreateFence; |
| 192 | if (!strcmp(name, "ResetFences")) |
| 193 | return (void *) table->ResetFences; |
| 194 | if (!strcmp(name, "GetFenceStatus")) |
| 195 | return (void *) table->GetFenceStatus; |
| 196 | if (!strcmp(name, "WaitForFences")) |
| 197 | return (void *) table->WaitForFences; |
| 198 | if (!strcmp(name, "CreateSemaphore")) |
| 199 | return (void *) table->CreateSemaphore; |
| 200 | if (!strcmp(name, "QueueSignalSemaphore")) |
| 201 | return (void *) table->QueueSignalSemaphore; |
| 202 | if (!strcmp(name, "QueueWaitSemaphore")) |
| 203 | return (void *) table->QueueWaitSemaphore; |
| 204 | if (!strcmp(name, "CreateEvent")) |
| 205 | return (void *) table->CreateEvent; |
| 206 | if (!strcmp(name, "GetEventStatus")) |
| 207 | return (void *) table->GetEventStatus; |
| 208 | if (!strcmp(name, "SetEvent")) |
| 209 | return (void *) table->SetEvent; |
| 210 | if (!strcmp(name, "ResetEvent")) |
| 211 | return (void *) table->ResetEvent; |
| 212 | if (!strcmp(name, "CreateQueryPool")) |
| 213 | return (void *) table->CreateQueryPool; |
| 214 | if (!strcmp(name, "GetQueryPoolResults")) |
| 215 | return (void *) table->GetQueryPoolResults; |
Jon Ashburn | d55a394 | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 216 | if (!strcmp(name, "CreateBuffer")) |
| 217 | return (void *) table->CreateBuffer; |
| 218 | if (!strcmp(name, "CreateBufferView")) |
| 219 | return (void *) table->CreateBufferView; |
| 220 | if (!strcmp(name, "CreateImage")) |
| 221 | return (void *) table->CreateImage; |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 222 | if (!strcmp(name, "GetImageSubresourceLayout")) |
| 223 | return (void *) table->GetImageSubresourceLayout; |
Jon Ashburn | d55a394 | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 224 | if (!strcmp(name, "CreateImageView")) |
| 225 | return (void *) table->CreateImageView; |
| 226 | if (!strcmp(name, "CreateColorAttachmentView")) |
| 227 | return (void *) table->CreateColorAttachmentView; |
| 228 | if (!strcmp(name, "CreateDepthStencilView")) |
| 229 | return (void *) table->CreateDepthStencilView; |
Courtney Goeltzenleuchter | 2d2cb68 | 2015-06-24 18:24:19 -0600 | [diff] [blame] | 230 | if (!strcmp(name, "CreateShaderModule")) |
| 231 | return (void *) table->CreateShaderModule; |
Jon Ashburn | d55a394 | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 232 | if (!strcmp(name, "CreateShader")) |
| 233 | return (void *) table->CreateShader; |
| 234 | if (!strcmp(name, "CreateGraphicsPipeline")) |
| 235 | return (void *) table->CreateGraphicsPipeline; |
| 236 | if (!strcmp(name, "CreateGraphicsPipelineDerivative")) |
| 237 | return (void *) table->CreateGraphicsPipelineDerivative; |
| 238 | if (!strcmp(name, "CreateComputePipeline")) |
| 239 | return (void *) table->CreateComputePipeline; |
| 240 | if (!strcmp(name, "StorePipeline")) |
| 241 | return (void *) table->StorePipeline; |
| 242 | if (!strcmp(name, "LoadPipeline")) |
| 243 | return (void *) table->LoadPipeline; |
| 244 | if (!strcmp(name, "LoadPipelineDerivative")) |
| 245 | return (void *) table->LoadPipelineDerivative; |
| 246 | if (!strcmp(name, "CreatePipelineLayout")) |
| 247 | return (void *) table->CreatePipelineLayout; |
| 248 | if (!strcmp(name, "CreateSampler")) |
| 249 | return (void *) table->CreateSampler; |
| 250 | if (!strcmp(name, "CreateDescriptorSetLayout")) |
| 251 | return (void *) table->CreateDescriptorSetLayout; |
Jon Ashburn | d55a394 | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 252 | if (!strcmp(name, "CreateDescriptorPool")) |
| 253 | return (void *) table->CreateDescriptorPool; |
| 254 | if (!strcmp(name, "ResetDescriptorPool")) |
| 255 | return (void *) table->ResetDescriptorPool; |
| 256 | if (!strcmp(name, "AllocDescriptorSets")) |
| 257 | return (void *) table->AllocDescriptorSets; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 258 | if (!strcmp(name, "UpdateDescriptorSets")) |
| 259 | return (void *) table->UpdateDescriptorSets; |
Jon Ashburn | d55a394 | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 260 | if (!strcmp(name, "CreateDynamicViewportState")) |
| 261 | return (void *) table->CreateDynamicViewportState; |
| 262 | if (!strcmp(name, "CreateDynamicRasterState")) |
| 263 | return (void *) table->CreateDynamicRasterState; |
| 264 | if (!strcmp(name, "CreateDynamicColorBlendState")) |
| 265 | return (void *) table->CreateDynamicColorBlendState; |
| 266 | if (!strcmp(name, "CreateDynamicDepthStencilState")) |
| 267 | return (void *) table->CreateDynamicDepthStencilState; |
| 268 | if (!strcmp(name, "CreateCommandBuffer")) |
| 269 | return (void *) table->CreateCommandBuffer; |
| 270 | if (!strcmp(name, "BeginCommandBuffer")) |
| 271 | return (void *) table->BeginCommandBuffer; |
| 272 | if (!strcmp(name, "EndCommandBuffer")) |
| 273 | return (void *) table->EndCommandBuffer; |
| 274 | if (!strcmp(name, "ResetCommandBuffer")) |
| 275 | return (void *) table->ResetCommandBuffer; |
| 276 | if (!strcmp(name, "CmdBindPipeline")) |
| 277 | return (void *) table->CmdBindPipeline; |
| 278 | if (!strcmp(name, "CmdBindDynamicStateObject")) |
| 279 | return (void *) table->CmdBindDynamicStateObject; |
| 280 | if (!strcmp(name, "CmdBindDescriptorSets")) |
| 281 | return (void *) table->CmdBindDescriptorSets; |
| 282 | if (!strcmp(name, "CmdBindVertexBuffers")) |
| 283 | return (void *) table->CmdBindVertexBuffers; |
| 284 | if (!strcmp(name, "CmdBindIndexBuffer")) |
| 285 | return (void *) table->CmdBindIndexBuffer; |
| 286 | if (!strcmp(name, "CmdDraw")) |
| 287 | return (void *) table->CmdDraw; |
| 288 | if (!strcmp(name, "CmdDrawIndexed")) |
| 289 | return (void *) table->CmdDrawIndexed; |
| 290 | if (!strcmp(name, "CmdDrawIndirect")) |
| 291 | return (void *) table->CmdDrawIndirect; |
| 292 | if (!strcmp(name, "CmdDrawIndexedIndirect")) |
| 293 | return (void *) table->CmdDrawIndexedIndirect; |
| 294 | if (!strcmp(name, "CmdDispatch")) |
| 295 | return (void *) table->CmdDispatch; |
| 296 | if (!strcmp(name, "CmdDispatchIndirect")) |
| 297 | return (void *) table->CmdDispatchIndirect; |
| 298 | if (!strcmp(name, "CmdCopyBuffer")) |
| 299 | return (void *) table->CmdCopyBuffer; |
| 300 | if (!strcmp(name, "CmdCopyImage")) |
| 301 | return (void *) table->CmdCopyImage; |
| 302 | if (!strcmp(name, "CmdBlitImage")) |
| 303 | return (void *) table->CmdBlitImage; |
| 304 | if (!strcmp(name, "CmdCopyBufferToImage")) |
| 305 | return (void *) table->CmdCopyBufferToImage; |
| 306 | if (!strcmp(name, "CmdCopyImageToBuffer")) |
| 307 | return (void *) table->CmdCopyImageToBuffer; |
Jon Ashburn | d55a394 | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 308 | if (!strcmp(name, "CmdUpdateBuffer")) |
| 309 | return (void *) table->CmdUpdateBuffer; |
| 310 | if (!strcmp(name, "CmdFillBuffer")) |
| 311 | return (void *) table->CmdFillBuffer; |
| 312 | if (!strcmp(name, "CmdClearColorImage")) |
| 313 | return (void *) table->CmdClearColorImage; |
Chris Forbes | d9be82b | 2015-06-22 17:21:59 +1200 | [diff] [blame] | 314 | if (!strcmp(name, "CmdClearDepthStencilImage")) |
| 315 | return (void *) table->CmdClearDepthStencilImage; |
| 316 | if (!strcmp(name, "CmdClearColorAttachment")) |
| 317 | return (void *) table->CmdClearColorAttachment; |
| 318 | if (!strcmp(name, "CmdClearDepthStencilAttachment")) |
| 319 | return (void *) table->CmdClearDepthStencilAttachment; |
Jon Ashburn | d55a394 | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 320 | if (!strcmp(name, "CmdResolveImage")) |
| 321 | return (void *) table->CmdResolveImage; |
| 322 | if (!strcmp(name, "CmdSetEvent")) |
| 323 | return (void *) table->CmdSetEvent; |
| 324 | if (!strcmp(name, "CmdResetEvent")) |
| 325 | return (void *) table->CmdResetEvent; |
| 326 | if (!strcmp(name, "CmdWaitEvents")) |
| 327 | return (void *) table->CmdWaitEvents; |
| 328 | if (!strcmp(name, "CmdPipelineBarrier")) |
| 329 | return (void *) table->CmdPipelineBarrier; |
| 330 | if (!strcmp(name, "CmdBeginQuery")) |
| 331 | return (void *) table->CmdBeginQuery; |
| 332 | if (!strcmp(name, "CmdEndQuery")) |
| 333 | return (void *) table->CmdEndQuery; |
| 334 | if (!strcmp(name, "CmdResetQueryPool")) |
| 335 | return (void *) table->CmdResetQueryPool; |
| 336 | if (!strcmp(name, "CmdWriteTimestamp")) |
| 337 | return (void *) table->CmdWriteTimestamp; |
| 338 | if (!strcmp(name, "CmdCopyQueryPoolResults")) |
| 339 | return (void *) table->CmdCopyQueryPoolResults; |
Jon Ashburn | d55a394 | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 340 | if (!strcmp(name, "CreateFramebuffer")) |
| 341 | return (void *) table->CreateFramebuffer; |
| 342 | if (!strcmp(name, "CreateRenderPass")) |
| 343 | return (void *) table->CreateRenderPass; |
| 344 | if (!strcmp(name, "CmdBeginRenderPass")) |
| 345 | return (void *) table->CmdBeginRenderPass; |
| 346 | if (!strcmp(name, "CmdEndRenderPass")) |
| 347 | return (void *) table->CmdEndRenderPass; |
Jon Ashburn | d55a394 | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 348 | |
| 349 | return NULL; |
| 350 | } |
Jon Ashburn | fbb4e25 | 2015-05-04 16:27:53 -0600 | [diff] [blame] | 351 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 352 | static inline void loader_init_instance_core_dispatch_table(VkLayerInstanceDispatchTable *table, |
Jon Ashburn | 27cd584 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 353 | PFN_vkGetInstanceProcAddr gpa, |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 354 | VkInstance inst_next, |
Jon Ashburn | 27cd584 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 355 | VkInstance inst) |
Jon Ashburn | fbb4e25 | 2015-05-04 16:27:53 -0600 | [diff] [blame] | 356 | { |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 357 | // If layer is next, this will trigger layers to initialize their dispatch tables |
| 358 | //then use the gpa in their dispatch for subsequent layers in the chain |
| 359 | table->GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) gpa(inst_next, "vkGetInstanceProcAddr"); |
| 360 | |
Jon Ashburn | 27cd584 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 361 | table->CreateInstance = (PFN_vkCreateInstance) gpa(inst, "vkCreateInstance"); |
| 362 | table->DestroyInstance = (PFN_vkDestroyInstance) gpa(inst, "vkDestroyInstance"); |
| 363 | table->EnumeratePhysicalDevices = (PFN_vkEnumeratePhysicalDevices) gpa(inst, "vkEnumeratePhysicalDevices"); |
Chris Forbes | bc0bb77 | 2015-06-21 22:55:02 +1200 | [diff] [blame] | 364 | table->GetPhysicalDeviceFeatures = (PFN_vkGetPhysicalDeviceFeatures) gpa(inst, "vkGetPhysicalDeviceFeatures"); |
| 365 | table->GetPhysicalDeviceFormatInfo = (PFN_vkGetPhysicalDeviceFormatInfo) gpa(inst, "vkGetPhysicalDeviceFormatInfo"); |
| 366 | table->GetPhysicalDeviceLimits = (PFN_vkGetPhysicalDeviceLimits) gpa(inst, "vkGetPhysicalDeviceLimits"); |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 367 | table->GetPhysicalDeviceProperties = (PFN_vkGetPhysicalDeviceProperties) gpa(inst, "vkGetPhysicalDeviceProperties"); |
| 368 | table->GetPhysicalDevicePerformance = (PFN_vkGetPhysicalDevicePerformance) gpa(inst, "vkGetPhysicalDevicePerformance"); |
| 369 | table->GetPhysicalDeviceQueueCount = (PFN_vkGetPhysicalDeviceQueueCount) gpa(inst, "vkGetPhysicalDeviceQueueCount"); |
| 370 | table->GetPhysicalDeviceQueueProperties = (PFN_vkGetPhysicalDeviceQueueProperties) gpa(inst, "vkGetPhysicalDeviceQueueProperties"); |
| 371 | table->GetPhysicalDeviceMemoryProperties = (PFN_vkGetPhysicalDeviceMemoryProperties) gpa(inst, "vkGetPhysicalDeviceMemoryProperties"); |
| 372 | table->GetPhysicalDeviceExtensionProperties = (PFN_vkGetPhysicalDeviceExtensionProperties) gpa(inst, "vkGetPhysicalDeviceExtensionProperties"); |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame^] | 373 | table->GetPhysicalDeviceLayerProperties = (PFN_vkGetPhysicalDeviceLayerProperties) gpa(inst, "vkGetPhysicalDeviceLayerProperties"); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 374 | } |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 375 | |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 376 | static inline void loader_init_instance_extension_dispatch_table( |
| 377 | VkLayerInstanceDispatchTable *table, |
| 378 | PFN_vkGetInstanceProcAddr gpa, |
| 379 | VkInstance inst) |
| 380 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 381 | table->DbgCreateMsgCallback = (PFN_vkDbgCreateMsgCallback) gpa(inst, "vkDbgCreateMsgCallback"); |
| 382 | table->DbgDestroyMsgCallback = (PFN_vkDbgDestroyMsgCallback) gpa(inst, "vkDbgDestroyMsgCallback"); |
Jon Ashburn | fbb4e25 | 2015-05-04 16:27:53 -0600 | [diff] [blame] | 383 | } |
Jon Ashburn | 27cd584 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 384 | |
| 385 | static inline void *loader_lookup_instance_dispatch_table( |
| 386 | const VkLayerInstanceDispatchTable *table, |
| 387 | const char *name) |
| 388 | { |
| 389 | if (!name || name[0] != 'v' || name[1] != 'k') |
| 390 | return NULL; |
| 391 | |
| 392 | name += 2; |
| 393 | if (!strcmp(name, "CreateInstance")) |
| 394 | return (void *) table->CreateInstance; |
| 395 | if (!strcmp(name, "DestroyInstance")) |
| 396 | return (void *) table->DestroyInstance; |
| 397 | if (!strcmp(name, "EnumeratePhysicalDevices")) |
| 398 | return (void *) table->EnumeratePhysicalDevices; |
Chris Forbes | bc0bb77 | 2015-06-21 22:55:02 +1200 | [diff] [blame] | 399 | if (!strcmp(name, "GetPhysicalDeviceFeatures")) |
| 400 | return (void *) table->GetPhysicalDeviceFeatures; |
| 401 | if (!strcmp(name, "GetPhysicalDeviceFormatInfo")) |
| 402 | return (void *) table->GetPhysicalDeviceFormatInfo; |
| 403 | if (!strcmp(name, "GetPhysicalDeviceLimits")) |
| 404 | return (void *) table->GetPhysicalDeviceLimits; |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 405 | if (!strcmp(name, "GetPhysicalDeviceProperties")) |
| 406 | return (void *) table->GetPhysicalDeviceProperties; |
| 407 | if (!strcmp(name, "GetPhysicalDevicePerformance")) |
| 408 | return (void *) table->GetPhysicalDevicePerformance; |
| 409 | if (!strcmp(name, "GetPhysicalDeviceQueueCount")) |
| 410 | return (void *) table->GetPhysicalDeviceQueueCount; |
| 411 | if (!strcmp(name, "GetPhysicalDeviceQueueProperties")) |
| 412 | return (void *) table->GetPhysicalDeviceQueueProperties; |
| 413 | if (!strcmp(name, "GetPhysicalDeviceMemoryProperties")) |
| 414 | return (void *) table->GetPhysicalDeviceMemoryProperties; |
Jon Ashburn | 27cd584 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 415 | if (!strcmp(name, "GetInstanceProcAddr")) |
| 416 | return (void *) table->GetInstanceProcAddr; |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 417 | if (!strcmp(name, "GetPhysicalDeviceExtensionProperties")) |
| 418 | return (void *) table->GetPhysicalDeviceExtensionProperties; |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame^] | 419 | if (!strcmp(name, "GetPhysicalDeviceLayerProperties")) |
| 420 | return (void *) table->GetPhysicalDeviceLayerProperties; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 421 | if (!strcmp(name, "DbgCreateMsgCallback")) |
| 422 | return (void *) table->DbgCreateMsgCallback; |
| 423 | if (!strcmp(name, "DbgDestroyMsgCallback")) |
| 424 | return (void *) table->DbgDestroyMsgCallback; |
| 425 | |
Jon Ashburn | 27cd584 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 426 | return NULL; |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 427 | } |