• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 // This file is ***GENERATED***.  Do Not Edit.
3 // See layer_chassis_dispatch_generator.py for modifications.
4 
5 /* Copyright (c) 2015-2019 The Khronos Group Inc.
6  * Copyright (c) 2015-2019 Valve Corporation
7  * Copyright (c) 2015-2019 LunarG, Inc.
8  * Copyright (c) 2015-2019 Google Inc.
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  *     http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  * Author: Mark Lobodzinski <mark@lunarg.com>
23  */
24 
25 #include <mutex>
26 #include "chassis.h"
27 #include "layer_chassis_dispatch.h"
28 #include "vk_layer_utils.h"
29 
30 // This intentionally includes a cpp file
31 #include "vk_safe_struct.cpp"
32 
33 // shared_mutex support added in MSVC 2015 update 2
34 #if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023918 && NTDDI_VERSION > NTDDI_WIN10_RS2
35     #include <shared_mutex>
36     typedef std::shared_mutex dispatch_lock_t;
37     typedef std::shared_lock<dispatch_lock_t> read_dispatch_lock_guard_t;
38     typedef std::unique_lock<dispatch_lock_t> write_dispatch_lock_guard_t;
39 #else
40     typedef std::mutex dispatch_lock_t;
41     typedef std::unique_lock<dispatch_lock_t> read_dispatch_lock_guard_t;
42     typedef std::unique_lock<dispatch_lock_t> write_dispatch_lock_guard_t;
43 #endif
44 dispatch_lock_t dispatch_lock;
45 
46 // Unique Objects pNext extension handling function
WrapPnextChainHandles(ValidationObject * layer_data,const void * pNext)47 void WrapPnextChainHandles(ValidationObject *layer_data, const void *pNext) {
48     void *cur_pnext = const_cast<void *>(pNext);
49     while (cur_pnext != NULL) {
50         VkBaseOutStructure *header = reinterpret_cast<VkBaseOutStructure *>(cur_pnext);
51 
52         switch (header->sType) {
53 #ifdef VK_USE_PLATFORM_WIN32_KHR
54             case VK_STRUCTURE_TYPE_WIN32_KEYED_MUTEX_ACQUIRE_RELEASE_INFO_KHR: {
55                     safe_VkWin32KeyedMutexAcquireReleaseInfoKHR *safe_struct = reinterpret_cast<safe_VkWin32KeyedMutexAcquireReleaseInfoKHR *>(cur_pnext);
56                     if (safe_struct->pAcquireSyncs) {
57                         for (uint32_t index0 = 0; index0 < safe_struct->acquireCount; ++index0) {
58                             safe_struct->pAcquireSyncs[index0] = layer_data->Unwrap(safe_struct->pAcquireSyncs[index0]);
59                         }
60                     }
61                     if (safe_struct->pReleaseSyncs) {
62                         for (uint32_t index0 = 0; index0 < safe_struct->releaseCount; ++index0) {
63                             safe_struct->pReleaseSyncs[index0] = layer_data->Unwrap(safe_struct->pReleaseSyncs[index0]);
64                         }
65                     }
66                 } break;
67 #endif // VK_USE_PLATFORM_WIN32_KHR
68 
69 #ifdef VK_USE_PLATFORM_WIN32_KHR
70             case VK_STRUCTURE_TYPE_WIN32_KEYED_MUTEX_ACQUIRE_RELEASE_INFO_NV: {
71                     safe_VkWin32KeyedMutexAcquireReleaseInfoNV *safe_struct = reinterpret_cast<safe_VkWin32KeyedMutexAcquireReleaseInfoNV *>(cur_pnext);
72                     if (safe_struct->pAcquireSyncs) {
73                         for (uint32_t index0 = 0; index0 < safe_struct->acquireCount; ++index0) {
74                             safe_struct->pAcquireSyncs[index0] = layer_data->Unwrap(safe_struct->pAcquireSyncs[index0]);
75                         }
76                     }
77                     if (safe_struct->pReleaseSyncs) {
78                         for (uint32_t index0 = 0; index0 < safe_struct->releaseCount; ++index0) {
79                             safe_struct->pReleaseSyncs[index0] = layer_data->Unwrap(safe_struct->pReleaseSyncs[index0]);
80                         }
81                     }
82                 } break;
83 #endif // VK_USE_PLATFORM_WIN32_KHR
84 
85             case VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV: {
86                     safe_VkDedicatedAllocationMemoryAllocateInfoNV *safe_struct = reinterpret_cast<safe_VkDedicatedAllocationMemoryAllocateInfoNV *>(cur_pnext);
87                     if (safe_struct->image) {
88                         safe_struct->image = layer_data->Unwrap(safe_struct->image);
89                     }
90                     if (safe_struct->buffer) {
91                         safe_struct->buffer = layer_data->Unwrap(safe_struct->buffer);
92                     }
93                 } break;
94 
95             case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO: {
96                     safe_VkMemoryDedicatedAllocateInfo *safe_struct = reinterpret_cast<safe_VkMemoryDedicatedAllocateInfo *>(cur_pnext);
97                     if (safe_struct->image) {
98                         safe_struct->image = layer_data->Unwrap(safe_struct->image);
99                     }
100                     if (safe_struct->buffer) {
101                         safe_struct->buffer = layer_data->Unwrap(safe_struct->buffer);
102                     }
103                 } break;
104 
105             case VK_STRUCTURE_TYPE_IMAGE_SWAPCHAIN_CREATE_INFO_KHR: {
106                     safe_VkImageSwapchainCreateInfoKHR *safe_struct = reinterpret_cast<safe_VkImageSwapchainCreateInfoKHR *>(cur_pnext);
107                     if (safe_struct->swapchain) {
108                         safe_struct->swapchain = layer_data->Unwrap(safe_struct->swapchain);
109                     }
110                 } break;
111 
112             case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO: {
113                     safe_VkSamplerYcbcrConversionInfo *safe_struct = reinterpret_cast<safe_VkSamplerYcbcrConversionInfo *>(cur_pnext);
114                     if (safe_struct->conversion) {
115                         safe_struct->conversion = layer_data->Unwrap(safe_struct->conversion);
116                     }
117                 } break;
118 
119             case VK_STRUCTURE_TYPE_SHADER_MODULE_VALIDATION_CACHE_CREATE_INFO_EXT: {
120                     safe_VkShaderModuleValidationCacheCreateInfoEXT *safe_struct = reinterpret_cast<safe_VkShaderModuleValidationCacheCreateInfoEXT *>(cur_pnext);
121                     if (safe_struct->validationCache) {
122                         safe_struct->validationCache = layer_data->Unwrap(safe_struct->validationCache);
123                     }
124                 } break;
125 
126             case VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_NV: {
127                     safe_VkWriteDescriptorSetAccelerationStructureNV *safe_struct = reinterpret_cast<safe_VkWriteDescriptorSetAccelerationStructureNV *>(cur_pnext);
128                     if (safe_struct->pAccelerationStructures) {
129                         for (uint32_t index0 = 0; index0 < safe_struct->accelerationStructureCount; ++index0) {
130                             safe_struct->pAccelerationStructures[index0] = layer_data->Unwrap(safe_struct->pAccelerationStructures[index0]);
131                         }
132                     }
133                 } break;
134 
135             case VK_STRUCTURE_TYPE_RENDER_PASS_ATTACHMENT_BEGIN_INFO_KHR: {
136                     safe_VkRenderPassAttachmentBeginInfoKHR *safe_struct = reinterpret_cast<safe_VkRenderPassAttachmentBeginInfoKHR *>(cur_pnext);
137                     if (safe_struct->pAttachments) {
138                         for (uint32_t index0 = 0; index0 < safe_struct->attachmentCount; ++index0) {
139                             safe_struct->pAttachments[index0] = layer_data->Unwrap(safe_struct->pAttachments[index0]);
140                         }
141                     }
142                 } break;
143 
144             case VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR: {
145                     safe_VkBindImageMemorySwapchainInfoKHR *safe_struct = reinterpret_cast<safe_VkBindImageMemorySwapchainInfoKHR *>(cur_pnext);
146                     if (safe_struct->swapchain) {
147                         safe_struct->swapchain = layer_data->Unwrap(safe_struct->swapchain);
148                     }
149                 } break;
150 
151             default:
152                 break;
153         }
154 
155         // Process the next structure in the chain
156         cur_pnext = header->pNext;
157     }
158 }
159 
160 
161 // Manually written Dispatch routines
162 
DispatchCreateComputePipelines(VkDevice device,VkPipelineCache pipelineCache,uint32_t createInfoCount,const VkComputePipelineCreateInfo * pCreateInfos,const VkAllocationCallbacks * pAllocator,VkPipeline * pPipelines)163 VkResult DispatchCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
164                                         const VkComputePipelineCreateInfo *pCreateInfos,
165                                         const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) {
166     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
167     if (!wrap_handles) return layer_data->device_dispatch_table.CreateComputePipelines(device, pipelineCache, createInfoCount,
168                                                                                           pCreateInfos, pAllocator, pPipelines);
169     safe_VkComputePipelineCreateInfo *local_pCreateInfos = NULL;
170     if (pCreateInfos) {
171         local_pCreateInfos = new safe_VkComputePipelineCreateInfo[createInfoCount];
172         for (uint32_t idx0 = 0; idx0 < createInfoCount; ++idx0) {
173             local_pCreateInfos[idx0].initialize(&pCreateInfos[idx0]);
174             if (pCreateInfos[idx0].basePipelineHandle) {
175                 local_pCreateInfos[idx0].basePipelineHandle = layer_data->Unwrap(pCreateInfos[idx0].basePipelineHandle);
176             }
177             if (pCreateInfos[idx0].layout) {
178                 local_pCreateInfos[idx0].layout = layer_data->Unwrap(pCreateInfos[idx0].layout);
179             }
180             if (pCreateInfos[idx0].stage.module) {
181                 local_pCreateInfos[idx0].stage.module = layer_data->Unwrap(pCreateInfos[idx0].stage.module);
182             }
183         }
184     }
185     if (pipelineCache) {
186         pipelineCache = layer_data->Unwrap(pipelineCache);
187     }
188 
189     VkResult result = layer_data->device_dispatch_table.CreateComputePipelines(device, pipelineCache, createInfoCount,
190                                                                                local_pCreateInfos->ptr(), pAllocator, pPipelines);
191     delete[] local_pCreateInfos;
192     {
193         for (uint32_t i = 0; i < createInfoCount; ++i) {
194             if (pPipelines[i] != VK_NULL_HANDLE) {
195                 pPipelines[i] = layer_data->WrapNew(pPipelines[i]);
196             }
197         }
198     }
199     return result;
200 }
201 
DispatchCreateGraphicsPipelines(VkDevice device,VkPipelineCache pipelineCache,uint32_t createInfoCount,const VkGraphicsPipelineCreateInfo * pCreateInfos,const VkAllocationCallbacks * pAllocator,VkPipeline * pPipelines)202 VkResult DispatchCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
203                                          const VkGraphicsPipelineCreateInfo *pCreateInfos,
204                                          const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) {
205     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
206     if (!wrap_handles) return layer_data->device_dispatch_table.CreateGraphicsPipelines(device, pipelineCache, createInfoCount,
207                                                                                            pCreateInfos, pAllocator, pPipelines);
208     safe_VkGraphicsPipelineCreateInfo *local_pCreateInfos = nullptr;
209     if (pCreateInfos) {
210         local_pCreateInfos = new safe_VkGraphicsPipelineCreateInfo[createInfoCount];
211         read_dispatch_lock_guard_t lock(dispatch_lock);
212         for (uint32_t idx0 = 0; idx0 < createInfoCount; ++idx0) {
213             bool uses_color_attachment = false;
214             bool uses_depthstencil_attachment = false;
215             {
216                 const auto subpasses_uses_it = layer_data->renderpasses_states.find(layer_data->Unwrap(pCreateInfos[idx0].renderPass));
217                 if (subpasses_uses_it != layer_data->renderpasses_states.end()) {
218                     const auto &subpasses_uses = subpasses_uses_it->second;
219                     if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[idx0].subpass))
220                         uses_color_attachment = true;
221                     if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[idx0].subpass))
222                         uses_depthstencil_attachment = true;
223                 }
224             }
225 
226             local_pCreateInfos[idx0].initialize(&pCreateInfos[idx0], uses_color_attachment, uses_depthstencil_attachment);
227 
228             if (pCreateInfos[idx0].basePipelineHandle) {
229                 local_pCreateInfos[idx0].basePipelineHandle = layer_data->Unwrap(pCreateInfos[idx0].basePipelineHandle);
230             }
231             if (pCreateInfos[idx0].layout) {
232                 local_pCreateInfos[idx0].layout = layer_data->Unwrap(pCreateInfos[idx0].layout);
233             }
234             if (pCreateInfos[idx0].pStages) {
235                 for (uint32_t idx1 = 0; idx1 < pCreateInfos[idx0].stageCount; ++idx1) {
236                     if (pCreateInfos[idx0].pStages[idx1].module) {
237                         local_pCreateInfos[idx0].pStages[idx1].module = layer_data->Unwrap(pCreateInfos[idx0].pStages[idx1].module);
238                     }
239                 }
240             }
241             if (pCreateInfos[idx0].renderPass) {
242                 local_pCreateInfos[idx0].renderPass = layer_data->Unwrap(pCreateInfos[idx0].renderPass);
243             }
244         }
245     }
246     if (pipelineCache) {
247         pipelineCache = layer_data->Unwrap(pipelineCache);
248     }
249 
250     VkResult result = layer_data->device_dispatch_table.CreateGraphicsPipelines(device, pipelineCache, createInfoCount,
251                                                                                 local_pCreateInfos->ptr(), pAllocator, pPipelines);
252     delete[] local_pCreateInfos;
253     {
254         for (uint32_t i = 0; i < createInfoCount; ++i) {
255             if (pPipelines[i] != VK_NULL_HANDLE) {
256                 pPipelines[i] = layer_data->WrapNew(pPipelines[i]);
257             }
258         }
259     }
260     return result;
261 }
262 
263 template <typename T>
UpdateCreateRenderPassState(ValidationObject * layer_data,const T * pCreateInfo,VkRenderPass renderPass)264 static void UpdateCreateRenderPassState(ValidationObject *layer_data, const T *pCreateInfo, VkRenderPass renderPass) {
265     auto &renderpass_state = layer_data->renderpasses_states[renderPass];
266 
267     for (uint32_t subpass = 0; subpass < pCreateInfo->subpassCount; ++subpass) {
268         bool uses_color = false;
269         for (uint32_t i = 0; i < pCreateInfo->pSubpasses[subpass].colorAttachmentCount && !uses_color; ++i)
270             if (pCreateInfo->pSubpasses[subpass].pColorAttachments[i].attachment != VK_ATTACHMENT_UNUSED) uses_color = true;
271 
272         bool uses_depthstencil = false;
273         if (pCreateInfo->pSubpasses[subpass].pDepthStencilAttachment)
274             if (pCreateInfo->pSubpasses[subpass].pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED)
275                 uses_depthstencil = true;
276 
277         if (uses_color) renderpass_state.subpasses_using_color_attachment.insert(subpass);
278         if (uses_depthstencil) renderpass_state.subpasses_using_depthstencil_attachment.insert(subpass);
279     }
280 }
281 
DispatchCreateRenderPass(VkDevice device,const VkRenderPassCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkRenderPass * pRenderPass)282 VkResult DispatchCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
283                                   const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass) {
284     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
285     VkResult result = layer_data->device_dispatch_table.CreateRenderPass(device, pCreateInfo, pAllocator, pRenderPass);
286     if (!wrap_handles) return result;
287     if (VK_SUCCESS == result) {
288         write_dispatch_lock_guard_t lock(dispatch_lock);
289         UpdateCreateRenderPassState(layer_data, pCreateInfo, *pRenderPass);
290         *pRenderPass = layer_data->WrapNew(*pRenderPass);
291     }
292     return result;
293 }
294 
DispatchCreateRenderPass2KHR(VkDevice device,const VkRenderPassCreateInfo2KHR * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkRenderPass * pRenderPass)295 VkResult DispatchCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
296                                       const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass) {
297     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
298     VkResult result = layer_data->device_dispatch_table.CreateRenderPass2KHR(device, pCreateInfo, pAllocator, pRenderPass);
299     if (!wrap_handles) return result;
300     if (VK_SUCCESS == result) {
301         write_dispatch_lock_guard_t lock(dispatch_lock);
302         UpdateCreateRenderPassState(layer_data, pCreateInfo, *pRenderPass);
303         *pRenderPass = layer_data->WrapNew(*pRenderPass);
304     }
305     return result;
306 }
307 
DispatchDestroyRenderPass(VkDevice device,VkRenderPass renderPass,const VkAllocationCallbacks * pAllocator)308 void DispatchDestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks *pAllocator) {
309     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
310     if (!wrap_handles) return layer_data->device_dispatch_table.DestroyRenderPass(device, renderPass, pAllocator);
311     uint64_t renderPass_id = reinterpret_cast<uint64_t &>(renderPass);
312 
313     auto iter = unique_id_mapping.pop(renderPass_id);
314     if (iter != unique_id_mapping.end()) {
315         renderPass = (VkRenderPass)iter->second;
316     } else {
317         renderPass = (VkRenderPass)0;
318     }
319 
320     layer_data->device_dispatch_table.DestroyRenderPass(device, renderPass, pAllocator);
321 
322     write_dispatch_lock_guard_t lock(dispatch_lock);
323     layer_data->renderpasses_states.erase(renderPass);
324 }
325 
DispatchCreateSwapchainKHR(VkDevice device,const VkSwapchainCreateInfoKHR * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSwapchainKHR * pSwapchain)326 VkResult DispatchCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
327                                     const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain) {
328     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
329     if (!wrap_handles) return layer_data->device_dispatch_table.CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain);
330     safe_VkSwapchainCreateInfoKHR *local_pCreateInfo = NULL;
331     if (pCreateInfo) {
332         local_pCreateInfo = new safe_VkSwapchainCreateInfoKHR(pCreateInfo);
333         local_pCreateInfo->oldSwapchain = layer_data->Unwrap(pCreateInfo->oldSwapchain);
334         // Surface is instance-level object
335         local_pCreateInfo->surface = layer_data->Unwrap(pCreateInfo->surface);
336     }
337 
338     VkResult result = layer_data->device_dispatch_table.CreateSwapchainKHR(device, local_pCreateInfo->ptr(), pAllocator, pSwapchain);
339     delete local_pCreateInfo;
340 
341     if (VK_SUCCESS == result) {
342         *pSwapchain = layer_data->WrapNew(*pSwapchain);
343     }
344     return result;
345 }
346 
DispatchCreateSharedSwapchainsKHR(VkDevice device,uint32_t swapchainCount,const VkSwapchainCreateInfoKHR * pCreateInfos,const VkAllocationCallbacks * pAllocator,VkSwapchainKHR * pSwapchains)347 VkResult DispatchCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount, const VkSwapchainCreateInfoKHR *pCreateInfos,
348                                            const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchains) {
349     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
350     if (!wrap_handles)
351         return layer_data->device_dispatch_table.CreateSharedSwapchainsKHR(device, swapchainCount, pCreateInfos, pAllocator,
352                                                                            pSwapchains);
353     safe_VkSwapchainCreateInfoKHR *local_pCreateInfos = NULL;
354     {
355         if (pCreateInfos) {
356             local_pCreateInfos = new safe_VkSwapchainCreateInfoKHR[swapchainCount];
357             for (uint32_t i = 0; i < swapchainCount; ++i) {
358                 local_pCreateInfos[i].initialize(&pCreateInfos[i]);
359                 if (pCreateInfos[i].surface) {
360                     // Surface is instance-level object
361                     local_pCreateInfos[i].surface = layer_data->Unwrap(pCreateInfos[i].surface);
362                 }
363                 if (pCreateInfos[i].oldSwapchain) {
364                     local_pCreateInfos[i].oldSwapchain = layer_data->Unwrap(pCreateInfos[i].oldSwapchain);
365                 }
366             }
367         }
368     }
369     VkResult result = layer_data->device_dispatch_table.CreateSharedSwapchainsKHR(device, swapchainCount, local_pCreateInfos->ptr(),
370                                                                                   pAllocator, pSwapchains);
371     delete[] local_pCreateInfos;
372     if (VK_SUCCESS == result) {
373         for (uint32_t i = 0; i < swapchainCount; i++) {
374             pSwapchains[i] = layer_data->WrapNew(pSwapchains[i]);
375         }
376     }
377     return result;
378 }
379 
DispatchGetSwapchainImagesKHR(VkDevice device,VkSwapchainKHR swapchain,uint32_t * pSwapchainImageCount,VkImage * pSwapchainImages)380 VkResult DispatchGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount,
381                                        VkImage *pSwapchainImages) {
382     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
383     if (!wrap_handles)
384         return layer_data->device_dispatch_table.GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages);
385     VkSwapchainKHR wrapped_swapchain_handle = swapchain;
386     if (VK_NULL_HANDLE != swapchain) {
387         swapchain = layer_data->Unwrap(swapchain);
388     }
389     VkResult result =
390         layer_data->device_dispatch_table.GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages);
391     if ((VK_SUCCESS == result) || (VK_INCOMPLETE == result)) {
392         if ((*pSwapchainImageCount > 0) && pSwapchainImages) {
393             write_dispatch_lock_guard_t lock(dispatch_lock);
394             auto &wrapped_swapchain_image_handles = layer_data->swapchain_wrapped_image_handle_map[wrapped_swapchain_handle];
395             for (uint32_t i = static_cast<uint32_t>(wrapped_swapchain_image_handles.size()); i < *pSwapchainImageCount; i++) {
396                 wrapped_swapchain_image_handles.emplace_back(layer_data->WrapNew(pSwapchainImages[i]));
397             }
398             for (uint32_t i = 0; i < *pSwapchainImageCount; i++) {
399                 pSwapchainImages[i] = wrapped_swapchain_image_handles[i];
400             }
401         }
402     }
403     return result;
404 }
405 
DispatchDestroySwapchainKHR(VkDevice device,VkSwapchainKHR swapchain,const VkAllocationCallbacks * pAllocator)406 void DispatchDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks *pAllocator) {
407     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
408     if (!wrap_handles) return layer_data->device_dispatch_table.DestroySwapchainKHR(device, swapchain, pAllocator);
409     write_dispatch_lock_guard_t lock(dispatch_lock);
410 
411     auto &image_array = layer_data->swapchain_wrapped_image_handle_map[swapchain];
412     for (auto &image_handle : image_array) {
413         unique_id_mapping.erase(HandleToUint64(image_handle));
414     }
415     layer_data->swapchain_wrapped_image_handle_map.erase(swapchain);
416     lock.unlock();
417 
418     uint64_t swapchain_id = HandleToUint64(swapchain);
419 
420     auto iter = unique_id_mapping.pop(swapchain_id);
421     if (iter != unique_id_mapping.end()) {
422         swapchain = (VkSwapchainKHR)iter->second;
423     } else {
424         swapchain = (VkSwapchainKHR)0;
425     }
426 
427     layer_data->device_dispatch_table.DestroySwapchainKHR(device, swapchain, pAllocator);
428 }
429 
DispatchQueuePresentKHR(VkQueue queue,const VkPresentInfoKHR * pPresentInfo)430 VkResult DispatchQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) {
431     auto layer_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map);
432     if (!wrap_handles) return layer_data->device_dispatch_table.QueuePresentKHR(queue, pPresentInfo);
433     safe_VkPresentInfoKHR *local_pPresentInfo = NULL;
434     {
435         if (pPresentInfo) {
436             local_pPresentInfo = new safe_VkPresentInfoKHR(pPresentInfo);
437             if (local_pPresentInfo->pWaitSemaphores) {
438                 for (uint32_t index1 = 0; index1 < local_pPresentInfo->waitSemaphoreCount; ++index1) {
439                     local_pPresentInfo->pWaitSemaphores[index1] = layer_data->Unwrap(pPresentInfo->pWaitSemaphores[index1]);
440                 }
441             }
442             if (local_pPresentInfo->pSwapchains) {
443                 for (uint32_t index1 = 0; index1 < local_pPresentInfo->swapchainCount; ++index1) {
444                     local_pPresentInfo->pSwapchains[index1] = layer_data->Unwrap(pPresentInfo->pSwapchains[index1]);
445                 }
446             }
447         }
448     }
449     VkResult result = layer_data->device_dispatch_table.QueuePresentKHR(queue, local_pPresentInfo->ptr());
450 
451     // pResults is an output array embedded in a structure. The code generator neglects to copy back from the safe_* version,
452     // so handle it as a special case here:
453     if (pPresentInfo && pPresentInfo->pResults) {
454         for (uint32_t i = 0; i < pPresentInfo->swapchainCount; i++) {
455             pPresentInfo->pResults[i] = local_pPresentInfo->pResults[i];
456         }
457     }
458     delete local_pPresentInfo;
459     return result;
460 }
461 
DispatchDestroyDescriptorPool(VkDevice device,VkDescriptorPool descriptorPool,const VkAllocationCallbacks * pAllocator)462 void DispatchDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks *pAllocator) {
463     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
464     if (!wrap_handles) return layer_data->device_dispatch_table.DestroyDescriptorPool(device, descriptorPool, pAllocator);
465     write_dispatch_lock_guard_t lock(dispatch_lock);
466 
467     // remove references to implicitly freed descriptor sets
468     for(auto descriptor_set : layer_data->pool_descriptor_sets_map[descriptorPool]) {
469         unique_id_mapping.erase(reinterpret_cast<uint64_t &>(descriptor_set));
470     }
471     layer_data->pool_descriptor_sets_map.erase(descriptorPool);
472     lock.unlock();
473 
474     uint64_t descriptorPool_id = reinterpret_cast<uint64_t &>(descriptorPool);
475 
476     auto iter = unique_id_mapping.pop(descriptorPool_id);
477     if (iter != unique_id_mapping.end()) {
478         descriptorPool = (VkDescriptorPool)iter->second;
479     } else {
480         descriptorPool = (VkDescriptorPool)0;
481     }
482 
483     layer_data->device_dispatch_table.DestroyDescriptorPool(device, descriptorPool, pAllocator);
484 }
485 
DispatchResetDescriptorPool(VkDevice device,VkDescriptorPool descriptorPool,VkDescriptorPoolResetFlags flags)486 VkResult DispatchResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags) {
487     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
488     if (!wrap_handles) return layer_data->device_dispatch_table.ResetDescriptorPool(device, descriptorPool, flags);
489     VkDescriptorPool local_descriptor_pool = VK_NULL_HANDLE;
490     {
491         local_descriptor_pool = layer_data->Unwrap(descriptorPool);
492     }
493     VkResult result = layer_data->device_dispatch_table.ResetDescriptorPool(device, local_descriptor_pool, flags);
494     if (VK_SUCCESS == result) {
495         write_dispatch_lock_guard_t lock(dispatch_lock);
496         // remove references to implicitly freed descriptor sets
497         for(auto descriptor_set : layer_data->pool_descriptor_sets_map[descriptorPool]) {
498             unique_id_mapping.erase(reinterpret_cast<uint64_t &>(descriptor_set));
499         }
500         layer_data->pool_descriptor_sets_map[descriptorPool].clear();
501     }
502 
503     return result;
504 }
505 
DispatchAllocateDescriptorSets(VkDevice device,const VkDescriptorSetAllocateInfo * pAllocateInfo,VkDescriptorSet * pDescriptorSets)506 VkResult DispatchAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo,
507                                         VkDescriptorSet *pDescriptorSets) {
508     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
509     if (!wrap_handles) return layer_data->device_dispatch_table.AllocateDescriptorSets(device, pAllocateInfo, pDescriptorSets);
510     safe_VkDescriptorSetAllocateInfo *local_pAllocateInfo = NULL;
511     {
512         if (pAllocateInfo) {
513             local_pAllocateInfo = new safe_VkDescriptorSetAllocateInfo(pAllocateInfo);
514             if (pAllocateInfo->descriptorPool) {
515                 local_pAllocateInfo->descriptorPool = layer_data->Unwrap(pAllocateInfo->descriptorPool);
516             }
517             if (local_pAllocateInfo->pSetLayouts) {
518                 for (uint32_t index1 = 0; index1 < local_pAllocateInfo->descriptorSetCount; ++index1) {
519                     local_pAllocateInfo->pSetLayouts[index1] = layer_data->Unwrap(local_pAllocateInfo->pSetLayouts[index1]);
520                 }
521             }
522         }
523     }
524     VkResult result = layer_data->device_dispatch_table.AllocateDescriptorSets(
525         device, (const VkDescriptorSetAllocateInfo *)local_pAllocateInfo, pDescriptorSets);
526     if (local_pAllocateInfo) {
527         delete local_pAllocateInfo;
528     }
529     if (VK_SUCCESS == result) {
530         write_dispatch_lock_guard_t lock(dispatch_lock);
531         auto &pool_descriptor_sets = layer_data->pool_descriptor_sets_map[pAllocateInfo->descriptorPool];
532         for (uint32_t index0 = 0; index0 < pAllocateInfo->descriptorSetCount; index0++) {
533             pDescriptorSets[index0] = layer_data->WrapNew(pDescriptorSets[index0]);
534             pool_descriptor_sets.insert(pDescriptorSets[index0]);
535         }
536     }
537     return result;
538 }
539 
DispatchFreeDescriptorSets(VkDevice device,VkDescriptorPool descriptorPool,uint32_t descriptorSetCount,const VkDescriptorSet * pDescriptorSets)540 VkResult DispatchFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount,
541                                     const VkDescriptorSet *pDescriptorSets) {
542     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
543     if (!wrap_handles)
544         return layer_data->device_dispatch_table.FreeDescriptorSets(device, descriptorPool, descriptorSetCount, pDescriptorSets);
545     VkDescriptorSet *local_pDescriptorSets = NULL;
546     VkDescriptorPool local_descriptor_pool = VK_NULL_HANDLE;
547     {
548         local_descriptor_pool = layer_data->Unwrap(descriptorPool);
549         if (pDescriptorSets) {
550             local_pDescriptorSets = new VkDescriptorSet[descriptorSetCount];
551             for (uint32_t index0 = 0; index0 < descriptorSetCount; ++index0) {
552                 local_pDescriptorSets[index0] = layer_data->Unwrap(pDescriptorSets[index0]);
553             }
554         }
555     }
556     VkResult result = layer_data->device_dispatch_table.FreeDescriptorSets(device, local_descriptor_pool, descriptorSetCount,
557                                                                            (const VkDescriptorSet *)local_pDescriptorSets);
558     if (local_pDescriptorSets) delete[] local_pDescriptorSets;
559     if ((VK_SUCCESS == result) && (pDescriptorSets)) {
560         write_dispatch_lock_guard_t lock(dispatch_lock);
561         auto &pool_descriptor_sets = layer_data->pool_descriptor_sets_map[descriptorPool];
562         for (uint32_t index0 = 0; index0 < descriptorSetCount; index0++) {
563             VkDescriptorSet handle = pDescriptorSets[index0];
564             pool_descriptor_sets.erase(handle);
565             uint64_t unique_id = reinterpret_cast<uint64_t &>(handle);
566             unique_id_mapping.erase(unique_id);
567         }
568     }
569     return result;
570 }
571 
572 // This is the core version of this routine.  The extension version is below.
DispatchCreateDescriptorUpdateTemplate(VkDevice device,const VkDescriptorUpdateTemplateCreateInfoKHR * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkDescriptorUpdateTemplateKHR * pDescriptorUpdateTemplate)573 VkResult DispatchCreateDescriptorUpdateTemplate(VkDevice device, const VkDescriptorUpdateTemplateCreateInfoKHR *pCreateInfo,
574                                                 const VkAllocationCallbacks *pAllocator,
575                                                 VkDescriptorUpdateTemplateKHR *pDescriptorUpdateTemplate) {
576     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
577     if (!wrap_handles)
578         return layer_data->device_dispatch_table.CreateDescriptorUpdateTemplate(device, pCreateInfo, pAllocator,
579                                                                                 pDescriptorUpdateTemplate);
580     safe_VkDescriptorUpdateTemplateCreateInfo *local_create_info = NULL;
581     {
582         if (pCreateInfo) {
583             local_create_info = new safe_VkDescriptorUpdateTemplateCreateInfo(pCreateInfo);
584             if (pCreateInfo->descriptorSetLayout) {
585                 local_create_info->descriptorSetLayout = layer_data->Unwrap(pCreateInfo->descriptorSetLayout);
586             }
587             if (pCreateInfo->pipelineLayout) {
588                 local_create_info->pipelineLayout = layer_data->Unwrap(pCreateInfo->pipelineLayout);
589             }
590         }
591     }
592     VkResult result = layer_data->device_dispatch_table.CreateDescriptorUpdateTemplate(device, local_create_info->ptr(), pAllocator,
593                                                                                        pDescriptorUpdateTemplate);
594     if (VK_SUCCESS == result) {
595         write_dispatch_lock_guard_t lock(dispatch_lock);
596         *pDescriptorUpdateTemplate = layer_data->WrapNew(*pDescriptorUpdateTemplate);
597 
598         // Shadow template createInfo for later updates
599         std::unique_ptr<TEMPLATE_STATE> template_state(new TEMPLATE_STATE(*pDescriptorUpdateTemplate, local_create_info));
600         layer_data->desc_template_createinfo_map[(uint64_t)*pDescriptorUpdateTemplate] = std::move(template_state);
601     }
602     return result;
603 }
604 
605 // This is the extension version of this routine.  The core version is above.
DispatchCreateDescriptorUpdateTemplateKHR(VkDevice device,const VkDescriptorUpdateTemplateCreateInfoKHR * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkDescriptorUpdateTemplateKHR * pDescriptorUpdateTemplate)606 VkResult DispatchCreateDescriptorUpdateTemplateKHR(VkDevice device, const VkDescriptorUpdateTemplateCreateInfoKHR *pCreateInfo,
607                                                    const VkAllocationCallbacks *pAllocator,
608                                                    VkDescriptorUpdateTemplateKHR *pDescriptorUpdateTemplate) {
609     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
610     if (!wrap_handles)
611         return layer_data->device_dispatch_table.CreateDescriptorUpdateTemplateKHR(device, pCreateInfo, pAllocator,
612                                                                                    pDescriptorUpdateTemplate);
613     safe_VkDescriptorUpdateTemplateCreateInfo *local_create_info = NULL;
614     {
615         if (pCreateInfo) {
616             local_create_info = new safe_VkDescriptorUpdateTemplateCreateInfo(pCreateInfo);
617             if (pCreateInfo->descriptorSetLayout) {
618                 local_create_info->descriptorSetLayout = layer_data->Unwrap(pCreateInfo->descriptorSetLayout);
619             }
620             if (pCreateInfo->pipelineLayout) {
621                 local_create_info->pipelineLayout = layer_data->Unwrap(pCreateInfo->pipelineLayout);
622             }
623         }
624     }
625     VkResult result = layer_data->device_dispatch_table.CreateDescriptorUpdateTemplateKHR(device, local_create_info->ptr(), pAllocator,
626                                                                                           pDescriptorUpdateTemplate);
627     if (VK_SUCCESS == result) {
628         write_dispatch_lock_guard_t lock(dispatch_lock);
629         *pDescriptorUpdateTemplate = layer_data->WrapNew(*pDescriptorUpdateTemplate);
630 
631         // Shadow template createInfo for later updates
632         std::unique_ptr<TEMPLATE_STATE> template_state(new TEMPLATE_STATE(*pDescriptorUpdateTemplate, local_create_info));
633         layer_data->desc_template_createinfo_map[(uint64_t)*pDescriptorUpdateTemplate] = std::move(template_state);
634     }
635     return result;
636 }
637 
638 // This is the core version of this routine.  The extension version is below.
DispatchDestroyDescriptorUpdateTemplate(VkDevice device,VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate,const VkAllocationCallbacks * pAllocator)639 void DispatchDestroyDescriptorUpdateTemplate(VkDevice device, VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate,
640                                              const VkAllocationCallbacks *pAllocator) {
641     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
642     if (!wrap_handles)
643         return layer_data->device_dispatch_table.DestroyDescriptorUpdateTemplate(device, descriptorUpdateTemplate, pAllocator);
644     write_dispatch_lock_guard_t lock(dispatch_lock);
645     uint64_t descriptor_update_template_id = reinterpret_cast<uint64_t &>(descriptorUpdateTemplate);
646     layer_data->desc_template_createinfo_map.erase(descriptor_update_template_id);
647     lock.unlock();
648 
649     auto iter = unique_id_mapping.pop(descriptor_update_template_id);
650     if (iter != unique_id_mapping.end()) {
651         descriptorUpdateTemplate = (VkDescriptorUpdateTemplate)iter->second;
652     } else {
653         descriptorUpdateTemplate = (VkDescriptorUpdateTemplate)0;
654     }
655 
656     layer_data->device_dispatch_table.DestroyDescriptorUpdateTemplate(device, descriptorUpdateTemplate, pAllocator);
657 }
658 
659 // This is the extension version of this routine.  The core version is above.
DispatchDestroyDescriptorUpdateTemplateKHR(VkDevice device,VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate,const VkAllocationCallbacks * pAllocator)660 void DispatchDestroyDescriptorUpdateTemplateKHR(VkDevice device, VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate,
661                                                 const VkAllocationCallbacks *pAllocator) {
662     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
663     if (!wrap_handles)
664         return layer_data->device_dispatch_table.DestroyDescriptorUpdateTemplateKHR(device, descriptorUpdateTemplate, pAllocator);
665     write_dispatch_lock_guard_t lock(dispatch_lock);
666     uint64_t descriptor_update_template_id = reinterpret_cast<uint64_t &>(descriptorUpdateTemplate);
667     layer_data->desc_template_createinfo_map.erase(descriptor_update_template_id);
668     lock.unlock();
669 
670     auto iter = unique_id_mapping.pop(descriptor_update_template_id);
671     if (iter != unique_id_mapping.end()) {
672         descriptorUpdateTemplate = (VkDescriptorUpdateTemplate)iter->second;
673     } else {
674         descriptorUpdateTemplate = (VkDescriptorUpdateTemplate)0;
675     }
676 
677     layer_data->device_dispatch_table.DestroyDescriptorUpdateTemplateKHR(device, descriptorUpdateTemplate, pAllocator);
678 }
679 
BuildUnwrappedUpdateTemplateBuffer(ValidationObject * layer_data,uint64_t descriptorUpdateTemplate,const void * pData)680 void *BuildUnwrappedUpdateTemplateBuffer(ValidationObject *layer_data, uint64_t descriptorUpdateTemplate, const void *pData) {
681     auto const template_map_entry = layer_data->desc_template_createinfo_map.find(descriptorUpdateTemplate);
682     if (template_map_entry == layer_data->desc_template_createinfo_map.end()) {
683         assert(0);
684     }
685     auto const &create_info = template_map_entry->second->create_info;
686     size_t allocation_size = 0;
687     std::vector<std::tuple<size_t, VulkanObjectType, uint64_t, size_t>> template_entries;
688 
689     for (uint32_t i = 0; i < create_info.descriptorUpdateEntryCount; i++) {
690         for (uint32_t j = 0; j < create_info.pDescriptorUpdateEntries[i].descriptorCount; j++) {
691             size_t offset = create_info.pDescriptorUpdateEntries[i].offset + j * create_info.pDescriptorUpdateEntries[i].stride;
692             char *update_entry = (char *)(pData) + offset;
693 
694             switch (create_info.pDescriptorUpdateEntries[i].descriptorType) {
695                 case VK_DESCRIPTOR_TYPE_SAMPLER:
696                 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
697                 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
698                 case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
699                 case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT: {
700                     auto image_entry = reinterpret_cast<VkDescriptorImageInfo *>(update_entry);
701                     allocation_size = std::max(allocation_size, offset + sizeof(VkDescriptorImageInfo));
702 
703                     VkDescriptorImageInfo *wrapped_entry = new VkDescriptorImageInfo(*image_entry);
704                     wrapped_entry->sampler = layer_data->Unwrap(image_entry->sampler);
705                     wrapped_entry->imageView = layer_data->Unwrap(image_entry->imageView);
706                     template_entries.emplace_back(offset, kVulkanObjectTypeImage, CastToUint64(wrapped_entry), 0);
707                 } break;
708 
709                 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
710                 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
711                 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
712                 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: {
713                     auto buffer_entry = reinterpret_cast<VkDescriptorBufferInfo *>(update_entry);
714                     allocation_size = std::max(allocation_size, offset + sizeof(VkDescriptorBufferInfo));
715 
716                     VkDescriptorBufferInfo *wrapped_entry = new VkDescriptorBufferInfo(*buffer_entry);
717                     wrapped_entry->buffer = layer_data->Unwrap(buffer_entry->buffer);
718                     template_entries.emplace_back(offset, kVulkanObjectTypeBuffer, CastToUint64(wrapped_entry), 0);
719                 } break;
720 
721                 case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
722                 case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: {
723                     auto buffer_view_handle = reinterpret_cast<VkBufferView *>(update_entry);
724                     allocation_size = std::max(allocation_size, offset + sizeof(VkBufferView));
725 
726                     VkBufferView wrapped_entry = layer_data->Unwrap(*buffer_view_handle);
727                     template_entries.emplace_back(offset, kVulkanObjectTypeBufferView, CastToUint64(wrapped_entry), 0);
728                 } break;
729                 case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT: {
730                     size_t numBytes = create_info.pDescriptorUpdateEntries[i].descriptorCount;
731                     allocation_size = std::max(allocation_size, offset + numBytes);
732                     // nothing to unwrap, just plain data
733                     template_entries.emplace_back(offset, kVulkanObjectTypeUnknown, CastToUint64(update_entry),
734                                                   numBytes);
735                     // to break out of the loop
736                     j = create_info.pDescriptorUpdateEntries[i].descriptorCount;
737                 } break;
738                 default:
739                     assert(0);
740                     break;
741             }
742         }
743     }
744     // Allocate required buffer size and populate with source/unwrapped data
745     void *unwrapped_data = malloc(allocation_size);
746     for (auto &this_entry : template_entries) {
747         VulkanObjectType type = std::get<1>(this_entry);
748         void *destination = (char *)unwrapped_data + std::get<0>(this_entry);
749         uint64_t source = std::get<2>(this_entry);
750         size_t size = std::get<3>(this_entry);
751 
752         if (size != 0) {
753             assert(type == kVulkanObjectTypeUnknown);
754             memcpy(destination, CastFromUint64<void *>(source), size);
755         } else {
756             switch (type) {
757                 case kVulkanObjectTypeImage:
758                     *(reinterpret_cast<VkDescriptorImageInfo *>(destination)) =
759                         *(reinterpret_cast<VkDescriptorImageInfo *>(source));
760                     delete CastFromUint64<VkDescriptorImageInfo *>(source);
761                     break;
762                 case kVulkanObjectTypeBuffer:
763                     *(reinterpret_cast<VkDescriptorBufferInfo *>(destination)) =
764                         *(CastFromUint64<VkDescriptorBufferInfo *>(source));
765                     delete CastFromUint64<VkDescriptorBufferInfo *>(source);
766                     break;
767                 case kVulkanObjectTypeBufferView:
768                     *(reinterpret_cast<VkBufferView *>(destination)) = CastFromUint64<VkBufferView>(source);
769                     break;
770                 default:
771                     assert(0);
772                     break;
773             }
774         }
775     }
776     return (void *)unwrapped_data;
777 }
778 
DispatchUpdateDescriptorSetWithTemplate(VkDevice device,VkDescriptorSet descriptorSet,VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate,const void * pData)779 void DispatchUpdateDescriptorSetWithTemplate(VkDevice device, VkDescriptorSet descriptorSet,
780                                              VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate, const void *pData) {
781     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
782     if (!wrap_handles)
783         return layer_data->device_dispatch_table.UpdateDescriptorSetWithTemplate(device, descriptorSet, descriptorUpdateTemplate,
784                                                                                  pData);
785     uint64_t template_handle = reinterpret_cast<uint64_t &>(descriptorUpdateTemplate);
786     void *unwrapped_buffer = nullptr;
787     {
788         read_dispatch_lock_guard_t lock(dispatch_lock);
789         descriptorSet = layer_data->Unwrap(descriptorSet);
790         descriptorUpdateTemplate = (VkDescriptorUpdateTemplate)layer_data->Unwrap(descriptorUpdateTemplate);
791         unwrapped_buffer = BuildUnwrappedUpdateTemplateBuffer(layer_data, template_handle, pData);
792     }
793     layer_data->device_dispatch_table.UpdateDescriptorSetWithTemplate(device, descriptorSet, descriptorUpdateTemplate, unwrapped_buffer);
794     free(unwrapped_buffer);
795 }
796 
DispatchUpdateDescriptorSetWithTemplateKHR(VkDevice device,VkDescriptorSet descriptorSet,VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate,const void * pData)797 void DispatchUpdateDescriptorSetWithTemplateKHR(VkDevice device, VkDescriptorSet descriptorSet,
798                                                 VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate, const void *pData) {
799     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
800     if (!wrap_handles)
801         return layer_data->device_dispatch_table.UpdateDescriptorSetWithTemplateKHR(device, descriptorSet, descriptorUpdateTemplate,
802                                                                                     pData);
803     uint64_t template_handle = reinterpret_cast<uint64_t &>(descriptorUpdateTemplate);
804     void *unwrapped_buffer = nullptr;
805     {
806         read_dispatch_lock_guard_t lock(dispatch_lock);
807         descriptorSet = layer_data->Unwrap(descriptorSet);
808         descriptorUpdateTemplate = layer_data->Unwrap(descriptorUpdateTemplate);
809         unwrapped_buffer = BuildUnwrappedUpdateTemplateBuffer(layer_data, template_handle, pData);
810     }
811     layer_data->device_dispatch_table.UpdateDescriptorSetWithTemplateKHR(device, descriptorSet, descriptorUpdateTemplate, unwrapped_buffer);
812     free(unwrapped_buffer);
813 }
814 
DispatchCmdPushDescriptorSetWithTemplateKHR(VkCommandBuffer commandBuffer,VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate,VkPipelineLayout layout,uint32_t set,const void * pData)815 void DispatchCmdPushDescriptorSetWithTemplateKHR(VkCommandBuffer commandBuffer,
816                                                  VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate, VkPipelineLayout layout,
817                                                  uint32_t set, const void *pData) {
818     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
819     if (!wrap_handles)
820         return layer_data->device_dispatch_table.CmdPushDescriptorSetWithTemplateKHR(commandBuffer, descriptorUpdateTemplate,
821                                                                                      layout, set, pData);
822     uint64_t template_handle = reinterpret_cast<uint64_t &>(descriptorUpdateTemplate);
823     void *unwrapped_buffer = nullptr;
824     {
825         read_dispatch_lock_guard_t lock(dispatch_lock);
826         descriptorUpdateTemplate = layer_data->Unwrap(descriptorUpdateTemplate);
827         layout = layer_data->Unwrap(layout);
828         unwrapped_buffer = BuildUnwrappedUpdateTemplateBuffer(layer_data, template_handle, pData);
829     }
830     layer_data->device_dispatch_table.CmdPushDescriptorSetWithTemplateKHR(commandBuffer, descriptorUpdateTemplate, layout, set,
831                                                                  unwrapped_buffer);
832     free(unwrapped_buffer);
833 }
834 
DispatchGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice,uint32_t * pPropertyCount,VkDisplayPropertiesKHR * pProperties)835 VkResult DispatchGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
836                                                        VkDisplayPropertiesKHR *pProperties) {
837     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
838     VkResult result =
839         layer_data->instance_dispatch_table.GetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, pPropertyCount, pProperties);
840     if (!wrap_handles) return result;
841     if ((result == VK_SUCCESS || result == VK_INCOMPLETE) && pProperties) {
842         for (uint32_t idx0 = 0; idx0 < *pPropertyCount; ++idx0) {
843             pProperties[idx0].display = layer_data->MaybeWrapDisplay(pProperties[idx0].display, layer_data);
844         }
845     }
846     return result;
847 }
848 
DispatchGetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physicalDevice,uint32_t * pPropertyCount,VkDisplayProperties2KHR * pProperties)849 VkResult DispatchGetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
850                                                         VkDisplayProperties2KHR *pProperties) {
851     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
852     VkResult result =
853         layer_data->instance_dispatch_table.GetPhysicalDeviceDisplayProperties2KHR(physicalDevice, pPropertyCount, pProperties);
854     if (!wrap_handles) return result;
855     if ((result == VK_SUCCESS || result == VK_INCOMPLETE) && pProperties) {
856         for (uint32_t idx0 = 0; idx0 < *pPropertyCount; ++idx0) {
857             pProperties[idx0].displayProperties.display =
858                 layer_data->MaybeWrapDisplay(pProperties[idx0].displayProperties.display, layer_data);
859         }
860     }
861     return result;
862 }
863 
DispatchGetPhysicalDeviceDisplayPlanePropertiesKHR(VkPhysicalDevice physicalDevice,uint32_t * pPropertyCount,VkDisplayPlanePropertiesKHR * pProperties)864 VkResult DispatchGetPhysicalDeviceDisplayPlanePropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
865                                                             VkDisplayPlanePropertiesKHR *pProperties) {
866     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
867     VkResult result =
868         layer_data->instance_dispatch_table.GetPhysicalDeviceDisplayPlanePropertiesKHR(physicalDevice, pPropertyCount, pProperties);
869     if (!wrap_handles) return result;
870     if ((result == VK_SUCCESS || result == VK_INCOMPLETE) && pProperties) {
871         for (uint32_t idx0 = 0; idx0 < *pPropertyCount; ++idx0) {
872             VkDisplayKHR &opt_display = pProperties[idx0].currentDisplay;
873             if (opt_display) opt_display = layer_data->MaybeWrapDisplay(opt_display, layer_data);
874         }
875     }
876     return result;
877 }
878 
DispatchGetPhysicalDeviceDisplayPlaneProperties2KHR(VkPhysicalDevice physicalDevice,uint32_t * pPropertyCount,VkDisplayPlaneProperties2KHR * pProperties)879 VkResult DispatchGetPhysicalDeviceDisplayPlaneProperties2KHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
880                                                              VkDisplayPlaneProperties2KHR *pProperties) {
881     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
882     VkResult result = layer_data->instance_dispatch_table.GetPhysicalDeviceDisplayPlaneProperties2KHR(physicalDevice,
883                                                                                                       pPropertyCount, pProperties);
884     if (!wrap_handles) return result;
885     if ((result == VK_SUCCESS || result == VK_INCOMPLETE) && pProperties) {
886         for (uint32_t idx0 = 0; idx0 < *pPropertyCount; ++idx0) {
887             VkDisplayKHR &opt_display = pProperties[idx0].displayPlaneProperties.currentDisplay;
888             if (opt_display) opt_display = layer_data->MaybeWrapDisplay(opt_display, layer_data);
889         }
890     }
891     return result;
892 }
893 
DispatchGetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice,uint32_t planeIndex,uint32_t * pDisplayCount,VkDisplayKHR * pDisplays)894 VkResult DispatchGetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, uint32_t planeIndex, uint32_t *pDisplayCount,
895                                                      VkDisplayKHR *pDisplays) {
896     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
897     VkResult result = layer_data->instance_dispatch_table.GetDisplayPlaneSupportedDisplaysKHR(physicalDevice, planeIndex,
898                                                                                               pDisplayCount, pDisplays);
899     if ((result == VK_SUCCESS || result == VK_INCOMPLETE) && pDisplays) {
900     if (!wrap_handles) return result;
901         for (uint32_t i = 0; i < *pDisplayCount; ++i) {
902             if (pDisplays[i]) pDisplays[i] = layer_data->MaybeWrapDisplay(pDisplays[i], layer_data);
903         }
904     }
905     return result;
906 }
907 
DispatchGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice,VkDisplayKHR display,uint32_t * pPropertyCount,VkDisplayModePropertiesKHR * pProperties)908 VkResult DispatchGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t *pPropertyCount,
909                                              VkDisplayModePropertiesKHR *pProperties) {
910     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
911     if (!wrap_handles)
912         return layer_data->instance_dispatch_table.GetDisplayModePropertiesKHR(physicalDevice, display, pPropertyCount,
913                                                                                pProperties);
914     {
915         display = layer_data->Unwrap(display);
916     }
917 
918     VkResult result = layer_data->instance_dispatch_table.GetDisplayModePropertiesKHR(physicalDevice, display, pPropertyCount, pProperties);
919     if ((result == VK_SUCCESS || result == VK_INCOMPLETE) && pProperties) {
920         for (uint32_t idx0 = 0; idx0 < *pPropertyCount; ++idx0) {
921             pProperties[idx0].displayMode = layer_data->WrapNew(pProperties[idx0].displayMode);
922         }
923     }
924     return result;
925 }
926 
DispatchGetDisplayModeProperties2KHR(VkPhysicalDevice physicalDevice,VkDisplayKHR display,uint32_t * pPropertyCount,VkDisplayModeProperties2KHR * pProperties)927 VkResult DispatchGetDisplayModeProperties2KHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t *pPropertyCount,
928                                               VkDisplayModeProperties2KHR *pProperties) {
929     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
930     if (!wrap_handles)
931         return layer_data->instance_dispatch_table.GetDisplayModeProperties2KHR(physicalDevice, display, pPropertyCount,
932                                                                                 pProperties);
933     {
934         display = layer_data->Unwrap(display);
935     }
936 
937     VkResult result =
938         layer_data->instance_dispatch_table.GetDisplayModeProperties2KHR(physicalDevice, display, pPropertyCount, pProperties);
939     if ((result == VK_SUCCESS || result == VK_INCOMPLETE) && pProperties) {
940         for (uint32_t idx0 = 0; idx0 < *pPropertyCount; ++idx0) {
941             pProperties[idx0].displayModeProperties.displayMode = layer_data->WrapNew(pProperties[idx0].displayModeProperties.displayMode);
942         }
943     }
944     return result;
945 }
946 
DispatchDebugMarkerSetObjectTagEXT(VkDevice device,const VkDebugMarkerObjectTagInfoEXT * pTagInfo)947 VkResult DispatchDebugMarkerSetObjectTagEXT(VkDevice device, const VkDebugMarkerObjectTagInfoEXT *pTagInfo) {
948     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
949     if (!wrap_handles) return layer_data->device_dispatch_table.DebugMarkerSetObjectTagEXT(device, pTagInfo);
950     safe_VkDebugMarkerObjectTagInfoEXT local_tag_info(pTagInfo);
951     {
952         auto it = unique_id_mapping.find(reinterpret_cast<uint64_t &>(local_tag_info.object));
953         if (it != unique_id_mapping.end()) {
954             local_tag_info.object = it->second;
955         }
956     }
957     VkResult result = layer_data->device_dispatch_table.DebugMarkerSetObjectTagEXT(device,
958                                                                                    reinterpret_cast<VkDebugMarkerObjectTagInfoEXT *>(&local_tag_info));
959     return result;
960 }
961 
DispatchDebugMarkerSetObjectNameEXT(VkDevice device,const VkDebugMarkerObjectNameInfoEXT * pNameInfo)962 VkResult DispatchDebugMarkerSetObjectNameEXT(VkDevice device, const VkDebugMarkerObjectNameInfoEXT *pNameInfo) {
963     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
964     if (!wrap_handles) return layer_data->device_dispatch_table.DebugMarkerSetObjectNameEXT(device, pNameInfo);
965     safe_VkDebugMarkerObjectNameInfoEXT local_name_info(pNameInfo);
966     {
967         auto it = unique_id_mapping.find(reinterpret_cast<uint64_t &>(local_name_info.object));
968         if (it != unique_id_mapping.end()) {
969             local_name_info.object = it->second;
970         }
971     }
972     VkResult result = layer_data->device_dispatch_table.DebugMarkerSetObjectNameEXT(
973         device, reinterpret_cast<VkDebugMarkerObjectNameInfoEXT *>(&local_name_info));
974     return result;
975 }
976 
977 // VK_EXT_debug_utils
DispatchSetDebugUtilsObjectTagEXT(VkDevice device,const VkDebugUtilsObjectTagInfoEXT * pTagInfo)978 VkResult DispatchSetDebugUtilsObjectTagEXT(VkDevice device, const VkDebugUtilsObjectTagInfoEXT *pTagInfo) {
979     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
980     if (!wrap_handles) return layer_data->device_dispatch_table.SetDebugUtilsObjectTagEXT(device, pTagInfo);
981     safe_VkDebugUtilsObjectTagInfoEXT local_tag_info(pTagInfo);
982     {
983         auto it = unique_id_mapping.find(reinterpret_cast<uint64_t &>(local_tag_info.objectHandle));
984         if (it != unique_id_mapping.end()) {
985             local_tag_info.objectHandle = it->second;
986         }
987     }
988     VkResult result = layer_data->device_dispatch_table.SetDebugUtilsObjectTagEXT(
989         device, reinterpret_cast<const VkDebugUtilsObjectTagInfoEXT *>(&local_tag_info));
990     return result;
991 }
992 
DispatchSetDebugUtilsObjectNameEXT(VkDevice device,const VkDebugUtilsObjectNameInfoEXT * pNameInfo)993 VkResult DispatchSetDebugUtilsObjectNameEXT(VkDevice device, const VkDebugUtilsObjectNameInfoEXT *pNameInfo) {
994     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
995     if (!wrap_handles) return layer_data->device_dispatch_table.SetDebugUtilsObjectNameEXT(device, pNameInfo);
996     safe_VkDebugUtilsObjectNameInfoEXT local_name_info(pNameInfo);
997     {
998         auto it = unique_id_mapping.find(reinterpret_cast<uint64_t &>(local_name_info.objectHandle));
999         if (it != unique_id_mapping.end()) {
1000             local_name_info.objectHandle = it->second;
1001         }
1002     }
1003     VkResult result = layer_data->device_dispatch_table.SetDebugUtilsObjectNameEXT(
1004         device, reinterpret_cast<const VkDebugUtilsObjectNameInfoEXT *>(&local_name_info));
1005     return result;
1006 }
1007 
1008 
1009 
1010 
1011 // Skip vkCreateInstance dispatch, manually generated
1012 
1013 // Skip vkDestroyInstance dispatch, manually generated
1014 
DispatchEnumeratePhysicalDevices(VkInstance instance,uint32_t * pPhysicalDeviceCount,VkPhysicalDevice * pPhysicalDevices)1015 VkResult DispatchEnumeratePhysicalDevices(
1016     VkInstance                                  instance,
1017     uint32_t*                                   pPhysicalDeviceCount,
1018     VkPhysicalDevice*                           pPhysicalDevices)
1019 {
1020     auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
1021     VkResult result = layer_data->instance_dispatch_table.EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices);
1022 
1023     return result;
1024 }
1025 
DispatchGetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice,VkPhysicalDeviceFeatures * pFeatures)1026 void DispatchGetPhysicalDeviceFeatures(
1027     VkPhysicalDevice                            physicalDevice,
1028     VkPhysicalDeviceFeatures*                   pFeatures)
1029 {
1030     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
1031     layer_data->instance_dispatch_table.GetPhysicalDeviceFeatures(physicalDevice, pFeatures);
1032 
1033 }
1034 
DispatchGetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice,VkFormat format,VkFormatProperties * pFormatProperties)1035 void DispatchGetPhysicalDeviceFormatProperties(
1036     VkPhysicalDevice                            physicalDevice,
1037     VkFormat                                    format,
1038     VkFormatProperties*                         pFormatProperties)
1039 {
1040     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
1041     layer_data->instance_dispatch_table.GetPhysicalDeviceFormatProperties(physicalDevice, format, pFormatProperties);
1042 
1043 }
1044 
DispatchGetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice,VkFormat format,VkImageType type,VkImageTiling tiling,VkImageUsageFlags usage,VkImageCreateFlags flags,VkImageFormatProperties * pImageFormatProperties)1045 VkResult DispatchGetPhysicalDeviceImageFormatProperties(
1046     VkPhysicalDevice                            physicalDevice,
1047     VkFormat                                    format,
1048     VkImageType                                 type,
1049     VkImageTiling                               tiling,
1050     VkImageUsageFlags                           usage,
1051     VkImageCreateFlags                          flags,
1052     VkImageFormatProperties*                    pImageFormatProperties)
1053 {
1054     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
1055     VkResult result = layer_data->instance_dispatch_table.GetPhysicalDeviceImageFormatProperties(physicalDevice, format, type, tiling, usage, flags, pImageFormatProperties);
1056 
1057     return result;
1058 }
1059 
DispatchGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice,VkPhysicalDeviceProperties * pProperties)1060 void DispatchGetPhysicalDeviceProperties(
1061     VkPhysicalDevice                            physicalDevice,
1062     VkPhysicalDeviceProperties*                 pProperties)
1063 {
1064     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
1065     layer_data->instance_dispatch_table.GetPhysicalDeviceProperties(physicalDevice, pProperties);
1066 
1067 }
1068 
DispatchGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice,uint32_t * pQueueFamilyPropertyCount,VkQueueFamilyProperties * pQueueFamilyProperties)1069 void DispatchGetPhysicalDeviceQueueFamilyProperties(
1070     VkPhysicalDevice                            physicalDevice,
1071     uint32_t*                                   pQueueFamilyPropertyCount,
1072     VkQueueFamilyProperties*                    pQueueFamilyProperties)
1073 {
1074     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
1075     layer_data->instance_dispatch_table.GetPhysicalDeviceQueueFamilyProperties(physicalDevice, pQueueFamilyPropertyCount, pQueueFamilyProperties);
1076 
1077 }
1078 
DispatchGetPhysicalDeviceMemoryProperties(VkPhysicalDevice physicalDevice,VkPhysicalDeviceMemoryProperties * pMemoryProperties)1079 void DispatchGetPhysicalDeviceMemoryProperties(
1080     VkPhysicalDevice                            physicalDevice,
1081     VkPhysicalDeviceMemoryProperties*           pMemoryProperties)
1082 {
1083     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
1084     layer_data->instance_dispatch_table.GetPhysicalDeviceMemoryProperties(physicalDevice, pMemoryProperties);
1085 
1086 }
1087 
DispatchGetInstanceProcAddr(VkInstance instance,const char * pName)1088 PFN_vkVoidFunction DispatchGetInstanceProcAddr(
1089     VkInstance                                  instance,
1090     const char*                                 pName)
1091 {
1092     auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
1093     PFN_vkVoidFunction result = layer_data->instance_dispatch_table.GetInstanceProcAddr(instance, pName);
1094 
1095     return result;
1096 }
1097 
DispatchGetDeviceProcAddr(VkDevice device,const char * pName)1098 PFN_vkVoidFunction DispatchGetDeviceProcAddr(
1099     VkDevice                                    device,
1100     const char*                                 pName)
1101 {
1102     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1103     PFN_vkVoidFunction result = layer_data->device_dispatch_table.GetDeviceProcAddr(device, pName);
1104 
1105     return result;
1106 }
1107 
1108 // Skip vkCreateDevice dispatch, manually generated
1109 
1110 // Skip vkDestroyDevice dispatch, manually generated
1111 
1112 // Skip vkEnumerateInstanceExtensionProperties dispatch, manually generated
1113 
1114 // Skip vkEnumerateDeviceExtensionProperties dispatch, manually generated
1115 
1116 // Skip vkEnumerateInstanceLayerProperties dispatch, manually generated
1117 
1118 // Skip vkEnumerateDeviceLayerProperties dispatch, manually generated
1119 
DispatchGetDeviceQueue(VkDevice device,uint32_t queueFamilyIndex,uint32_t queueIndex,VkQueue * pQueue)1120 void DispatchGetDeviceQueue(
1121     VkDevice                                    device,
1122     uint32_t                                    queueFamilyIndex,
1123     uint32_t                                    queueIndex,
1124     VkQueue*                                    pQueue)
1125 {
1126     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1127     layer_data->device_dispatch_table.GetDeviceQueue(device, queueFamilyIndex, queueIndex, pQueue);
1128 
1129 }
1130 
DispatchQueueSubmit(VkQueue queue,uint32_t submitCount,const VkSubmitInfo * pSubmits,VkFence fence)1131 VkResult DispatchQueueSubmit(
1132     VkQueue                                     queue,
1133     uint32_t                                    submitCount,
1134     const VkSubmitInfo*                         pSubmits,
1135     VkFence                                     fence)
1136 {
1137     auto layer_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map);
1138     if (!wrap_handles) return layer_data->device_dispatch_table.QueueSubmit(queue, submitCount, pSubmits, fence);
1139     safe_VkSubmitInfo *local_pSubmits = NULL;
1140     {
1141         if (pSubmits) {
1142             local_pSubmits = new safe_VkSubmitInfo[submitCount];
1143             for (uint32_t index0 = 0; index0 < submitCount; ++index0) {
1144                 local_pSubmits[index0].initialize(&pSubmits[index0]);
1145                 WrapPnextChainHandles(layer_data, local_pSubmits[index0].pNext);
1146                 if (local_pSubmits[index0].pWaitSemaphores) {
1147                     for (uint32_t index1 = 0; index1 < local_pSubmits[index0].waitSemaphoreCount; ++index1) {
1148                         local_pSubmits[index0].pWaitSemaphores[index1] = layer_data->Unwrap(local_pSubmits[index0].pWaitSemaphores[index1]);
1149                     }
1150                 }
1151                 if (local_pSubmits[index0].pSignalSemaphores) {
1152                     for (uint32_t index1 = 0; index1 < local_pSubmits[index0].signalSemaphoreCount; ++index1) {
1153                         local_pSubmits[index0].pSignalSemaphores[index1] = layer_data->Unwrap(local_pSubmits[index0].pSignalSemaphores[index1]);
1154                     }
1155                 }
1156             }
1157         }
1158         fence = layer_data->Unwrap(fence);
1159     }
1160     VkResult result = layer_data->device_dispatch_table.QueueSubmit(queue, submitCount, (const VkSubmitInfo*)local_pSubmits, fence);
1161     if (local_pSubmits) {
1162         delete[] local_pSubmits;
1163     }
1164     return result;
1165 }
1166 
DispatchQueueWaitIdle(VkQueue queue)1167 VkResult DispatchQueueWaitIdle(
1168     VkQueue                                     queue)
1169 {
1170     auto layer_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map);
1171     VkResult result = layer_data->device_dispatch_table.QueueWaitIdle(queue);
1172 
1173     return result;
1174 }
1175 
DispatchDeviceWaitIdle(VkDevice device)1176 VkResult DispatchDeviceWaitIdle(
1177     VkDevice                                    device)
1178 {
1179     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1180     VkResult result = layer_data->device_dispatch_table.DeviceWaitIdle(device);
1181 
1182     return result;
1183 }
1184 
DispatchAllocateMemory(VkDevice device,const VkMemoryAllocateInfo * pAllocateInfo,const VkAllocationCallbacks * pAllocator,VkDeviceMemory * pMemory)1185 VkResult DispatchAllocateMemory(
1186     VkDevice                                    device,
1187     const VkMemoryAllocateInfo*                 pAllocateInfo,
1188     const VkAllocationCallbacks*                pAllocator,
1189     VkDeviceMemory*                             pMemory)
1190 {
1191     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1192     if (!wrap_handles) return layer_data->device_dispatch_table.AllocateMemory(device, pAllocateInfo, pAllocator, pMemory);
1193     safe_VkMemoryAllocateInfo *local_pAllocateInfo = NULL;
1194     {
1195         if (pAllocateInfo) {
1196             local_pAllocateInfo = new safe_VkMemoryAllocateInfo(pAllocateInfo);
1197             WrapPnextChainHandles(layer_data, local_pAllocateInfo->pNext);
1198         }
1199     }
1200     VkResult result = layer_data->device_dispatch_table.AllocateMemory(device, (const VkMemoryAllocateInfo*)local_pAllocateInfo, pAllocator, pMemory);
1201     if (local_pAllocateInfo) {
1202         delete local_pAllocateInfo;
1203     }
1204     if (VK_SUCCESS == result) {
1205         *pMemory = layer_data->WrapNew(*pMemory);
1206     }
1207     return result;
1208 }
1209 
DispatchFreeMemory(VkDevice device,VkDeviceMemory memory,const VkAllocationCallbacks * pAllocator)1210 void DispatchFreeMemory(
1211     VkDevice                                    device,
1212     VkDeviceMemory                              memory,
1213     const VkAllocationCallbacks*                pAllocator)
1214 {
1215     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1216     if (!wrap_handles) return layer_data->device_dispatch_table.FreeMemory(device, memory, pAllocator);
1217     uint64_t memory_id = reinterpret_cast<uint64_t &>(memory);
1218     auto iter = unique_id_mapping.pop(memory_id);
1219     if (iter != unique_id_mapping.end()) {
1220         memory = (VkDeviceMemory)iter->second;
1221     } else {
1222         memory = (VkDeviceMemory)0;
1223     }
1224     layer_data->device_dispatch_table.FreeMemory(device, memory, pAllocator);
1225 
1226 }
1227 
DispatchMapMemory(VkDevice device,VkDeviceMemory memory,VkDeviceSize offset,VkDeviceSize size,VkMemoryMapFlags flags,void ** ppData)1228 VkResult DispatchMapMemory(
1229     VkDevice                                    device,
1230     VkDeviceMemory                              memory,
1231     VkDeviceSize                                offset,
1232     VkDeviceSize                                size,
1233     VkMemoryMapFlags                            flags,
1234     void**                                      ppData)
1235 {
1236     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1237     if (!wrap_handles) return layer_data->device_dispatch_table.MapMemory(device, memory, offset, size, flags, ppData);
1238     {
1239         memory = layer_data->Unwrap(memory);
1240     }
1241     VkResult result = layer_data->device_dispatch_table.MapMemory(device, memory, offset, size, flags, ppData);
1242 
1243     return result;
1244 }
1245 
DispatchUnmapMemory(VkDevice device,VkDeviceMemory memory)1246 void DispatchUnmapMemory(
1247     VkDevice                                    device,
1248     VkDeviceMemory                              memory)
1249 {
1250     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1251     if (!wrap_handles) return layer_data->device_dispatch_table.UnmapMemory(device, memory);
1252     {
1253         memory = layer_data->Unwrap(memory);
1254     }
1255     layer_data->device_dispatch_table.UnmapMemory(device, memory);
1256 
1257 }
1258 
DispatchFlushMappedMemoryRanges(VkDevice device,uint32_t memoryRangeCount,const VkMappedMemoryRange * pMemoryRanges)1259 VkResult DispatchFlushMappedMemoryRanges(
1260     VkDevice                                    device,
1261     uint32_t                                    memoryRangeCount,
1262     const VkMappedMemoryRange*                  pMemoryRanges)
1263 {
1264     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1265     if (!wrap_handles) return layer_data->device_dispatch_table.FlushMappedMemoryRanges(device, memoryRangeCount, pMemoryRanges);
1266     safe_VkMappedMemoryRange *local_pMemoryRanges = NULL;
1267     {
1268         if (pMemoryRanges) {
1269             local_pMemoryRanges = new safe_VkMappedMemoryRange[memoryRangeCount];
1270             for (uint32_t index0 = 0; index0 < memoryRangeCount; ++index0) {
1271                 local_pMemoryRanges[index0].initialize(&pMemoryRanges[index0]);
1272                 if (pMemoryRanges[index0].memory) {
1273                     local_pMemoryRanges[index0].memory = layer_data->Unwrap(pMemoryRanges[index0].memory);
1274                 }
1275             }
1276         }
1277     }
1278     VkResult result = layer_data->device_dispatch_table.FlushMappedMemoryRanges(device, memoryRangeCount, (const VkMappedMemoryRange*)local_pMemoryRanges);
1279     if (local_pMemoryRanges) {
1280         delete[] local_pMemoryRanges;
1281     }
1282     return result;
1283 }
1284 
DispatchInvalidateMappedMemoryRanges(VkDevice device,uint32_t memoryRangeCount,const VkMappedMemoryRange * pMemoryRanges)1285 VkResult DispatchInvalidateMappedMemoryRanges(
1286     VkDevice                                    device,
1287     uint32_t                                    memoryRangeCount,
1288     const VkMappedMemoryRange*                  pMemoryRanges)
1289 {
1290     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1291     if (!wrap_handles) return layer_data->device_dispatch_table.InvalidateMappedMemoryRanges(device, memoryRangeCount, pMemoryRanges);
1292     safe_VkMappedMemoryRange *local_pMemoryRanges = NULL;
1293     {
1294         if (pMemoryRanges) {
1295             local_pMemoryRanges = new safe_VkMappedMemoryRange[memoryRangeCount];
1296             for (uint32_t index0 = 0; index0 < memoryRangeCount; ++index0) {
1297                 local_pMemoryRanges[index0].initialize(&pMemoryRanges[index0]);
1298                 if (pMemoryRanges[index0].memory) {
1299                     local_pMemoryRanges[index0].memory = layer_data->Unwrap(pMemoryRanges[index0].memory);
1300                 }
1301             }
1302         }
1303     }
1304     VkResult result = layer_data->device_dispatch_table.InvalidateMappedMemoryRanges(device, memoryRangeCount, (const VkMappedMemoryRange*)local_pMemoryRanges);
1305     if (local_pMemoryRanges) {
1306         delete[] local_pMemoryRanges;
1307     }
1308     return result;
1309 }
1310 
DispatchGetDeviceMemoryCommitment(VkDevice device,VkDeviceMemory memory,VkDeviceSize * pCommittedMemoryInBytes)1311 void DispatchGetDeviceMemoryCommitment(
1312     VkDevice                                    device,
1313     VkDeviceMemory                              memory,
1314     VkDeviceSize*                               pCommittedMemoryInBytes)
1315 {
1316     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1317     if (!wrap_handles) return layer_data->device_dispatch_table.GetDeviceMemoryCommitment(device, memory, pCommittedMemoryInBytes);
1318     {
1319         memory = layer_data->Unwrap(memory);
1320     }
1321     layer_data->device_dispatch_table.GetDeviceMemoryCommitment(device, memory, pCommittedMemoryInBytes);
1322 
1323 }
1324 
DispatchBindBufferMemory(VkDevice device,VkBuffer buffer,VkDeviceMemory memory,VkDeviceSize memoryOffset)1325 VkResult DispatchBindBufferMemory(
1326     VkDevice                                    device,
1327     VkBuffer                                    buffer,
1328     VkDeviceMemory                              memory,
1329     VkDeviceSize                                memoryOffset)
1330 {
1331     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1332     if (!wrap_handles) return layer_data->device_dispatch_table.BindBufferMemory(device, buffer, memory, memoryOffset);
1333     {
1334         buffer = layer_data->Unwrap(buffer);
1335         memory = layer_data->Unwrap(memory);
1336     }
1337     VkResult result = layer_data->device_dispatch_table.BindBufferMemory(device, buffer, memory, memoryOffset);
1338 
1339     return result;
1340 }
1341 
DispatchBindImageMemory(VkDevice device,VkImage image,VkDeviceMemory memory,VkDeviceSize memoryOffset)1342 VkResult DispatchBindImageMemory(
1343     VkDevice                                    device,
1344     VkImage                                     image,
1345     VkDeviceMemory                              memory,
1346     VkDeviceSize                                memoryOffset)
1347 {
1348     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1349     if (!wrap_handles) return layer_data->device_dispatch_table.BindImageMemory(device, image, memory, memoryOffset);
1350     {
1351         image = layer_data->Unwrap(image);
1352         memory = layer_data->Unwrap(memory);
1353     }
1354     VkResult result = layer_data->device_dispatch_table.BindImageMemory(device, image, memory, memoryOffset);
1355 
1356     return result;
1357 }
1358 
DispatchGetBufferMemoryRequirements(VkDevice device,VkBuffer buffer,VkMemoryRequirements * pMemoryRequirements)1359 void DispatchGetBufferMemoryRequirements(
1360     VkDevice                                    device,
1361     VkBuffer                                    buffer,
1362     VkMemoryRequirements*                       pMemoryRequirements)
1363 {
1364     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1365     if (!wrap_handles) return layer_data->device_dispatch_table.GetBufferMemoryRequirements(device, buffer, pMemoryRequirements);
1366     {
1367         buffer = layer_data->Unwrap(buffer);
1368     }
1369     layer_data->device_dispatch_table.GetBufferMemoryRequirements(device, buffer, pMemoryRequirements);
1370 
1371 }
1372 
DispatchGetImageMemoryRequirements(VkDevice device,VkImage image,VkMemoryRequirements * pMemoryRequirements)1373 void DispatchGetImageMemoryRequirements(
1374     VkDevice                                    device,
1375     VkImage                                     image,
1376     VkMemoryRequirements*                       pMemoryRequirements)
1377 {
1378     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1379     if (!wrap_handles) return layer_data->device_dispatch_table.GetImageMemoryRequirements(device, image, pMemoryRequirements);
1380     {
1381         image = layer_data->Unwrap(image);
1382     }
1383     layer_data->device_dispatch_table.GetImageMemoryRequirements(device, image, pMemoryRequirements);
1384 
1385 }
1386 
DispatchGetImageSparseMemoryRequirements(VkDevice device,VkImage image,uint32_t * pSparseMemoryRequirementCount,VkSparseImageMemoryRequirements * pSparseMemoryRequirements)1387 void DispatchGetImageSparseMemoryRequirements(
1388     VkDevice                                    device,
1389     VkImage                                     image,
1390     uint32_t*                                   pSparseMemoryRequirementCount,
1391     VkSparseImageMemoryRequirements*            pSparseMemoryRequirements)
1392 {
1393     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1394     if (!wrap_handles) return layer_data->device_dispatch_table.GetImageSparseMemoryRequirements(device, image, pSparseMemoryRequirementCount, pSparseMemoryRequirements);
1395     {
1396         image = layer_data->Unwrap(image);
1397     }
1398     layer_data->device_dispatch_table.GetImageSparseMemoryRequirements(device, image, pSparseMemoryRequirementCount, pSparseMemoryRequirements);
1399 
1400 }
1401 
DispatchGetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice physicalDevice,VkFormat format,VkImageType type,VkSampleCountFlagBits samples,VkImageUsageFlags usage,VkImageTiling tiling,uint32_t * pPropertyCount,VkSparseImageFormatProperties * pProperties)1402 void DispatchGetPhysicalDeviceSparseImageFormatProperties(
1403     VkPhysicalDevice                            physicalDevice,
1404     VkFormat                                    format,
1405     VkImageType                                 type,
1406     VkSampleCountFlagBits                       samples,
1407     VkImageUsageFlags                           usage,
1408     VkImageTiling                               tiling,
1409     uint32_t*                                   pPropertyCount,
1410     VkSparseImageFormatProperties*              pProperties)
1411 {
1412     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
1413     layer_data->instance_dispatch_table.GetPhysicalDeviceSparseImageFormatProperties(physicalDevice, format, type, samples, usage, tiling, pPropertyCount, pProperties);
1414 
1415 }
1416 
DispatchQueueBindSparse(VkQueue queue,uint32_t bindInfoCount,const VkBindSparseInfo * pBindInfo,VkFence fence)1417 VkResult DispatchQueueBindSparse(
1418     VkQueue                                     queue,
1419     uint32_t                                    bindInfoCount,
1420     const VkBindSparseInfo*                     pBindInfo,
1421     VkFence                                     fence)
1422 {
1423     auto layer_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map);
1424     if (!wrap_handles) return layer_data->device_dispatch_table.QueueBindSparse(queue, bindInfoCount, pBindInfo, fence);
1425     safe_VkBindSparseInfo *local_pBindInfo = NULL;
1426     {
1427         if (pBindInfo) {
1428             local_pBindInfo = new safe_VkBindSparseInfo[bindInfoCount];
1429             for (uint32_t index0 = 0; index0 < bindInfoCount; ++index0) {
1430                 local_pBindInfo[index0].initialize(&pBindInfo[index0]);
1431                 if (local_pBindInfo[index0].pWaitSemaphores) {
1432                     for (uint32_t index1 = 0; index1 < local_pBindInfo[index0].waitSemaphoreCount; ++index1) {
1433                         local_pBindInfo[index0].pWaitSemaphores[index1] = layer_data->Unwrap(local_pBindInfo[index0].pWaitSemaphores[index1]);
1434                     }
1435                 }
1436                 if (local_pBindInfo[index0].pBufferBinds) {
1437                     for (uint32_t index1 = 0; index1 < local_pBindInfo[index0].bufferBindCount; ++index1) {
1438                         if (pBindInfo[index0].pBufferBinds[index1].buffer) {
1439                             local_pBindInfo[index0].pBufferBinds[index1].buffer = layer_data->Unwrap(pBindInfo[index0].pBufferBinds[index1].buffer);
1440                         }
1441                         if (local_pBindInfo[index0].pBufferBinds[index1].pBinds) {
1442                             for (uint32_t index2 = 0; index2 < local_pBindInfo[index0].pBufferBinds[index1].bindCount; ++index2) {
1443                                 if (pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory) {
1444                                     local_pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory = layer_data->Unwrap(pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory);
1445                                 }
1446                             }
1447                         }
1448                     }
1449                 }
1450                 if (local_pBindInfo[index0].pImageOpaqueBinds) {
1451                     for (uint32_t index1 = 0; index1 < local_pBindInfo[index0].imageOpaqueBindCount; ++index1) {
1452                         if (pBindInfo[index0].pImageOpaqueBinds[index1].image) {
1453                             local_pBindInfo[index0].pImageOpaqueBinds[index1].image = layer_data->Unwrap(pBindInfo[index0].pImageOpaqueBinds[index1].image);
1454                         }
1455                         if (local_pBindInfo[index0].pImageOpaqueBinds[index1].pBinds) {
1456                             for (uint32_t index2 = 0; index2 < local_pBindInfo[index0].pImageOpaqueBinds[index1].bindCount; ++index2) {
1457                                 if (pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory) {
1458                                     local_pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory = layer_data->Unwrap(pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory);
1459                                 }
1460                             }
1461                         }
1462                     }
1463                 }
1464                 if (local_pBindInfo[index0].pImageBinds) {
1465                     for (uint32_t index1 = 0; index1 < local_pBindInfo[index0].imageBindCount; ++index1) {
1466                         if (pBindInfo[index0].pImageBinds[index1].image) {
1467                             local_pBindInfo[index0].pImageBinds[index1].image = layer_data->Unwrap(pBindInfo[index0].pImageBinds[index1].image);
1468                         }
1469                         if (local_pBindInfo[index0].pImageBinds[index1].pBinds) {
1470                             for (uint32_t index2 = 0; index2 < local_pBindInfo[index0].pImageBinds[index1].bindCount; ++index2) {
1471                                 if (pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory) {
1472                                     local_pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory = layer_data->Unwrap(pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory);
1473                                 }
1474                             }
1475                         }
1476                     }
1477                 }
1478                 if (local_pBindInfo[index0].pSignalSemaphores) {
1479                     for (uint32_t index1 = 0; index1 < local_pBindInfo[index0].signalSemaphoreCount; ++index1) {
1480                         local_pBindInfo[index0].pSignalSemaphores[index1] = layer_data->Unwrap(local_pBindInfo[index0].pSignalSemaphores[index1]);
1481                     }
1482                 }
1483             }
1484         }
1485         fence = layer_data->Unwrap(fence);
1486     }
1487     VkResult result = layer_data->device_dispatch_table.QueueBindSparse(queue, bindInfoCount, (const VkBindSparseInfo*)local_pBindInfo, fence);
1488     if (local_pBindInfo) {
1489         delete[] local_pBindInfo;
1490     }
1491     return result;
1492 }
1493 
DispatchCreateFence(VkDevice device,const VkFenceCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkFence * pFence)1494 VkResult DispatchCreateFence(
1495     VkDevice                                    device,
1496     const VkFenceCreateInfo*                    pCreateInfo,
1497     const VkAllocationCallbacks*                pAllocator,
1498     VkFence*                                    pFence)
1499 {
1500     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1501     if (!wrap_handles) return layer_data->device_dispatch_table.CreateFence(device, pCreateInfo, pAllocator, pFence);
1502     VkResult result = layer_data->device_dispatch_table.CreateFence(device, pCreateInfo, pAllocator, pFence);
1503     if (VK_SUCCESS == result) {
1504         *pFence = layer_data->WrapNew(*pFence);
1505     }
1506     return result;
1507 }
1508 
DispatchDestroyFence(VkDevice device,VkFence fence,const VkAllocationCallbacks * pAllocator)1509 void DispatchDestroyFence(
1510     VkDevice                                    device,
1511     VkFence                                     fence,
1512     const VkAllocationCallbacks*                pAllocator)
1513 {
1514     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1515     if (!wrap_handles) return layer_data->device_dispatch_table.DestroyFence(device, fence, pAllocator);
1516     uint64_t fence_id = reinterpret_cast<uint64_t &>(fence);
1517     auto iter = unique_id_mapping.pop(fence_id);
1518     if (iter != unique_id_mapping.end()) {
1519         fence = (VkFence)iter->second;
1520     } else {
1521         fence = (VkFence)0;
1522     }
1523     layer_data->device_dispatch_table.DestroyFence(device, fence, pAllocator);
1524 
1525 }
1526 
DispatchResetFences(VkDevice device,uint32_t fenceCount,const VkFence * pFences)1527 VkResult DispatchResetFences(
1528     VkDevice                                    device,
1529     uint32_t                                    fenceCount,
1530     const VkFence*                              pFences)
1531 {
1532     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1533     if (!wrap_handles) return layer_data->device_dispatch_table.ResetFences(device, fenceCount, pFences);
1534     VkFence *local_pFences = NULL;
1535     {
1536         if (pFences) {
1537             local_pFences = new VkFence[fenceCount];
1538             for (uint32_t index0 = 0; index0 < fenceCount; ++index0) {
1539                 local_pFences[index0] = layer_data->Unwrap(pFences[index0]);
1540             }
1541         }
1542     }
1543     VkResult result = layer_data->device_dispatch_table.ResetFences(device, fenceCount, (const VkFence*)local_pFences);
1544     if (local_pFences)
1545         delete[] local_pFences;
1546     return result;
1547 }
1548 
DispatchGetFenceStatus(VkDevice device,VkFence fence)1549 VkResult DispatchGetFenceStatus(
1550     VkDevice                                    device,
1551     VkFence                                     fence)
1552 {
1553     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1554     if (!wrap_handles) return layer_data->device_dispatch_table.GetFenceStatus(device, fence);
1555     {
1556         fence = layer_data->Unwrap(fence);
1557     }
1558     VkResult result = layer_data->device_dispatch_table.GetFenceStatus(device, fence);
1559 
1560     return result;
1561 }
1562 
DispatchWaitForFences(VkDevice device,uint32_t fenceCount,const VkFence * pFences,VkBool32 waitAll,uint64_t timeout)1563 VkResult DispatchWaitForFences(
1564     VkDevice                                    device,
1565     uint32_t                                    fenceCount,
1566     const VkFence*                              pFences,
1567     VkBool32                                    waitAll,
1568     uint64_t                                    timeout)
1569 {
1570     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1571     if (!wrap_handles) return layer_data->device_dispatch_table.WaitForFences(device, fenceCount, pFences, waitAll, timeout);
1572     VkFence *local_pFences = NULL;
1573     {
1574         if (pFences) {
1575             local_pFences = new VkFence[fenceCount];
1576             for (uint32_t index0 = 0; index0 < fenceCount; ++index0) {
1577                 local_pFences[index0] = layer_data->Unwrap(pFences[index0]);
1578             }
1579         }
1580     }
1581     VkResult result = layer_data->device_dispatch_table.WaitForFences(device, fenceCount, (const VkFence*)local_pFences, waitAll, timeout);
1582     if (local_pFences)
1583         delete[] local_pFences;
1584     return result;
1585 }
1586 
DispatchCreateSemaphore(VkDevice device,const VkSemaphoreCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSemaphore * pSemaphore)1587 VkResult DispatchCreateSemaphore(
1588     VkDevice                                    device,
1589     const VkSemaphoreCreateInfo*                pCreateInfo,
1590     const VkAllocationCallbacks*                pAllocator,
1591     VkSemaphore*                                pSemaphore)
1592 {
1593     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1594     if (!wrap_handles) return layer_data->device_dispatch_table.CreateSemaphore(device, pCreateInfo, pAllocator, pSemaphore);
1595     VkResult result = layer_data->device_dispatch_table.CreateSemaphore(device, pCreateInfo, pAllocator, pSemaphore);
1596     if (VK_SUCCESS == result) {
1597         *pSemaphore = layer_data->WrapNew(*pSemaphore);
1598     }
1599     return result;
1600 }
1601 
DispatchDestroySemaphore(VkDevice device,VkSemaphore semaphore,const VkAllocationCallbacks * pAllocator)1602 void DispatchDestroySemaphore(
1603     VkDevice                                    device,
1604     VkSemaphore                                 semaphore,
1605     const VkAllocationCallbacks*                pAllocator)
1606 {
1607     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1608     if (!wrap_handles) return layer_data->device_dispatch_table.DestroySemaphore(device, semaphore, pAllocator);
1609     uint64_t semaphore_id = reinterpret_cast<uint64_t &>(semaphore);
1610     auto iter = unique_id_mapping.pop(semaphore_id);
1611     if (iter != unique_id_mapping.end()) {
1612         semaphore = (VkSemaphore)iter->second;
1613     } else {
1614         semaphore = (VkSemaphore)0;
1615     }
1616     layer_data->device_dispatch_table.DestroySemaphore(device, semaphore, pAllocator);
1617 
1618 }
1619 
DispatchCreateEvent(VkDevice device,const VkEventCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkEvent * pEvent)1620 VkResult DispatchCreateEvent(
1621     VkDevice                                    device,
1622     const VkEventCreateInfo*                    pCreateInfo,
1623     const VkAllocationCallbacks*                pAllocator,
1624     VkEvent*                                    pEvent)
1625 {
1626     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1627     if (!wrap_handles) return layer_data->device_dispatch_table.CreateEvent(device, pCreateInfo, pAllocator, pEvent);
1628     VkResult result = layer_data->device_dispatch_table.CreateEvent(device, pCreateInfo, pAllocator, pEvent);
1629     if (VK_SUCCESS == result) {
1630         *pEvent = layer_data->WrapNew(*pEvent);
1631     }
1632     return result;
1633 }
1634 
DispatchDestroyEvent(VkDevice device,VkEvent event,const VkAllocationCallbacks * pAllocator)1635 void DispatchDestroyEvent(
1636     VkDevice                                    device,
1637     VkEvent                                     event,
1638     const VkAllocationCallbacks*                pAllocator)
1639 {
1640     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1641     if (!wrap_handles) return layer_data->device_dispatch_table.DestroyEvent(device, event, pAllocator);
1642     uint64_t event_id = reinterpret_cast<uint64_t &>(event);
1643     auto iter = unique_id_mapping.pop(event_id);
1644     if (iter != unique_id_mapping.end()) {
1645         event = (VkEvent)iter->second;
1646     } else {
1647         event = (VkEvent)0;
1648     }
1649     layer_data->device_dispatch_table.DestroyEvent(device, event, pAllocator);
1650 
1651 }
1652 
DispatchGetEventStatus(VkDevice device,VkEvent event)1653 VkResult DispatchGetEventStatus(
1654     VkDevice                                    device,
1655     VkEvent                                     event)
1656 {
1657     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1658     if (!wrap_handles) return layer_data->device_dispatch_table.GetEventStatus(device, event);
1659     {
1660         event = layer_data->Unwrap(event);
1661     }
1662     VkResult result = layer_data->device_dispatch_table.GetEventStatus(device, event);
1663 
1664     return result;
1665 }
1666 
DispatchSetEvent(VkDevice device,VkEvent event)1667 VkResult DispatchSetEvent(
1668     VkDevice                                    device,
1669     VkEvent                                     event)
1670 {
1671     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1672     if (!wrap_handles) return layer_data->device_dispatch_table.SetEvent(device, event);
1673     {
1674         event = layer_data->Unwrap(event);
1675     }
1676     VkResult result = layer_data->device_dispatch_table.SetEvent(device, event);
1677 
1678     return result;
1679 }
1680 
DispatchResetEvent(VkDevice device,VkEvent event)1681 VkResult DispatchResetEvent(
1682     VkDevice                                    device,
1683     VkEvent                                     event)
1684 {
1685     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1686     if (!wrap_handles) return layer_data->device_dispatch_table.ResetEvent(device, event);
1687     {
1688         event = layer_data->Unwrap(event);
1689     }
1690     VkResult result = layer_data->device_dispatch_table.ResetEvent(device, event);
1691 
1692     return result;
1693 }
1694 
DispatchCreateQueryPool(VkDevice device,const VkQueryPoolCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkQueryPool * pQueryPool)1695 VkResult DispatchCreateQueryPool(
1696     VkDevice                                    device,
1697     const VkQueryPoolCreateInfo*                pCreateInfo,
1698     const VkAllocationCallbacks*                pAllocator,
1699     VkQueryPool*                                pQueryPool)
1700 {
1701     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1702     if (!wrap_handles) return layer_data->device_dispatch_table.CreateQueryPool(device, pCreateInfo, pAllocator, pQueryPool);
1703     VkResult result = layer_data->device_dispatch_table.CreateQueryPool(device, pCreateInfo, pAllocator, pQueryPool);
1704     if (VK_SUCCESS == result) {
1705         *pQueryPool = layer_data->WrapNew(*pQueryPool);
1706     }
1707     return result;
1708 }
1709 
DispatchDestroyQueryPool(VkDevice device,VkQueryPool queryPool,const VkAllocationCallbacks * pAllocator)1710 void DispatchDestroyQueryPool(
1711     VkDevice                                    device,
1712     VkQueryPool                                 queryPool,
1713     const VkAllocationCallbacks*                pAllocator)
1714 {
1715     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1716     if (!wrap_handles) return layer_data->device_dispatch_table.DestroyQueryPool(device, queryPool, pAllocator);
1717     uint64_t queryPool_id = reinterpret_cast<uint64_t &>(queryPool);
1718     auto iter = unique_id_mapping.pop(queryPool_id);
1719     if (iter != unique_id_mapping.end()) {
1720         queryPool = (VkQueryPool)iter->second;
1721     } else {
1722         queryPool = (VkQueryPool)0;
1723     }
1724     layer_data->device_dispatch_table.DestroyQueryPool(device, queryPool, pAllocator);
1725 
1726 }
1727 
DispatchGetQueryPoolResults(VkDevice device,VkQueryPool queryPool,uint32_t firstQuery,uint32_t queryCount,size_t dataSize,void * pData,VkDeviceSize stride,VkQueryResultFlags flags)1728 VkResult DispatchGetQueryPoolResults(
1729     VkDevice                                    device,
1730     VkQueryPool                                 queryPool,
1731     uint32_t                                    firstQuery,
1732     uint32_t                                    queryCount,
1733     size_t                                      dataSize,
1734     void*                                       pData,
1735     VkDeviceSize                                stride,
1736     VkQueryResultFlags                          flags)
1737 {
1738     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1739     if (!wrap_handles) return layer_data->device_dispatch_table.GetQueryPoolResults(device, queryPool, firstQuery, queryCount, dataSize, pData, stride, flags);
1740     {
1741         queryPool = layer_data->Unwrap(queryPool);
1742     }
1743     VkResult result = layer_data->device_dispatch_table.GetQueryPoolResults(device, queryPool, firstQuery, queryCount, dataSize, pData, stride, flags);
1744 
1745     return result;
1746 }
1747 
DispatchCreateBuffer(VkDevice device,const VkBufferCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkBuffer * pBuffer)1748 VkResult DispatchCreateBuffer(
1749     VkDevice                                    device,
1750     const VkBufferCreateInfo*                   pCreateInfo,
1751     const VkAllocationCallbacks*                pAllocator,
1752     VkBuffer*                                   pBuffer)
1753 {
1754     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1755     if (!wrap_handles) return layer_data->device_dispatch_table.CreateBuffer(device, pCreateInfo, pAllocator, pBuffer);
1756     VkResult result = layer_data->device_dispatch_table.CreateBuffer(device, pCreateInfo, pAllocator, pBuffer);
1757     if (VK_SUCCESS == result) {
1758         *pBuffer = layer_data->WrapNew(*pBuffer);
1759     }
1760     return result;
1761 }
1762 
DispatchDestroyBuffer(VkDevice device,VkBuffer buffer,const VkAllocationCallbacks * pAllocator)1763 void DispatchDestroyBuffer(
1764     VkDevice                                    device,
1765     VkBuffer                                    buffer,
1766     const VkAllocationCallbacks*                pAllocator)
1767 {
1768     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1769     if (!wrap_handles) return layer_data->device_dispatch_table.DestroyBuffer(device, buffer, pAllocator);
1770     uint64_t buffer_id = reinterpret_cast<uint64_t &>(buffer);
1771     auto iter = unique_id_mapping.pop(buffer_id);
1772     if (iter != unique_id_mapping.end()) {
1773         buffer = (VkBuffer)iter->second;
1774     } else {
1775         buffer = (VkBuffer)0;
1776     }
1777     layer_data->device_dispatch_table.DestroyBuffer(device, buffer, pAllocator);
1778 
1779 }
1780 
DispatchCreateBufferView(VkDevice device,const VkBufferViewCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkBufferView * pView)1781 VkResult DispatchCreateBufferView(
1782     VkDevice                                    device,
1783     const VkBufferViewCreateInfo*               pCreateInfo,
1784     const VkAllocationCallbacks*                pAllocator,
1785     VkBufferView*                               pView)
1786 {
1787     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1788     if (!wrap_handles) return layer_data->device_dispatch_table.CreateBufferView(device, pCreateInfo, pAllocator, pView);
1789     safe_VkBufferViewCreateInfo *local_pCreateInfo = NULL;
1790     {
1791         if (pCreateInfo) {
1792             local_pCreateInfo = new safe_VkBufferViewCreateInfo(pCreateInfo);
1793             if (pCreateInfo->buffer) {
1794                 local_pCreateInfo->buffer = layer_data->Unwrap(pCreateInfo->buffer);
1795             }
1796         }
1797     }
1798     VkResult result = layer_data->device_dispatch_table.CreateBufferView(device, (const VkBufferViewCreateInfo*)local_pCreateInfo, pAllocator, pView);
1799     if (local_pCreateInfo) {
1800         delete local_pCreateInfo;
1801     }
1802     if (VK_SUCCESS == result) {
1803         *pView = layer_data->WrapNew(*pView);
1804     }
1805     return result;
1806 }
1807 
DispatchDestroyBufferView(VkDevice device,VkBufferView bufferView,const VkAllocationCallbacks * pAllocator)1808 void DispatchDestroyBufferView(
1809     VkDevice                                    device,
1810     VkBufferView                                bufferView,
1811     const VkAllocationCallbacks*                pAllocator)
1812 {
1813     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1814     if (!wrap_handles) return layer_data->device_dispatch_table.DestroyBufferView(device, bufferView, pAllocator);
1815     uint64_t bufferView_id = reinterpret_cast<uint64_t &>(bufferView);
1816     auto iter = unique_id_mapping.pop(bufferView_id);
1817     if (iter != unique_id_mapping.end()) {
1818         bufferView = (VkBufferView)iter->second;
1819     } else {
1820         bufferView = (VkBufferView)0;
1821     }
1822     layer_data->device_dispatch_table.DestroyBufferView(device, bufferView, pAllocator);
1823 
1824 }
1825 
DispatchCreateImage(VkDevice device,const VkImageCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkImage * pImage)1826 VkResult DispatchCreateImage(
1827     VkDevice                                    device,
1828     const VkImageCreateInfo*                    pCreateInfo,
1829     const VkAllocationCallbacks*                pAllocator,
1830     VkImage*                                    pImage)
1831 {
1832     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1833     if (!wrap_handles) return layer_data->device_dispatch_table.CreateImage(device, pCreateInfo, pAllocator, pImage);
1834     safe_VkImageCreateInfo *local_pCreateInfo = NULL;
1835     {
1836         if (pCreateInfo) {
1837             local_pCreateInfo = new safe_VkImageCreateInfo(pCreateInfo);
1838             WrapPnextChainHandles(layer_data, local_pCreateInfo->pNext);
1839         }
1840     }
1841     VkResult result = layer_data->device_dispatch_table.CreateImage(device, (const VkImageCreateInfo*)local_pCreateInfo, pAllocator, pImage);
1842     if (local_pCreateInfo) {
1843         delete local_pCreateInfo;
1844     }
1845     if (VK_SUCCESS == result) {
1846         *pImage = layer_data->WrapNew(*pImage);
1847     }
1848     return result;
1849 }
1850 
DispatchDestroyImage(VkDevice device,VkImage image,const VkAllocationCallbacks * pAllocator)1851 void DispatchDestroyImage(
1852     VkDevice                                    device,
1853     VkImage                                     image,
1854     const VkAllocationCallbacks*                pAllocator)
1855 {
1856     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1857     if (!wrap_handles) return layer_data->device_dispatch_table.DestroyImage(device, image, pAllocator);
1858     uint64_t image_id = reinterpret_cast<uint64_t &>(image);
1859     auto iter = unique_id_mapping.pop(image_id);
1860     if (iter != unique_id_mapping.end()) {
1861         image = (VkImage)iter->second;
1862     } else {
1863         image = (VkImage)0;
1864     }
1865     layer_data->device_dispatch_table.DestroyImage(device, image, pAllocator);
1866 
1867 }
1868 
DispatchGetImageSubresourceLayout(VkDevice device,VkImage image,const VkImageSubresource * pSubresource,VkSubresourceLayout * pLayout)1869 void DispatchGetImageSubresourceLayout(
1870     VkDevice                                    device,
1871     VkImage                                     image,
1872     const VkImageSubresource*                   pSubresource,
1873     VkSubresourceLayout*                        pLayout)
1874 {
1875     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1876     if (!wrap_handles) return layer_data->device_dispatch_table.GetImageSubresourceLayout(device, image, pSubresource, pLayout);
1877     {
1878         image = layer_data->Unwrap(image);
1879     }
1880     layer_data->device_dispatch_table.GetImageSubresourceLayout(device, image, pSubresource, pLayout);
1881 
1882 }
1883 
DispatchCreateImageView(VkDevice device,const VkImageViewCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkImageView * pView)1884 VkResult DispatchCreateImageView(
1885     VkDevice                                    device,
1886     const VkImageViewCreateInfo*                pCreateInfo,
1887     const VkAllocationCallbacks*                pAllocator,
1888     VkImageView*                                pView)
1889 {
1890     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1891     if (!wrap_handles) return layer_data->device_dispatch_table.CreateImageView(device, pCreateInfo, pAllocator, pView);
1892     safe_VkImageViewCreateInfo *local_pCreateInfo = NULL;
1893     {
1894         if (pCreateInfo) {
1895             local_pCreateInfo = new safe_VkImageViewCreateInfo(pCreateInfo);
1896             if (pCreateInfo->image) {
1897                 local_pCreateInfo->image = layer_data->Unwrap(pCreateInfo->image);
1898             }
1899             WrapPnextChainHandles(layer_data, local_pCreateInfo->pNext);
1900         }
1901     }
1902     VkResult result = layer_data->device_dispatch_table.CreateImageView(device, (const VkImageViewCreateInfo*)local_pCreateInfo, pAllocator, pView);
1903     if (local_pCreateInfo) {
1904         delete local_pCreateInfo;
1905     }
1906     if (VK_SUCCESS == result) {
1907         *pView = layer_data->WrapNew(*pView);
1908     }
1909     return result;
1910 }
1911 
DispatchDestroyImageView(VkDevice device,VkImageView imageView,const VkAllocationCallbacks * pAllocator)1912 void DispatchDestroyImageView(
1913     VkDevice                                    device,
1914     VkImageView                                 imageView,
1915     const VkAllocationCallbacks*                pAllocator)
1916 {
1917     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1918     if (!wrap_handles) return layer_data->device_dispatch_table.DestroyImageView(device, imageView, pAllocator);
1919     uint64_t imageView_id = reinterpret_cast<uint64_t &>(imageView);
1920     auto iter = unique_id_mapping.pop(imageView_id);
1921     if (iter != unique_id_mapping.end()) {
1922         imageView = (VkImageView)iter->second;
1923     } else {
1924         imageView = (VkImageView)0;
1925     }
1926     layer_data->device_dispatch_table.DestroyImageView(device, imageView, pAllocator);
1927 
1928 }
1929 
DispatchCreateShaderModule(VkDevice device,const VkShaderModuleCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkShaderModule * pShaderModule)1930 VkResult DispatchCreateShaderModule(
1931     VkDevice                                    device,
1932     const VkShaderModuleCreateInfo*             pCreateInfo,
1933     const VkAllocationCallbacks*                pAllocator,
1934     VkShaderModule*                             pShaderModule)
1935 {
1936     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1937     if (!wrap_handles) return layer_data->device_dispatch_table.CreateShaderModule(device, pCreateInfo, pAllocator, pShaderModule);
1938     safe_VkShaderModuleCreateInfo *local_pCreateInfo = NULL;
1939     {
1940         if (pCreateInfo) {
1941             local_pCreateInfo = new safe_VkShaderModuleCreateInfo(pCreateInfo);
1942             WrapPnextChainHandles(layer_data, local_pCreateInfo->pNext);
1943         }
1944     }
1945     VkResult result = layer_data->device_dispatch_table.CreateShaderModule(device, (const VkShaderModuleCreateInfo*)local_pCreateInfo, pAllocator, pShaderModule);
1946     if (local_pCreateInfo) {
1947         delete local_pCreateInfo;
1948     }
1949     if (VK_SUCCESS == result) {
1950         *pShaderModule = layer_data->WrapNew(*pShaderModule);
1951     }
1952     return result;
1953 }
1954 
DispatchDestroyShaderModule(VkDevice device,VkShaderModule shaderModule,const VkAllocationCallbacks * pAllocator)1955 void DispatchDestroyShaderModule(
1956     VkDevice                                    device,
1957     VkShaderModule                              shaderModule,
1958     const VkAllocationCallbacks*                pAllocator)
1959 {
1960     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1961     if (!wrap_handles) return layer_data->device_dispatch_table.DestroyShaderModule(device, shaderModule, pAllocator);
1962     uint64_t shaderModule_id = reinterpret_cast<uint64_t &>(shaderModule);
1963     auto iter = unique_id_mapping.pop(shaderModule_id);
1964     if (iter != unique_id_mapping.end()) {
1965         shaderModule = (VkShaderModule)iter->second;
1966     } else {
1967         shaderModule = (VkShaderModule)0;
1968     }
1969     layer_data->device_dispatch_table.DestroyShaderModule(device, shaderModule, pAllocator);
1970 
1971 }
1972 
DispatchCreatePipelineCache(VkDevice device,const VkPipelineCacheCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkPipelineCache * pPipelineCache)1973 VkResult DispatchCreatePipelineCache(
1974     VkDevice                                    device,
1975     const VkPipelineCacheCreateInfo*            pCreateInfo,
1976     const VkAllocationCallbacks*                pAllocator,
1977     VkPipelineCache*                            pPipelineCache)
1978 {
1979     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1980     if (!wrap_handles) return layer_data->device_dispatch_table.CreatePipelineCache(device, pCreateInfo, pAllocator, pPipelineCache);
1981     VkResult result = layer_data->device_dispatch_table.CreatePipelineCache(device, pCreateInfo, pAllocator, pPipelineCache);
1982     if (VK_SUCCESS == result) {
1983         *pPipelineCache = layer_data->WrapNew(*pPipelineCache);
1984     }
1985     return result;
1986 }
1987 
DispatchDestroyPipelineCache(VkDevice device,VkPipelineCache pipelineCache,const VkAllocationCallbacks * pAllocator)1988 void DispatchDestroyPipelineCache(
1989     VkDevice                                    device,
1990     VkPipelineCache                             pipelineCache,
1991     const VkAllocationCallbacks*                pAllocator)
1992 {
1993     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
1994     if (!wrap_handles) return layer_data->device_dispatch_table.DestroyPipelineCache(device, pipelineCache, pAllocator);
1995     uint64_t pipelineCache_id = reinterpret_cast<uint64_t &>(pipelineCache);
1996     auto iter = unique_id_mapping.pop(pipelineCache_id);
1997     if (iter != unique_id_mapping.end()) {
1998         pipelineCache = (VkPipelineCache)iter->second;
1999     } else {
2000         pipelineCache = (VkPipelineCache)0;
2001     }
2002     layer_data->device_dispatch_table.DestroyPipelineCache(device, pipelineCache, pAllocator);
2003 
2004 }
2005 
DispatchGetPipelineCacheData(VkDevice device,VkPipelineCache pipelineCache,size_t * pDataSize,void * pData)2006 VkResult DispatchGetPipelineCacheData(
2007     VkDevice                                    device,
2008     VkPipelineCache                             pipelineCache,
2009     size_t*                                     pDataSize,
2010     void*                                       pData)
2011 {
2012     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2013     if (!wrap_handles) return layer_data->device_dispatch_table.GetPipelineCacheData(device, pipelineCache, pDataSize, pData);
2014     {
2015         pipelineCache = layer_data->Unwrap(pipelineCache);
2016     }
2017     VkResult result = layer_data->device_dispatch_table.GetPipelineCacheData(device, pipelineCache, pDataSize, pData);
2018 
2019     return result;
2020 }
2021 
DispatchMergePipelineCaches(VkDevice device,VkPipelineCache dstCache,uint32_t srcCacheCount,const VkPipelineCache * pSrcCaches)2022 VkResult DispatchMergePipelineCaches(
2023     VkDevice                                    device,
2024     VkPipelineCache                             dstCache,
2025     uint32_t                                    srcCacheCount,
2026     const VkPipelineCache*                      pSrcCaches)
2027 {
2028     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2029     if (!wrap_handles) return layer_data->device_dispatch_table.MergePipelineCaches(device, dstCache, srcCacheCount, pSrcCaches);
2030     VkPipelineCache *local_pSrcCaches = NULL;
2031     {
2032         dstCache = layer_data->Unwrap(dstCache);
2033         if (pSrcCaches) {
2034             local_pSrcCaches = new VkPipelineCache[srcCacheCount];
2035             for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
2036                 local_pSrcCaches[index0] = layer_data->Unwrap(pSrcCaches[index0]);
2037             }
2038         }
2039     }
2040     VkResult result = layer_data->device_dispatch_table.MergePipelineCaches(device, dstCache, srcCacheCount, (const VkPipelineCache*)local_pSrcCaches);
2041     if (local_pSrcCaches)
2042         delete[] local_pSrcCaches;
2043     return result;
2044 }
2045 
2046 // Skip vkCreateGraphicsPipelines dispatch, manually generated
2047 
2048 // Skip vkCreateComputePipelines dispatch, manually generated
2049 
DispatchDestroyPipeline(VkDevice device,VkPipeline pipeline,const VkAllocationCallbacks * pAllocator)2050 void DispatchDestroyPipeline(
2051     VkDevice                                    device,
2052     VkPipeline                                  pipeline,
2053     const VkAllocationCallbacks*                pAllocator)
2054 {
2055     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2056     if (!wrap_handles) return layer_data->device_dispatch_table.DestroyPipeline(device, pipeline, pAllocator);
2057     uint64_t pipeline_id = reinterpret_cast<uint64_t &>(pipeline);
2058     auto iter = unique_id_mapping.pop(pipeline_id);
2059     if (iter != unique_id_mapping.end()) {
2060         pipeline = (VkPipeline)iter->second;
2061     } else {
2062         pipeline = (VkPipeline)0;
2063     }
2064     layer_data->device_dispatch_table.DestroyPipeline(device, pipeline, pAllocator);
2065 
2066 }
2067 
DispatchCreatePipelineLayout(VkDevice device,const VkPipelineLayoutCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkPipelineLayout * pPipelineLayout)2068 VkResult DispatchCreatePipelineLayout(
2069     VkDevice                                    device,
2070     const VkPipelineLayoutCreateInfo*           pCreateInfo,
2071     const VkAllocationCallbacks*                pAllocator,
2072     VkPipelineLayout*                           pPipelineLayout)
2073 {
2074     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2075     if (!wrap_handles) return layer_data->device_dispatch_table.CreatePipelineLayout(device, pCreateInfo, pAllocator, pPipelineLayout);
2076     safe_VkPipelineLayoutCreateInfo *local_pCreateInfo = NULL;
2077     {
2078         if (pCreateInfo) {
2079             local_pCreateInfo = new safe_VkPipelineLayoutCreateInfo(pCreateInfo);
2080             if (local_pCreateInfo->pSetLayouts) {
2081                 for (uint32_t index1 = 0; index1 < local_pCreateInfo->setLayoutCount; ++index1) {
2082                     local_pCreateInfo->pSetLayouts[index1] = layer_data->Unwrap(local_pCreateInfo->pSetLayouts[index1]);
2083                 }
2084             }
2085         }
2086     }
2087     VkResult result = layer_data->device_dispatch_table.CreatePipelineLayout(device, (const VkPipelineLayoutCreateInfo*)local_pCreateInfo, pAllocator, pPipelineLayout);
2088     if (local_pCreateInfo) {
2089         delete local_pCreateInfo;
2090     }
2091     if (VK_SUCCESS == result) {
2092         *pPipelineLayout = layer_data->WrapNew(*pPipelineLayout);
2093     }
2094     return result;
2095 }
2096 
DispatchDestroyPipelineLayout(VkDevice device,VkPipelineLayout pipelineLayout,const VkAllocationCallbacks * pAllocator)2097 void DispatchDestroyPipelineLayout(
2098     VkDevice                                    device,
2099     VkPipelineLayout                            pipelineLayout,
2100     const VkAllocationCallbacks*                pAllocator)
2101 {
2102     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2103     if (!wrap_handles) return layer_data->device_dispatch_table.DestroyPipelineLayout(device, pipelineLayout, pAllocator);
2104     uint64_t pipelineLayout_id = reinterpret_cast<uint64_t &>(pipelineLayout);
2105     auto iter = unique_id_mapping.pop(pipelineLayout_id);
2106     if (iter != unique_id_mapping.end()) {
2107         pipelineLayout = (VkPipelineLayout)iter->second;
2108     } else {
2109         pipelineLayout = (VkPipelineLayout)0;
2110     }
2111     layer_data->device_dispatch_table.DestroyPipelineLayout(device, pipelineLayout, pAllocator);
2112 
2113 }
2114 
DispatchCreateSampler(VkDevice device,const VkSamplerCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSampler * pSampler)2115 VkResult DispatchCreateSampler(
2116     VkDevice                                    device,
2117     const VkSamplerCreateInfo*                  pCreateInfo,
2118     const VkAllocationCallbacks*                pAllocator,
2119     VkSampler*                                  pSampler)
2120 {
2121     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2122     if (!wrap_handles) return layer_data->device_dispatch_table.CreateSampler(device, pCreateInfo, pAllocator, pSampler);
2123     safe_VkSamplerCreateInfo *local_pCreateInfo = NULL;
2124     {
2125         if (pCreateInfo) {
2126             local_pCreateInfo = new safe_VkSamplerCreateInfo(pCreateInfo);
2127             WrapPnextChainHandles(layer_data, local_pCreateInfo->pNext);
2128         }
2129     }
2130     VkResult result = layer_data->device_dispatch_table.CreateSampler(device, (const VkSamplerCreateInfo*)local_pCreateInfo, pAllocator, pSampler);
2131     if (local_pCreateInfo) {
2132         delete local_pCreateInfo;
2133     }
2134     if (VK_SUCCESS == result) {
2135         *pSampler = layer_data->WrapNew(*pSampler);
2136     }
2137     return result;
2138 }
2139 
DispatchDestroySampler(VkDevice device,VkSampler sampler,const VkAllocationCallbacks * pAllocator)2140 void DispatchDestroySampler(
2141     VkDevice                                    device,
2142     VkSampler                                   sampler,
2143     const VkAllocationCallbacks*                pAllocator)
2144 {
2145     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2146     if (!wrap_handles) return layer_data->device_dispatch_table.DestroySampler(device, sampler, pAllocator);
2147     uint64_t sampler_id = reinterpret_cast<uint64_t &>(sampler);
2148     auto iter = unique_id_mapping.pop(sampler_id);
2149     if (iter != unique_id_mapping.end()) {
2150         sampler = (VkSampler)iter->second;
2151     } else {
2152         sampler = (VkSampler)0;
2153     }
2154     layer_data->device_dispatch_table.DestroySampler(device, sampler, pAllocator);
2155 
2156 }
2157 
DispatchCreateDescriptorSetLayout(VkDevice device,const VkDescriptorSetLayoutCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkDescriptorSetLayout * pSetLayout)2158 VkResult DispatchCreateDescriptorSetLayout(
2159     VkDevice                                    device,
2160     const VkDescriptorSetLayoutCreateInfo*      pCreateInfo,
2161     const VkAllocationCallbacks*                pAllocator,
2162     VkDescriptorSetLayout*                      pSetLayout)
2163 {
2164     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2165     if (!wrap_handles) return layer_data->device_dispatch_table.CreateDescriptorSetLayout(device, pCreateInfo, pAllocator, pSetLayout);
2166     safe_VkDescriptorSetLayoutCreateInfo *local_pCreateInfo = NULL;
2167     {
2168         if (pCreateInfo) {
2169             local_pCreateInfo = new safe_VkDescriptorSetLayoutCreateInfo(pCreateInfo);
2170             if (local_pCreateInfo->pBindings) {
2171                 for (uint32_t index1 = 0; index1 < local_pCreateInfo->bindingCount; ++index1) {
2172                     if (local_pCreateInfo->pBindings[index1].pImmutableSamplers) {
2173                         for (uint32_t index2 = 0; index2 < local_pCreateInfo->pBindings[index1].descriptorCount; ++index2) {
2174                             local_pCreateInfo->pBindings[index1].pImmutableSamplers[index2] = layer_data->Unwrap(local_pCreateInfo->pBindings[index1].pImmutableSamplers[index2]);
2175                         }
2176                     }
2177                 }
2178             }
2179         }
2180     }
2181     VkResult result = layer_data->device_dispatch_table.CreateDescriptorSetLayout(device, (const VkDescriptorSetLayoutCreateInfo*)local_pCreateInfo, pAllocator, pSetLayout);
2182     if (local_pCreateInfo) {
2183         delete local_pCreateInfo;
2184     }
2185     if (VK_SUCCESS == result) {
2186         *pSetLayout = layer_data->WrapNew(*pSetLayout);
2187     }
2188     return result;
2189 }
2190 
DispatchDestroyDescriptorSetLayout(VkDevice device,VkDescriptorSetLayout descriptorSetLayout,const VkAllocationCallbacks * pAllocator)2191 void DispatchDestroyDescriptorSetLayout(
2192     VkDevice                                    device,
2193     VkDescriptorSetLayout                       descriptorSetLayout,
2194     const VkAllocationCallbacks*                pAllocator)
2195 {
2196     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2197     if (!wrap_handles) return layer_data->device_dispatch_table.DestroyDescriptorSetLayout(device, descriptorSetLayout, pAllocator);
2198     uint64_t descriptorSetLayout_id = reinterpret_cast<uint64_t &>(descriptorSetLayout);
2199     auto iter = unique_id_mapping.pop(descriptorSetLayout_id);
2200     if (iter != unique_id_mapping.end()) {
2201         descriptorSetLayout = (VkDescriptorSetLayout)iter->second;
2202     } else {
2203         descriptorSetLayout = (VkDescriptorSetLayout)0;
2204     }
2205     layer_data->device_dispatch_table.DestroyDescriptorSetLayout(device, descriptorSetLayout, pAllocator);
2206 
2207 }
2208 
DispatchCreateDescriptorPool(VkDevice device,const VkDescriptorPoolCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkDescriptorPool * pDescriptorPool)2209 VkResult DispatchCreateDescriptorPool(
2210     VkDevice                                    device,
2211     const VkDescriptorPoolCreateInfo*           pCreateInfo,
2212     const VkAllocationCallbacks*                pAllocator,
2213     VkDescriptorPool*                           pDescriptorPool)
2214 {
2215     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2216     if (!wrap_handles) return layer_data->device_dispatch_table.CreateDescriptorPool(device, pCreateInfo, pAllocator, pDescriptorPool);
2217     VkResult result = layer_data->device_dispatch_table.CreateDescriptorPool(device, pCreateInfo, pAllocator, pDescriptorPool);
2218     if (VK_SUCCESS == result) {
2219         *pDescriptorPool = layer_data->WrapNew(*pDescriptorPool);
2220     }
2221     return result;
2222 }
2223 
2224 // Skip vkDestroyDescriptorPool dispatch, manually generated
2225 
2226 // Skip vkResetDescriptorPool dispatch, manually generated
2227 
2228 // Skip vkAllocateDescriptorSets dispatch, manually generated
2229 
2230 // Skip vkFreeDescriptorSets dispatch, manually generated
2231 
DispatchUpdateDescriptorSets(VkDevice device,uint32_t descriptorWriteCount,const VkWriteDescriptorSet * pDescriptorWrites,uint32_t descriptorCopyCount,const VkCopyDescriptorSet * pDescriptorCopies)2232 void DispatchUpdateDescriptorSets(
2233     VkDevice                                    device,
2234     uint32_t                                    descriptorWriteCount,
2235     const VkWriteDescriptorSet*                 pDescriptorWrites,
2236     uint32_t                                    descriptorCopyCount,
2237     const VkCopyDescriptorSet*                  pDescriptorCopies)
2238 {
2239     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2240     if (!wrap_handles) return layer_data->device_dispatch_table.UpdateDescriptorSets(device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies);
2241     safe_VkWriteDescriptorSet *local_pDescriptorWrites = NULL;
2242     safe_VkCopyDescriptorSet *local_pDescriptorCopies = NULL;
2243     {
2244         if (pDescriptorWrites) {
2245             local_pDescriptorWrites = new safe_VkWriteDescriptorSet[descriptorWriteCount];
2246             for (uint32_t index0 = 0; index0 < descriptorWriteCount; ++index0) {
2247                 local_pDescriptorWrites[index0].initialize(&pDescriptorWrites[index0]);
2248                 WrapPnextChainHandles(layer_data, local_pDescriptorWrites[index0].pNext);
2249                 if (pDescriptorWrites[index0].dstSet) {
2250                     local_pDescriptorWrites[index0].dstSet = layer_data->Unwrap(pDescriptorWrites[index0].dstSet);
2251                 }
2252                 if (local_pDescriptorWrites[index0].pImageInfo) {
2253                     for (uint32_t index1 = 0; index1 < local_pDescriptorWrites[index0].descriptorCount; ++index1) {
2254                         if (pDescriptorWrites[index0].pImageInfo[index1].sampler) {
2255                             local_pDescriptorWrites[index0].pImageInfo[index1].sampler = layer_data->Unwrap(pDescriptorWrites[index0].pImageInfo[index1].sampler);
2256                         }
2257                         if (pDescriptorWrites[index0].pImageInfo[index1].imageView) {
2258                             local_pDescriptorWrites[index0].pImageInfo[index1].imageView = layer_data->Unwrap(pDescriptorWrites[index0].pImageInfo[index1].imageView);
2259                         }
2260                     }
2261                 }
2262                 if (local_pDescriptorWrites[index0].pBufferInfo) {
2263                     for (uint32_t index1 = 0; index1 < local_pDescriptorWrites[index0].descriptorCount; ++index1) {
2264                         if (pDescriptorWrites[index0].pBufferInfo[index1].buffer) {
2265                             local_pDescriptorWrites[index0].pBufferInfo[index1].buffer = layer_data->Unwrap(pDescriptorWrites[index0].pBufferInfo[index1].buffer);
2266                         }
2267                     }
2268                 }
2269                 if (local_pDescriptorWrites[index0].pTexelBufferView) {
2270                     for (uint32_t index1 = 0; index1 < local_pDescriptorWrites[index0].descriptorCount; ++index1) {
2271                         local_pDescriptorWrites[index0].pTexelBufferView[index1] = layer_data->Unwrap(local_pDescriptorWrites[index0].pTexelBufferView[index1]);
2272                     }
2273                 }
2274             }
2275         }
2276         if (pDescriptorCopies) {
2277             local_pDescriptorCopies = new safe_VkCopyDescriptorSet[descriptorCopyCount];
2278             for (uint32_t index0 = 0; index0 < descriptorCopyCount; ++index0) {
2279                 local_pDescriptorCopies[index0].initialize(&pDescriptorCopies[index0]);
2280                 if (pDescriptorCopies[index0].srcSet) {
2281                     local_pDescriptorCopies[index0].srcSet = layer_data->Unwrap(pDescriptorCopies[index0].srcSet);
2282                 }
2283                 if (pDescriptorCopies[index0].dstSet) {
2284                     local_pDescriptorCopies[index0].dstSet = layer_data->Unwrap(pDescriptorCopies[index0].dstSet);
2285                 }
2286             }
2287         }
2288     }
2289     layer_data->device_dispatch_table.UpdateDescriptorSets(device, descriptorWriteCount, (const VkWriteDescriptorSet*)local_pDescriptorWrites, descriptorCopyCount, (const VkCopyDescriptorSet*)local_pDescriptorCopies);
2290     if (local_pDescriptorWrites) {
2291         delete[] local_pDescriptorWrites;
2292     }
2293     if (local_pDescriptorCopies) {
2294         delete[] local_pDescriptorCopies;
2295     }
2296 }
2297 
DispatchCreateFramebuffer(VkDevice device,const VkFramebufferCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkFramebuffer * pFramebuffer)2298 VkResult DispatchCreateFramebuffer(
2299     VkDevice                                    device,
2300     const VkFramebufferCreateInfo*              pCreateInfo,
2301     const VkAllocationCallbacks*                pAllocator,
2302     VkFramebuffer*                              pFramebuffer)
2303 {
2304     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2305     if (!wrap_handles) return layer_data->device_dispatch_table.CreateFramebuffer(device, pCreateInfo, pAllocator, pFramebuffer);
2306     safe_VkFramebufferCreateInfo *local_pCreateInfo = NULL;
2307     {
2308         if (pCreateInfo) {
2309             local_pCreateInfo = new safe_VkFramebufferCreateInfo(pCreateInfo);
2310             if (pCreateInfo->renderPass) {
2311                 local_pCreateInfo->renderPass = layer_data->Unwrap(pCreateInfo->renderPass);
2312             }
2313             if (local_pCreateInfo->pAttachments) {
2314                 for (uint32_t index1 = 0; index1 < local_pCreateInfo->attachmentCount; ++index1) {
2315                     local_pCreateInfo->pAttachments[index1] = layer_data->Unwrap(local_pCreateInfo->pAttachments[index1]);
2316                 }
2317             }
2318         }
2319     }
2320     VkResult result = layer_data->device_dispatch_table.CreateFramebuffer(device, (const VkFramebufferCreateInfo*)local_pCreateInfo, pAllocator, pFramebuffer);
2321     if (local_pCreateInfo) {
2322         delete local_pCreateInfo;
2323     }
2324     if (VK_SUCCESS == result) {
2325         *pFramebuffer = layer_data->WrapNew(*pFramebuffer);
2326     }
2327     return result;
2328 }
2329 
DispatchDestroyFramebuffer(VkDevice device,VkFramebuffer framebuffer,const VkAllocationCallbacks * pAllocator)2330 void DispatchDestroyFramebuffer(
2331     VkDevice                                    device,
2332     VkFramebuffer                               framebuffer,
2333     const VkAllocationCallbacks*                pAllocator)
2334 {
2335     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2336     if (!wrap_handles) return layer_data->device_dispatch_table.DestroyFramebuffer(device, framebuffer, pAllocator);
2337     uint64_t framebuffer_id = reinterpret_cast<uint64_t &>(framebuffer);
2338     auto iter = unique_id_mapping.pop(framebuffer_id);
2339     if (iter != unique_id_mapping.end()) {
2340         framebuffer = (VkFramebuffer)iter->second;
2341     } else {
2342         framebuffer = (VkFramebuffer)0;
2343     }
2344     layer_data->device_dispatch_table.DestroyFramebuffer(device, framebuffer, pAllocator);
2345 
2346 }
2347 
2348 // Skip vkCreateRenderPass dispatch, manually generated
2349 
2350 // Skip vkDestroyRenderPass dispatch, manually generated
2351 
DispatchGetRenderAreaGranularity(VkDevice device,VkRenderPass renderPass,VkExtent2D * pGranularity)2352 void DispatchGetRenderAreaGranularity(
2353     VkDevice                                    device,
2354     VkRenderPass                                renderPass,
2355     VkExtent2D*                                 pGranularity)
2356 {
2357     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2358     if (!wrap_handles) return layer_data->device_dispatch_table.GetRenderAreaGranularity(device, renderPass, pGranularity);
2359     {
2360         renderPass = layer_data->Unwrap(renderPass);
2361     }
2362     layer_data->device_dispatch_table.GetRenderAreaGranularity(device, renderPass, pGranularity);
2363 
2364 }
2365 
DispatchCreateCommandPool(VkDevice device,const VkCommandPoolCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkCommandPool * pCommandPool)2366 VkResult DispatchCreateCommandPool(
2367     VkDevice                                    device,
2368     const VkCommandPoolCreateInfo*              pCreateInfo,
2369     const VkAllocationCallbacks*                pAllocator,
2370     VkCommandPool*                              pCommandPool)
2371 {
2372     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2373     if (!wrap_handles) return layer_data->device_dispatch_table.CreateCommandPool(device, pCreateInfo, pAllocator, pCommandPool);
2374     VkResult result = layer_data->device_dispatch_table.CreateCommandPool(device, pCreateInfo, pAllocator, pCommandPool);
2375     if (VK_SUCCESS == result) {
2376         *pCommandPool = layer_data->WrapNew(*pCommandPool);
2377     }
2378     return result;
2379 }
2380 
DispatchDestroyCommandPool(VkDevice device,VkCommandPool commandPool,const VkAllocationCallbacks * pAllocator)2381 void DispatchDestroyCommandPool(
2382     VkDevice                                    device,
2383     VkCommandPool                               commandPool,
2384     const VkAllocationCallbacks*                pAllocator)
2385 {
2386     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2387     if (!wrap_handles) return layer_data->device_dispatch_table.DestroyCommandPool(device, commandPool, pAllocator);
2388     uint64_t commandPool_id = reinterpret_cast<uint64_t &>(commandPool);
2389     auto iter = unique_id_mapping.pop(commandPool_id);
2390     if (iter != unique_id_mapping.end()) {
2391         commandPool = (VkCommandPool)iter->second;
2392     } else {
2393         commandPool = (VkCommandPool)0;
2394     }
2395     layer_data->device_dispatch_table.DestroyCommandPool(device, commandPool, pAllocator);
2396 
2397 }
2398 
DispatchResetCommandPool(VkDevice device,VkCommandPool commandPool,VkCommandPoolResetFlags flags)2399 VkResult DispatchResetCommandPool(
2400     VkDevice                                    device,
2401     VkCommandPool                               commandPool,
2402     VkCommandPoolResetFlags                     flags)
2403 {
2404     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2405     if (!wrap_handles) return layer_data->device_dispatch_table.ResetCommandPool(device, commandPool, flags);
2406     {
2407         commandPool = layer_data->Unwrap(commandPool);
2408     }
2409     VkResult result = layer_data->device_dispatch_table.ResetCommandPool(device, commandPool, flags);
2410 
2411     return result;
2412 }
2413 
DispatchAllocateCommandBuffers(VkDevice device,const VkCommandBufferAllocateInfo * pAllocateInfo,VkCommandBuffer * pCommandBuffers)2414 VkResult DispatchAllocateCommandBuffers(
2415     VkDevice                                    device,
2416     const VkCommandBufferAllocateInfo*          pAllocateInfo,
2417     VkCommandBuffer*                            pCommandBuffers)
2418 {
2419     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2420     if (!wrap_handles) return layer_data->device_dispatch_table.AllocateCommandBuffers(device, pAllocateInfo, pCommandBuffers);
2421     safe_VkCommandBufferAllocateInfo *local_pAllocateInfo = NULL;
2422     {
2423         if (pAllocateInfo) {
2424             local_pAllocateInfo = new safe_VkCommandBufferAllocateInfo(pAllocateInfo);
2425             if (pAllocateInfo->commandPool) {
2426                 local_pAllocateInfo->commandPool = layer_data->Unwrap(pAllocateInfo->commandPool);
2427             }
2428         }
2429     }
2430     VkResult result = layer_data->device_dispatch_table.AllocateCommandBuffers(device, (const VkCommandBufferAllocateInfo*)local_pAllocateInfo, pCommandBuffers);
2431     if (local_pAllocateInfo) {
2432         delete local_pAllocateInfo;
2433     }
2434     return result;
2435 }
2436 
DispatchFreeCommandBuffers(VkDevice device,VkCommandPool commandPool,uint32_t commandBufferCount,const VkCommandBuffer * pCommandBuffers)2437 void DispatchFreeCommandBuffers(
2438     VkDevice                                    device,
2439     VkCommandPool                               commandPool,
2440     uint32_t                                    commandBufferCount,
2441     const VkCommandBuffer*                      pCommandBuffers)
2442 {
2443     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
2444     if (!wrap_handles) return layer_data->device_dispatch_table.FreeCommandBuffers(device, commandPool, commandBufferCount, pCommandBuffers);
2445     {
2446         commandPool = layer_data->Unwrap(commandPool);
2447     }
2448     layer_data->device_dispatch_table.FreeCommandBuffers(device, commandPool, commandBufferCount, pCommandBuffers);
2449 
2450 }
2451 
DispatchBeginCommandBuffer(VkCommandBuffer commandBuffer,const VkCommandBufferBeginInfo * pBeginInfo)2452 VkResult DispatchBeginCommandBuffer(
2453     VkCommandBuffer                             commandBuffer,
2454     const VkCommandBufferBeginInfo*             pBeginInfo)
2455 {
2456     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2457     if (!wrap_handles) return layer_data->device_dispatch_table.BeginCommandBuffer(commandBuffer, pBeginInfo);
2458     safe_VkCommandBufferBeginInfo *local_pBeginInfo = NULL;
2459     {
2460         if (pBeginInfo) {
2461             local_pBeginInfo = new safe_VkCommandBufferBeginInfo(pBeginInfo);
2462             if (local_pBeginInfo->pInheritanceInfo) {
2463                 if (pBeginInfo->pInheritanceInfo->renderPass) {
2464                     local_pBeginInfo->pInheritanceInfo->renderPass = layer_data->Unwrap(pBeginInfo->pInheritanceInfo->renderPass);
2465                 }
2466                 if (pBeginInfo->pInheritanceInfo->framebuffer) {
2467                     local_pBeginInfo->pInheritanceInfo->framebuffer = layer_data->Unwrap(pBeginInfo->pInheritanceInfo->framebuffer);
2468                 }
2469             }
2470         }
2471     }
2472     VkResult result = layer_data->device_dispatch_table.BeginCommandBuffer(commandBuffer, (const VkCommandBufferBeginInfo*)local_pBeginInfo);
2473     if (local_pBeginInfo) {
2474         delete local_pBeginInfo;
2475     }
2476     return result;
2477 }
2478 
DispatchEndCommandBuffer(VkCommandBuffer commandBuffer)2479 VkResult DispatchEndCommandBuffer(
2480     VkCommandBuffer                             commandBuffer)
2481 {
2482     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2483     VkResult result = layer_data->device_dispatch_table.EndCommandBuffer(commandBuffer);
2484 
2485     return result;
2486 }
2487 
DispatchResetCommandBuffer(VkCommandBuffer commandBuffer,VkCommandBufferResetFlags flags)2488 VkResult DispatchResetCommandBuffer(
2489     VkCommandBuffer                             commandBuffer,
2490     VkCommandBufferResetFlags                   flags)
2491 {
2492     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2493     VkResult result = layer_data->device_dispatch_table.ResetCommandBuffer(commandBuffer, flags);
2494 
2495     return result;
2496 }
2497 
DispatchCmdBindPipeline(VkCommandBuffer commandBuffer,VkPipelineBindPoint pipelineBindPoint,VkPipeline pipeline)2498 void DispatchCmdBindPipeline(
2499     VkCommandBuffer                             commandBuffer,
2500     VkPipelineBindPoint                         pipelineBindPoint,
2501     VkPipeline                                  pipeline)
2502 {
2503     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2504     if (!wrap_handles) return layer_data->device_dispatch_table.CmdBindPipeline(commandBuffer, pipelineBindPoint, pipeline);
2505     {
2506         pipeline = layer_data->Unwrap(pipeline);
2507     }
2508     layer_data->device_dispatch_table.CmdBindPipeline(commandBuffer, pipelineBindPoint, pipeline);
2509 
2510 }
2511 
DispatchCmdSetViewport(VkCommandBuffer commandBuffer,uint32_t firstViewport,uint32_t viewportCount,const VkViewport * pViewports)2512 void DispatchCmdSetViewport(
2513     VkCommandBuffer                             commandBuffer,
2514     uint32_t                                    firstViewport,
2515     uint32_t                                    viewportCount,
2516     const VkViewport*                           pViewports)
2517 {
2518     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2519     layer_data->device_dispatch_table.CmdSetViewport(commandBuffer, firstViewport, viewportCount, pViewports);
2520 
2521 }
2522 
DispatchCmdSetScissor(VkCommandBuffer commandBuffer,uint32_t firstScissor,uint32_t scissorCount,const VkRect2D * pScissors)2523 void DispatchCmdSetScissor(
2524     VkCommandBuffer                             commandBuffer,
2525     uint32_t                                    firstScissor,
2526     uint32_t                                    scissorCount,
2527     const VkRect2D*                             pScissors)
2528 {
2529     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2530     layer_data->device_dispatch_table.CmdSetScissor(commandBuffer, firstScissor, scissorCount, pScissors);
2531 
2532 }
2533 
DispatchCmdSetLineWidth(VkCommandBuffer commandBuffer,float lineWidth)2534 void DispatchCmdSetLineWidth(
2535     VkCommandBuffer                             commandBuffer,
2536     float                                       lineWidth)
2537 {
2538     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2539     layer_data->device_dispatch_table.CmdSetLineWidth(commandBuffer, lineWidth);
2540 
2541 }
2542 
DispatchCmdSetDepthBias(VkCommandBuffer commandBuffer,float depthBiasConstantFactor,float depthBiasClamp,float depthBiasSlopeFactor)2543 void DispatchCmdSetDepthBias(
2544     VkCommandBuffer                             commandBuffer,
2545     float                                       depthBiasConstantFactor,
2546     float                                       depthBiasClamp,
2547     float                                       depthBiasSlopeFactor)
2548 {
2549     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2550     layer_data->device_dispatch_table.CmdSetDepthBias(commandBuffer, depthBiasConstantFactor, depthBiasClamp, depthBiasSlopeFactor);
2551 
2552 }
2553 
DispatchCmdSetBlendConstants(VkCommandBuffer commandBuffer,const float blendConstants[4])2554 void DispatchCmdSetBlendConstants(
2555     VkCommandBuffer                             commandBuffer,
2556     const float                                 blendConstants[4])
2557 {
2558     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2559     layer_data->device_dispatch_table.CmdSetBlendConstants(commandBuffer, blendConstants);
2560 
2561 }
2562 
DispatchCmdSetDepthBounds(VkCommandBuffer commandBuffer,float minDepthBounds,float maxDepthBounds)2563 void DispatchCmdSetDepthBounds(
2564     VkCommandBuffer                             commandBuffer,
2565     float                                       minDepthBounds,
2566     float                                       maxDepthBounds)
2567 {
2568     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2569     layer_data->device_dispatch_table.CmdSetDepthBounds(commandBuffer, minDepthBounds, maxDepthBounds);
2570 
2571 }
2572 
DispatchCmdSetStencilCompareMask(VkCommandBuffer commandBuffer,VkStencilFaceFlags faceMask,uint32_t compareMask)2573 void DispatchCmdSetStencilCompareMask(
2574     VkCommandBuffer                             commandBuffer,
2575     VkStencilFaceFlags                          faceMask,
2576     uint32_t                                    compareMask)
2577 {
2578     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2579     layer_data->device_dispatch_table.CmdSetStencilCompareMask(commandBuffer, faceMask, compareMask);
2580 
2581 }
2582 
DispatchCmdSetStencilWriteMask(VkCommandBuffer commandBuffer,VkStencilFaceFlags faceMask,uint32_t writeMask)2583 void DispatchCmdSetStencilWriteMask(
2584     VkCommandBuffer                             commandBuffer,
2585     VkStencilFaceFlags                          faceMask,
2586     uint32_t                                    writeMask)
2587 {
2588     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2589     layer_data->device_dispatch_table.CmdSetStencilWriteMask(commandBuffer, faceMask, writeMask);
2590 
2591 }
2592 
DispatchCmdSetStencilReference(VkCommandBuffer commandBuffer,VkStencilFaceFlags faceMask,uint32_t reference)2593 void DispatchCmdSetStencilReference(
2594     VkCommandBuffer                             commandBuffer,
2595     VkStencilFaceFlags                          faceMask,
2596     uint32_t                                    reference)
2597 {
2598     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2599     layer_data->device_dispatch_table.CmdSetStencilReference(commandBuffer, faceMask, reference);
2600 
2601 }
2602 
DispatchCmdBindDescriptorSets(VkCommandBuffer commandBuffer,VkPipelineBindPoint pipelineBindPoint,VkPipelineLayout layout,uint32_t firstSet,uint32_t descriptorSetCount,const VkDescriptorSet * pDescriptorSets,uint32_t dynamicOffsetCount,const uint32_t * pDynamicOffsets)2603 void DispatchCmdBindDescriptorSets(
2604     VkCommandBuffer                             commandBuffer,
2605     VkPipelineBindPoint                         pipelineBindPoint,
2606     VkPipelineLayout                            layout,
2607     uint32_t                                    firstSet,
2608     uint32_t                                    descriptorSetCount,
2609     const VkDescriptorSet*                      pDescriptorSets,
2610     uint32_t                                    dynamicOffsetCount,
2611     const uint32_t*                             pDynamicOffsets)
2612 {
2613     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2614     if (!wrap_handles) return layer_data->device_dispatch_table.CmdBindDescriptorSets(commandBuffer, pipelineBindPoint, layout, firstSet, descriptorSetCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets);
2615     VkDescriptorSet *local_pDescriptorSets = NULL;
2616     {
2617         layout = layer_data->Unwrap(layout);
2618         if (pDescriptorSets) {
2619             local_pDescriptorSets = new VkDescriptorSet[descriptorSetCount];
2620             for (uint32_t index0 = 0; index0 < descriptorSetCount; ++index0) {
2621                 local_pDescriptorSets[index0] = layer_data->Unwrap(pDescriptorSets[index0]);
2622             }
2623         }
2624     }
2625     layer_data->device_dispatch_table.CmdBindDescriptorSets(commandBuffer, pipelineBindPoint, layout, firstSet, descriptorSetCount, (const VkDescriptorSet*)local_pDescriptorSets, dynamicOffsetCount, pDynamicOffsets);
2626     if (local_pDescriptorSets)
2627         delete[] local_pDescriptorSets;
2628 }
2629 
DispatchCmdBindIndexBuffer(VkCommandBuffer commandBuffer,VkBuffer buffer,VkDeviceSize offset,VkIndexType indexType)2630 void DispatchCmdBindIndexBuffer(
2631     VkCommandBuffer                             commandBuffer,
2632     VkBuffer                                    buffer,
2633     VkDeviceSize                                offset,
2634     VkIndexType                                 indexType)
2635 {
2636     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2637     if (!wrap_handles) return layer_data->device_dispatch_table.CmdBindIndexBuffer(commandBuffer, buffer, offset, indexType);
2638     {
2639         buffer = layer_data->Unwrap(buffer);
2640     }
2641     layer_data->device_dispatch_table.CmdBindIndexBuffer(commandBuffer, buffer, offset, indexType);
2642 
2643 }
2644 
DispatchCmdBindVertexBuffers(VkCommandBuffer commandBuffer,uint32_t firstBinding,uint32_t bindingCount,const VkBuffer * pBuffers,const VkDeviceSize * pOffsets)2645 void DispatchCmdBindVertexBuffers(
2646     VkCommandBuffer                             commandBuffer,
2647     uint32_t                                    firstBinding,
2648     uint32_t                                    bindingCount,
2649     const VkBuffer*                             pBuffers,
2650     const VkDeviceSize*                         pOffsets)
2651 {
2652     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2653     if (!wrap_handles) return layer_data->device_dispatch_table.CmdBindVertexBuffers(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets);
2654     VkBuffer *local_pBuffers = NULL;
2655     {
2656         if (pBuffers) {
2657             local_pBuffers = new VkBuffer[bindingCount];
2658             for (uint32_t index0 = 0; index0 < bindingCount; ++index0) {
2659                 local_pBuffers[index0] = layer_data->Unwrap(pBuffers[index0]);
2660             }
2661         }
2662     }
2663     layer_data->device_dispatch_table.CmdBindVertexBuffers(commandBuffer, firstBinding, bindingCount, (const VkBuffer*)local_pBuffers, pOffsets);
2664     if (local_pBuffers)
2665         delete[] local_pBuffers;
2666 }
2667 
DispatchCmdDraw(VkCommandBuffer commandBuffer,uint32_t vertexCount,uint32_t instanceCount,uint32_t firstVertex,uint32_t firstInstance)2668 void DispatchCmdDraw(
2669     VkCommandBuffer                             commandBuffer,
2670     uint32_t                                    vertexCount,
2671     uint32_t                                    instanceCount,
2672     uint32_t                                    firstVertex,
2673     uint32_t                                    firstInstance)
2674 {
2675     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2676     layer_data->device_dispatch_table.CmdDraw(commandBuffer, vertexCount, instanceCount, firstVertex, firstInstance);
2677 
2678 }
2679 
DispatchCmdDrawIndexed(VkCommandBuffer commandBuffer,uint32_t indexCount,uint32_t instanceCount,uint32_t firstIndex,int32_t vertexOffset,uint32_t firstInstance)2680 void DispatchCmdDrawIndexed(
2681     VkCommandBuffer                             commandBuffer,
2682     uint32_t                                    indexCount,
2683     uint32_t                                    instanceCount,
2684     uint32_t                                    firstIndex,
2685     int32_t                                     vertexOffset,
2686     uint32_t                                    firstInstance)
2687 {
2688     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2689     layer_data->device_dispatch_table.CmdDrawIndexed(commandBuffer, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
2690 
2691 }
2692 
DispatchCmdDrawIndirect(VkCommandBuffer commandBuffer,VkBuffer buffer,VkDeviceSize offset,uint32_t drawCount,uint32_t stride)2693 void DispatchCmdDrawIndirect(
2694     VkCommandBuffer                             commandBuffer,
2695     VkBuffer                                    buffer,
2696     VkDeviceSize                                offset,
2697     uint32_t                                    drawCount,
2698     uint32_t                                    stride)
2699 {
2700     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2701     if (!wrap_handles) return layer_data->device_dispatch_table.CmdDrawIndirect(commandBuffer, buffer, offset, drawCount, stride);
2702     {
2703         buffer = layer_data->Unwrap(buffer);
2704     }
2705     layer_data->device_dispatch_table.CmdDrawIndirect(commandBuffer, buffer, offset, drawCount, stride);
2706 
2707 }
2708 
DispatchCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer,VkBuffer buffer,VkDeviceSize offset,uint32_t drawCount,uint32_t stride)2709 void DispatchCmdDrawIndexedIndirect(
2710     VkCommandBuffer                             commandBuffer,
2711     VkBuffer                                    buffer,
2712     VkDeviceSize                                offset,
2713     uint32_t                                    drawCount,
2714     uint32_t                                    stride)
2715 {
2716     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2717     if (!wrap_handles) return layer_data->device_dispatch_table.CmdDrawIndexedIndirect(commandBuffer, buffer, offset, drawCount, stride);
2718     {
2719         buffer = layer_data->Unwrap(buffer);
2720     }
2721     layer_data->device_dispatch_table.CmdDrawIndexedIndirect(commandBuffer, buffer, offset, drawCount, stride);
2722 
2723 }
2724 
DispatchCmdDispatch(VkCommandBuffer commandBuffer,uint32_t groupCountX,uint32_t groupCountY,uint32_t groupCountZ)2725 void DispatchCmdDispatch(
2726     VkCommandBuffer                             commandBuffer,
2727     uint32_t                                    groupCountX,
2728     uint32_t                                    groupCountY,
2729     uint32_t                                    groupCountZ)
2730 {
2731     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2732     layer_data->device_dispatch_table.CmdDispatch(commandBuffer, groupCountX, groupCountY, groupCountZ);
2733 
2734 }
2735 
DispatchCmdDispatchIndirect(VkCommandBuffer commandBuffer,VkBuffer buffer,VkDeviceSize offset)2736 void DispatchCmdDispatchIndirect(
2737     VkCommandBuffer                             commandBuffer,
2738     VkBuffer                                    buffer,
2739     VkDeviceSize                                offset)
2740 {
2741     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2742     if (!wrap_handles) return layer_data->device_dispatch_table.CmdDispatchIndirect(commandBuffer, buffer, offset);
2743     {
2744         buffer = layer_data->Unwrap(buffer);
2745     }
2746     layer_data->device_dispatch_table.CmdDispatchIndirect(commandBuffer, buffer, offset);
2747 
2748 }
2749 
DispatchCmdCopyBuffer(VkCommandBuffer commandBuffer,VkBuffer srcBuffer,VkBuffer dstBuffer,uint32_t regionCount,const VkBufferCopy * pRegions)2750 void DispatchCmdCopyBuffer(
2751     VkCommandBuffer                             commandBuffer,
2752     VkBuffer                                    srcBuffer,
2753     VkBuffer                                    dstBuffer,
2754     uint32_t                                    regionCount,
2755     const VkBufferCopy*                         pRegions)
2756 {
2757     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2758     if (!wrap_handles) return layer_data->device_dispatch_table.CmdCopyBuffer(commandBuffer, srcBuffer, dstBuffer, regionCount, pRegions);
2759     {
2760         srcBuffer = layer_data->Unwrap(srcBuffer);
2761         dstBuffer = layer_data->Unwrap(dstBuffer);
2762     }
2763     layer_data->device_dispatch_table.CmdCopyBuffer(commandBuffer, srcBuffer, dstBuffer, regionCount, pRegions);
2764 
2765 }
2766 
DispatchCmdCopyImage(VkCommandBuffer commandBuffer,VkImage srcImage,VkImageLayout srcImageLayout,VkImage dstImage,VkImageLayout dstImageLayout,uint32_t regionCount,const VkImageCopy * pRegions)2767 void DispatchCmdCopyImage(
2768     VkCommandBuffer                             commandBuffer,
2769     VkImage                                     srcImage,
2770     VkImageLayout                               srcImageLayout,
2771     VkImage                                     dstImage,
2772     VkImageLayout                               dstImageLayout,
2773     uint32_t                                    regionCount,
2774     const VkImageCopy*                          pRegions)
2775 {
2776     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2777     if (!wrap_handles) return layer_data->device_dispatch_table.CmdCopyImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions);
2778     {
2779         srcImage = layer_data->Unwrap(srcImage);
2780         dstImage = layer_data->Unwrap(dstImage);
2781     }
2782     layer_data->device_dispatch_table.CmdCopyImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions);
2783 
2784 }
2785 
DispatchCmdBlitImage(VkCommandBuffer commandBuffer,VkImage srcImage,VkImageLayout srcImageLayout,VkImage dstImage,VkImageLayout dstImageLayout,uint32_t regionCount,const VkImageBlit * pRegions,VkFilter filter)2786 void DispatchCmdBlitImage(
2787     VkCommandBuffer                             commandBuffer,
2788     VkImage                                     srcImage,
2789     VkImageLayout                               srcImageLayout,
2790     VkImage                                     dstImage,
2791     VkImageLayout                               dstImageLayout,
2792     uint32_t                                    regionCount,
2793     const VkImageBlit*                          pRegions,
2794     VkFilter                                    filter)
2795 {
2796     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2797     if (!wrap_handles) return layer_data->device_dispatch_table.CmdBlitImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions, filter);
2798     {
2799         srcImage = layer_data->Unwrap(srcImage);
2800         dstImage = layer_data->Unwrap(dstImage);
2801     }
2802     layer_data->device_dispatch_table.CmdBlitImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions, filter);
2803 
2804 }
2805 
DispatchCmdCopyBufferToImage(VkCommandBuffer commandBuffer,VkBuffer srcBuffer,VkImage dstImage,VkImageLayout dstImageLayout,uint32_t regionCount,const VkBufferImageCopy * pRegions)2806 void DispatchCmdCopyBufferToImage(
2807     VkCommandBuffer                             commandBuffer,
2808     VkBuffer                                    srcBuffer,
2809     VkImage                                     dstImage,
2810     VkImageLayout                               dstImageLayout,
2811     uint32_t                                    regionCount,
2812     const VkBufferImageCopy*                    pRegions)
2813 {
2814     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2815     if (!wrap_handles) return layer_data->device_dispatch_table.CmdCopyBufferToImage(commandBuffer, srcBuffer, dstImage, dstImageLayout, regionCount, pRegions);
2816     {
2817         srcBuffer = layer_data->Unwrap(srcBuffer);
2818         dstImage = layer_data->Unwrap(dstImage);
2819     }
2820     layer_data->device_dispatch_table.CmdCopyBufferToImage(commandBuffer, srcBuffer, dstImage, dstImageLayout, regionCount, pRegions);
2821 
2822 }
2823 
DispatchCmdCopyImageToBuffer(VkCommandBuffer commandBuffer,VkImage srcImage,VkImageLayout srcImageLayout,VkBuffer dstBuffer,uint32_t regionCount,const VkBufferImageCopy * pRegions)2824 void DispatchCmdCopyImageToBuffer(
2825     VkCommandBuffer                             commandBuffer,
2826     VkImage                                     srcImage,
2827     VkImageLayout                               srcImageLayout,
2828     VkBuffer                                    dstBuffer,
2829     uint32_t                                    regionCount,
2830     const VkBufferImageCopy*                    pRegions)
2831 {
2832     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2833     if (!wrap_handles) return layer_data->device_dispatch_table.CmdCopyImageToBuffer(commandBuffer, srcImage, srcImageLayout, dstBuffer, regionCount, pRegions);
2834     {
2835         srcImage = layer_data->Unwrap(srcImage);
2836         dstBuffer = layer_data->Unwrap(dstBuffer);
2837     }
2838     layer_data->device_dispatch_table.CmdCopyImageToBuffer(commandBuffer, srcImage, srcImageLayout, dstBuffer, regionCount, pRegions);
2839 
2840 }
2841 
DispatchCmdUpdateBuffer(VkCommandBuffer commandBuffer,VkBuffer dstBuffer,VkDeviceSize dstOffset,VkDeviceSize dataSize,const void * pData)2842 void DispatchCmdUpdateBuffer(
2843     VkCommandBuffer                             commandBuffer,
2844     VkBuffer                                    dstBuffer,
2845     VkDeviceSize                                dstOffset,
2846     VkDeviceSize                                dataSize,
2847     const void*                                 pData)
2848 {
2849     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2850     if (!wrap_handles) return layer_data->device_dispatch_table.CmdUpdateBuffer(commandBuffer, dstBuffer, dstOffset, dataSize, pData);
2851     {
2852         dstBuffer = layer_data->Unwrap(dstBuffer);
2853     }
2854     layer_data->device_dispatch_table.CmdUpdateBuffer(commandBuffer, dstBuffer, dstOffset, dataSize, pData);
2855 
2856 }
2857 
DispatchCmdFillBuffer(VkCommandBuffer commandBuffer,VkBuffer dstBuffer,VkDeviceSize dstOffset,VkDeviceSize size,uint32_t data)2858 void DispatchCmdFillBuffer(
2859     VkCommandBuffer                             commandBuffer,
2860     VkBuffer                                    dstBuffer,
2861     VkDeviceSize                                dstOffset,
2862     VkDeviceSize                                size,
2863     uint32_t                                    data)
2864 {
2865     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2866     if (!wrap_handles) return layer_data->device_dispatch_table.CmdFillBuffer(commandBuffer, dstBuffer, dstOffset, size, data);
2867     {
2868         dstBuffer = layer_data->Unwrap(dstBuffer);
2869     }
2870     layer_data->device_dispatch_table.CmdFillBuffer(commandBuffer, dstBuffer, dstOffset, size, data);
2871 
2872 }
2873 
DispatchCmdClearColorImage(VkCommandBuffer commandBuffer,VkImage image,VkImageLayout imageLayout,const VkClearColorValue * pColor,uint32_t rangeCount,const VkImageSubresourceRange * pRanges)2874 void DispatchCmdClearColorImage(
2875     VkCommandBuffer                             commandBuffer,
2876     VkImage                                     image,
2877     VkImageLayout                               imageLayout,
2878     const VkClearColorValue*                    pColor,
2879     uint32_t                                    rangeCount,
2880     const VkImageSubresourceRange*              pRanges)
2881 {
2882     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2883     if (!wrap_handles) return layer_data->device_dispatch_table.CmdClearColorImage(commandBuffer, image, imageLayout, pColor, rangeCount, pRanges);
2884     {
2885         image = layer_data->Unwrap(image);
2886     }
2887     layer_data->device_dispatch_table.CmdClearColorImage(commandBuffer, image, imageLayout, pColor, rangeCount, pRanges);
2888 
2889 }
2890 
DispatchCmdClearDepthStencilImage(VkCommandBuffer commandBuffer,VkImage image,VkImageLayout imageLayout,const VkClearDepthStencilValue * pDepthStencil,uint32_t rangeCount,const VkImageSubresourceRange * pRanges)2891 void DispatchCmdClearDepthStencilImage(
2892     VkCommandBuffer                             commandBuffer,
2893     VkImage                                     image,
2894     VkImageLayout                               imageLayout,
2895     const VkClearDepthStencilValue*             pDepthStencil,
2896     uint32_t                                    rangeCount,
2897     const VkImageSubresourceRange*              pRanges)
2898 {
2899     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2900     if (!wrap_handles) return layer_data->device_dispatch_table.CmdClearDepthStencilImage(commandBuffer, image, imageLayout, pDepthStencil, rangeCount, pRanges);
2901     {
2902         image = layer_data->Unwrap(image);
2903     }
2904     layer_data->device_dispatch_table.CmdClearDepthStencilImage(commandBuffer, image, imageLayout, pDepthStencil, rangeCount, pRanges);
2905 
2906 }
2907 
DispatchCmdClearAttachments(VkCommandBuffer commandBuffer,uint32_t attachmentCount,const VkClearAttachment * pAttachments,uint32_t rectCount,const VkClearRect * pRects)2908 void DispatchCmdClearAttachments(
2909     VkCommandBuffer                             commandBuffer,
2910     uint32_t                                    attachmentCount,
2911     const VkClearAttachment*                    pAttachments,
2912     uint32_t                                    rectCount,
2913     const VkClearRect*                          pRects)
2914 {
2915     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2916     layer_data->device_dispatch_table.CmdClearAttachments(commandBuffer, attachmentCount, pAttachments, rectCount, pRects);
2917 
2918 }
2919 
DispatchCmdResolveImage(VkCommandBuffer commandBuffer,VkImage srcImage,VkImageLayout srcImageLayout,VkImage dstImage,VkImageLayout dstImageLayout,uint32_t regionCount,const VkImageResolve * pRegions)2920 void DispatchCmdResolveImage(
2921     VkCommandBuffer                             commandBuffer,
2922     VkImage                                     srcImage,
2923     VkImageLayout                               srcImageLayout,
2924     VkImage                                     dstImage,
2925     VkImageLayout                               dstImageLayout,
2926     uint32_t                                    regionCount,
2927     const VkImageResolve*                       pRegions)
2928 {
2929     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2930     if (!wrap_handles) return layer_data->device_dispatch_table.CmdResolveImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions);
2931     {
2932         srcImage = layer_data->Unwrap(srcImage);
2933         dstImage = layer_data->Unwrap(dstImage);
2934     }
2935     layer_data->device_dispatch_table.CmdResolveImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions);
2936 
2937 }
2938 
DispatchCmdSetEvent(VkCommandBuffer commandBuffer,VkEvent event,VkPipelineStageFlags stageMask)2939 void DispatchCmdSetEvent(
2940     VkCommandBuffer                             commandBuffer,
2941     VkEvent                                     event,
2942     VkPipelineStageFlags                        stageMask)
2943 {
2944     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2945     if (!wrap_handles) return layer_data->device_dispatch_table.CmdSetEvent(commandBuffer, event, stageMask);
2946     {
2947         event = layer_data->Unwrap(event);
2948     }
2949     layer_data->device_dispatch_table.CmdSetEvent(commandBuffer, event, stageMask);
2950 
2951 }
2952 
DispatchCmdResetEvent(VkCommandBuffer commandBuffer,VkEvent event,VkPipelineStageFlags stageMask)2953 void DispatchCmdResetEvent(
2954     VkCommandBuffer                             commandBuffer,
2955     VkEvent                                     event,
2956     VkPipelineStageFlags                        stageMask)
2957 {
2958     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2959     if (!wrap_handles) return layer_data->device_dispatch_table.CmdResetEvent(commandBuffer, event, stageMask);
2960     {
2961         event = layer_data->Unwrap(event);
2962     }
2963     layer_data->device_dispatch_table.CmdResetEvent(commandBuffer, event, stageMask);
2964 
2965 }
2966 
DispatchCmdWaitEvents(VkCommandBuffer commandBuffer,uint32_t eventCount,const VkEvent * pEvents,VkPipelineStageFlags srcStageMask,VkPipelineStageFlags dstStageMask,uint32_t memoryBarrierCount,const VkMemoryBarrier * pMemoryBarriers,uint32_t bufferMemoryBarrierCount,const VkBufferMemoryBarrier * pBufferMemoryBarriers,uint32_t imageMemoryBarrierCount,const VkImageMemoryBarrier * pImageMemoryBarriers)2967 void DispatchCmdWaitEvents(
2968     VkCommandBuffer                             commandBuffer,
2969     uint32_t                                    eventCount,
2970     const VkEvent*                              pEvents,
2971     VkPipelineStageFlags                        srcStageMask,
2972     VkPipelineStageFlags                        dstStageMask,
2973     uint32_t                                    memoryBarrierCount,
2974     const VkMemoryBarrier*                      pMemoryBarriers,
2975     uint32_t                                    bufferMemoryBarrierCount,
2976     const VkBufferMemoryBarrier*                pBufferMemoryBarriers,
2977     uint32_t                                    imageMemoryBarrierCount,
2978     const VkImageMemoryBarrier*                 pImageMemoryBarriers)
2979 {
2980     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
2981     if (!wrap_handles) return layer_data->device_dispatch_table.CmdWaitEvents(commandBuffer, eventCount, pEvents, srcStageMask, dstStageMask, memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers);
2982     VkEvent *local_pEvents = NULL;
2983     safe_VkBufferMemoryBarrier *local_pBufferMemoryBarriers = NULL;
2984     safe_VkImageMemoryBarrier *local_pImageMemoryBarriers = NULL;
2985     {
2986         if (pEvents) {
2987             local_pEvents = new VkEvent[eventCount];
2988             for (uint32_t index0 = 0; index0 < eventCount; ++index0) {
2989                 local_pEvents[index0] = layer_data->Unwrap(pEvents[index0]);
2990             }
2991         }
2992         if (pBufferMemoryBarriers) {
2993             local_pBufferMemoryBarriers = new safe_VkBufferMemoryBarrier[bufferMemoryBarrierCount];
2994             for (uint32_t index0 = 0; index0 < bufferMemoryBarrierCount; ++index0) {
2995                 local_pBufferMemoryBarriers[index0].initialize(&pBufferMemoryBarriers[index0]);
2996                 if (pBufferMemoryBarriers[index0].buffer) {
2997                     local_pBufferMemoryBarriers[index0].buffer = layer_data->Unwrap(pBufferMemoryBarriers[index0].buffer);
2998                 }
2999             }
3000         }
3001         if (pImageMemoryBarriers) {
3002             local_pImageMemoryBarriers = new safe_VkImageMemoryBarrier[imageMemoryBarrierCount];
3003             for (uint32_t index0 = 0; index0 < imageMemoryBarrierCount; ++index0) {
3004                 local_pImageMemoryBarriers[index0].initialize(&pImageMemoryBarriers[index0]);
3005                 if (pImageMemoryBarriers[index0].image) {
3006                     local_pImageMemoryBarriers[index0].image = layer_data->Unwrap(pImageMemoryBarriers[index0].image);
3007                 }
3008             }
3009         }
3010     }
3011     layer_data->device_dispatch_table.CmdWaitEvents(commandBuffer, eventCount, (const VkEvent*)local_pEvents, srcStageMask, dstStageMask, memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, (const VkBufferMemoryBarrier*)local_pBufferMemoryBarriers, imageMemoryBarrierCount, (const VkImageMemoryBarrier*)local_pImageMemoryBarriers);
3012     if (local_pEvents)
3013         delete[] local_pEvents;
3014     if (local_pBufferMemoryBarriers) {
3015         delete[] local_pBufferMemoryBarriers;
3016     }
3017     if (local_pImageMemoryBarriers) {
3018         delete[] local_pImageMemoryBarriers;
3019     }
3020 }
3021 
DispatchCmdPipelineBarrier(VkCommandBuffer commandBuffer,VkPipelineStageFlags srcStageMask,VkPipelineStageFlags dstStageMask,VkDependencyFlags dependencyFlags,uint32_t memoryBarrierCount,const VkMemoryBarrier * pMemoryBarriers,uint32_t bufferMemoryBarrierCount,const VkBufferMemoryBarrier * pBufferMemoryBarriers,uint32_t imageMemoryBarrierCount,const VkImageMemoryBarrier * pImageMemoryBarriers)3022 void DispatchCmdPipelineBarrier(
3023     VkCommandBuffer                             commandBuffer,
3024     VkPipelineStageFlags                        srcStageMask,
3025     VkPipelineStageFlags                        dstStageMask,
3026     VkDependencyFlags                           dependencyFlags,
3027     uint32_t                                    memoryBarrierCount,
3028     const VkMemoryBarrier*                      pMemoryBarriers,
3029     uint32_t                                    bufferMemoryBarrierCount,
3030     const VkBufferMemoryBarrier*                pBufferMemoryBarriers,
3031     uint32_t                                    imageMemoryBarrierCount,
3032     const VkImageMemoryBarrier*                 pImageMemoryBarriers)
3033 {
3034     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
3035     if (!wrap_handles) return layer_data->device_dispatch_table.CmdPipelineBarrier(commandBuffer, srcStageMask, dstStageMask, dependencyFlags, memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers);
3036     safe_VkBufferMemoryBarrier *local_pBufferMemoryBarriers = NULL;
3037     safe_VkImageMemoryBarrier *local_pImageMemoryBarriers = NULL;
3038     {
3039         if (pBufferMemoryBarriers) {
3040             local_pBufferMemoryBarriers = new safe_VkBufferMemoryBarrier[bufferMemoryBarrierCount];
3041             for (uint32_t index0 = 0; index0 < bufferMemoryBarrierCount; ++index0) {
3042                 local_pBufferMemoryBarriers[index0].initialize(&pBufferMemoryBarriers[index0]);
3043                 if (pBufferMemoryBarriers[index0].buffer) {
3044                     local_pBufferMemoryBarriers[index0].buffer = layer_data->Unwrap(pBufferMemoryBarriers[index0].buffer);
3045                 }
3046             }
3047         }
3048         if (pImageMemoryBarriers) {
3049             local_pImageMemoryBarriers = new safe_VkImageMemoryBarrier[imageMemoryBarrierCount];
3050             for (uint32_t index0 = 0; index0 < imageMemoryBarrierCount; ++index0) {
3051                 local_pImageMemoryBarriers[index0].initialize(&pImageMemoryBarriers[index0]);
3052                 if (pImageMemoryBarriers[index0].image) {
3053                     local_pImageMemoryBarriers[index0].image = layer_data->Unwrap(pImageMemoryBarriers[index0].image);
3054                 }
3055             }
3056         }
3057     }
3058     layer_data->device_dispatch_table.CmdPipelineBarrier(commandBuffer, srcStageMask, dstStageMask, dependencyFlags, memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, (const VkBufferMemoryBarrier*)local_pBufferMemoryBarriers, imageMemoryBarrierCount, (const VkImageMemoryBarrier*)local_pImageMemoryBarriers);
3059     if (local_pBufferMemoryBarriers) {
3060         delete[] local_pBufferMemoryBarriers;
3061     }
3062     if (local_pImageMemoryBarriers) {
3063         delete[] local_pImageMemoryBarriers;
3064     }
3065 }
3066 
DispatchCmdBeginQuery(VkCommandBuffer commandBuffer,VkQueryPool queryPool,uint32_t query,VkQueryControlFlags flags)3067 void DispatchCmdBeginQuery(
3068     VkCommandBuffer                             commandBuffer,
3069     VkQueryPool                                 queryPool,
3070     uint32_t                                    query,
3071     VkQueryControlFlags                         flags)
3072 {
3073     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
3074     if (!wrap_handles) return layer_data->device_dispatch_table.CmdBeginQuery(commandBuffer, queryPool, query, flags);
3075     {
3076         queryPool = layer_data->Unwrap(queryPool);
3077     }
3078     layer_data->device_dispatch_table.CmdBeginQuery(commandBuffer, queryPool, query, flags);
3079 
3080 }
3081 
DispatchCmdEndQuery(VkCommandBuffer commandBuffer,VkQueryPool queryPool,uint32_t query)3082 void DispatchCmdEndQuery(
3083     VkCommandBuffer                             commandBuffer,
3084     VkQueryPool                                 queryPool,
3085     uint32_t                                    query)
3086 {
3087     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
3088     if (!wrap_handles) return layer_data->device_dispatch_table.CmdEndQuery(commandBuffer, queryPool, query);
3089     {
3090         queryPool = layer_data->Unwrap(queryPool);
3091     }
3092     layer_data->device_dispatch_table.CmdEndQuery(commandBuffer, queryPool, query);
3093 
3094 }
3095 
DispatchCmdResetQueryPool(VkCommandBuffer commandBuffer,VkQueryPool queryPool,uint32_t firstQuery,uint32_t queryCount)3096 void DispatchCmdResetQueryPool(
3097     VkCommandBuffer                             commandBuffer,
3098     VkQueryPool                                 queryPool,
3099     uint32_t                                    firstQuery,
3100     uint32_t                                    queryCount)
3101 {
3102     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
3103     if (!wrap_handles) return layer_data->device_dispatch_table.CmdResetQueryPool(commandBuffer, queryPool, firstQuery, queryCount);
3104     {
3105         queryPool = layer_data->Unwrap(queryPool);
3106     }
3107     layer_data->device_dispatch_table.CmdResetQueryPool(commandBuffer, queryPool, firstQuery, queryCount);
3108 
3109 }
3110 
DispatchCmdWriteTimestamp(VkCommandBuffer commandBuffer,VkPipelineStageFlagBits pipelineStage,VkQueryPool queryPool,uint32_t query)3111 void DispatchCmdWriteTimestamp(
3112     VkCommandBuffer                             commandBuffer,
3113     VkPipelineStageFlagBits                     pipelineStage,
3114     VkQueryPool                                 queryPool,
3115     uint32_t                                    query)
3116 {
3117     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
3118     if (!wrap_handles) return layer_data->device_dispatch_table.CmdWriteTimestamp(commandBuffer, pipelineStage, queryPool, query);
3119     {
3120         queryPool = layer_data->Unwrap(queryPool);
3121     }
3122     layer_data->device_dispatch_table.CmdWriteTimestamp(commandBuffer, pipelineStage, queryPool, query);
3123 
3124 }
3125 
DispatchCmdCopyQueryPoolResults(VkCommandBuffer commandBuffer,VkQueryPool queryPool,uint32_t firstQuery,uint32_t queryCount,VkBuffer dstBuffer,VkDeviceSize dstOffset,VkDeviceSize stride,VkQueryResultFlags flags)3126 void DispatchCmdCopyQueryPoolResults(
3127     VkCommandBuffer                             commandBuffer,
3128     VkQueryPool                                 queryPool,
3129     uint32_t                                    firstQuery,
3130     uint32_t                                    queryCount,
3131     VkBuffer                                    dstBuffer,
3132     VkDeviceSize                                dstOffset,
3133     VkDeviceSize                                stride,
3134     VkQueryResultFlags                          flags)
3135 {
3136     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
3137     if (!wrap_handles) return layer_data->device_dispatch_table.CmdCopyQueryPoolResults(commandBuffer, queryPool, firstQuery, queryCount, dstBuffer, dstOffset, stride, flags);
3138     {
3139         queryPool = layer_data->Unwrap(queryPool);
3140         dstBuffer = layer_data->Unwrap(dstBuffer);
3141     }
3142     layer_data->device_dispatch_table.CmdCopyQueryPoolResults(commandBuffer, queryPool, firstQuery, queryCount, dstBuffer, dstOffset, stride, flags);
3143 
3144 }
3145 
DispatchCmdPushConstants(VkCommandBuffer commandBuffer,VkPipelineLayout layout,VkShaderStageFlags stageFlags,uint32_t offset,uint32_t size,const void * pValues)3146 void DispatchCmdPushConstants(
3147     VkCommandBuffer                             commandBuffer,
3148     VkPipelineLayout                            layout,
3149     VkShaderStageFlags                          stageFlags,
3150     uint32_t                                    offset,
3151     uint32_t                                    size,
3152     const void*                                 pValues)
3153 {
3154     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
3155     if (!wrap_handles) return layer_data->device_dispatch_table.CmdPushConstants(commandBuffer, layout, stageFlags, offset, size, pValues);
3156     {
3157         layout = layer_data->Unwrap(layout);
3158     }
3159     layer_data->device_dispatch_table.CmdPushConstants(commandBuffer, layout, stageFlags, offset, size, pValues);
3160 
3161 }
3162 
DispatchCmdBeginRenderPass(VkCommandBuffer commandBuffer,const VkRenderPassBeginInfo * pRenderPassBegin,VkSubpassContents contents)3163 void DispatchCmdBeginRenderPass(
3164     VkCommandBuffer                             commandBuffer,
3165     const VkRenderPassBeginInfo*                pRenderPassBegin,
3166     VkSubpassContents                           contents)
3167 {
3168     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
3169     if (!wrap_handles) return layer_data->device_dispatch_table.CmdBeginRenderPass(commandBuffer, pRenderPassBegin, contents);
3170     safe_VkRenderPassBeginInfo *local_pRenderPassBegin = NULL;
3171     {
3172         if (pRenderPassBegin) {
3173             local_pRenderPassBegin = new safe_VkRenderPassBeginInfo(pRenderPassBegin);
3174             if (pRenderPassBegin->renderPass) {
3175                 local_pRenderPassBegin->renderPass = layer_data->Unwrap(pRenderPassBegin->renderPass);
3176             }
3177             if (pRenderPassBegin->framebuffer) {
3178                 local_pRenderPassBegin->framebuffer = layer_data->Unwrap(pRenderPassBegin->framebuffer);
3179             }
3180             WrapPnextChainHandles(layer_data, local_pRenderPassBegin->pNext);
3181         }
3182     }
3183     layer_data->device_dispatch_table.CmdBeginRenderPass(commandBuffer, (const VkRenderPassBeginInfo*)local_pRenderPassBegin, contents);
3184     if (local_pRenderPassBegin) {
3185         delete local_pRenderPassBegin;
3186     }
3187 }
3188 
DispatchCmdNextSubpass(VkCommandBuffer commandBuffer,VkSubpassContents contents)3189 void DispatchCmdNextSubpass(
3190     VkCommandBuffer                             commandBuffer,
3191     VkSubpassContents                           contents)
3192 {
3193     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
3194     layer_data->device_dispatch_table.CmdNextSubpass(commandBuffer, contents);
3195 
3196 }
3197 
DispatchCmdEndRenderPass(VkCommandBuffer commandBuffer)3198 void DispatchCmdEndRenderPass(
3199     VkCommandBuffer                             commandBuffer)
3200 {
3201     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
3202     layer_data->device_dispatch_table.CmdEndRenderPass(commandBuffer);
3203 
3204 }
3205 
DispatchCmdExecuteCommands(VkCommandBuffer commandBuffer,uint32_t commandBufferCount,const VkCommandBuffer * pCommandBuffers)3206 void DispatchCmdExecuteCommands(
3207     VkCommandBuffer                             commandBuffer,
3208     uint32_t                                    commandBufferCount,
3209     const VkCommandBuffer*                      pCommandBuffers)
3210 {
3211     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
3212     layer_data->device_dispatch_table.CmdExecuteCommands(commandBuffer, commandBufferCount, pCommandBuffers);
3213 
3214 }
3215 
3216 // Skip vkEnumerateInstanceVersion dispatch, manually generated
3217 
DispatchBindBufferMemory2(VkDevice device,uint32_t bindInfoCount,const VkBindBufferMemoryInfo * pBindInfos)3218 VkResult DispatchBindBufferMemory2(
3219     VkDevice                                    device,
3220     uint32_t                                    bindInfoCount,
3221     const VkBindBufferMemoryInfo*               pBindInfos)
3222 {
3223     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
3224     if (!wrap_handles) return layer_data->device_dispatch_table.BindBufferMemory2(device, bindInfoCount, pBindInfos);
3225     safe_VkBindBufferMemoryInfo *local_pBindInfos = NULL;
3226     {
3227         if (pBindInfos) {
3228             local_pBindInfos = new safe_VkBindBufferMemoryInfo[bindInfoCount];
3229             for (uint32_t index0 = 0; index0 < bindInfoCount; ++index0) {
3230                 local_pBindInfos[index0].initialize(&pBindInfos[index0]);
3231                 if (pBindInfos[index0].buffer) {
3232                     local_pBindInfos[index0].buffer = layer_data->Unwrap(pBindInfos[index0].buffer);
3233                 }
3234                 if (pBindInfos[index0].memory) {
3235                     local_pBindInfos[index0].memory = layer_data->Unwrap(pBindInfos[index0].memory);
3236                 }
3237             }
3238         }
3239     }
3240     VkResult result = layer_data->device_dispatch_table.BindBufferMemory2(device, bindInfoCount, (const VkBindBufferMemoryInfo*)local_pBindInfos);
3241     if (local_pBindInfos) {
3242         delete[] local_pBindInfos;
3243     }
3244     return result;
3245 }
3246 
DispatchBindImageMemory2(VkDevice device,uint32_t bindInfoCount,const VkBindImageMemoryInfo * pBindInfos)3247 VkResult DispatchBindImageMemory2(
3248     VkDevice                                    device,
3249     uint32_t                                    bindInfoCount,
3250     const VkBindImageMemoryInfo*                pBindInfos)
3251 {
3252     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
3253     if (!wrap_handles) return layer_data->device_dispatch_table.BindImageMemory2(device, bindInfoCount, pBindInfos);
3254     safe_VkBindImageMemoryInfo *local_pBindInfos = NULL;
3255     {
3256         if (pBindInfos) {
3257             local_pBindInfos = new safe_VkBindImageMemoryInfo[bindInfoCount];
3258             for (uint32_t index0 = 0; index0 < bindInfoCount; ++index0) {
3259                 local_pBindInfos[index0].initialize(&pBindInfos[index0]);
3260                 WrapPnextChainHandles(layer_data, local_pBindInfos[index0].pNext);
3261                 if (pBindInfos[index0].image) {
3262                     local_pBindInfos[index0].image = layer_data->Unwrap(pBindInfos[index0].image);
3263                 }
3264                 if (pBindInfos[index0].memory) {
3265                     local_pBindInfos[index0].memory = layer_data->Unwrap(pBindInfos[index0].memory);
3266                 }
3267             }
3268         }
3269     }
3270     VkResult result = layer_data->device_dispatch_table.BindImageMemory2(device, bindInfoCount, (const VkBindImageMemoryInfo*)local_pBindInfos);
3271     if (local_pBindInfos) {
3272         delete[] local_pBindInfos;
3273     }
3274     return result;
3275 }
3276 
DispatchGetDeviceGroupPeerMemoryFeatures(VkDevice device,uint32_t heapIndex,uint32_t localDeviceIndex,uint32_t remoteDeviceIndex,VkPeerMemoryFeatureFlags * pPeerMemoryFeatures)3277 void DispatchGetDeviceGroupPeerMemoryFeatures(
3278     VkDevice                                    device,
3279     uint32_t                                    heapIndex,
3280     uint32_t                                    localDeviceIndex,
3281     uint32_t                                    remoteDeviceIndex,
3282     VkPeerMemoryFeatureFlags*                   pPeerMemoryFeatures)
3283 {
3284     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
3285     layer_data->device_dispatch_table.GetDeviceGroupPeerMemoryFeatures(device, heapIndex, localDeviceIndex, remoteDeviceIndex, pPeerMemoryFeatures);
3286 
3287 }
3288 
DispatchCmdSetDeviceMask(VkCommandBuffer commandBuffer,uint32_t deviceMask)3289 void DispatchCmdSetDeviceMask(
3290     VkCommandBuffer                             commandBuffer,
3291     uint32_t                                    deviceMask)
3292 {
3293     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
3294     layer_data->device_dispatch_table.CmdSetDeviceMask(commandBuffer, deviceMask);
3295 
3296 }
3297 
DispatchCmdDispatchBase(VkCommandBuffer commandBuffer,uint32_t baseGroupX,uint32_t baseGroupY,uint32_t baseGroupZ,uint32_t groupCountX,uint32_t groupCountY,uint32_t groupCountZ)3298 void DispatchCmdDispatchBase(
3299     VkCommandBuffer                             commandBuffer,
3300     uint32_t                                    baseGroupX,
3301     uint32_t                                    baseGroupY,
3302     uint32_t                                    baseGroupZ,
3303     uint32_t                                    groupCountX,
3304     uint32_t                                    groupCountY,
3305     uint32_t                                    groupCountZ)
3306 {
3307     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
3308     layer_data->device_dispatch_table.CmdDispatchBase(commandBuffer, baseGroupX, baseGroupY, baseGroupZ, groupCountX, groupCountY, groupCountZ);
3309 
3310 }
3311 
DispatchEnumeratePhysicalDeviceGroups(VkInstance instance,uint32_t * pPhysicalDeviceGroupCount,VkPhysicalDeviceGroupProperties * pPhysicalDeviceGroupProperties)3312 VkResult DispatchEnumeratePhysicalDeviceGroups(
3313     VkInstance                                  instance,
3314     uint32_t*                                   pPhysicalDeviceGroupCount,
3315     VkPhysicalDeviceGroupProperties*            pPhysicalDeviceGroupProperties)
3316 {
3317     auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
3318     VkResult result = layer_data->instance_dispatch_table.EnumeratePhysicalDeviceGroups(instance, pPhysicalDeviceGroupCount, pPhysicalDeviceGroupProperties);
3319 
3320     return result;
3321 }
3322 
DispatchGetImageMemoryRequirements2(VkDevice device,const VkImageMemoryRequirementsInfo2 * pInfo,VkMemoryRequirements2 * pMemoryRequirements)3323 void DispatchGetImageMemoryRequirements2(
3324     VkDevice                                    device,
3325     const VkImageMemoryRequirementsInfo2*       pInfo,
3326     VkMemoryRequirements2*                      pMemoryRequirements)
3327 {
3328     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
3329     if (!wrap_handles) return layer_data->device_dispatch_table.GetImageMemoryRequirements2(device, pInfo, pMemoryRequirements);
3330     safe_VkImageMemoryRequirementsInfo2 *local_pInfo = NULL;
3331     {
3332         if (pInfo) {
3333             local_pInfo = new safe_VkImageMemoryRequirementsInfo2(pInfo);
3334             if (pInfo->image) {
3335                 local_pInfo->image = layer_data->Unwrap(pInfo->image);
3336             }
3337         }
3338     }
3339     layer_data->device_dispatch_table.GetImageMemoryRequirements2(device, (const VkImageMemoryRequirementsInfo2*)local_pInfo, pMemoryRequirements);
3340     if (local_pInfo) {
3341         delete local_pInfo;
3342     }
3343 }
3344 
DispatchGetBufferMemoryRequirements2(VkDevice device,const VkBufferMemoryRequirementsInfo2 * pInfo,VkMemoryRequirements2 * pMemoryRequirements)3345 void DispatchGetBufferMemoryRequirements2(
3346     VkDevice                                    device,
3347     const VkBufferMemoryRequirementsInfo2*      pInfo,
3348     VkMemoryRequirements2*                      pMemoryRequirements)
3349 {
3350     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
3351     if (!wrap_handles) return layer_data->device_dispatch_table.GetBufferMemoryRequirements2(device, pInfo, pMemoryRequirements);
3352     safe_VkBufferMemoryRequirementsInfo2 *local_pInfo = NULL;
3353     {
3354         if (pInfo) {
3355             local_pInfo = new safe_VkBufferMemoryRequirementsInfo2(pInfo);
3356             if (pInfo->buffer) {
3357                 local_pInfo->buffer = layer_data->Unwrap(pInfo->buffer);
3358             }
3359         }
3360     }
3361     layer_data->device_dispatch_table.GetBufferMemoryRequirements2(device, (const VkBufferMemoryRequirementsInfo2*)local_pInfo, pMemoryRequirements);
3362     if (local_pInfo) {
3363         delete local_pInfo;
3364     }
3365 }
3366 
DispatchGetImageSparseMemoryRequirements2(VkDevice device,const VkImageSparseMemoryRequirementsInfo2 * pInfo,uint32_t * pSparseMemoryRequirementCount,VkSparseImageMemoryRequirements2 * pSparseMemoryRequirements)3367 void DispatchGetImageSparseMemoryRequirements2(
3368     VkDevice                                    device,
3369     const VkImageSparseMemoryRequirementsInfo2* pInfo,
3370     uint32_t*                                   pSparseMemoryRequirementCount,
3371     VkSparseImageMemoryRequirements2*           pSparseMemoryRequirements)
3372 {
3373     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
3374     if (!wrap_handles) return layer_data->device_dispatch_table.GetImageSparseMemoryRequirements2(device, pInfo, pSparseMemoryRequirementCount, pSparseMemoryRequirements);
3375     safe_VkImageSparseMemoryRequirementsInfo2 *local_pInfo = NULL;
3376     {
3377         if (pInfo) {
3378             local_pInfo = new safe_VkImageSparseMemoryRequirementsInfo2(pInfo);
3379             if (pInfo->image) {
3380                 local_pInfo->image = layer_data->Unwrap(pInfo->image);
3381             }
3382         }
3383     }
3384     layer_data->device_dispatch_table.GetImageSparseMemoryRequirements2(device, (const VkImageSparseMemoryRequirementsInfo2*)local_pInfo, pSparseMemoryRequirementCount, pSparseMemoryRequirements);
3385     if (local_pInfo) {
3386         delete local_pInfo;
3387     }
3388 }
3389 
DispatchGetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice,VkPhysicalDeviceFeatures2 * pFeatures)3390 void DispatchGetPhysicalDeviceFeatures2(
3391     VkPhysicalDevice                            physicalDevice,
3392     VkPhysicalDeviceFeatures2*                  pFeatures)
3393 {
3394     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
3395     layer_data->instance_dispatch_table.GetPhysicalDeviceFeatures2(physicalDevice, pFeatures);
3396 
3397 }
3398 
DispatchGetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,VkPhysicalDeviceProperties2 * pProperties)3399 void DispatchGetPhysicalDeviceProperties2(
3400     VkPhysicalDevice                            physicalDevice,
3401     VkPhysicalDeviceProperties2*                pProperties)
3402 {
3403     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
3404     layer_data->instance_dispatch_table.GetPhysicalDeviceProperties2(physicalDevice, pProperties);
3405 
3406 }
3407 
DispatchGetPhysicalDeviceFormatProperties2(VkPhysicalDevice physicalDevice,VkFormat format,VkFormatProperties2 * pFormatProperties)3408 void DispatchGetPhysicalDeviceFormatProperties2(
3409     VkPhysicalDevice                            physicalDevice,
3410     VkFormat                                    format,
3411     VkFormatProperties2*                        pFormatProperties)
3412 {
3413     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
3414     layer_data->instance_dispatch_table.GetPhysicalDeviceFormatProperties2(physicalDevice, format, pFormatProperties);
3415 
3416 }
3417 
DispatchGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,const VkPhysicalDeviceImageFormatInfo2 * pImageFormatInfo,VkImageFormatProperties2 * pImageFormatProperties)3418 VkResult DispatchGetPhysicalDeviceImageFormatProperties2(
3419     VkPhysicalDevice                            physicalDevice,
3420     const VkPhysicalDeviceImageFormatInfo2*     pImageFormatInfo,
3421     VkImageFormatProperties2*                   pImageFormatProperties)
3422 {
3423     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
3424     if (!wrap_handles) return layer_data->instance_dispatch_table.GetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties);
3425     safe_VkPhysicalDeviceImageFormatInfo2 *local_pImageFormatInfo = NULL;
3426     {
3427         if (pImageFormatInfo) {
3428             local_pImageFormatInfo = new safe_VkPhysicalDeviceImageFormatInfo2(pImageFormatInfo);
3429             WrapPnextChainHandles(layer_data, local_pImageFormatInfo->pNext);
3430         }
3431     }
3432     VkResult result = layer_data->instance_dispatch_table.GetPhysicalDeviceImageFormatProperties2(physicalDevice, (const VkPhysicalDeviceImageFormatInfo2*)local_pImageFormatInfo, pImageFormatProperties);
3433     if (local_pImageFormatInfo) {
3434         delete local_pImageFormatInfo;
3435     }
3436     return result;
3437 }
3438 
DispatchGetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice,uint32_t * pQueueFamilyPropertyCount,VkQueueFamilyProperties2 * pQueueFamilyProperties)3439 void DispatchGetPhysicalDeviceQueueFamilyProperties2(
3440     VkPhysicalDevice                            physicalDevice,
3441     uint32_t*                                   pQueueFamilyPropertyCount,
3442     VkQueueFamilyProperties2*                   pQueueFamilyProperties)
3443 {
3444     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
3445     layer_data->instance_dispatch_table.GetPhysicalDeviceQueueFamilyProperties2(physicalDevice, pQueueFamilyPropertyCount, pQueueFamilyProperties);
3446 
3447 }
3448 
DispatchGetPhysicalDeviceMemoryProperties2(VkPhysicalDevice physicalDevice,VkPhysicalDeviceMemoryProperties2 * pMemoryProperties)3449 void DispatchGetPhysicalDeviceMemoryProperties2(
3450     VkPhysicalDevice                            physicalDevice,
3451     VkPhysicalDeviceMemoryProperties2*          pMemoryProperties)
3452 {
3453     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
3454     layer_data->instance_dispatch_table.GetPhysicalDeviceMemoryProperties2(physicalDevice, pMemoryProperties);
3455 
3456 }
3457 
DispatchGetPhysicalDeviceSparseImageFormatProperties2(VkPhysicalDevice physicalDevice,const VkPhysicalDeviceSparseImageFormatInfo2 * pFormatInfo,uint32_t * pPropertyCount,VkSparseImageFormatProperties2 * pProperties)3458 void DispatchGetPhysicalDeviceSparseImageFormatProperties2(
3459     VkPhysicalDevice                            physicalDevice,
3460     const VkPhysicalDeviceSparseImageFormatInfo2* pFormatInfo,
3461     uint32_t*                                   pPropertyCount,
3462     VkSparseImageFormatProperties2*             pProperties)
3463 {
3464     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
3465     layer_data->instance_dispatch_table.GetPhysicalDeviceSparseImageFormatProperties2(physicalDevice, pFormatInfo, pPropertyCount, pProperties);
3466 
3467 }
3468 
DispatchTrimCommandPool(VkDevice device,VkCommandPool commandPool,VkCommandPoolTrimFlags flags)3469 void DispatchTrimCommandPool(
3470     VkDevice                                    device,
3471     VkCommandPool                               commandPool,
3472     VkCommandPoolTrimFlags                      flags)
3473 {
3474     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
3475     if (!wrap_handles) return layer_data->device_dispatch_table.TrimCommandPool(device, commandPool, flags);
3476     {
3477         commandPool = layer_data->Unwrap(commandPool);
3478     }
3479     layer_data->device_dispatch_table.TrimCommandPool(device, commandPool, flags);
3480 
3481 }
3482 
DispatchGetDeviceQueue2(VkDevice device,const VkDeviceQueueInfo2 * pQueueInfo,VkQueue * pQueue)3483 void DispatchGetDeviceQueue2(
3484     VkDevice                                    device,
3485     const VkDeviceQueueInfo2*                   pQueueInfo,
3486     VkQueue*                                    pQueue)
3487 {
3488     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
3489     layer_data->device_dispatch_table.GetDeviceQueue2(device, pQueueInfo, pQueue);
3490 
3491 }
3492 
DispatchCreateSamplerYcbcrConversion(VkDevice device,const VkSamplerYcbcrConversionCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSamplerYcbcrConversion * pYcbcrConversion)3493 VkResult DispatchCreateSamplerYcbcrConversion(
3494     VkDevice                                    device,
3495     const VkSamplerYcbcrConversionCreateInfo*   pCreateInfo,
3496     const VkAllocationCallbacks*                pAllocator,
3497     VkSamplerYcbcrConversion*                   pYcbcrConversion)
3498 {
3499     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
3500     if (!wrap_handles) return layer_data->device_dispatch_table.CreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion);
3501     safe_VkSamplerYcbcrConversionCreateInfo *local_pCreateInfo = NULL;
3502     {
3503         if (pCreateInfo) {
3504             local_pCreateInfo = new safe_VkSamplerYcbcrConversionCreateInfo(pCreateInfo);
3505             WrapPnextChainHandles(layer_data, local_pCreateInfo->pNext);
3506         }
3507     }
3508     VkResult result = layer_data->device_dispatch_table.CreateSamplerYcbcrConversion(device, (const VkSamplerYcbcrConversionCreateInfo*)local_pCreateInfo, pAllocator, pYcbcrConversion);
3509     if (local_pCreateInfo) {
3510         delete local_pCreateInfo;
3511     }
3512     if (VK_SUCCESS == result) {
3513         *pYcbcrConversion = layer_data->WrapNew(*pYcbcrConversion);
3514     }
3515     return result;
3516 }
3517 
DispatchDestroySamplerYcbcrConversion(VkDevice device,VkSamplerYcbcrConversion ycbcrConversion,const VkAllocationCallbacks * pAllocator)3518 void DispatchDestroySamplerYcbcrConversion(
3519     VkDevice                                    device,
3520     VkSamplerYcbcrConversion                    ycbcrConversion,
3521     const VkAllocationCallbacks*                pAllocator)
3522 {
3523     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
3524     if (!wrap_handles) return layer_data->device_dispatch_table.DestroySamplerYcbcrConversion(device, ycbcrConversion, pAllocator);
3525     uint64_t ycbcrConversion_id = reinterpret_cast<uint64_t &>(ycbcrConversion);
3526     auto iter = unique_id_mapping.pop(ycbcrConversion_id);
3527     if (iter != unique_id_mapping.end()) {
3528         ycbcrConversion = (VkSamplerYcbcrConversion)iter->second;
3529     } else {
3530         ycbcrConversion = (VkSamplerYcbcrConversion)0;
3531     }
3532     layer_data->device_dispatch_table.DestroySamplerYcbcrConversion(device, ycbcrConversion, pAllocator);
3533 
3534 }
3535 
3536 // Skip vkCreateDescriptorUpdateTemplate dispatch, manually generated
3537 
3538 // Skip vkDestroyDescriptorUpdateTemplate dispatch, manually generated
3539 
3540 // Skip vkUpdateDescriptorSetWithTemplate dispatch, manually generated
3541 
DispatchGetPhysicalDeviceExternalBufferProperties(VkPhysicalDevice physicalDevice,const VkPhysicalDeviceExternalBufferInfo * pExternalBufferInfo,VkExternalBufferProperties * pExternalBufferProperties)3542 void DispatchGetPhysicalDeviceExternalBufferProperties(
3543     VkPhysicalDevice                            physicalDevice,
3544     const VkPhysicalDeviceExternalBufferInfo*   pExternalBufferInfo,
3545     VkExternalBufferProperties*                 pExternalBufferProperties)
3546 {
3547     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
3548     layer_data->instance_dispatch_table.GetPhysicalDeviceExternalBufferProperties(physicalDevice, pExternalBufferInfo, pExternalBufferProperties);
3549 
3550 }
3551 
DispatchGetPhysicalDeviceExternalFenceProperties(VkPhysicalDevice physicalDevice,const VkPhysicalDeviceExternalFenceInfo * pExternalFenceInfo,VkExternalFenceProperties * pExternalFenceProperties)3552 void DispatchGetPhysicalDeviceExternalFenceProperties(
3553     VkPhysicalDevice                            physicalDevice,
3554     const VkPhysicalDeviceExternalFenceInfo*    pExternalFenceInfo,
3555     VkExternalFenceProperties*                  pExternalFenceProperties)
3556 {
3557     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
3558     layer_data->instance_dispatch_table.GetPhysicalDeviceExternalFenceProperties(physicalDevice, pExternalFenceInfo, pExternalFenceProperties);
3559 
3560 }
3561 
DispatchGetPhysicalDeviceExternalSemaphoreProperties(VkPhysicalDevice physicalDevice,const VkPhysicalDeviceExternalSemaphoreInfo * pExternalSemaphoreInfo,VkExternalSemaphoreProperties * pExternalSemaphoreProperties)3562 void DispatchGetPhysicalDeviceExternalSemaphoreProperties(
3563     VkPhysicalDevice                            physicalDevice,
3564     const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo,
3565     VkExternalSemaphoreProperties*              pExternalSemaphoreProperties)
3566 {
3567     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
3568     layer_data->instance_dispatch_table.GetPhysicalDeviceExternalSemaphoreProperties(physicalDevice, pExternalSemaphoreInfo, pExternalSemaphoreProperties);
3569 
3570 }
3571 
DispatchGetDescriptorSetLayoutSupport(VkDevice device,const VkDescriptorSetLayoutCreateInfo * pCreateInfo,VkDescriptorSetLayoutSupport * pSupport)3572 void DispatchGetDescriptorSetLayoutSupport(
3573     VkDevice                                    device,
3574     const VkDescriptorSetLayoutCreateInfo*      pCreateInfo,
3575     VkDescriptorSetLayoutSupport*               pSupport)
3576 {
3577     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
3578     if (!wrap_handles) return layer_data->device_dispatch_table.GetDescriptorSetLayoutSupport(device, pCreateInfo, pSupport);
3579     safe_VkDescriptorSetLayoutCreateInfo *local_pCreateInfo = NULL;
3580     {
3581         if (pCreateInfo) {
3582             local_pCreateInfo = new safe_VkDescriptorSetLayoutCreateInfo(pCreateInfo);
3583             if (local_pCreateInfo->pBindings) {
3584                 for (uint32_t index1 = 0; index1 < local_pCreateInfo->bindingCount; ++index1) {
3585                     if (local_pCreateInfo->pBindings[index1].pImmutableSamplers) {
3586                         for (uint32_t index2 = 0; index2 < local_pCreateInfo->pBindings[index1].descriptorCount; ++index2) {
3587                             local_pCreateInfo->pBindings[index1].pImmutableSamplers[index2] = layer_data->Unwrap(local_pCreateInfo->pBindings[index1].pImmutableSamplers[index2]);
3588                         }
3589                     }
3590                 }
3591             }
3592         }
3593     }
3594     layer_data->device_dispatch_table.GetDescriptorSetLayoutSupport(device, (const VkDescriptorSetLayoutCreateInfo*)local_pCreateInfo, pSupport);
3595     if (local_pCreateInfo) {
3596         delete local_pCreateInfo;
3597     }
3598 }
3599 
DispatchDestroySurfaceKHR(VkInstance instance,VkSurfaceKHR surface,const VkAllocationCallbacks * pAllocator)3600 void DispatchDestroySurfaceKHR(
3601     VkInstance                                  instance,
3602     VkSurfaceKHR                                surface,
3603     const VkAllocationCallbacks*                pAllocator)
3604 {
3605     auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
3606     if (!wrap_handles) return layer_data->instance_dispatch_table.DestroySurfaceKHR(instance, surface, pAllocator);
3607     uint64_t surface_id = reinterpret_cast<uint64_t &>(surface);
3608     auto iter = unique_id_mapping.pop(surface_id);
3609     if (iter != unique_id_mapping.end()) {
3610         surface = (VkSurfaceKHR)iter->second;
3611     } else {
3612         surface = (VkSurfaceKHR)0;
3613     }
3614     layer_data->instance_dispatch_table.DestroySurfaceKHR(instance, surface, pAllocator);
3615 
3616 }
3617 
DispatchGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice,uint32_t queueFamilyIndex,VkSurfaceKHR surface,VkBool32 * pSupported)3618 VkResult DispatchGetPhysicalDeviceSurfaceSupportKHR(
3619     VkPhysicalDevice                            physicalDevice,
3620     uint32_t                                    queueFamilyIndex,
3621     VkSurfaceKHR                                surface,
3622     VkBool32*                                   pSupported)
3623 {
3624     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
3625     if (!wrap_handles) return layer_data->instance_dispatch_table.GetPhysicalDeviceSurfaceSupportKHR(physicalDevice, queueFamilyIndex, surface, pSupported);
3626     {
3627         surface = layer_data->Unwrap(surface);
3628     }
3629     VkResult result = layer_data->instance_dispatch_table.GetPhysicalDeviceSurfaceSupportKHR(physicalDevice, queueFamilyIndex, surface, pSupported);
3630 
3631     return result;
3632 }
3633 
DispatchGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice,VkSurfaceKHR surface,VkSurfaceCapabilitiesKHR * pSurfaceCapabilities)3634 VkResult DispatchGetPhysicalDeviceSurfaceCapabilitiesKHR(
3635     VkPhysicalDevice                            physicalDevice,
3636     VkSurfaceKHR                                surface,
3637     VkSurfaceCapabilitiesKHR*                   pSurfaceCapabilities)
3638 {
3639     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
3640     if (!wrap_handles) return layer_data->instance_dispatch_table.GetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, surface, pSurfaceCapabilities);
3641     {
3642         surface = layer_data->Unwrap(surface);
3643     }
3644     VkResult result = layer_data->instance_dispatch_table.GetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, surface, pSurfaceCapabilities);
3645 
3646     return result;
3647 }
3648 
DispatchGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,VkSurfaceKHR surface,uint32_t * pSurfaceFormatCount,VkSurfaceFormatKHR * pSurfaceFormats)3649 VkResult DispatchGetPhysicalDeviceSurfaceFormatsKHR(
3650     VkPhysicalDevice                            physicalDevice,
3651     VkSurfaceKHR                                surface,
3652     uint32_t*                                   pSurfaceFormatCount,
3653     VkSurfaceFormatKHR*                         pSurfaceFormats)
3654 {
3655     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
3656     if (!wrap_handles) return layer_data->instance_dispatch_table.GetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, surface, pSurfaceFormatCount, pSurfaceFormats);
3657     {
3658         surface = layer_data->Unwrap(surface);
3659     }
3660     VkResult result = layer_data->instance_dispatch_table.GetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, surface, pSurfaceFormatCount, pSurfaceFormats);
3661 
3662     return result;
3663 }
3664 
DispatchGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,VkSurfaceKHR surface,uint32_t * pPresentModeCount,VkPresentModeKHR * pPresentModes)3665 VkResult DispatchGetPhysicalDeviceSurfacePresentModesKHR(
3666     VkPhysicalDevice                            physicalDevice,
3667     VkSurfaceKHR                                surface,
3668     uint32_t*                                   pPresentModeCount,
3669     VkPresentModeKHR*                           pPresentModes)
3670 {
3671     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
3672     if (!wrap_handles) return layer_data->instance_dispatch_table.GetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, surface, pPresentModeCount, pPresentModes);
3673     {
3674         surface = layer_data->Unwrap(surface);
3675     }
3676     VkResult result = layer_data->instance_dispatch_table.GetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, surface, pPresentModeCount, pPresentModes);
3677 
3678     return result;
3679 }
3680 
3681 // Skip vkCreateSwapchainKHR dispatch, manually generated
3682 
3683 // Skip vkDestroySwapchainKHR dispatch, manually generated
3684 
3685 // Skip vkGetSwapchainImagesKHR dispatch, manually generated
3686 
DispatchAcquireNextImageKHR(VkDevice device,VkSwapchainKHR swapchain,uint64_t timeout,VkSemaphore semaphore,VkFence fence,uint32_t * pImageIndex)3687 VkResult DispatchAcquireNextImageKHR(
3688     VkDevice                                    device,
3689     VkSwapchainKHR                              swapchain,
3690     uint64_t                                    timeout,
3691     VkSemaphore                                 semaphore,
3692     VkFence                                     fence,
3693     uint32_t*                                   pImageIndex)
3694 {
3695     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
3696     if (!wrap_handles) return layer_data->device_dispatch_table.AcquireNextImageKHR(device, swapchain, timeout, semaphore, fence, pImageIndex);
3697     {
3698         swapchain = layer_data->Unwrap(swapchain);
3699         semaphore = layer_data->Unwrap(semaphore);
3700         fence = layer_data->Unwrap(fence);
3701     }
3702     VkResult result = layer_data->device_dispatch_table.AcquireNextImageKHR(device, swapchain, timeout, semaphore, fence, pImageIndex);
3703 
3704     return result;
3705 }
3706 
3707 // Skip vkQueuePresentKHR dispatch, manually generated
3708 
DispatchGetDeviceGroupPresentCapabilitiesKHR(VkDevice device,VkDeviceGroupPresentCapabilitiesKHR * pDeviceGroupPresentCapabilities)3709 VkResult DispatchGetDeviceGroupPresentCapabilitiesKHR(
3710     VkDevice                                    device,
3711     VkDeviceGroupPresentCapabilitiesKHR*        pDeviceGroupPresentCapabilities)
3712 {
3713     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
3714     VkResult result = layer_data->device_dispatch_table.GetDeviceGroupPresentCapabilitiesKHR(device, pDeviceGroupPresentCapabilities);
3715 
3716     return result;
3717 }
3718 
DispatchGetDeviceGroupSurfacePresentModesKHR(VkDevice device,VkSurfaceKHR surface,VkDeviceGroupPresentModeFlagsKHR * pModes)3719 VkResult DispatchGetDeviceGroupSurfacePresentModesKHR(
3720     VkDevice                                    device,
3721     VkSurfaceKHR                                surface,
3722     VkDeviceGroupPresentModeFlagsKHR*           pModes)
3723 {
3724     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
3725     if (!wrap_handles) return layer_data->device_dispatch_table.GetDeviceGroupSurfacePresentModesKHR(device, surface, pModes);
3726     {
3727         surface = layer_data->Unwrap(surface);
3728     }
3729     VkResult result = layer_data->device_dispatch_table.GetDeviceGroupSurfacePresentModesKHR(device, surface, pModes);
3730 
3731     return result;
3732 }
3733 
DispatchGetPhysicalDevicePresentRectanglesKHR(VkPhysicalDevice physicalDevice,VkSurfaceKHR surface,uint32_t * pRectCount,VkRect2D * pRects)3734 VkResult DispatchGetPhysicalDevicePresentRectanglesKHR(
3735     VkPhysicalDevice                            physicalDevice,
3736     VkSurfaceKHR                                surface,
3737     uint32_t*                                   pRectCount,
3738     VkRect2D*                                   pRects)
3739 {
3740     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
3741     if (!wrap_handles) return layer_data->instance_dispatch_table.GetPhysicalDevicePresentRectanglesKHR(physicalDevice, surface, pRectCount, pRects);
3742     {
3743         surface = layer_data->Unwrap(surface);
3744     }
3745     VkResult result = layer_data->instance_dispatch_table.GetPhysicalDevicePresentRectanglesKHR(physicalDevice, surface, pRectCount, pRects);
3746 
3747     return result;
3748 }
3749 
DispatchAcquireNextImage2KHR(VkDevice device,const VkAcquireNextImageInfoKHR * pAcquireInfo,uint32_t * pImageIndex)3750 VkResult DispatchAcquireNextImage2KHR(
3751     VkDevice                                    device,
3752     const VkAcquireNextImageInfoKHR*            pAcquireInfo,
3753     uint32_t*                                   pImageIndex)
3754 {
3755     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
3756     if (!wrap_handles) return layer_data->device_dispatch_table.AcquireNextImage2KHR(device, pAcquireInfo, pImageIndex);
3757     safe_VkAcquireNextImageInfoKHR *local_pAcquireInfo = NULL;
3758     {
3759         if (pAcquireInfo) {
3760             local_pAcquireInfo = new safe_VkAcquireNextImageInfoKHR(pAcquireInfo);
3761             if (pAcquireInfo->swapchain) {
3762                 local_pAcquireInfo->swapchain = layer_data->Unwrap(pAcquireInfo->swapchain);
3763             }
3764             if (pAcquireInfo->semaphore) {
3765                 local_pAcquireInfo->semaphore = layer_data->Unwrap(pAcquireInfo->semaphore);
3766             }
3767             if (pAcquireInfo->fence) {
3768                 local_pAcquireInfo->fence = layer_data->Unwrap(pAcquireInfo->fence);
3769             }
3770         }
3771     }
3772     VkResult result = layer_data->device_dispatch_table.AcquireNextImage2KHR(device, (const VkAcquireNextImageInfoKHR*)local_pAcquireInfo, pImageIndex);
3773     if (local_pAcquireInfo) {
3774         delete local_pAcquireInfo;
3775     }
3776     return result;
3777 }
3778 
3779 // Skip vkGetPhysicalDeviceDisplayPropertiesKHR dispatch, manually generated
3780 
3781 // Skip vkGetPhysicalDeviceDisplayPlanePropertiesKHR dispatch, manually generated
3782 
3783 // Skip vkGetDisplayPlaneSupportedDisplaysKHR dispatch, manually generated
3784 
3785 // Skip vkGetDisplayModePropertiesKHR dispatch, manually generated
3786 
DispatchCreateDisplayModeKHR(VkPhysicalDevice physicalDevice,VkDisplayKHR display,const VkDisplayModeCreateInfoKHR * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkDisplayModeKHR * pMode)3787 VkResult DispatchCreateDisplayModeKHR(
3788     VkPhysicalDevice                            physicalDevice,
3789     VkDisplayKHR                                display,
3790     const VkDisplayModeCreateInfoKHR*           pCreateInfo,
3791     const VkAllocationCallbacks*                pAllocator,
3792     VkDisplayModeKHR*                           pMode)
3793 {
3794     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
3795     if (!wrap_handles) return layer_data->instance_dispatch_table.CreateDisplayModeKHR(physicalDevice, display, pCreateInfo, pAllocator, pMode);
3796     {
3797         display = layer_data->Unwrap(display);
3798     }
3799     VkResult result = layer_data->instance_dispatch_table.CreateDisplayModeKHR(physicalDevice, display, pCreateInfo, pAllocator, pMode);
3800     if (VK_SUCCESS == result) {
3801         *pMode = layer_data->WrapNew(*pMode);
3802     }
3803     return result;
3804 }
3805 
DispatchGetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physicalDevice,VkDisplayModeKHR mode,uint32_t planeIndex,VkDisplayPlaneCapabilitiesKHR * pCapabilities)3806 VkResult DispatchGetDisplayPlaneCapabilitiesKHR(
3807     VkPhysicalDevice                            physicalDevice,
3808     VkDisplayModeKHR                            mode,
3809     uint32_t                                    planeIndex,
3810     VkDisplayPlaneCapabilitiesKHR*              pCapabilities)
3811 {
3812     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
3813     if (!wrap_handles) return layer_data->instance_dispatch_table.GetDisplayPlaneCapabilitiesKHR(physicalDevice, mode, planeIndex, pCapabilities);
3814     {
3815         mode = layer_data->Unwrap(mode);
3816     }
3817     VkResult result = layer_data->instance_dispatch_table.GetDisplayPlaneCapabilitiesKHR(physicalDevice, mode, planeIndex, pCapabilities);
3818 
3819     return result;
3820 }
3821 
DispatchCreateDisplayPlaneSurfaceKHR(VkInstance instance,const VkDisplaySurfaceCreateInfoKHR * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSurfaceKHR * pSurface)3822 VkResult DispatchCreateDisplayPlaneSurfaceKHR(
3823     VkInstance                                  instance,
3824     const VkDisplaySurfaceCreateInfoKHR*        pCreateInfo,
3825     const VkAllocationCallbacks*                pAllocator,
3826     VkSurfaceKHR*                               pSurface)
3827 {
3828     auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
3829     if (!wrap_handles) return layer_data->instance_dispatch_table.CreateDisplayPlaneSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
3830     safe_VkDisplaySurfaceCreateInfoKHR *local_pCreateInfo = NULL;
3831     {
3832         if (pCreateInfo) {
3833             local_pCreateInfo = new safe_VkDisplaySurfaceCreateInfoKHR(pCreateInfo);
3834             if (pCreateInfo->displayMode) {
3835                 local_pCreateInfo->displayMode = layer_data->Unwrap(pCreateInfo->displayMode);
3836             }
3837         }
3838     }
3839     VkResult result = layer_data->instance_dispatch_table.CreateDisplayPlaneSurfaceKHR(instance, (const VkDisplaySurfaceCreateInfoKHR*)local_pCreateInfo, pAllocator, pSurface);
3840     if (local_pCreateInfo) {
3841         delete local_pCreateInfo;
3842     }
3843     if (VK_SUCCESS == result) {
3844         *pSurface = layer_data->WrapNew(*pSurface);
3845     }
3846     return result;
3847 }
3848 
3849 // Skip vkCreateSharedSwapchainsKHR dispatch, manually generated
3850 
3851 #ifdef VK_USE_PLATFORM_XLIB_KHR
3852 
DispatchCreateXlibSurfaceKHR(VkInstance instance,const VkXlibSurfaceCreateInfoKHR * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSurfaceKHR * pSurface)3853 VkResult DispatchCreateXlibSurfaceKHR(
3854     VkInstance                                  instance,
3855     const VkXlibSurfaceCreateInfoKHR*           pCreateInfo,
3856     const VkAllocationCallbacks*                pAllocator,
3857     VkSurfaceKHR*                               pSurface)
3858 {
3859     auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
3860     if (!wrap_handles) return layer_data->instance_dispatch_table.CreateXlibSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
3861     VkResult result = layer_data->instance_dispatch_table.CreateXlibSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
3862     if (VK_SUCCESS == result) {
3863         *pSurface = layer_data->WrapNew(*pSurface);
3864     }
3865     return result;
3866 }
3867 #endif // VK_USE_PLATFORM_XLIB_KHR
3868 
3869 #ifdef VK_USE_PLATFORM_XLIB_KHR
3870 
DispatchGetPhysicalDeviceXlibPresentationSupportKHR(VkPhysicalDevice physicalDevice,uint32_t queueFamilyIndex,Display * dpy,VisualID visualID)3871 VkBool32 DispatchGetPhysicalDeviceXlibPresentationSupportKHR(
3872     VkPhysicalDevice                            physicalDevice,
3873     uint32_t                                    queueFamilyIndex,
3874     Display*                                    dpy,
3875     VisualID                                    visualID)
3876 {
3877     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
3878     VkBool32 result = layer_data->instance_dispatch_table.GetPhysicalDeviceXlibPresentationSupportKHR(physicalDevice, queueFamilyIndex, dpy, visualID);
3879 
3880     return result;
3881 }
3882 #endif // VK_USE_PLATFORM_XLIB_KHR
3883 
3884 #ifdef VK_USE_PLATFORM_XCB_KHR
3885 
DispatchCreateXcbSurfaceKHR(VkInstance instance,const VkXcbSurfaceCreateInfoKHR * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSurfaceKHR * pSurface)3886 VkResult DispatchCreateXcbSurfaceKHR(
3887     VkInstance                                  instance,
3888     const VkXcbSurfaceCreateInfoKHR*            pCreateInfo,
3889     const VkAllocationCallbacks*                pAllocator,
3890     VkSurfaceKHR*                               pSurface)
3891 {
3892     auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
3893     if (!wrap_handles) return layer_data->instance_dispatch_table.CreateXcbSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
3894     VkResult result = layer_data->instance_dispatch_table.CreateXcbSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
3895     if (VK_SUCCESS == result) {
3896         *pSurface = layer_data->WrapNew(*pSurface);
3897     }
3898     return result;
3899 }
3900 #endif // VK_USE_PLATFORM_XCB_KHR
3901 
3902 #ifdef VK_USE_PLATFORM_XCB_KHR
3903 
DispatchGetPhysicalDeviceXcbPresentationSupportKHR(VkPhysicalDevice physicalDevice,uint32_t queueFamilyIndex,xcb_connection_t * connection,xcb_visualid_t visual_id)3904 VkBool32 DispatchGetPhysicalDeviceXcbPresentationSupportKHR(
3905     VkPhysicalDevice                            physicalDevice,
3906     uint32_t                                    queueFamilyIndex,
3907     xcb_connection_t*                           connection,
3908     xcb_visualid_t                              visual_id)
3909 {
3910     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
3911     VkBool32 result = layer_data->instance_dispatch_table.GetPhysicalDeviceXcbPresentationSupportKHR(physicalDevice, queueFamilyIndex, connection, visual_id);
3912 
3913     return result;
3914 }
3915 #endif // VK_USE_PLATFORM_XCB_KHR
3916 
3917 #ifdef VK_USE_PLATFORM_WAYLAND_KHR
3918 
DispatchCreateWaylandSurfaceKHR(VkInstance instance,const VkWaylandSurfaceCreateInfoKHR * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSurfaceKHR * pSurface)3919 VkResult DispatchCreateWaylandSurfaceKHR(
3920     VkInstance                                  instance,
3921     const VkWaylandSurfaceCreateInfoKHR*        pCreateInfo,
3922     const VkAllocationCallbacks*                pAllocator,
3923     VkSurfaceKHR*                               pSurface)
3924 {
3925     auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
3926     if (!wrap_handles) return layer_data->instance_dispatch_table.CreateWaylandSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
3927     VkResult result = layer_data->instance_dispatch_table.CreateWaylandSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
3928     if (VK_SUCCESS == result) {
3929         *pSurface = layer_data->WrapNew(*pSurface);
3930     }
3931     return result;
3932 }
3933 #endif // VK_USE_PLATFORM_WAYLAND_KHR
3934 
3935 #ifdef VK_USE_PLATFORM_WAYLAND_KHR
3936 
DispatchGetPhysicalDeviceWaylandPresentationSupportKHR(VkPhysicalDevice physicalDevice,uint32_t queueFamilyIndex,struct wl_display * display)3937 VkBool32 DispatchGetPhysicalDeviceWaylandPresentationSupportKHR(
3938     VkPhysicalDevice                            physicalDevice,
3939     uint32_t                                    queueFamilyIndex,
3940     struct wl_display*                          display)
3941 {
3942     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
3943     VkBool32 result = layer_data->instance_dispatch_table.GetPhysicalDeviceWaylandPresentationSupportKHR(physicalDevice, queueFamilyIndex, display);
3944 
3945     return result;
3946 }
3947 #endif // VK_USE_PLATFORM_WAYLAND_KHR
3948 
3949 #ifdef VK_USE_PLATFORM_ANDROID_KHR
3950 
DispatchCreateAndroidSurfaceKHR(VkInstance instance,const VkAndroidSurfaceCreateInfoKHR * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSurfaceKHR * pSurface)3951 VkResult DispatchCreateAndroidSurfaceKHR(
3952     VkInstance                                  instance,
3953     const VkAndroidSurfaceCreateInfoKHR*        pCreateInfo,
3954     const VkAllocationCallbacks*                pAllocator,
3955     VkSurfaceKHR*                               pSurface)
3956 {
3957     auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
3958     if (!wrap_handles) return layer_data->instance_dispatch_table.CreateAndroidSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
3959     VkResult result = layer_data->instance_dispatch_table.CreateAndroidSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
3960     if (VK_SUCCESS == result) {
3961         *pSurface = layer_data->WrapNew(*pSurface);
3962     }
3963     return result;
3964 }
3965 #endif // VK_USE_PLATFORM_ANDROID_KHR
3966 
3967 #ifdef VK_USE_PLATFORM_WIN32_KHR
3968 
DispatchCreateWin32SurfaceKHR(VkInstance instance,const VkWin32SurfaceCreateInfoKHR * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSurfaceKHR * pSurface)3969 VkResult DispatchCreateWin32SurfaceKHR(
3970     VkInstance                                  instance,
3971     const VkWin32SurfaceCreateInfoKHR*          pCreateInfo,
3972     const VkAllocationCallbacks*                pAllocator,
3973     VkSurfaceKHR*                               pSurface)
3974 {
3975     auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
3976     if (!wrap_handles) return layer_data->instance_dispatch_table.CreateWin32SurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
3977     VkResult result = layer_data->instance_dispatch_table.CreateWin32SurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
3978     if (VK_SUCCESS == result) {
3979         *pSurface = layer_data->WrapNew(*pSurface);
3980     }
3981     return result;
3982 }
3983 #endif // VK_USE_PLATFORM_WIN32_KHR
3984 
3985 #ifdef VK_USE_PLATFORM_WIN32_KHR
3986 
DispatchGetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice physicalDevice,uint32_t queueFamilyIndex)3987 VkBool32 DispatchGetPhysicalDeviceWin32PresentationSupportKHR(
3988     VkPhysicalDevice                            physicalDevice,
3989     uint32_t                                    queueFamilyIndex)
3990 {
3991     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
3992     VkBool32 result = layer_data->instance_dispatch_table.GetPhysicalDeviceWin32PresentationSupportKHR(physicalDevice, queueFamilyIndex);
3993 
3994     return result;
3995 }
3996 #endif // VK_USE_PLATFORM_WIN32_KHR
3997 
DispatchGetPhysicalDeviceFeatures2KHR(VkPhysicalDevice physicalDevice,VkPhysicalDeviceFeatures2 * pFeatures)3998 void DispatchGetPhysicalDeviceFeatures2KHR(
3999     VkPhysicalDevice                            physicalDevice,
4000     VkPhysicalDeviceFeatures2*                  pFeatures)
4001 {
4002     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
4003     layer_data->instance_dispatch_table.GetPhysicalDeviceFeatures2KHR(physicalDevice, pFeatures);
4004 
4005 }
4006 
DispatchGetPhysicalDeviceProperties2KHR(VkPhysicalDevice physicalDevice,VkPhysicalDeviceProperties2 * pProperties)4007 void DispatchGetPhysicalDeviceProperties2KHR(
4008     VkPhysicalDevice                            physicalDevice,
4009     VkPhysicalDeviceProperties2*                pProperties)
4010 {
4011     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
4012     layer_data->instance_dispatch_table.GetPhysicalDeviceProperties2KHR(physicalDevice, pProperties);
4013 
4014 }
4015 
DispatchGetPhysicalDeviceFormatProperties2KHR(VkPhysicalDevice physicalDevice,VkFormat format,VkFormatProperties2 * pFormatProperties)4016 void DispatchGetPhysicalDeviceFormatProperties2KHR(
4017     VkPhysicalDevice                            physicalDevice,
4018     VkFormat                                    format,
4019     VkFormatProperties2*                        pFormatProperties)
4020 {
4021     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
4022     layer_data->instance_dispatch_table.GetPhysicalDeviceFormatProperties2KHR(physicalDevice, format, pFormatProperties);
4023 
4024 }
4025 
DispatchGetPhysicalDeviceImageFormatProperties2KHR(VkPhysicalDevice physicalDevice,const VkPhysicalDeviceImageFormatInfo2 * pImageFormatInfo,VkImageFormatProperties2 * pImageFormatProperties)4026 VkResult DispatchGetPhysicalDeviceImageFormatProperties2KHR(
4027     VkPhysicalDevice                            physicalDevice,
4028     const VkPhysicalDeviceImageFormatInfo2*     pImageFormatInfo,
4029     VkImageFormatProperties2*                   pImageFormatProperties)
4030 {
4031     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
4032     if (!wrap_handles) return layer_data->instance_dispatch_table.GetPhysicalDeviceImageFormatProperties2KHR(physicalDevice, pImageFormatInfo, pImageFormatProperties);
4033     safe_VkPhysicalDeviceImageFormatInfo2 *local_pImageFormatInfo = NULL;
4034     {
4035         if (pImageFormatInfo) {
4036             local_pImageFormatInfo = new safe_VkPhysicalDeviceImageFormatInfo2(pImageFormatInfo);
4037             WrapPnextChainHandles(layer_data, local_pImageFormatInfo->pNext);
4038         }
4039     }
4040     VkResult result = layer_data->instance_dispatch_table.GetPhysicalDeviceImageFormatProperties2KHR(physicalDevice, (const VkPhysicalDeviceImageFormatInfo2*)local_pImageFormatInfo, pImageFormatProperties);
4041     if (local_pImageFormatInfo) {
4042         delete local_pImageFormatInfo;
4043     }
4044     return result;
4045 }
4046 
DispatchGetPhysicalDeviceQueueFamilyProperties2KHR(VkPhysicalDevice physicalDevice,uint32_t * pQueueFamilyPropertyCount,VkQueueFamilyProperties2 * pQueueFamilyProperties)4047 void DispatchGetPhysicalDeviceQueueFamilyProperties2KHR(
4048     VkPhysicalDevice                            physicalDevice,
4049     uint32_t*                                   pQueueFamilyPropertyCount,
4050     VkQueueFamilyProperties2*                   pQueueFamilyProperties)
4051 {
4052     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
4053     layer_data->instance_dispatch_table.GetPhysicalDeviceQueueFamilyProperties2KHR(physicalDevice, pQueueFamilyPropertyCount, pQueueFamilyProperties);
4054 
4055 }
4056 
DispatchGetPhysicalDeviceMemoryProperties2KHR(VkPhysicalDevice physicalDevice,VkPhysicalDeviceMemoryProperties2 * pMemoryProperties)4057 void DispatchGetPhysicalDeviceMemoryProperties2KHR(
4058     VkPhysicalDevice                            physicalDevice,
4059     VkPhysicalDeviceMemoryProperties2*          pMemoryProperties)
4060 {
4061     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
4062     layer_data->instance_dispatch_table.GetPhysicalDeviceMemoryProperties2KHR(physicalDevice, pMemoryProperties);
4063 
4064 }
4065 
DispatchGetPhysicalDeviceSparseImageFormatProperties2KHR(VkPhysicalDevice physicalDevice,const VkPhysicalDeviceSparseImageFormatInfo2 * pFormatInfo,uint32_t * pPropertyCount,VkSparseImageFormatProperties2 * pProperties)4066 void DispatchGetPhysicalDeviceSparseImageFormatProperties2KHR(
4067     VkPhysicalDevice                            physicalDevice,
4068     const VkPhysicalDeviceSparseImageFormatInfo2* pFormatInfo,
4069     uint32_t*                                   pPropertyCount,
4070     VkSparseImageFormatProperties2*             pProperties)
4071 {
4072     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
4073     layer_data->instance_dispatch_table.GetPhysicalDeviceSparseImageFormatProperties2KHR(physicalDevice, pFormatInfo, pPropertyCount, pProperties);
4074 
4075 }
4076 
DispatchGetDeviceGroupPeerMemoryFeaturesKHR(VkDevice device,uint32_t heapIndex,uint32_t localDeviceIndex,uint32_t remoteDeviceIndex,VkPeerMemoryFeatureFlags * pPeerMemoryFeatures)4077 void DispatchGetDeviceGroupPeerMemoryFeaturesKHR(
4078     VkDevice                                    device,
4079     uint32_t                                    heapIndex,
4080     uint32_t                                    localDeviceIndex,
4081     uint32_t                                    remoteDeviceIndex,
4082     VkPeerMemoryFeatureFlags*                   pPeerMemoryFeatures)
4083 {
4084     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4085     layer_data->device_dispatch_table.GetDeviceGroupPeerMemoryFeaturesKHR(device, heapIndex, localDeviceIndex, remoteDeviceIndex, pPeerMemoryFeatures);
4086 
4087 }
4088 
DispatchCmdSetDeviceMaskKHR(VkCommandBuffer commandBuffer,uint32_t deviceMask)4089 void DispatchCmdSetDeviceMaskKHR(
4090     VkCommandBuffer                             commandBuffer,
4091     uint32_t                                    deviceMask)
4092 {
4093     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
4094     layer_data->device_dispatch_table.CmdSetDeviceMaskKHR(commandBuffer, deviceMask);
4095 
4096 }
4097 
DispatchCmdDispatchBaseKHR(VkCommandBuffer commandBuffer,uint32_t baseGroupX,uint32_t baseGroupY,uint32_t baseGroupZ,uint32_t groupCountX,uint32_t groupCountY,uint32_t groupCountZ)4098 void DispatchCmdDispatchBaseKHR(
4099     VkCommandBuffer                             commandBuffer,
4100     uint32_t                                    baseGroupX,
4101     uint32_t                                    baseGroupY,
4102     uint32_t                                    baseGroupZ,
4103     uint32_t                                    groupCountX,
4104     uint32_t                                    groupCountY,
4105     uint32_t                                    groupCountZ)
4106 {
4107     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
4108     layer_data->device_dispatch_table.CmdDispatchBaseKHR(commandBuffer, baseGroupX, baseGroupY, baseGroupZ, groupCountX, groupCountY, groupCountZ);
4109 
4110 }
4111 
DispatchTrimCommandPoolKHR(VkDevice device,VkCommandPool commandPool,VkCommandPoolTrimFlags flags)4112 void DispatchTrimCommandPoolKHR(
4113     VkDevice                                    device,
4114     VkCommandPool                               commandPool,
4115     VkCommandPoolTrimFlags                      flags)
4116 {
4117     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4118     if (!wrap_handles) return layer_data->device_dispatch_table.TrimCommandPoolKHR(device, commandPool, flags);
4119     {
4120         commandPool = layer_data->Unwrap(commandPool);
4121     }
4122     layer_data->device_dispatch_table.TrimCommandPoolKHR(device, commandPool, flags);
4123 
4124 }
4125 
DispatchEnumeratePhysicalDeviceGroupsKHR(VkInstance instance,uint32_t * pPhysicalDeviceGroupCount,VkPhysicalDeviceGroupProperties * pPhysicalDeviceGroupProperties)4126 VkResult DispatchEnumeratePhysicalDeviceGroupsKHR(
4127     VkInstance                                  instance,
4128     uint32_t*                                   pPhysicalDeviceGroupCount,
4129     VkPhysicalDeviceGroupProperties*            pPhysicalDeviceGroupProperties)
4130 {
4131     auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
4132     VkResult result = layer_data->instance_dispatch_table.EnumeratePhysicalDeviceGroupsKHR(instance, pPhysicalDeviceGroupCount, pPhysicalDeviceGroupProperties);
4133 
4134     return result;
4135 }
4136 
DispatchGetPhysicalDeviceExternalBufferPropertiesKHR(VkPhysicalDevice physicalDevice,const VkPhysicalDeviceExternalBufferInfo * pExternalBufferInfo,VkExternalBufferProperties * pExternalBufferProperties)4137 void DispatchGetPhysicalDeviceExternalBufferPropertiesKHR(
4138     VkPhysicalDevice                            physicalDevice,
4139     const VkPhysicalDeviceExternalBufferInfo*   pExternalBufferInfo,
4140     VkExternalBufferProperties*                 pExternalBufferProperties)
4141 {
4142     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
4143     layer_data->instance_dispatch_table.GetPhysicalDeviceExternalBufferPropertiesKHR(physicalDevice, pExternalBufferInfo, pExternalBufferProperties);
4144 
4145 }
4146 
4147 #ifdef VK_USE_PLATFORM_WIN32_KHR
4148 
DispatchGetMemoryWin32HandleKHR(VkDevice device,const VkMemoryGetWin32HandleInfoKHR * pGetWin32HandleInfo,HANDLE * pHandle)4149 VkResult DispatchGetMemoryWin32HandleKHR(
4150     VkDevice                                    device,
4151     const VkMemoryGetWin32HandleInfoKHR*        pGetWin32HandleInfo,
4152     HANDLE*                                     pHandle)
4153 {
4154     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4155     if (!wrap_handles) return layer_data->device_dispatch_table.GetMemoryWin32HandleKHR(device, pGetWin32HandleInfo, pHandle);
4156     safe_VkMemoryGetWin32HandleInfoKHR *local_pGetWin32HandleInfo = NULL;
4157     {
4158         if (pGetWin32HandleInfo) {
4159             local_pGetWin32HandleInfo = new safe_VkMemoryGetWin32HandleInfoKHR(pGetWin32HandleInfo);
4160             if (pGetWin32HandleInfo->memory) {
4161                 local_pGetWin32HandleInfo->memory = layer_data->Unwrap(pGetWin32HandleInfo->memory);
4162             }
4163         }
4164     }
4165     VkResult result = layer_data->device_dispatch_table.GetMemoryWin32HandleKHR(device, (const VkMemoryGetWin32HandleInfoKHR*)local_pGetWin32HandleInfo, pHandle);
4166     if (local_pGetWin32HandleInfo) {
4167         delete local_pGetWin32HandleInfo;
4168     }
4169     return result;
4170 }
4171 #endif // VK_USE_PLATFORM_WIN32_KHR
4172 
4173 #ifdef VK_USE_PLATFORM_WIN32_KHR
4174 
DispatchGetMemoryWin32HandlePropertiesKHR(VkDevice device,VkExternalMemoryHandleTypeFlagBits handleType,HANDLE handle,VkMemoryWin32HandlePropertiesKHR * pMemoryWin32HandleProperties)4175 VkResult DispatchGetMemoryWin32HandlePropertiesKHR(
4176     VkDevice                                    device,
4177     VkExternalMemoryHandleTypeFlagBits          handleType,
4178     HANDLE                                      handle,
4179     VkMemoryWin32HandlePropertiesKHR*           pMemoryWin32HandleProperties)
4180 {
4181     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4182     VkResult result = layer_data->device_dispatch_table.GetMemoryWin32HandlePropertiesKHR(device, handleType, handle, pMemoryWin32HandleProperties);
4183 
4184     return result;
4185 }
4186 #endif // VK_USE_PLATFORM_WIN32_KHR
4187 
DispatchGetMemoryFdKHR(VkDevice device,const VkMemoryGetFdInfoKHR * pGetFdInfo,int * pFd)4188 VkResult DispatchGetMemoryFdKHR(
4189     VkDevice                                    device,
4190     const VkMemoryGetFdInfoKHR*                 pGetFdInfo,
4191     int*                                        pFd)
4192 {
4193     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4194     if (!wrap_handles) return layer_data->device_dispatch_table.GetMemoryFdKHR(device, pGetFdInfo, pFd);
4195     safe_VkMemoryGetFdInfoKHR *local_pGetFdInfo = NULL;
4196     {
4197         if (pGetFdInfo) {
4198             local_pGetFdInfo = new safe_VkMemoryGetFdInfoKHR(pGetFdInfo);
4199             if (pGetFdInfo->memory) {
4200                 local_pGetFdInfo->memory = layer_data->Unwrap(pGetFdInfo->memory);
4201             }
4202         }
4203     }
4204     VkResult result = layer_data->device_dispatch_table.GetMemoryFdKHR(device, (const VkMemoryGetFdInfoKHR*)local_pGetFdInfo, pFd);
4205     if (local_pGetFdInfo) {
4206         delete local_pGetFdInfo;
4207     }
4208     return result;
4209 }
4210 
DispatchGetMemoryFdPropertiesKHR(VkDevice device,VkExternalMemoryHandleTypeFlagBits handleType,int fd,VkMemoryFdPropertiesKHR * pMemoryFdProperties)4211 VkResult DispatchGetMemoryFdPropertiesKHR(
4212     VkDevice                                    device,
4213     VkExternalMemoryHandleTypeFlagBits          handleType,
4214     int                                         fd,
4215     VkMemoryFdPropertiesKHR*                    pMemoryFdProperties)
4216 {
4217     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4218     VkResult result = layer_data->device_dispatch_table.GetMemoryFdPropertiesKHR(device, handleType, fd, pMemoryFdProperties);
4219 
4220     return result;
4221 }
4222 
DispatchGetPhysicalDeviceExternalSemaphorePropertiesKHR(VkPhysicalDevice physicalDevice,const VkPhysicalDeviceExternalSemaphoreInfo * pExternalSemaphoreInfo,VkExternalSemaphoreProperties * pExternalSemaphoreProperties)4223 void DispatchGetPhysicalDeviceExternalSemaphorePropertiesKHR(
4224     VkPhysicalDevice                            physicalDevice,
4225     const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo,
4226     VkExternalSemaphoreProperties*              pExternalSemaphoreProperties)
4227 {
4228     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
4229     layer_data->instance_dispatch_table.GetPhysicalDeviceExternalSemaphorePropertiesKHR(physicalDevice, pExternalSemaphoreInfo, pExternalSemaphoreProperties);
4230 
4231 }
4232 
4233 #ifdef VK_USE_PLATFORM_WIN32_KHR
4234 
DispatchImportSemaphoreWin32HandleKHR(VkDevice device,const VkImportSemaphoreWin32HandleInfoKHR * pImportSemaphoreWin32HandleInfo)4235 VkResult DispatchImportSemaphoreWin32HandleKHR(
4236     VkDevice                                    device,
4237     const VkImportSemaphoreWin32HandleInfoKHR*  pImportSemaphoreWin32HandleInfo)
4238 {
4239     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4240     if (!wrap_handles) return layer_data->device_dispatch_table.ImportSemaphoreWin32HandleKHR(device, pImportSemaphoreWin32HandleInfo);
4241     safe_VkImportSemaphoreWin32HandleInfoKHR *local_pImportSemaphoreWin32HandleInfo = NULL;
4242     {
4243         if (pImportSemaphoreWin32HandleInfo) {
4244             local_pImportSemaphoreWin32HandleInfo = new safe_VkImportSemaphoreWin32HandleInfoKHR(pImportSemaphoreWin32HandleInfo);
4245             if (pImportSemaphoreWin32HandleInfo->semaphore) {
4246                 local_pImportSemaphoreWin32HandleInfo->semaphore = layer_data->Unwrap(pImportSemaphoreWin32HandleInfo->semaphore);
4247             }
4248         }
4249     }
4250     VkResult result = layer_data->device_dispatch_table.ImportSemaphoreWin32HandleKHR(device, (const VkImportSemaphoreWin32HandleInfoKHR*)local_pImportSemaphoreWin32HandleInfo);
4251     if (local_pImportSemaphoreWin32HandleInfo) {
4252         delete local_pImportSemaphoreWin32HandleInfo;
4253     }
4254     return result;
4255 }
4256 #endif // VK_USE_PLATFORM_WIN32_KHR
4257 
4258 #ifdef VK_USE_PLATFORM_WIN32_KHR
4259 
DispatchGetSemaphoreWin32HandleKHR(VkDevice device,const VkSemaphoreGetWin32HandleInfoKHR * pGetWin32HandleInfo,HANDLE * pHandle)4260 VkResult DispatchGetSemaphoreWin32HandleKHR(
4261     VkDevice                                    device,
4262     const VkSemaphoreGetWin32HandleInfoKHR*     pGetWin32HandleInfo,
4263     HANDLE*                                     pHandle)
4264 {
4265     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4266     if (!wrap_handles) return layer_data->device_dispatch_table.GetSemaphoreWin32HandleKHR(device, pGetWin32HandleInfo, pHandle);
4267     safe_VkSemaphoreGetWin32HandleInfoKHR *local_pGetWin32HandleInfo = NULL;
4268     {
4269         if (pGetWin32HandleInfo) {
4270             local_pGetWin32HandleInfo = new safe_VkSemaphoreGetWin32HandleInfoKHR(pGetWin32HandleInfo);
4271             if (pGetWin32HandleInfo->semaphore) {
4272                 local_pGetWin32HandleInfo->semaphore = layer_data->Unwrap(pGetWin32HandleInfo->semaphore);
4273             }
4274         }
4275     }
4276     VkResult result = layer_data->device_dispatch_table.GetSemaphoreWin32HandleKHR(device, (const VkSemaphoreGetWin32HandleInfoKHR*)local_pGetWin32HandleInfo, pHandle);
4277     if (local_pGetWin32HandleInfo) {
4278         delete local_pGetWin32HandleInfo;
4279     }
4280     return result;
4281 }
4282 #endif // VK_USE_PLATFORM_WIN32_KHR
4283 
DispatchImportSemaphoreFdKHR(VkDevice device,const VkImportSemaphoreFdInfoKHR * pImportSemaphoreFdInfo)4284 VkResult DispatchImportSemaphoreFdKHR(
4285     VkDevice                                    device,
4286     const VkImportSemaphoreFdInfoKHR*           pImportSemaphoreFdInfo)
4287 {
4288     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4289     if (!wrap_handles) return layer_data->device_dispatch_table.ImportSemaphoreFdKHR(device, pImportSemaphoreFdInfo);
4290     safe_VkImportSemaphoreFdInfoKHR *local_pImportSemaphoreFdInfo = NULL;
4291     {
4292         if (pImportSemaphoreFdInfo) {
4293             local_pImportSemaphoreFdInfo = new safe_VkImportSemaphoreFdInfoKHR(pImportSemaphoreFdInfo);
4294             if (pImportSemaphoreFdInfo->semaphore) {
4295                 local_pImportSemaphoreFdInfo->semaphore = layer_data->Unwrap(pImportSemaphoreFdInfo->semaphore);
4296             }
4297         }
4298     }
4299     VkResult result = layer_data->device_dispatch_table.ImportSemaphoreFdKHR(device, (const VkImportSemaphoreFdInfoKHR*)local_pImportSemaphoreFdInfo);
4300     if (local_pImportSemaphoreFdInfo) {
4301         delete local_pImportSemaphoreFdInfo;
4302     }
4303     return result;
4304 }
4305 
DispatchGetSemaphoreFdKHR(VkDevice device,const VkSemaphoreGetFdInfoKHR * pGetFdInfo,int * pFd)4306 VkResult DispatchGetSemaphoreFdKHR(
4307     VkDevice                                    device,
4308     const VkSemaphoreGetFdInfoKHR*              pGetFdInfo,
4309     int*                                        pFd)
4310 {
4311     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4312     if (!wrap_handles) return layer_data->device_dispatch_table.GetSemaphoreFdKHR(device, pGetFdInfo, pFd);
4313     safe_VkSemaphoreGetFdInfoKHR *local_pGetFdInfo = NULL;
4314     {
4315         if (pGetFdInfo) {
4316             local_pGetFdInfo = new safe_VkSemaphoreGetFdInfoKHR(pGetFdInfo);
4317             if (pGetFdInfo->semaphore) {
4318                 local_pGetFdInfo->semaphore = layer_data->Unwrap(pGetFdInfo->semaphore);
4319             }
4320         }
4321     }
4322     VkResult result = layer_data->device_dispatch_table.GetSemaphoreFdKHR(device, (const VkSemaphoreGetFdInfoKHR*)local_pGetFdInfo, pFd);
4323     if (local_pGetFdInfo) {
4324         delete local_pGetFdInfo;
4325     }
4326     return result;
4327 }
4328 
DispatchCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,VkPipelineBindPoint pipelineBindPoint,VkPipelineLayout layout,uint32_t set,uint32_t descriptorWriteCount,const VkWriteDescriptorSet * pDescriptorWrites)4329 void DispatchCmdPushDescriptorSetKHR(
4330     VkCommandBuffer                             commandBuffer,
4331     VkPipelineBindPoint                         pipelineBindPoint,
4332     VkPipelineLayout                            layout,
4333     uint32_t                                    set,
4334     uint32_t                                    descriptorWriteCount,
4335     const VkWriteDescriptorSet*                 pDescriptorWrites)
4336 {
4337     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
4338     if (!wrap_handles) return layer_data->device_dispatch_table.CmdPushDescriptorSetKHR(commandBuffer, pipelineBindPoint, layout, set, descriptorWriteCount, pDescriptorWrites);
4339     safe_VkWriteDescriptorSet *local_pDescriptorWrites = NULL;
4340     {
4341         layout = layer_data->Unwrap(layout);
4342         if (pDescriptorWrites) {
4343             local_pDescriptorWrites = new safe_VkWriteDescriptorSet[descriptorWriteCount];
4344             for (uint32_t index0 = 0; index0 < descriptorWriteCount; ++index0) {
4345                 local_pDescriptorWrites[index0].initialize(&pDescriptorWrites[index0]);
4346                 WrapPnextChainHandles(layer_data, local_pDescriptorWrites[index0].pNext);
4347                 if (pDescriptorWrites[index0].dstSet) {
4348                     local_pDescriptorWrites[index0].dstSet = layer_data->Unwrap(pDescriptorWrites[index0].dstSet);
4349                 }
4350                 if (local_pDescriptorWrites[index0].pImageInfo) {
4351                     for (uint32_t index1 = 0; index1 < local_pDescriptorWrites[index0].descriptorCount; ++index1) {
4352                         if (pDescriptorWrites[index0].pImageInfo[index1].sampler) {
4353                             local_pDescriptorWrites[index0].pImageInfo[index1].sampler = layer_data->Unwrap(pDescriptorWrites[index0].pImageInfo[index1].sampler);
4354                         }
4355                         if (pDescriptorWrites[index0].pImageInfo[index1].imageView) {
4356                             local_pDescriptorWrites[index0].pImageInfo[index1].imageView = layer_data->Unwrap(pDescriptorWrites[index0].pImageInfo[index1].imageView);
4357                         }
4358                     }
4359                 }
4360                 if (local_pDescriptorWrites[index0].pBufferInfo) {
4361                     for (uint32_t index1 = 0; index1 < local_pDescriptorWrites[index0].descriptorCount; ++index1) {
4362                         if (pDescriptorWrites[index0].pBufferInfo[index1].buffer) {
4363                             local_pDescriptorWrites[index0].pBufferInfo[index1].buffer = layer_data->Unwrap(pDescriptorWrites[index0].pBufferInfo[index1].buffer);
4364                         }
4365                     }
4366                 }
4367                 if (local_pDescriptorWrites[index0].pTexelBufferView) {
4368                     for (uint32_t index1 = 0; index1 < local_pDescriptorWrites[index0].descriptorCount; ++index1) {
4369                         local_pDescriptorWrites[index0].pTexelBufferView[index1] = layer_data->Unwrap(local_pDescriptorWrites[index0].pTexelBufferView[index1]);
4370                     }
4371                 }
4372             }
4373         }
4374     }
4375     layer_data->device_dispatch_table.CmdPushDescriptorSetKHR(commandBuffer, pipelineBindPoint, layout, set, descriptorWriteCount, (const VkWriteDescriptorSet*)local_pDescriptorWrites);
4376     if (local_pDescriptorWrites) {
4377         delete[] local_pDescriptorWrites;
4378     }
4379 }
4380 
4381 // Skip vkCmdPushDescriptorSetWithTemplateKHR dispatch, manually generated
4382 
4383 // Skip vkCreateDescriptorUpdateTemplateKHR dispatch, manually generated
4384 
4385 // Skip vkDestroyDescriptorUpdateTemplateKHR dispatch, manually generated
4386 
4387 // Skip vkUpdateDescriptorSetWithTemplateKHR dispatch, manually generated
4388 
4389 // Skip vkCreateRenderPass2KHR dispatch, manually generated
4390 
DispatchCmdBeginRenderPass2KHR(VkCommandBuffer commandBuffer,const VkRenderPassBeginInfo * pRenderPassBegin,const VkSubpassBeginInfoKHR * pSubpassBeginInfo)4391 void DispatchCmdBeginRenderPass2KHR(
4392     VkCommandBuffer                             commandBuffer,
4393     const VkRenderPassBeginInfo*                pRenderPassBegin,
4394     const VkSubpassBeginInfoKHR*                pSubpassBeginInfo)
4395 {
4396     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
4397     if (!wrap_handles) return layer_data->device_dispatch_table.CmdBeginRenderPass2KHR(commandBuffer, pRenderPassBegin, pSubpassBeginInfo);
4398     safe_VkRenderPassBeginInfo *local_pRenderPassBegin = NULL;
4399     {
4400         if (pRenderPassBegin) {
4401             local_pRenderPassBegin = new safe_VkRenderPassBeginInfo(pRenderPassBegin);
4402             if (pRenderPassBegin->renderPass) {
4403                 local_pRenderPassBegin->renderPass = layer_data->Unwrap(pRenderPassBegin->renderPass);
4404             }
4405             if (pRenderPassBegin->framebuffer) {
4406                 local_pRenderPassBegin->framebuffer = layer_data->Unwrap(pRenderPassBegin->framebuffer);
4407             }
4408             WrapPnextChainHandles(layer_data, local_pRenderPassBegin->pNext);
4409         }
4410     }
4411     layer_data->device_dispatch_table.CmdBeginRenderPass2KHR(commandBuffer, (const VkRenderPassBeginInfo*)local_pRenderPassBegin, pSubpassBeginInfo);
4412     if (local_pRenderPassBegin) {
4413         delete local_pRenderPassBegin;
4414     }
4415 }
4416 
DispatchCmdNextSubpass2KHR(VkCommandBuffer commandBuffer,const VkSubpassBeginInfoKHR * pSubpassBeginInfo,const VkSubpassEndInfoKHR * pSubpassEndInfo)4417 void DispatchCmdNextSubpass2KHR(
4418     VkCommandBuffer                             commandBuffer,
4419     const VkSubpassBeginInfoKHR*                pSubpassBeginInfo,
4420     const VkSubpassEndInfoKHR*                  pSubpassEndInfo)
4421 {
4422     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
4423     layer_data->device_dispatch_table.CmdNextSubpass2KHR(commandBuffer, pSubpassBeginInfo, pSubpassEndInfo);
4424 
4425 }
4426 
DispatchCmdEndRenderPass2KHR(VkCommandBuffer commandBuffer,const VkSubpassEndInfoKHR * pSubpassEndInfo)4427 void DispatchCmdEndRenderPass2KHR(
4428     VkCommandBuffer                             commandBuffer,
4429     const VkSubpassEndInfoKHR*                  pSubpassEndInfo)
4430 {
4431     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
4432     layer_data->device_dispatch_table.CmdEndRenderPass2KHR(commandBuffer, pSubpassEndInfo);
4433 
4434 }
4435 
DispatchGetSwapchainStatusKHR(VkDevice device,VkSwapchainKHR swapchain)4436 VkResult DispatchGetSwapchainStatusKHR(
4437     VkDevice                                    device,
4438     VkSwapchainKHR                              swapchain)
4439 {
4440     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4441     if (!wrap_handles) return layer_data->device_dispatch_table.GetSwapchainStatusKHR(device, swapchain);
4442     {
4443         swapchain = layer_data->Unwrap(swapchain);
4444     }
4445     VkResult result = layer_data->device_dispatch_table.GetSwapchainStatusKHR(device, swapchain);
4446 
4447     return result;
4448 }
4449 
DispatchGetPhysicalDeviceExternalFencePropertiesKHR(VkPhysicalDevice physicalDevice,const VkPhysicalDeviceExternalFenceInfo * pExternalFenceInfo,VkExternalFenceProperties * pExternalFenceProperties)4450 void DispatchGetPhysicalDeviceExternalFencePropertiesKHR(
4451     VkPhysicalDevice                            physicalDevice,
4452     const VkPhysicalDeviceExternalFenceInfo*    pExternalFenceInfo,
4453     VkExternalFenceProperties*                  pExternalFenceProperties)
4454 {
4455     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
4456     layer_data->instance_dispatch_table.GetPhysicalDeviceExternalFencePropertiesKHR(physicalDevice, pExternalFenceInfo, pExternalFenceProperties);
4457 
4458 }
4459 
4460 #ifdef VK_USE_PLATFORM_WIN32_KHR
4461 
DispatchImportFenceWin32HandleKHR(VkDevice device,const VkImportFenceWin32HandleInfoKHR * pImportFenceWin32HandleInfo)4462 VkResult DispatchImportFenceWin32HandleKHR(
4463     VkDevice                                    device,
4464     const VkImportFenceWin32HandleInfoKHR*      pImportFenceWin32HandleInfo)
4465 {
4466     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4467     if (!wrap_handles) return layer_data->device_dispatch_table.ImportFenceWin32HandleKHR(device, pImportFenceWin32HandleInfo);
4468     safe_VkImportFenceWin32HandleInfoKHR *local_pImportFenceWin32HandleInfo = NULL;
4469     {
4470         if (pImportFenceWin32HandleInfo) {
4471             local_pImportFenceWin32HandleInfo = new safe_VkImportFenceWin32HandleInfoKHR(pImportFenceWin32HandleInfo);
4472             if (pImportFenceWin32HandleInfo->fence) {
4473                 local_pImportFenceWin32HandleInfo->fence = layer_data->Unwrap(pImportFenceWin32HandleInfo->fence);
4474             }
4475         }
4476     }
4477     VkResult result = layer_data->device_dispatch_table.ImportFenceWin32HandleKHR(device, (const VkImportFenceWin32HandleInfoKHR*)local_pImportFenceWin32HandleInfo);
4478     if (local_pImportFenceWin32HandleInfo) {
4479         delete local_pImportFenceWin32HandleInfo;
4480     }
4481     return result;
4482 }
4483 #endif // VK_USE_PLATFORM_WIN32_KHR
4484 
4485 #ifdef VK_USE_PLATFORM_WIN32_KHR
4486 
DispatchGetFenceWin32HandleKHR(VkDevice device,const VkFenceGetWin32HandleInfoKHR * pGetWin32HandleInfo,HANDLE * pHandle)4487 VkResult DispatchGetFenceWin32HandleKHR(
4488     VkDevice                                    device,
4489     const VkFenceGetWin32HandleInfoKHR*         pGetWin32HandleInfo,
4490     HANDLE*                                     pHandle)
4491 {
4492     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4493     if (!wrap_handles) return layer_data->device_dispatch_table.GetFenceWin32HandleKHR(device, pGetWin32HandleInfo, pHandle);
4494     safe_VkFenceGetWin32HandleInfoKHR *local_pGetWin32HandleInfo = NULL;
4495     {
4496         if (pGetWin32HandleInfo) {
4497             local_pGetWin32HandleInfo = new safe_VkFenceGetWin32HandleInfoKHR(pGetWin32HandleInfo);
4498             if (pGetWin32HandleInfo->fence) {
4499                 local_pGetWin32HandleInfo->fence = layer_data->Unwrap(pGetWin32HandleInfo->fence);
4500             }
4501         }
4502     }
4503     VkResult result = layer_data->device_dispatch_table.GetFenceWin32HandleKHR(device, (const VkFenceGetWin32HandleInfoKHR*)local_pGetWin32HandleInfo, pHandle);
4504     if (local_pGetWin32HandleInfo) {
4505         delete local_pGetWin32HandleInfo;
4506     }
4507     return result;
4508 }
4509 #endif // VK_USE_PLATFORM_WIN32_KHR
4510 
DispatchImportFenceFdKHR(VkDevice device,const VkImportFenceFdInfoKHR * pImportFenceFdInfo)4511 VkResult DispatchImportFenceFdKHR(
4512     VkDevice                                    device,
4513     const VkImportFenceFdInfoKHR*               pImportFenceFdInfo)
4514 {
4515     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4516     if (!wrap_handles) return layer_data->device_dispatch_table.ImportFenceFdKHR(device, pImportFenceFdInfo);
4517     safe_VkImportFenceFdInfoKHR *local_pImportFenceFdInfo = NULL;
4518     {
4519         if (pImportFenceFdInfo) {
4520             local_pImportFenceFdInfo = new safe_VkImportFenceFdInfoKHR(pImportFenceFdInfo);
4521             if (pImportFenceFdInfo->fence) {
4522                 local_pImportFenceFdInfo->fence = layer_data->Unwrap(pImportFenceFdInfo->fence);
4523             }
4524         }
4525     }
4526     VkResult result = layer_data->device_dispatch_table.ImportFenceFdKHR(device, (const VkImportFenceFdInfoKHR*)local_pImportFenceFdInfo);
4527     if (local_pImportFenceFdInfo) {
4528         delete local_pImportFenceFdInfo;
4529     }
4530     return result;
4531 }
4532 
DispatchGetFenceFdKHR(VkDevice device,const VkFenceGetFdInfoKHR * pGetFdInfo,int * pFd)4533 VkResult DispatchGetFenceFdKHR(
4534     VkDevice                                    device,
4535     const VkFenceGetFdInfoKHR*                  pGetFdInfo,
4536     int*                                        pFd)
4537 {
4538     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4539     if (!wrap_handles) return layer_data->device_dispatch_table.GetFenceFdKHR(device, pGetFdInfo, pFd);
4540     safe_VkFenceGetFdInfoKHR *local_pGetFdInfo = NULL;
4541     {
4542         if (pGetFdInfo) {
4543             local_pGetFdInfo = new safe_VkFenceGetFdInfoKHR(pGetFdInfo);
4544             if (pGetFdInfo->fence) {
4545                 local_pGetFdInfo->fence = layer_data->Unwrap(pGetFdInfo->fence);
4546             }
4547         }
4548     }
4549     VkResult result = layer_data->device_dispatch_table.GetFenceFdKHR(device, (const VkFenceGetFdInfoKHR*)local_pGetFdInfo, pFd);
4550     if (local_pGetFdInfo) {
4551         delete local_pGetFdInfo;
4552     }
4553     return result;
4554 }
4555 
DispatchGetPhysicalDeviceSurfaceCapabilities2KHR(VkPhysicalDevice physicalDevice,const VkPhysicalDeviceSurfaceInfo2KHR * pSurfaceInfo,VkSurfaceCapabilities2KHR * pSurfaceCapabilities)4556 VkResult DispatchGetPhysicalDeviceSurfaceCapabilities2KHR(
4557     VkPhysicalDevice                            physicalDevice,
4558     const VkPhysicalDeviceSurfaceInfo2KHR*      pSurfaceInfo,
4559     VkSurfaceCapabilities2KHR*                  pSurfaceCapabilities)
4560 {
4561     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
4562     if (!wrap_handles) return layer_data->instance_dispatch_table.GetPhysicalDeviceSurfaceCapabilities2KHR(physicalDevice, pSurfaceInfo, pSurfaceCapabilities);
4563     safe_VkPhysicalDeviceSurfaceInfo2KHR *local_pSurfaceInfo = NULL;
4564     {
4565         if (pSurfaceInfo) {
4566             local_pSurfaceInfo = new safe_VkPhysicalDeviceSurfaceInfo2KHR(pSurfaceInfo);
4567             if (pSurfaceInfo->surface) {
4568                 local_pSurfaceInfo->surface = layer_data->Unwrap(pSurfaceInfo->surface);
4569             }
4570         }
4571     }
4572     VkResult result = layer_data->instance_dispatch_table.GetPhysicalDeviceSurfaceCapabilities2KHR(physicalDevice, (const VkPhysicalDeviceSurfaceInfo2KHR*)local_pSurfaceInfo, pSurfaceCapabilities);
4573     if (local_pSurfaceInfo) {
4574         delete local_pSurfaceInfo;
4575     }
4576     return result;
4577 }
4578 
DispatchGetPhysicalDeviceSurfaceFormats2KHR(VkPhysicalDevice physicalDevice,const VkPhysicalDeviceSurfaceInfo2KHR * pSurfaceInfo,uint32_t * pSurfaceFormatCount,VkSurfaceFormat2KHR * pSurfaceFormats)4579 VkResult DispatchGetPhysicalDeviceSurfaceFormats2KHR(
4580     VkPhysicalDevice                            physicalDevice,
4581     const VkPhysicalDeviceSurfaceInfo2KHR*      pSurfaceInfo,
4582     uint32_t*                                   pSurfaceFormatCount,
4583     VkSurfaceFormat2KHR*                        pSurfaceFormats)
4584 {
4585     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
4586     if (!wrap_handles) return layer_data->instance_dispatch_table.GetPhysicalDeviceSurfaceFormats2KHR(physicalDevice, pSurfaceInfo, pSurfaceFormatCount, pSurfaceFormats);
4587     safe_VkPhysicalDeviceSurfaceInfo2KHR *local_pSurfaceInfo = NULL;
4588     {
4589         if (pSurfaceInfo) {
4590             local_pSurfaceInfo = new safe_VkPhysicalDeviceSurfaceInfo2KHR(pSurfaceInfo);
4591             if (pSurfaceInfo->surface) {
4592                 local_pSurfaceInfo->surface = layer_data->Unwrap(pSurfaceInfo->surface);
4593             }
4594         }
4595     }
4596     VkResult result = layer_data->instance_dispatch_table.GetPhysicalDeviceSurfaceFormats2KHR(physicalDevice, (const VkPhysicalDeviceSurfaceInfo2KHR*)local_pSurfaceInfo, pSurfaceFormatCount, pSurfaceFormats);
4597     if (local_pSurfaceInfo) {
4598         delete local_pSurfaceInfo;
4599     }
4600     return result;
4601 }
4602 
4603 // Skip vkGetPhysicalDeviceDisplayProperties2KHR dispatch, manually generated
4604 
4605 // Skip vkGetPhysicalDeviceDisplayPlaneProperties2KHR dispatch, manually generated
4606 
4607 // Skip vkGetDisplayModeProperties2KHR dispatch, manually generated
4608 
DispatchGetDisplayPlaneCapabilities2KHR(VkPhysicalDevice physicalDevice,const VkDisplayPlaneInfo2KHR * pDisplayPlaneInfo,VkDisplayPlaneCapabilities2KHR * pCapabilities)4609 VkResult DispatchGetDisplayPlaneCapabilities2KHR(
4610     VkPhysicalDevice                            physicalDevice,
4611     const VkDisplayPlaneInfo2KHR*               pDisplayPlaneInfo,
4612     VkDisplayPlaneCapabilities2KHR*             pCapabilities)
4613 {
4614     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
4615     if (!wrap_handles) return layer_data->instance_dispatch_table.GetDisplayPlaneCapabilities2KHR(physicalDevice, pDisplayPlaneInfo, pCapabilities);
4616     safe_VkDisplayPlaneInfo2KHR *local_pDisplayPlaneInfo = NULL;
4617     {
4618         if (pDisplayPlaneInfo) {
4619             local_pDisplayPlaneInfo = new safe_VkDisplayPlaneInfo2KHR(pDisplayPlaneInfo);
4620             if (pDisplayPlaneInfo->mode) {
4621                 local_pDisplayPlaneInfo->mode = layer_data->Unwrap(pDisplayPlaneInfo->mode);
4622             }
4623         }
4624     }
4625     VkResult result = layer_data->instance_dispatch_table.GetDisplayPlaneCapabilities2KHR(physicalDevice, (const VkDisplayPlaneInfo2KHR*)local_pDisplayPlaneInfo, pCapabilities);
4626     if (local_pDisplayPlaneInfo) {
4627         delete local_pDisplayPlaneInfo;
4628     }
4629     return result;
4630 }
4631 
DispatchGetImageMemoryRequirements2KHR(VkDevice device,const VkImageMemoryRequirementsInfo2 * pInfo,VkMemoryRequirements2 * pMemoryRequirements)4632 void DispatchGetImageMemoryRequirements2KHR(
4633     VkDevice                                    device,
4634     const VkImageMemoryRequirementsInfo2*       pInfo,
4635     VkMemoryRequirements2*                      pMemoryRequirements)
4636 {
4637     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4638     if (!wrap_handles) return layer_data->device_dispatch_table.GetImageMemoryRequirements2KHR(device, pInfo, pMemoryRequirements);
4639     safe_VkImageMemoryRequirementsInfo2 *local_pInfo = NULL;
4640     {
4641         if (pInfo) {
4642             local_pInfo = new safe_VkImageMemoryRequirementsInfo2(pInfo);
4643             if (pInfo->image) {
4644                 local_pInfo->image = layer_data->Unwrap(pInfo->image);
4645             }
4646         }
4647     }
4648     layer_data->device_dispatch_table.GetImageMemoryRequirements2KHR(device, (const VkImageMemoryRequirementsInfo2*)local_pInfo, pMemoryRequirements);
4649     if (local_pInfo) {
4650         delete local_pInfo;
4651     }
4652 }
4653 
DispatchGetBufferMemoryRequirements2KHR(VkDevice device,const VkBufferMemoryRequirementsInfo2 * pInfo,VkMemoryRequirements2 * pMemoryRequirements)4654 void DispatchGetBufferMemoryRequirements2KHR(
4655     VkDevice                                    device,
4656     const VkBufferMemoryRequirementsInfo2*      pInfo,
4657     VkMemoryRequirements2*                      pMemoryRequirements)
4658 {
4659     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4660     if (!wrap_handles) return layer_data->device_dispatch_table.GetBufferMemoryRequirements2KHR(device, pInfo, pMemoryRequirements);
4661     safe_VkBufferMemoryRequirementsInfo2 *local_pInfo = NULL;
4662     {
4663         if (pInfo) {
4664             local_pInfo = new safe_VkBufferMemoryRequirementsInfo2(pInfo);
4665             if (pInfo->buffer) {
4666                 local_pInfo->buffer = layer_data->Unwrap(pInfo->buffer);
4667             }
4668         }
4669     }
4670     layer_data->device_dispatch_table.GetBufferMemoryRequirements2KHR(device, (const VkBufferMemoryRequirementsInfo2*)local_pInfo, pMemoryRequirements);
4671     if (local_pInfo) {
4672         delete local_pInfo;
4673     }
4674 }
4675 
DispatchGetImageSparseMemoryRequirements2KHR(VkDevice device,const VkImageSparseMemoryRequirementsInfo2 * pInfo,uint32_t * pSparseMemoryRequirementCount,VkSparseImageMemoryRequirements2 * pSparseMemoryRequirements)4676 void DispatchGetImageSparseMemoryRequirements2KHR(
4677     VkDevice                                    device,
4678     const VkImageSparseMemoryRequirementsInfo2* pInfo,
4679     uint32_t*                                   pSparseMemoryRequirementCount,
4680     VkSparseImageMemoryRequirements2*           pSparseMemoryRequirements)
4681 {
4682     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4683     if (!wrap_handles) return layer_data->device_dispatch_table.GetImageSparseMemoryRequirements2KHR(device, pInfo, pSparseMemoryRequirementCount, pSparseMemoryRequirements);
4684     safe_VkImageSparseMemoryRequirementsInfo2 *local_pInfo = NULL;
4685     {
4686         if (pInfo) {
4687             local_pInfo = new safe_VkImageSparseMemoryRequirementsInfo2(pInfo);
4688             if (pInfo->image) {
4689                 local_pInfo->image = layer_data->Unwrap(pInfo->image);
4690             }
4691         }
4692     }
4693     layer_data->device_dispatch_table.GetImageSparseMemoryRequirements2KHR(device, (const VkImageSparseMemoryRequirementsInfo2*)local_pInfo, pSparseMemoryRequirementCount, pSparseMemoryRequirements);
4694     if (local_pInfo) {
4695         delete local_pInfo;
4696     }
4697 }
4698 
DispatchCreateSamplerYcbcrConversionKHR(VkDevice device,const VkSamplerYcbcrConversionCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSamplerYcbcrConversion * pYcbcrConversion)4699 VkResult DispatchCreateSamplerYcbcrConversionKHR(
4700     VkDevice                                    device,
4701     const VkSamplerYcbcrConversionCreateInfo*   pCreateInfo,
4702     const VkAllocationCallbacks*                pAllocator,
4703     VkSamplerYcbcrConversion*                   pYcbcrConversion)
4704 {
4705     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4706     if (!wrap_handles) return layer_data->device_dispatch_table.CreateSamplerYcbcrConversionKHR(device, pCreateInfo, pAllocator, pYcbcrConversion);
4707     safe_VkSamplerYcbcrConversionCreateInfo *local_pCreateInfo = NULL;
4708     {
4709         if (pCreateInfo) {
4710             local_pCreateInfo = new safe_VkSamplerYcbcrConversionCreateInfo(pCreateInfo);
4711             WrapPnextChainHandles(layer_data, local_pCreateInfo->pNext);
4712         }
4713     }
4714     VkResult result = layer_data->device_dispatch_table.CreateSamplerYcbcrConversionKHR(device, (const VkSamplerYcbcrConversionCreateInfo*)local_pCreateInfo, pAllocator, pYcbcrConversion);
4715     if (local_pCreateInfo) {
4716         delete local_pCreateInfo;
4717     }
4718     if (VK_SUCCESS == result) {
4719         *pYcbcrConversion = layer_data->WrapNew(*pYcbcrConversion);
4720     }
4721     return result;
4722 }
4723 
DispatchDestroySamplerYcbcrConversionKHR(VkDevice device,VkSamplerYcbcrConversion ycbcrConversion,const VkAllocationCallbacks * pAllocator)4724 void DispatchDestroySamplerYcbcrConversionKHR(
4725     VkDevice                                    device,
4726     VkSamplerYcbcrConversion                    ycbcrConversion,
4727     const VkAllocationCallbacks*                pAllocator)
4728 {
4729     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4730     if (!wrap_handles) return layer_data->device_dispatch_table.DestroySamplerYcbcrConversionKHR(device, ycbcrConversion, pAllocator);
4731     uint64_t ycbcrConversion_id = reinterpret_cast<uint64_t &>(ycbcrConversion);
4732     auto iter = unique_id_mapping.pop(ycbcrConversion_id);
4733     if (iter != unique_id_mapping.end()) {
4734         ycbcrConversion = (VkSamplerYcbcrConversion)iter->second;
4735     } else {
4736         ycbcrConversion = (VkSamplerYcbcrConversion)0;
4737     }
4738     layer_data->device_dispatch_table.DestroySamplerYcbcrConversionKHR(device, ycbcrConversion, pAllocator);
4739 
4740 }
4741 
DispatchBindBufferMemory2KHR(VkDevice device,uint32_t bindInfoCount,const VkBindBufferMemoryInfo * pBindInfos)4742 VkResult DispatchBindBufferMemory2KHR(
4743     VkDevice                                    device,
4744     uint32_t                                    bindInfoCount,
4745     const VkBindBufferMemoryInfo*               pBindInfos)
4746 {
4747     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4748     if (!wrap_handles) return layer_data->device_dispatch_table.BindBufferMemory2KHR(device, bindInfoCount, pBindInfos);
4749     safe_VkBindBufferMemoryInfo *local_pBindInfos = NULL;
4750     {
4751         if (pBindInfos) {
4752             local_pBindInfos = new safe_VkBindBufferMemoryInfo[bindInfoCount];
4753             for (uint32_t index0 = 0; index0 < bindInfoCount; ++index0) {
4754                 local_pBindInfos[index0].initialize(&pBindInfos[index0]);
4755                 if (pBindInfos[index0].buffer) {
4756                     local_pBindInfos[index0].buffer = layer_data->Unwrap(pBindInfos[index0].buffer);
4757                 }
4758                 if (pBindInfos[index0].memory) {
4759                     local_pBindInfos[index0].memory = layer_data->Unwrap(pBindInfos[index0].memory);
4760                 }
4761             }
4762         }
4763     }
4764     VkResult result = layer_data->device_dispatch_table.BindBufferMemory2KHR(device, bindInfoCount, (const VkBindBufferMemoryInfo*)local_pBindInfos);
4765     if (local_pBindInfos) {
4766         delete[] local_pBindInfos;
4767     }
4768     return result;
4769 }
4770 
DispatchBindImageMemory2KHR(VkDevice device,uint32_t bindInfoCount,const VkBindImageMemoryInfo * pBindInfos)4771 VkResult DispatchBindImageMemory2KHR(
4772     VkDevice                                    device,
4773     uint32_t                                    bindInfoCount,
4774     const VkBindImageMemoryInfo*                pBindInfos)
4775 {
4776     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4777     if (!wrap_handles) return layer_data->device_dispatch_table.BindImageMemory2KHR(device, bindInfoCount, pBindInfos);
4778     safe_VkBindImageMemoryInfo *local_pBindInfos = NULL;
4779     {
4780         if (pBindInfos) {
4781             local_pBindInfos = new safe_VkBindImageMemoryInfo[bindInfoCount];
4782             for (uint32_t index0 = 0; index0 < bindInfoCount; ++index0) {
4783                 local_pBindInfos[index0].initialize(&pBindInfos[index0]);
4784                 WrapPnextChainHandles(layer_data, local_pBindInfos[index0].pNext);
4785                 if (pBindInfos[index0].image) {
4786                     local_pBindInfos[index0].image = layer_data->Unwrap(pBindInfos[index0].image);
4787                 }
4788                 if (pBindInfos[index0].memory) {
4789                     local_pBindInfos[index0].memory = layer_data->Unwrap(pBindInfos[index0].memory);
4790                 }
4791             }
4792         }
4793     }
4794     VkResult result = layer_data->device_dispatch_table.BindImageMemory2KHR(device, bindInfoCount, (const VkBindImageMemoryInfo*)local_pBindInfos);
4795     if (local_pBindInfos) {
4796         delete[] local_pBindInfos;
4797     }
4798     return result;
4799 }
4800 
DispatchGetDescriptorSetLayoutSupportKHR(VkDevice device,const VkDescriptorSetLayoutCreateInfo * pCreateInfo,VkDescriptorSetLayoutSupport * pSupport)4801 void DispatchGetDescriptorSetLayoutSupportKHR(
4802     VkDevice                                    device,
4803     const VkDescriptorSetLayoutCreateInfo*      pCreateInfo,
4804     VkDescriptorSetLayoutSupport*               pSupport)
4805 {
4806     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4807     if (!wrap_handles) return layer_data->device_dispatch_table.GetDescriptorSetLayoutSupportKHR(device, pCreateInfo, pSupport);
4808     safe_VkDescriptorSetLayoutCreateInfo *local_pCreateInfo = NULL;
4809     {
4810         if (pCreateInfo) {
4811             local_pCreateInfo = new safe_VkDescriptorSetLayoutCreateInfo(pCreateInfo);
4812             if (local_pCreateInfo->pBindings) {
4813                 for (uint32_t index1 = 0; index1 < local_pCreateInfo->bindingCount; ++index1) {
4814                     if (local_pCreateInfo->pBindings[index1].pImmutableSamplers) {
4815                         for (uint32_t index2 = 0; index2 < local_pCreateInfo->pBindings[index1].descriptorCount; ++index2) {
4816                             local_pCreateInfo->pBindings[index1].pImmutableSamplers[index2] = layer_data->Unwrap(local_pCreateInfo->pBindings[index1].pImmutableSamplers[index2]);
4817                         }
4818                     }
4819                 }
4820             }
4821         }
4822     }
4823     layer_data->device_dispatch_table.GetDescriptorSetLayoutSupportKHR(device, (const VkDescriptorSetLayoutCreateInfo*)local_pCreateInfo, pSupport);
4824     if (local_pCreateInfo) {
4825         delete local_pCreateInfo;
4826     }
4827 }
4828 
DispatchCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer,VkBuffer buffer,VkDeviceSize offset,VkBuffer countBuffer,VkDeviceSize countBufferOffset,uint32_t maxDrawCount,uint32_t stride)4829 void DispatchCmdDrawIndirectCountKHR(
4830     VkCommandBuffer                             commandBuffer,
4831     VkBuffer                                    buffer,
4832     VkDeviceSize                                offset,
4833     VkBuffer                                    countBuffer,
4834     VkDeviceSize                                countBufferOffset,
4835     uint32_t                                    maxDrawCount,
4836     uint32_t                                    stride)
4837 {
4838     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
4839     if (!wrap_handles) return layer_data->device_dispatch_table.CmdDrawIndirectCountKHR(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride);
4840     {
4841         buffer = layer_data->Unwrap(buffer);
4842         countBuffer = layer_data->Unwrap(countBuffer);
4843     }
4844     layer_data->device_dispatch_table.CmdDrawIndirectCountKHR(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride);
4845 
4846 }
4847 
DispatchCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer,VkBuffer buffer,VkDeviceSize offset,VkBuffer countBuffer,VkDeviceSize countBufferOffset,uint32_t maxDrawCount,uint32_t stride)4848 void DispatchCmdDrawIndexedIndirectCountKHR(
4849     VkCommandBuffer                             commandBuffer,
4850     VkBuffer                                    buffer,
4851     VkDeviceSize                                offset,
4852     VkBuffer                                    countBuffer,
4853     VkDeviceSize                                countBufferOffset,
4854     uint32_t                                    maxDrawCount,
4855     uint32_t                                    stride)
4856 {
4857     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
4858     if (!wrap_handles) return layer_data->device_dispatch_table.CmdDrawIndexedIndirectCountKHR(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride);
4859     {
4860         buffer = layer_data->Unwrap(buffer);
4861         countBuffer = layer_data->Unwrap(countBuffer);
4862     }
4863     layer_data->device_dispatch_table.CmdDrawIndexedIndirectCountKHR(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride);
4864 
4865 }
4866 
DispatchGetPipelineExecutablePropertiesKHR(VkDevice device,const VkPipelineInfoKHR * pPipelineInfo,uint32_t * pExecutableCount,VkPipelineExecutablePropertiesKHR * pProperties)4867 VkResult DispatchGetPipelineExecutablePropertiesKHR(
4868     VkDevice                                    device,
4869     const VkPipelineInfoKHR*                    pPipelineInfo,
4870     uint32_t*                                   pExecutableCount,
4871     VkPipelineExecutablePropertiesKHR*          pProperties)
4872 {
4873     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4874     if (!wrap_handles) return layer_data->device_dispatch_table.GetPipelineExecutablePropertiesKHR(device, pPipelineInfo, pExecutableCount, pProperties);
4875     safe_VkPipelineInfoKHR *local_pPipelineInfo = NULL;
4876     {
4877         if (pPipelineInfo) {
4878             local_pPipelineInfo = new safe_VkPipelineInfoKHR(pPipelineInfo);
4879             if (pPipelineInfo->pipeline) {
4880                 local_pPipelineInfo->pipeline = layer_data->Unwrap(pPipelineInfo->pipeline);
4881             }
4882         }
4883     }
4884     VkResult result = layer_data->device_dispatch_table.GetPipelineExecutablePropertiesKHR(device, (const VkPipelineInfoKHR*)local_pPipelineInfo, pExecutableCount, pProperties);
4885     if (local_pPipelineInfo) {
4886         delete local_pPipelineInfo;
4887     }
4888     return result;
4889 }
4890 
DispatchGetPipelineExecutableStatisticsKHR(VkDevice device,const VkPipelineExecutableInfoKHR * pExecutableInfo,uint32_t * pStatisticCount,VkPipelineExecutableStatisticKHR * pStatistics)4891 VkResult DispatchGetPipelineExecutableStatisticsKHR(
4892     VkDevice                                    device,
4893     const VkPipelineExecutableInfoKHR*          pExecutableInfo,
4894     uint32_t*                                   pStatisticCount,
4895     VkPipelineExecutableStatisticKHR*           pStatistics)
4896 {
4897     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4898     if (!wrap_handles) return layer_data->device_dispatch_table.GetPipelineExecutableStatisticsKHR(device, pExecutableInfo, pStatisticCount, pStatistics);
4899     safe_VkPipelineExecutableInfoKHR *local_pExecutableInfo = NULL;
4900     {
4901         if (pExecutableInfo) {
4902             local_pExecutableInfo = new safe_VkPipelineExecutableInfoKHR(pExecutableInfo);
4903             if (pExecutableInfo->pipeline) {
4904                 local_pExecutableInfo->pipeline = layer_data->Unwrap(pExecutableInfo->pipeline);
4905             }
4906         }
4907     }
4908     VkResult result = layer_data->device_dispatch_table.GetPipelineExecutableStatisticsKHR(device, (const VkPipelineExecutableInfoKHR*)local_pExecutableInfo, pStatisticCount, pStatistics);
4909     if (local_pExecutableInfo) {
4910         delete local_pExecutableInfo;
4911     }
4912     return result;
4913 }
4914 
DispatchGetPipelineExecutableInternalRepresentationsKHR(VkDevice device,const VkPipelineExecutableInfoKHR * pExecutableInfo,uint32_t * pInternalRepresentationCount,VkPipelineExecutableInternalRepresentationKHR * pInternalRepresentations)4915 VkResult DispatchGetPipelineExecutableInternalRepresentationsKHR(
4916     VkDevice                                    device,
4917     const VkPipelineExecutableInfoKHR*          pExecutableInfo,
4918     uint32_t*                                   pInternalRepresentationCount,
4919     VkPipelineExecutableInternalRepresentationKHR* pInternalRepresentations)
4920 {
4921     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
4922     if (!wrap_handles) return layer_data->device_dispatch_table.GetPipelineExecutableInternalRepresentationsKHR(device, pExecutableInfo, pInternalRepresentationCount, pInternalRepresentations);
4923     safe_VkPipelineExecutableInfoKHR *local_pExecutableInfo = NULL;
4924     {
4925         if (pExecutableInfo) {
4926             local_pExecutableInfo = new safe_VkPipelineExecutableInfoKHR(pExecutableInfo);
4927             if (pExecutableInfo->pipeline) {
4928                 local_pExecutableInfo->pipeline = layer_data->Unwrap(pExecutableInfo->pipeline);
4929             }
4930         }
4931     }
4932     VkResult result = layer_data->device_dispatch_table.GetPipelineExecutableInternalRepresentationsKHR(device, (const VkPipelineExecutableInfoKHR*)local_pExecutableInfo, pInternalRepresentationCount, pInternalRepresentations);
4933     if (local_pExecutableInfo) {
4934         delete local_pExecutableInfo;
4935     }
4936     return result;
4937 }
4938 
DispatchCreateDebugReportCallbackEXT(VkInstance instance,const VkDebugReportCallbackCreateInfoEXT * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkDebugReportCallbackEXT * pCallback)4939 VkResult DispatchCreateDebugReportCallbackEXT(
4940     VkInstance                                  instance,
4941     const VkDebugReportCallbackCreateInfoEXT*   pCreateInfo,
4942     const VkAllocationCallbacks*                pAllocator,
4943     VkDebugReportCallbackEXT*                   pCallback)
4944 {
4945     auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
4946     if (!wrap_handles) return layer_data->instance_dispatch_table.CreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pCallback);
4947     VkResult result = layer_data->instance_dispatch_table.CreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pCallback);
4948     if (VK_SUCCESS == result) {
4949         *pCallback = layer_data->WrapNew(*pCallback);
4950     }
4951     return result;
4952 }
4953 
DispatchDestroyDebugReportCallbackEXT(VkInstance instance,VkDebugReportCallbackEXT callback,const VkAllocationCallbacks * pAllocator)4954 void DispatchDestroyDebugReportCallbackEXT(
4955     VkInstance                                  instance,
4956     VkDebugReportCallbackEXT                    callback,
4957     const VkAllocationCallbacks*                pAllocator)
4958 {
4959     auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
4960     if (!wrap_handles) return layer_data->instance_dispatch_table.DestroyDebugReportCallbackEXT(instance, callback, pAllocator);
4961     uint64_t callback_id = reinterpret_cast<uint64_t &>(callback);
4962     auto iter = unique_id_mapping.pop(callback_id);
4963     if (iter != unique_id_mapping.end()) {
4964         callback = (VkDebugReportCallbackEXT)iter->second;
4965     } else {
4966         callback = (VkDebugReportCallbackEXT)0;
4967     }
4968     layer_data->instance_dispatch_table.DestroyDebugReportCallbackEXT(instance, callback, pAllocator);
4969 
4970 }
4971 
DispatchDebugReportMessageEXT(VkInstance instance,VkDebugReportFlagsEXT flags,VkDebugReportObjectTypeEXT objectType,uint64_t object,size_t location,int32_t messageCode,const char * pLayerPrefix,const char * pMessage)4972 void DispatchDebugReportMessageEXT(
4973     VkInstance                                  instance,
4974     VkDebugReportFlagsEXT                       flags,
4975     VkDebugReportObjectTypeEXT                  objectType,
4976     uint64_t                                    object,
4977     size_t                                      location,
4978     int32_t                                     messageCode,
4979     const char*                                 pLayerPrefix,
4980     const char*                                 pMessage)
4981 {
4982     auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
4983     layer_data->instance_dispatch_table.DebugReportMessageEXT(instance, flags, objectType, object, location, messageCode, pLayerPrefix, pMessage);
4984 
4985 }
4986 
4987 // Skip vkDebugMarkerSetObjectTagEXT dispatch, manually generated
4988 
4989 // Skip vkDebugMarkerSetObjectNameEXT dispatch, manually generated
4990 
DispatchCmdDebugMarkerBeginEXT(VkCommandBuffer commandBuffer,const VkDebugMarkerMarkerInfoEXT * pMarkerInfo)4991 void DispatchCmdDebugMarkerBeginEXT(
4992     VkCommandBuffer                             commandBuffer,
4993     const VkDebugMarkerMarkerInfoEXT*           pMarkerInfo)
4994 {
4995     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
4996     layer_data->device_dispatch_table.CmdDebugMarkerBeginEXT(commandBuffer, pMarkerInfo);
4997 
4998 }
4999 
DispatchCmdDebugMarkerEndEXT(VkCommandBuffer commandBuffer)5000 void DispatchCmdDebugMarkerEndEXT(
5001     VkCommandBuffer                             commandBuffer)
5002 {
5003     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
5004     layer_data->device_dispatch_table.CmdDebugMarkerEndEXT(commandBuffer);
5005 
5006 }
5007 
DispatchCmdDebugMarkerInsertEXT(VkCommandBuffer commandBuffer,const VkDebugMarkerMarkerInfoEXT * pMarkerInfo)5008 void DispatchCmdDebugMarkerInsertEXT(
5009     VkCommandBuffer                             commandBuffer,
5010     const VkDebugMarkerMarkerInfoEXT*           pMarkerInfo)
5011 {
5012     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
5013     layer_data->device_dispatch_table.CmdDebugMarkerInsertEXT(commandBuffer, pMarkerInfo);
5014 
5015 }
5016 
DispatchCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,uint32_t firstBinding,uint32_t bindingCount,const VkBuffer * pBuffers,const VkDeviceSize * pOffsets,const VkDeviceSize * pSizes)5017 void DispatchCmdBindTransformFeedbackBuffersEXT(
5018     VkCommandBuffer                             commandBuffer,
5019     uint32_t                                    firstBinding,
5020     uint32_t                                    bindingCount,
5021     const VkBuffer*                             pBuffers,
5022     const VkDeviceSize*                         pOffsets,
5023     const VkDeviceSize*                         pSizes)
5024 {
5025     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
5026     if (!wrap_handles) return layer_data->device_dispatch_table.CmdBindTransformFeedbackBuffersEXT(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes);
5027     VkBuffer *local_pBuffers = NULL;
5028     {
5029         if (pBuffers) {
5030             local_pBuffers = new VkBuffer[bindingCount];
5031             for (uint32_t index0 = 0; index0 < bindingCount; ++index0) {
5032                 local_pBuffers[index0] = layer_data->Unwrap(pBuffers[index0]);
5033             }
5034         }
5035     }
5036     layer_data->device_dispatch_table.CmdBindTransformFeedbackBuffersEXT(commandBuffer, firstBinding, bindingCount, (const VkBuffer*)local_pBuffers, pOffsets, pSizes);
5037     if (local_pBuffers)
5038         delete[] local_pBuffers;
5039 }
5040 
DispatchCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,uint32_t firstCounterBuffer,uint32_t counterBufferCount,const VkBuffer * pCounterBuffers,const VkDeviceSize * pCounterBufferOffsets)5041 void DispatchCmdBeginTransformFeedbackEXT(
5042     VkCommandBuffer                             commandBuffer,
5043     uint32_t                                    firstCounterBuffer,
5044     uint32_t                                    counterBufferCount,
5045     const VkBuffer*                             pCounterBuffers,
5046     const VkDeviceSize*                         pCounterBufferOffsets)
5047 {
5048     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
5049     if (!wrap_handles) return layer_data->device_dispatch_table.CmdBeginTransformFeedbackEXT(commandBuffer, firstCounterBuffer, counterBufferCount, pCounterBuffers, pCounterBufferOffsets);
5050     VkBuffer *local_pCounterBuffers = NULL;
5051     {
5052         if (pCounterBuffers) {
5053             local_pCounterBuffers = new VkBuffer[counterBufferCount];
5054             for (uint32_t index0 = 0; index0 < counterBufferCount; ++index0) {
5055                 local_pCounterBuffers[index0] = layer_data->Unwrap(pCounterBuffers[index0]);
5056             }
5057         }
5058     }
5059     layer_data->device_dispatch_table.CmdBeginTransformFeedbackEXT(commandBuffer, firstCounterBuffer, counterBufferCount, (const VkBuffer*)local_pCounterBuffers, pCounterBufferOffsets);
5060     if (local_pCounterBuffers)
5061         delete[] local_pCounterBuffers;
5062 }
5063 
DispatchCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,uint32_t firstCounterBuffer,uint32_t counterBufferCount,const VkBuffer * pCounterBuffers,const VkDeviceSize * pCounterBufferOffsets)5064 void DispatchCmdEndTransformFeedbackEXT(
5065     VkCommandBuffer                             commandBuffer,
5066     uint32_t                                    firstCounterBuffer,
5067     uint32_t                                    counterBufferCount,
5068     const VkBuffer*                             pCounterBuffers,
5069     const VkDeviceSize*                         pCounterBufferOffsets)
5070 {
5071     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
5072     if (!wrap_handles) return layer_data->device_dispatch_table.CmdEndTransformFeedbackEXT(commandBuffer, firstCounterBuffer, counterBufferCount, pCounterBuffers, pCounterBufferOffsets);
5073     VkBuffer *local_pCounterBuffers = NULL;
5074     {
5075         if (pCounterBuffers) {
5076             local_pCounterBuffers = new VkBuffer[counterBufferCount];
5077             for (uint32_t index0 = 0; index0 < counterBufferCount; ++index0) {
5078                 local_pCounterBuffers[index0] = layer_data->Unwrap(pCounterBuffers[index0]);
5079             }
5080         }
5081     }
5082     layer_data->device_dispatch_table.CmdEndTransformFeedbackEXT(commandBuffer, firstCounterBuffer, counterBufferCount, (const VkBuffer*)local_pCounterBuffers, pCounterBufferOffsets);
5083     if (local_pCounterBuffers)
5084         delete[] local_pCounterBuffers;
5085 }
5086 
DispatchCmdBeginQueryIndexedEXT(VkCommandBuffer commandBuffer,VkQueryPool queryPool,uint32_t query,VkQueryControlFlags flags,uint32_t index)5087 void DispatchCmdBeginQueryIndexedEXT(
5088     VkCommandBuffer                             commandBuffer,
5089     VkQueryPool                                 queryPool,
5090     uint32_t                                    query,
5091     VkQueryControlFlags                         flags,
5092     uint32_t                                    index)
5093 {
5094     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
5095     if (!wrap_handles) return layer_data->device_dispatch_table.CmdBeginQueryIndexedEXT(commandBuffer, queryPool, query, flags, index);
5096     {
5097         queryPool = layer_data->Unwrap(queryPool);
5098     }
5099     layer_data->device_dispatch_table.CmdBeginQueryIndexedEXT(commandBuffer, queryPool, query, flags, index);
5100 
5101 }
5102 
DispatchCmdEndQueryIndexedEXT(VkCommandBuffer commandBuffer,VkQueryPool queryPool,uint32_t query,uint32_t index)5103 void DispatchCmdEndQueryIndexedEXT(
5104     VkCommandBuffer                             commandBuffer,
5105     VkQueryPool                                 queryPool,
5106     uint32_t                                    query,
5107     uint32_t                                    index)
5108 {
5109     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
5110     if (!wrap_handles) return layer_data->device_dispatch_table.CmdEndQueryIndexedEXT(commandBuffer, queryPool, query, index);
5111     {
5112         queryPool = layer_data->Unwrap(queryPool);
5113     }
5114     layer_data->device_dispatch_table.CmdEndQueryIndexedEXT(commandBuffer, queryPool, query, index);
5115 
5116 }
5117 
DispatchCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer,uint32_t instanceCount,uint32_t firstInstance,VkBuffer counterBuffer,VkDeviceSize counterBufferOffset,uint32_t counterOffset,uint32_t vertexStride)5118 void DispatchCmdDrawIndirectByteCountEXT(
5119     VkCommandBuffer                             commandBuffer,
5120     uint32_t                                    instanceCount,
5121     uint32_t                                    firstInstance,
5122     VkBuffer                                    counterBuffer,
5123     VkDeviceSize                                counterBufferOffset,
5124     uint32_t                                    counterOffset,
5125     uint32_t                                    vertexStride)
5126 {
5127     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
5128     if (!wrap_handles) return layer_data->device_dispatch_table.CmdDrawIndirectByteCountEXT(commandBuffer, instanceCount, firstInstance, counterBuffer, counterBufferOffset, counterOffset, vertexStride);
5129     {
5130         counterBuffer = layer_data->Unwrap(counterBuffer);
5131     }
5132     layer_data->device_dispatch_table.CmdDrawIndirectByteCountEXT(commandBuffer, instanceCount, firstInstance, counterBuffer, counterBufferOffset, counterOffset, vertexStride);
5133 
5134 }
5135 
DispatchGetImageViewHandleNVX(VkDevice device,const VkImageViewHandleInfoNVX * pInfo)5136 uint32_t DispatchGetImageViewHandleNVX(
5137     VkDevice                                    device,
5138     const VkImageViewHandleInfoNVX*             pInfo)
5139 {
5140     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
5141     if (!wrap_handles) return layer_data->device_dispatch_table.GetImageViewHandleNVX(device, pInfo);
5142     safe_VkImageViewHandleInfoNVX *local_pInfo = NULL;
5143     {
5144         if (pInfo) {
5145             local_pInfo = new safe_VkImageViewHandleInfoNVX(pInfo);
5146             if (pInfo->imageView) {
5147                 local_pInfo->imageView = layer_data->Unwrap(pInfo->imageView);
5148             }
5149             if (pInfo->sampler) {
5150                 local_pInfo->sampler = layer_data->Unwrap(pInfo->sampler);
5151             }
5152         }
5153     }
5154     uint32_t result = layer_data->device_dispatch_table.GetImageViewHandleNVX(device, (const VkImageViewHandleInfoNVX*)local_pInfo);
5155     if (local_pInfo) {
5156         delete local_pInfo;
5157     }
5158     return result;
5159 }
5160 
DispatchCmdDrawIndirectCountAMD(VkCommandBuffer commandBuffer,VkBuffer buffer,VkDeviceSize offset,VkBuffer countBuffer,VkDeviceSize countBufferOffset,uint32_t maxDrawCount,uint32_t stride)5161 void DispatchCmdDrawIndirectCountAMD(
5162     VkCommandBuffer                             commandBuffer,
5163     VkBuffer                                    buffer,
5164     VkDeviceSize                                offset,
5165     VkBuffer                                    countBuffer,
5166     VkDeviceSize                                countBufferOffset,
5167     uint32_t                                    maxDrawCount,
5168     uint32_t                                    stride)
5169 {
5170     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
5171     if (!wrap_handles) return layer_data->device_dispatch_table.CmdDrawIndirectCountAMD(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride);
5172     {
5173         buffer = layer_data->Unwrap(buffer);
5174         countBuffer = layer_data->Unwrap(countBuffer);
5175     }
5176     layer_data->device_dispatch_table.CmdDrawIndirectCountAMD(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride);
5177 
5178 }
5179 
DispatchCmdDrawIndexedIndirectCountAMD(VkCommandBuffer commandBuffer,VkBuffer buffer,VkDeviceSize offset,VkBuffer countBuffer,VkDeviceSize countBufferOffset,uint32_t maxDrawCount,uint32_t stride)5180 void DispatchCmdDrawIndexedIndirectCountAMD(
5181     VkCommandBuffer                             commandBuffer,
5182     VkBuffer                                    buffer,
5183     VkDeviceSize                                offset,
5184     VkBuffer                                    countBuffer,
5185     VkDeviceSize                                countBufferOffset,
5186     uint32_t                                    maxDrawCount,
5187     uint32_t                                    stride)
5188 {
5189     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
5190     if (!wrap_handles) return layer_data->device_dispatch_table.CmdDrawIndexedIndirectCountAMD(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride);
5191     {
5192         buffer = layer_data->Unwrap(buffer);
5193         countBuffer = layer_data->Unwrap(countBuffer);
5194     }
5195     layer_data->device_dispatch_table.CmdDrawIndexedIndirectCountAMD(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride);
5196 
5197 }
5198 
DispatchGetShaderInfoAMD(VkDevice device,VkPipeline pipeline,VkShaderStageFlagBits shaderStage,VkShaderInfoTypeAMD infoType,size_t * pInfoSize,void * pInfo)5199 VkResult DispatchGetShaderInfoAMD(
5200     VkDevice                                    device,
5201     VkPipeline                                  pipeline,
5202     VkShaderStageFlagBits                       shaderStage,
5203     VkShaderInfoTypeAMD                         infoType,
5204     size_t*                                     pInfoSize,
5205     void*                                       pInfo)
5206 {
5207     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
5208     if (!wrap_handles) return layer_data->device_dispatch_table.GetShaderInfoAMD(device, pipeline, shaderStage, infoType, pInfoSize, pInfo);
5209     {
5210         pipeline = layer_data->Unwrap(pipeline);
5211     }
5212     VkResult result = layer_data->device_dispatch_table.GetShaderInfoAMD(device, pipeline, shaderStage, infoType, pInfoSize, pInfo);
5213 
5214     return result;
5215 }
5216 
5217 #ifdef VK_USE_PLATFORM_GGP
5218 
DispatchCreateStreamDescriptorSurfaceGGP(VkInstance instance,const VkStreamDescriptorSurfaceCreateInfoGGP * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSurfaceKHR * pSurface)5219 VkResult DispatchCreateStreamDescriptorSurfaceGGP(
5220     VkInstance                                  instance,
5221     const VkStreamDescriptorSurfaceCreateInfoGGP* pCreateInfo,
5222     const VkAllocationCallbacks*                pAllocator,
5223     VkSurfaceKHR*                               pSurface)
5224 {
5225     auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
5226     if (!wrap_handles) return layer_data->instance_dispatch_table.CreateStreamDescriptorSurfaceGGP(instance, pCreateInfo, pAllocator, pSurface);
5227     VkResult result = layer_data->instance_dispatch_table.CreateStreamDescriptorSurfaceGGP(instance, pCreateInfo, pAllocator, pSurface);
5228     if (VK_SUCCESS == result) {
5229         *pSurface = layer_data->WrapNew(*pSurface);
5230     }
5231     return result;
5232 }
5233 #endif // VK_USE_PLATFORM_GGP
5234 
DispatchGetPhysicalDeviceExternalImageFormatPropertiesNV(VkPhysicalDevice physicalDevice,VkFormat format,VkImageType type,VkImageTiling tiling,VkImageUsageFlags usage,VkImageCreateFlags flags,VkExternalMemoryHandleTypeFlagsNV externalHandleType,VkExternalImageFormatPropertiesNV * pExternalImageFormatProperties)5235 VkResult DispatchGetPhysicalDeviceExternalImageFormatPropertiesNV(
5236     VkPhysicalDevice                            physicalDevice,
5237     VkFormat                                    format,
5238     VkImageType                                 type,
5239     VkImageTiling                               tiling,
5240     VkImageUsageFlags                           usage,
5241     VkImageCreateFlags                          flags,
5242     VkExternalMemoryHandleTypeFlagsNV           externalHandleType,
5243     VkExternalImageFormatPropertiesNV*          pExternalImageFormatProperties)
5244 {
5245     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
5246     VkResult result = layer_data->instance_dispatch_table.GetPhysicalDeviceExternalImageFormatPropertiesNV(physicalDevice, format, type, tiling, usage, flags, externalHandleType, pExternalImageFormatProperties);
5247 
5248     return result;
5249 }
5250 
5251 #ifdef VK_USE_PLATFORM_WIN32_KHR
5252 
DispatchGetMemoryWin32HandleNV(VkDevice device,VkDeviceMemory memory,VkExternalMemoryHandleTypeFlagsNV handleType,HANDLE * pHandle)5253 VkResult DispatchGetMemoryWin32HandleNV(
5254     VkDevice                                    device,
5255     VkDeviceMemory                              memory,
5256     VkExternalMemoryHandleTypeFlagsNV           handleType,
5257     HANDLE*                                     pHandle)
5258 {
5259     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
5260     if (!wrap_handles) return layer_data->device_dispatch_table.GetMemoryWin32HandleNV(device, memory, handleType, pHandle);
5261     {
5262         memory = layer_data->Unwrap(memory);
5263     }
5264     VkResult result = layer_data->device_dispatch_table.GetMemoryWin32HandleNV(device, memory, handleType, pHandle);
5265 
5266     return result;
5267 }
5268 #endif // VK_USE_PLATFORM_WIN32_KHR
5269 
5270 #ifdef VK_USE_PLATFORM_VI_NN
5271 
DispatchCreateViSurfaceNN(VkInstance instance,const VkViSurfaceCreateInfoNN * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSurfaceKHR * pSurface)5272 VkResult DispatchCreateViSurfaceNN(
5273     VkInstance                                  instance,
5274     const VkViSurfaceCreateInfoNN*              pCreateInfo,
5275     const VkAllocationCallbacks*                pAllocator,
5276     VkSurfaceKHR*                               pSurface)
5277 {
5278     auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
5279     if (!wrap_handles) return layer_data->instance_dispatch_table.CreateViSurfaceNN(instance, pCreateInfo, pAllocator, pSurface);
5280     VkResult result = layer_data->instance_dispatch_table.CreateViSurfaceNN(instance, pCreateInfo, pAllocator, pSurface);
5281     if (VK_SUCCESS == result) {
5282         *pSurface = layer_data->WrapNew(*pSurface);
5283     }
5284     return result;
5285 }
5286 #endif // VK_USE_PLATFORM_VI_NN
5287 
DispatchCmdBeginConditionalRenderingEXT(VkCommandBuffer commandBuffer,const VkConditionalRenderingBeginInfoEXT * pConditionalRenderingBegin)5288 void DispatchCmdBeginConditionalRenderingEXT(
5289     VkCommandBuffer                             commandBuffer,
5290     const VkConditionalRenderingBeginInfoEXT*   pConditionalRenderingBegin)
5291 {
5292     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
5293     if (!wrap_handles) return layer_data->device_dispatch_table.CmdBeginConditionalRenderingEXT(commandBuffer, pConditionalRenderingBegin);
5294     safe_VkConditionalRenderingBeginInfoEXT *local_pConditionalRenderingBegin = NULL;
5295     {
5296         if (pConditionalRenderingBegin) {
5297             local_pConditionalRenderingBegin = new safe_VkConditionalRenderingBeginInfoEXT(pConditionalRenderingBegin);
5298             if (pConditionalRenderingBegin->buffer) {
5299                 local_pConditionalRenderingBegin->buffer = layer_data->Unwrap(pConditionalRenderingBegin->buffer);
5300             }
5301         }
5302     }
5303     layer_data->device_dispatch_table.CmdBeginConditionalRenderingEXT(commandBuffer, (const VkConditionalRenderingBeginInfoEXT*)local_pConditionalRenderingBegin);
5304     if (local_pConditionalRenderingBegin) {
5305         delete local_pConditionalRenderingBegin;
5306     }
5307 }
5308 
DispatchCmdEndConditionalRenderingEXT(VkCommandBuffer commandBuffer)5309 void DispatchCmdEndConditionalRenderingEXT(
5310     VkCommandBuffer                             commandBuffer)
5311 {
5312     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
5313     layer_data->device_dispatch_table.CmdEndConditionalRenderingEXT(commandBuffer);
5314 
5315 }
5316 
DispatchCmdProcessCommandsNVX(VkCommandBuffer commandBuffer,const VkCmdProcessCommandsInfoNVX * pProcessCommandsInfo)5317 void DispatchCmdProcessCommandsNVX(
5318     VkCommandBuffer                             commandBuffer,
5319     const VkCmdProcessCommandsInfoNVX*          pProcessCommandsInfo)
5320 {
5321     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
5322     if (!wrap_handles) return layer_data->device_dispatch_table.CmdProcessCommandsNVX(commandBuffer, pProcessCommandsInfo);
5323     safe_VkCmdProcessCommandsInfoNVX *local_pProcessCommandsInfo = NULL;
5324     {
5325         if (pProcessCommandsInfo) {
5326             local_pProcessCommandsInfo = new safe_VkCmdProcessCommandsInfoNVX(pProcessCommandsInfo);
5327             if (pProcessCommandsInfo->objectTable) {
5328                 local_pProcessCommandsInfo->objectTable = layer_data->Unwrap(pProcessCommandsInfo->objectTable);
5329             }
5330             if (pProcessCommandsInfo->indirectCommandsLayout) {
5331                 local_pProcessCommandsInfo->indirectCommandsLayout = layer_data->Unwrap(pProcessCommandsInfo->indirectCommandsLayout);
5332             }
5333             if (local_pProcessCommandsInfo->pIndirectCommandsTokens) {
5334                 for (uint32_t index1 = 0; index1 < local_pProcessCommandsInfo->indirectCommandsTokenCount; ++index1) {
5335                     if (pProcessCommandsInfo->pIndirectCommandsTokens[index1].buffer) {
5336                         local_pProcessCommandsInfo->pIndirectCommandsTokens[index1].buffer = layer_data->Unwrap(pProcessCommandsInfo->pIndirectCommandsTokens[index1].buffer);
5337                     }
5338                 }
5339             }
5340             if (pProcessCommandsInfo->sequencesCountBuffer) {
5341                 local_pProcessCommandsInfo->sequencesCountBuffer = layer_data->Unwrap(pProcessCommandsInfo->sequencesCountBuffer);
5342             }
5343             if (pProcessCommandsInfo->sequencesIndexBuffer) {
5344                 local_pProcessCommandsInfo->sequencesIndexBuffer = layer_data->Unwrap(pProcessCommandsInfo->sequencesIndexBuffer);
5345             }
5346         }
5347     }
5348     layer_data->device_dispatch_table.CmdProcessCommandsNVX(commandBuffer, (const VkCmdProcessCommandsInfoNVX*)local_pProcessCommandsInfo);
5349     if (local_pProcessCommandsInfo) {
5350         delete local_pProcessCommandsInfo;
5351     }
5352 }
5353 
DispatchCmdReserveSpaceForCommandsNVX(VkCommandBuffer commandBuffer,const VkCmdReserveSpaceForCommandsInfoNVX * pReserveSpaceInfo)5354 void DispatchCmdReserveSpaceForCommandsNVX(
5355     VkCommandBuffer                             commandBuffer,
5356     const VkCmdReserveSpaceForCommandsInfoNVX*  pReserveSpaceInfo)
5357 {
5358     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
5359     if (!wrap_handles) return layer_data->device_dispatch_table.CmdReserveSpaceForCommandsNVX(commandBuffer, pReserveSpaceInfo);
5360     safe_VkCmdReserveSpaceForCommandsInfoNVX *local_pReserveSpaceInfo = NULL;
5361     {
5362         if (pReserveSpaceInfo) {
5363             local_pReserveSpaceInfo = new safe_VkCmdReserveSpaceForCommandsInfoNVX(pReserveSpaceInfo);
5364             if (pReserveSpaceInfo->objectTable) {
5365                 local_pReserveSpaceInfo->objectTable = layer_data->Unwrap(pReserveSpaceInfo->objectTable);
5366             }
5367             if (pReserveSpaceInfo->indirectCommandsLayout) {
5368                 local_pReserveSpaceInfo->indirectCommandsLayout = layer_data->Unwrap(pReserveSpaceInfo->indirectCommandsLayout);
5369             }
5370         }
5371     }
5372     layer_data->device_dispatch_table.CmdReserveSpaceForCommandsNVX(commandBuffer, (const VkCmdReserveSpaceForCommandsInfoNVX*)local_pReserveSpaceInfo);
5373     if (local_pReserveSpaceInfo) {
5374         delete local_pReserveSpaceInfo;
5375     }
5376 }
5377 
DispatchCreateIndirectCommandsLayoutNVX(VkDevice device,const VkIndirectCommandsLayoutCreateInfoNVX * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkIndirectCommandsLayoutNVX * pIndirectCommandsLayout)5378 VkResult DispatchCreateIndirectCommandsLayoutNVX(
5379     VkDevice                                    device,
5380     const VkIndirectCommandsLayoutCreateInfoNVX* pCreateInfo,
5381     const VkAllocationCallbacks*                pAllocator,
5382     VkIndirectCommandsLayoutNVX*                pIndirectCommandsLayout)
5383 {
5384     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
5385     if (!wrap_handles) return layer_data->device_dispatch_table.CreateIndirectCommandsLayoutNVX(device, pCreateInfo, pAllocator, pIndirectCommandsLayout);
5386     VkResult result = layer_data->device_dispatch_table.CreateIndirectCommandsLayoutNVX(device, pCreateInfo, pAllocator, pIndirectCommandsLayout);
5387     if (VK_SUCCESS == result) {
5388         *pIndirectCommandsLayout = layer_data->WrapNew(*pIndirectCommandsLayout);
5389     }
5390     return result;
5391 }
5392 
DispatchDestroyIndirectCommandsLayoutNVX(VkDevice device,VkIndirectCommandsLayoutNVX indirectCommandsLayout,const VkAllocationCallbacks * pAllocator)5393 void DispatchDestroyIndirectCommandsLayoutNVX(
5394     VkDevice                                    device,
5395     VkIndirectCommandsLayoutNVX                 indirectCommandsLayout,
5396     const VkAllocationCallbacks*                pAllocator)
5397 {
5398     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
5399     if (!wrap_handles) return layer_data->device_dispatch_table.DestroyIndirectCommandsLayoutNVX(device, indirectCommandsLayout, pAllocator);
5400     uint64_t indirectCommandsLayout_id = reinterpret_cast<uint64_t &>(indirectCommandsLayout);
5401     auto iter = unique_id_mapping.pop(indirectCommandsLayout_id);
5402     if (iter != unique_id_mapping.end()) {
5403         indirectCommandsLayout = (VkIndirectCommandsLayoutNVX)iter->second;
5404     } else {
5405         indirectCommandsLayout = (VkIndirectCommandsLayoutNVX)0;
5406     }
5407     layer_data->device_dispatch_table.DestroyIndirectCommandsLayoutNVX(device, indirectCommandsLayout, pAllocator);
5408 
5409 }
5410 
DispatchCreateObjectTableNVX(VkDevice device,const VkObjectTableCreateInfoNVX * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkObjectTableNVX * pObjectTable)5411 VkResult DispatchCreateObjectTableNVX(
5412     VkDevice                                    device,
5413     const VkObjectTableCreateInfoNVX*           pCreateInfo,
5414     const VkAllocationCallbacks*                pAllocator,
5415     VkObjectTableNVX*                           pObjectTable)
5416 {
5417     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
5418     if (!wrap_handles) return layer_data->device_dispatch_table.CreateObjectTableNVX(device, pCreateInfo, pAllocator, pObjectTable);
5419     VkResult result = layer_data->device_dispatch_table.CreateObjectTableNVX(device, pCreateInfo, pAllocator, pObjectTable);
5420     if (VK_SUCCESS == result) {
5421         *pObjectTable = layer_data->WrapNew(*pObjectTable);
5422     }
5423     return result;
5424 }
5425 
DispatchDestroyObjectTableNVX(VkDevice device,VkObjectTableNVX objectTable,const VkAllocationCallbacks * pAllocator)5426 void DispatchDestroyObjectTableNVX(
5427     VkDevice                                    device,
5428     VkObjectTableNVX                            objectTable,
5429     const VkAllocationCallbacks*                pAllocator)
5430 {
5431     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
5432     if (!wrap_handles) return layer_data->device_dispatch_table.DestroyObjectTableNVX(device, objectTable, pAllocator);
5433     uint64_t objectTable_id = reinterpret_cast<uint64_t &>(objectTable);
5434     auto iter = unique_id_mapping.pop(objectTable_id);
5435     if (iter != unique_id_mapping.end()) {
5436         objectTable = (VkObjectTableNVX)iter->second;
5437     } else {
5438         objectTable = (VkObjectTableNVX)0;
5439     }
5440     layer_data->device_dispatch_table.DestroyObjectTableNVX(device, objectTable, pAllocator);
5441 
5442 }
5443 
DispatchRegisterObjectsNVX(VkDevice device,VkObjectTableNVX objectTable,uint32_t objectCount,const VkObjectTableEntryNVX * const * ppObjectTableEntries,const uint32_t * pObjectIndices)5444 VkResult DispatchRegisterObjectsNVX(
5445     VkDevice                                    device,
5446     VkObjectTableNVX                            objectTable,
5447     uint32_t                                    objectCount,
5448     const VkObjectTableEntryNVX* const*         ppObjectTableEntries,
5449     const uint32_t*                             pObjectIndices)
5450 {
5451     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
5452     if (!wrap_handles) return layer_data->device_dispatch_table.RegisterObjectsNVX(device, objectTable, objectCount, ppObjectTableEntries, pObjectIndices);
5453     {
5454         objectTable = layer_data->Unwrap(objectTable);
5455     }
5456     VkResult result = layer_data->device_dispatch_table.RegisterObjectsNVX(device, objectTable, objectCount, ppObjectTableEntries, pObjectIndices);
5457 
5458     return result;
5459 }
5460 
DispatchUnregisterObjectsNVX(VkDevice device,VkObjectTableNVX objectTable,uint32_t objectCount,const VkObjectEntryTypeNVX * pObjectEntryTypes,const uint32_t * pObjectIndices)5461 VkResult DispatchUnregisterObjectsNVX(
5462     VkDevice                                    device,
5463     VkObjectTableNVX                            objectTable,
5464     uint32_t                                    objectCount,
5465     const VkObjectEntryTypeNVX*                 pObjectEntryTypes,
5466     const uint32_t*                             pObjectIndices)
5467 {
5468     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
5469     if (!wrap_handles) return layer_data->device_dispatch_table.UnregisterObjectsNVX(device, objectTable, objectCount, pObjectEntryTypes, pObjectIndices);
5470     {
5471         objectTable = layer_data->Unwrap(objectTable);
5472     }
5473     VkResult result = layer_data->device_dispatch_table.UnregisterObjectsNVX(device, objectTable, objectCount, pObjectEntryTypes, pObjectIndices);
5474 
5475     return result;
5476 }
5477 
DispatchGetPhysicalDeviceGeneratedCommandsPropertiesNVX(VkPhysicalDevice physicalDevice,VkDeviceGeneratedCommandsFeaturesNVX * pFeatures,VkDeviceGeneratedCommandsLimitsNVX * pLimits)5478 void DispatchGetPhysicalDeviceGeneratedCommandsPropertiesNVX(
5479     VkPhysicalDevice                            physicalDevice,
5480     VkDeviceGeneratedCommandsFeaturesNVX*       pFeatures,
5481     VkDeviceGeneratedCommandsLimitsNVX*         pLimits)
5482 {
5483     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
5484     layer_data->instance_dispatch_table.GetPhysicalDeviceGeneratedCommandsPropertiesNVX(physicalDevice, pFeatures, pLimits);
5485 
5486 }
5487 
DispatchCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer,uint32_t firstViewport,uint32_t viewportCount,const VkViewportWScalingNV * pViewportWScalings)5488 void DispatchCmdSetViewportWScalingNV(
5489     VkCommandBuffer                             commandBuffer,
5490     uint32_t                                    firstViewport,
5491     uint32_t                                    viewportCount,
5492     const VkViewportWScalingNV*                 pViewportWScalings)
5493 {
5494     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
5495     layer_data->device_dispatch_table.CmdSetViewportWScalingNV(commandBuffer, firstViewport, viewportCount, pViewportWScalings);
5496 
5497 }
5498 
DispatchReleaseDisplayEXT(VkPhysicalDevice physicalDevice,VkDisplayKHR display)5499 VkResult DispatchReleaseDisplayEXT(
5500     VkPhysicalDevice                            physicalDevice,
5501     VkDisplayKHR                                display)
5502 {
5503     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
5504     if (!wrap_handles) return layer_data->instance_dispatch_table.ReleaseDisplayEXT(physicalDevice, display);
5505     {
5506         display = layer_data->Unwrap(display);
5507     }
5508     VkResult result = layer_data->instance_dispatch_table.ReleaseDisplayEXT(physicalDevice, display);
5509 
5510     return result;
5511 }
5512 
5513 #ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
5514 
DispatchAcquireXlibDisplayEXT(VkPhysicalDevice physicalDevice,Display * dpy,VkDisplayKHR display)5515 VkResult DispatchAcquireXlibDisplayEXT(
5516     VkPhysicalDevice                            physicalDevice,
5517     Display*                                    dpy,
5518     VkDisplayKHR                                display)
5519 {
5520     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
5521     if (!wrap_handles) return layer_data->instance_dispatch_table.AcquireXlibDisplayEXT(physicalDevice, dpy, display);
5522     {
5523         display = layer_data->Unwrap(display);
5524     }
5525     VkResult result = layer_data->instance_dispatch_table.AcquireXlibDisplayEXT(physicalDevice, dpy, display);
5526 
5527     return result;
5528 }
5529 #endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT
5530 
5531 #ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
5532 
DispatchGetRandROutputDisplayEXT(VkPhysicalDevice physicalDevice,Display * dpy,RROutput rrOutput,VkDisplayKHR * pDisplay)5533 VkResult DispatchGetRandROutputDisplayEXT(
5534     VkPhysicalDevice                            physicalDevice,
5535     Display*                                    dpy,
5536     RROutput                                    rrOutput,
5537     VkDisplayKHR*                               pDisplay)
5538 {
5539     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
5540     if (!wrap_handles) return layer_data->instance_dispatch_table.GetRandROutputDisplayEXT(physicalDevice, dpy, rrOutput, pDisplay);
5541     VkResult result = layer_data->instance_dispatch_table.GetRandROutputDisplayEXT(physicalDevice, dpy, rrOutput, pDisplay);
5542     if (VK_SUCCESS == result) {
5543         *pDisplay = layer_data->WrapNew(*pDisplay);
5544     }
5545     return result;
5546 }
5547 #endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT
5548 
DispatchGetPhysicalDeviceSurfaceCapabilities2EXT(VkPhysicalDevice physicalDevice,VkSurfaceKHR surface,VkSurfaceCapabilities2EXT * pSurfaceCapabilities)5549 VkResult DispatchGetPhysicalDeviceSurfaceCapabilities2EXT(
5550     VkPhysicalDevice                            physicalDevice,
5551     VkSurfaceKHR                                surface,
5552     VkSurfaceCapabilities2EXT*                  pSurfaceCapabilities)
5553 {
5554     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
5555     if (!wrap_handles) return layer_data->instance_dispatch_table.GetPhysicalDeviceSurfaceCapabilities2EXT(physicalDevice, surface, pSurfaceCapabilities);
5556     {
5557         surface = layer_data->Unwrap(surface);
5558     }
5559     VkResult result = layer_data->instance_dispatch_table.GetPhysicalDeviceSurfaceCapabilities2EXT(physicalDevice, surface, pSurfaceCapabilities);
5560 
5561     return result;
5562 }
5563 
DispatchDisplayPowerControlEXT(VkDevice device,VkDisplayKHR display,const VkDisplayPowerInfoEXT * pDisplayPowerInfo)5564 VkResult DispatchDisplayPowerControlEXT(
5565     VkDevice                                    device,
5566     VkDisplayKHR                                display,
5567     const VkDisplayPowerInfoEXT*                pDisplayPowerInfo)
5568 {
5569     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
5570     if (!wrap_handles) return layer_data->device_dispatch_table.DisplayPowerControlEXT(device, display, pDisplayPowerInfo);
5571     {
5572         display = layer_data->Unwrap(display);
5573     }
5574     VkResult result = layer_data->device_dispatch_table.DisplayPowerControlEXT(device, display, pDisplayPowerInfo);
5575 
5576     return result;
5577 }
5578 
DispatchRegisterDeviceEventEXT(VkDevice device,const VkDeviceEventInfoEXT * pDeviceEventInfo,const VkAllocationCallbacks * pAllocator,VkFence * pFence)5579 VkResult DispatchRegisterDeviceEventEXT(
5580     VkDevice                                    device,
5581     const VkDeviceEventInfoEXT*                 pDeviceEventInfo,
5582     const VkAllocationCallbacks*                pAllocator,
5583     VkFence*                                    pFence)
5584 {
5585     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
5586     if (!wrap_handles) return layer_data->device_dispatch_table.RegisterDeviceEventEXT(device, pDeviceEventInfo, pAllocator, pFence);
5587     VkResult result = layer_data->device_dispatch_table.RegisterDeviceEventEXT(device, pDeviceEventInfo, pAllocator, pFence);
5588     if (VK_SUCCESS == result) {
5589         *pFence = layer_data->WrapNew(*pFence);
5590     }
5591     return result;
5592 }
5593 
DispatchRegisterDisplayEventEXT(VkDevice device,VkDisplayKHR display,const VkDisplayEventInfoEXT * pDisplayEventInfo,const VkAllocationCallbacks * pAllocator,VkFence * pFence)5594 VkResult DispatchRegisterDisplayEventEXT(
5595     VkDevice                                    device,
5596     VkDisplayKHR                                display,
5597     const VkDisplayEventInfoEXT*                pDisplayEventInfo,
5598     const VkAllocationCallbacks*                pAllocator,
5599     VkFence*                                    pFence)
5600 {
5601     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
5602     if (!wrap_handles) return layer_data->device_dispatch_table.RegisterDisplayEventEXT(device, display, pDisplayEventInfo, pAllocator, pFence);
5603     {
5604         display = layer_data->Unwrap(display);
5605     }
5606     VkResult result = layer_data->device_dispatch_table.RegisterDisplayEventEXT(device, display, pDisplayEventInfo, pAllocator, pFence);
5607     if (VK_SUCCESS == result) {
5608         *pFence = layer_data->WrapNew(*pFence);
5609     }
5610     return result;
5611 }
5612 
DispatchGetSwapchainCounterEXT(VkDevice device,VkSwapchainKHR swapchain,VkSurfaceCounterFlagBitsEXT counter,uint64_t * pCounterValue)5613 VkResult DispatchGetSwapchainCounterEXT(
5614     VkDevice                                    device,
5615     VkSwapchainKHR                              swapchain,
5616     VkSurfaceCounterFlagBitsEXT                 counter,
5617     uint64_t*                                   pCounterValue)
5618 {
5619     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
5620     if (!wrap_handles) return layer_data->device_dispatch_table.GetSwapchainCounterEXT(device, swapchain, counter, pCounterValue);
5621     {
5622         swapchain = layer_data->Unwrap(swapchain);
5623     }
5624     VkResult result = layer_data->device_dispatch_table.GetSwapchainCounterEXT(device, swapchain, counter, pCounterValue);
5625 
5626     return result;
5627 }
5628 
DispatchGetRefreshCycleDurationGOOGLE(VkDevice device,VkSwapchainKHR swapchain,VkRefreshCycleDurationGOOGLE * pDisplayTimingProperties)5629 VkResult DispatchGetRefreshCycleDurationGOOGLE(
5630     VkDevice                                    device,
5631     VkSwapchainKHR                              swapchain,
5632     VkRefreshCycleDurationGOOGLE*               pDisplayTimingProperties)
5633 {
5634     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
5635     if (!wrap_handles) return layer_data->device_dispatch_table.GetRefreshCycleDurationGOOGLE(device, swapchain, pDisplayTimingProperties);
5636     {
5637         swapchain = layer_data->Unwrap(swapchain);
5638     }
5639     VkResult result = layer_data->device_dispatch_table.GetRefreshCycleDurationGOOGLE(device, swapchain, pDisplayTimingProperties);
5640 
5641     return result;
5642 }
5643 
DispatchGetPastPresentationTimingGOOGLE(VkDevice device,VkSwapchainKHR swapchain,uint32_t * pPresentationTimingCount,VkPastPresentationTimingGOOGLE * pPresentationTimings)5644 VkResult DispatchGetPastPresentationTimingGOOGLE(
5645     VkDevice                                    device,
5646     VkSwapchainKHR                              swapchain,
5647     uint32_t*                                   pPresentationTimingCount,
5648     VkPastPresentationTimingGOOGLE*             pPresentationTimings)
5649 {
5650     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
5651     if (!wrap_handles) return layer_data->device_dispatch_table.GetPastPresentationTimingGOOGLE(device, swapchain, pPresentationTimingCount, pPresentationTimings);
5652     {
5653         swapchain = layer_data->Unwrap(swapchain);
5654     }
5655     VkResult result = layer_data->device_dispatch_table.GetPastPresentationTimingGOOGLE(device, swapchain, pPresentationTimingCount, pPresentationTimings);
5656 
5657     return result;
5658 }
5659 
DispatchCmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer,uint32_t firstDiscardRectangle,uint32_t discardRectangleCount,const VkRect2D * pDiscardRectangles)5660 void DispatchCmdSetDiscardRectangleEXT(
5661     VkCommandBuffer                             commandBuffer,
5662     uint32_t                                    firstDiscardRectangle,
5663     uint32_t                                    discardRectangleCount,
5664     const VkRect2D*                             pDiscardRectangles)
5665 {
5666     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
5667     layer_data->device_dispatch_table.CmdSetDiscardRectangleEXT(commandBuffer, firstDiscardRectangle, discardRectangleCount, pDiscardRectangles);
5668 
5669 }
5670 
DispatchSetHdrMetadataEXT(VkDevice device,uint32_t swapchainCount,const VkSwapchainKHR * pSwapchains,const VkHdrMetadataEXT * pMetadata)5671 void DispatchSetHdrMetadataEXT(
5672     VkDevice                                    device,
5673     uint32_t                                    swapchainCount,
5674     const VkSwapchainKHR*                       pSwapchains,
5675     const VkHdrMetadataEXT*                     pMetadata)
5676 {
5677     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
5678     if (!wrap_handles) return layer_data->device_dispatch_table.SetHdrMetadataEXT(device, swapchainCount, pSwapchains, pMetadata);
5679     VkSwapchainKHR *local_pSwapchains = NULL;
5680     {
5681         if (pSwapchains) {
5682             local_pSwapchains = new VkSwapchainKHR[swapchainCount];
5683             for (uint32_t index0 = 0; index0 < swapchainCount; ++index0) {
5684                 local_pSwapchains[index0] = layer_data->Unwrap(pSwapchains[index0]);
5685             }
5686         }
5687     }
5688     layer_data->device_dispatch_table.SetHdrMetadataEXT(device, swapchainCount, (const VkSwapchainKHR*)local_pSwapchains, pMetadata);
5689     if (local_pSwapchains)
5690         delete[] local_pSwapchains;
5691 }
5692 
5693 #ifdef VK_USE_PLATFORM_IOS_MVK
5694 
DispatchCreateIOSSurfaceMVK(VkInstance instance,const VkIOSSurfaceCreateInfoMVK * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSurfaceKHR * pSurface)5695 VkResult DispatchCreateIOSSurfaceMVK(
5696     VkInstance                                  instance,
5697     const VkIOSSurfaceCreateInfoMVK*            pCreateInfo,
5698     const VkAllocationCallbacks*                pAllocator,
5699     VkSurfaceKHR*                               pSurface)
5700 {
5701     auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
5702     if (!wrap_handles) return layer_data->instance_dispatch_table.CreateIOSSurfaceMVK(instance, pCreateInfo, pAllocator, pSurface);
5703     VkResult result = layer_data->instance_dispatch_table.CreateIOSSurfaceMVK(instance, pCreateInfo, pAllocator, pSurface);
5704     if (VK_SUCCESS == result) {
5705         *pSurface = layer_data->WrapNew(*pSurface);
5706     }
5707     return result;
5708 }
5709 #endif // VK_USE_PLATFORM_IOS_MVK
5710 
5711 #ifdef VK_USE_PLATFORM_MACOS_MVK
5712 
DispatchCreateMacOSSurfaceMVK(VkInstance instance,const VkMacOSSurfaceCreateInfoMVK * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSurfaceKHR * pSurface)5713 VkResult DispatchCreateMacOSSurfaceMVK(
5714     VkInstance                                  instance,
5715     const VkMacOSSurfaceCreateInfoMVK*          pCreateInfo,
5716     const VkAllocationCallbacks*                pAllocator,
5717     VkSurfaceKHR*                               pSurface)
5718 {
5719     auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
5720     if (!wrap_handles) return layer_data->instance_dispatch_table.CreateMacOSSurfaceMVK(instance, pCreateInfo, pAllocator, pSurface);
5721     VkResult result = layer_data->instance_dispatch_table.CreateMacOSSurfaceMVK(instance, pCreateInfo, pAllocator, pSurface);
5722     if (VK_SUCCESS == result) {
5723         *pSurface = layer_data->WrapNew(*pSurface);
5724     }
5725     return result;
5726 }
5727 #endif // VK_USE_PLATFORM_MACOS_MVK
5728 
5729 // Skip vkSetDebugUtilsObjectNameEXT dispatch, manually generated
5730 
5731 // Skip vkSetDebugUtilsObjectTagEXT dispatch, manually generated
5732 
DispatchQueueBeginDebugUtilsLabelEXT(VkQueue queue,const VkDebugUtilsLabelEXT * pLabelInfo)5733 void DispatchQueueBeginDebugUtilsLabelEXT(
5734     VkQueue                                     queue,
5735     const VkDebugUtilsLabelEXT*                 pLabelInfo)
5736 {
5737     auto layer_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map);
5738     layer_data->device_dispatch_table.QueueBeginDebugUtilsLabelEXT(queue, pLabelInfo);
5739 
5740 }
5741 
DispatchQueueEndDebugUtilsLabelEXT(VkQueue queue)5742 void DispatchQueueEndDebugUtilsLabelEXT(
5743     VkQueue                                     queue)
5744 {
5745     auto layer_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map);
5746     layer_data->device_dispatch_table.QueueEndDebugUtilsLabelEXT(queue);
5747 
5748 }
5749 
DispatchQueueInsertDebugUtilsLabelEXT(VkQueue queue,const VkDebugUtilsLabelEXT * pLabelInfo)5750 void DispatchQueueInsertDebugUtilsLabelEXT(
5751     VkQueue                                     queue,
5752     const VkDebugUtilsLabelEXT*                 pLabelInfo)
5753 {
5754     auto layer_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map);
5755     layer_data->device_dispatch_table.QueueInsertDebugUtilsLabelEXT(queue, pLabelInfo);
5756 
5757 }
5758 
DispatchCmdBeginDebugUtilsLabelEXT(VkCommandBuffer commandBuffer,const VkDebugUtilsLabelEXT * pLabelInfo)5759 void DispatchCmdBeginDebugUtilsLabelEXT(
5760     VkCommandBuffer                             commandBuffer,
5761     const VkDebugUtilsLabelEXT*                 pLabelInfo)
5762 {
5763     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
5764     layer_data->device_dispatch_table.CmdBeginDebugUtilsLabelEXT(commandBuffer, pLabelInfo);
5765 
5766 }
5767 
DispatchCmdEndDebugUtilsLabelEXT(VkCommandBuffer commandBuffer)5768 void DispatchCmdEndDebugUtilsLabelEXT(
5769     VkCommandBuffer                             commandBuffer)
5770 {
5771     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
5772     layer_data->device_dispatch_table.CmdEndDebugUtilsLabelEXT(commandBuffer);
5773 
5774 }
5775 
DispatchCmdInsertDebugUtilsLabelEXT(VkCommandBuffer commandBuffer,const VkDebugUtilsLabelEXT * pLabelInfo)5776 void DispatchCmdInsertDebugUtilsLabelEXT(
5777     VkCommandBuffer                             commandBuffer,
5778     const VkDebugUtilsLabelEXT*                 pLabelInfo)
5779 {
5780     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
5781     layer_data->device_dispatch_table.CmdInsertDebugUtilsLabelEXT(commandBuffer, pLabelInfo);
5782 
5783 }
5784 
DispatchCreateDebugUtilsMessengerEXT(VkInstance instance,const VkDebugUtilsMessengerCreateInfoEXT * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkDebugUtilsMessengerEXT * pMessenger)5785 VkResult DispatchCreateDebugUtilsMessengerEXT(
5786     VkInstance                                  instance,
5787     const VkDebugUtilsMessengerCreateInfoEXT*   pCreateInfo,
5788     const VkAllocationCallbacks*                pAllocator,
5789     VkDebugUtilsMessengerEXT*                   pMessenger)
5790 {
5791     auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
5792     if (!wrap_handles) return layer_data->instance_dispatch_table.CreateDebugUtilsMessengerEXT(instance, pCreateInfo, pAllocator, pMessenger);
5793     VkResult result = layer_data->instance_dispatch_table.CreateDebugUtilsMessengerEXT(instance, pCreateInfo, pAllocator, pMessenger);
5794     if (VK_SUCCESS == result) {
5795         *pMessenger = layer_data->WrapNew(*pMessenger);
5796     }
5797     return result;
5798 }
5799 
DispatchDestroyDebugUtilsMessengerEXT(VkInstance instance,VkDebugUtilsMessengerEXT messenger,const VkAllocationCallbacks * pAllocator)5800 void DispatchDestroyDebugUtilsMessengerEXT(
5801     VkInstance                                  instance,
5802     VkDebugUtilsMessengerEXT                    messenger,
5803     const VkAllocationCallbacks*                pAllocator)
5804 {
5805     auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
5806     if (!wrap_handles) return layer_data->instance_dispatch_table.DestroyDebugUtilsMessengerEXT(instance, messenger, pAllocator);
5807     uint64_t messenger_id = reinterpret_cast<uint64_t &>(messenger);
5808     auto iter = unique_id_mapping.pop(messenger_id);
5809     if (iter != unique_id_mapping.end()) {
5810         messenger = (VkDebugUtilsMessengerEXT)iter->second;
5811     } else {
5812         messenger = (VkDebugUtilsMessengerEXT)0;
5813     }
5814     layer_data->instance_dispatch_table.DestroyDebugUtilsMessengerEXT(instance, messenger, pAllocator);
5815 
5816 }
5817 
DispatchSubmitDebugUtilsMessageEXT(VkInstance instance,VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,VkDebugUtilsMessageTypeFlagsEXT messageTypes,const VkDebugUtilsMessengerCallbackDataEXT * pCallbackData)5818 void DispatchSubmitDebugUtilsMessageEXT(
5819     VkInstance                                  instance,
5820     VkDebugUtilsMessageSeverityFlagBitsEXT      messageSeverity,
5821     VkDebugUtilsMessageTypeFlagsEXT             messageTypes,
5822     const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData)
5823 {
5824     auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
5825     layer_data->instance_dispatch_table.SubmitDebugUtilsMessageEXT(instance, messageSeverity, messageTypes, pCallbackData);
5826 
5827 }
5828 
5829 #ifdef VK_USE_PLATFORM_ANDROID_KHR
5830 
DispatchGetAndroidHardwareBufferPropertiesANDROID(VkDevice device,const struct AHardwareBuffer * buffer,VkAndroidHardwareBufferPropertiesANDROID * pProperties)5831 VkResult DispatchGetAndroidHardwareBufferPropertiesANDROID(
5832     VkDevice                                    device,
5833     const struct AHardwareBuffer*               buffer,
5834     VkAndroidHardwareBufferPropertiesANDROID*   pProperties)
5835 {
5836     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
5837     VkResult result = layer_data->device_dispatch_table.GetAndroidHardwareBufferPropertiesANDROID(device, buffer, pProperties);
5838 
5839     return result;
5840 }
5841 #endif // VK_USE_PLATFORM_ANDROID_KHR
5842 
5843 #ifdef VK_USE_PLATFORM_ANDROID_KHR
5844 
DispatchGetMemoryAndroidHardwareBufferANDROID(VkDevice device,const VkMemoryGetAndroidHardwareBufferInfoANDROID * pInfo,struct AHardwareBuffer ** pBuffer)5845 VkResult DispatchGetMemoryAndroidHardwareBufferANDROID(
5846     VkDevice                                    device,
5847     const VkMemoryGetAndroidHardwareBufferInfoANDROID* pInfo,
5848     struct AHardwareBuffer**                    pBuffer)
5849 {
5850     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
5851     if (!wrap_handles) return layer_data->device_dispatch_table.GetMemoryAndroidHardwareBufferANDROID(device, pInfo, pBuffer);
5852     safe_VkMemoryGetAndroidHardwareBufferInfoANDROID *local_pInfo = NULL;
5853     {
5854         if (pInfo) {
5855             local_pInfo = new safe_VkMemoryGetAndroidHardwareBufferInfoANDROID(pInfo);
5856             if (pInfo->memory) {
5857                 local_pInfo->memory = layer_data->Unwrap(pInfo->memory);
5858             }
5859         }
5860     }
5861     VkResult result = layer_data->device_dispatch_table.GetMemoryAndroidHardwareBufferANDROID(device, (const VkMemoryGetAndroidHardwareBufferInfoANDROID*)local_pInfo, pBuffer);
5862     if (local_pInfo) {
5863         delete local_pInfo;
5864     }
5865     return result;
5866 }
5867 #endif // VK_USE_PLATFORM_ANDROID_KHR
5868 
DispatchCmdSetSampleLocationsEXT(VkCommandBuffer commandBuffer,const VkSampleLocationsInfoEXT * pSampleLocationsInfo)5869 void DispatchCmdSetSampleLocationsEXT(
5870     VkCommandBuffer                             commandBuffer,
5871     const VkSampleLocationsInfoEXT*             pSampleLocationsInfo)
5872 {
5873     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
5874     layer_data->device_dispatch_table.CmdSetSampleLocationsEXT(commandBuffer, pSampleLocationsInfo);
5875 
5876 }
5877 
DispatchGetPhysicalDeviceMultisamplePropertiesEXT(VkPhysicalDevice physicalDevice,VkSampleCountFlagBits samples,VkMultisamplePropertiesEXT * pMultisampleProperties)5878 void DispatchGetPhysicalDeviceMultisamplePropertiesEXT(
5879     VkPhysicalDevice                            physicalDevice,
5880     VkSampleCountFlagBits                       samples,
5881     VkMultisamplePropertiesEXT*                 pMultisampleProperties)
5882 {
5883     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
5884     layer_data->instance_dispatch_table.GetPhysicalDeviceMultisamplePropertiesEXT(physicalDevice, samples, pMultisampleProperties);
5885 
5886 }
5887 
DispatchGetImageDrmFormatModifierPropertiesEXT(VkDevice device,VkImage image,VkImageDrmFormatModifierPropertiesEXT * pProperties)5888 VkResult DispatchGetImageDrmFormatModifierPropertiesEXT(
5889     VkDevice                                    device,
5890     VkImage                                     image,
5891     VkImageDrmFormatModifierPropertiesEXT*      pProperties)
5892 {
5893     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
5894     if (!wrap_handles) return layer_data->device_dispatch_table.GetImageDrmFormatModifierPropertiesEXT(device, image, pProperties);
5895     {
5896         image = layer_data->Unwrap(image);
5897     }
5898     VkResult result = layer_data->device_dispatch_table.GetImageDrmFormatModifierPropertiesEXT(device, image, pProperties);
5899 
5900     return result;
5901 }
5902 
DispatchCreateValidationCacheEXT(VkDevice device,const VkValidationCacheCreateInfoEXT * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkValidationCacheEXT * pValidationCache)5903 VkResult DispatchCreateValidationCacheEXT(
5904     VkDevice                                    device,
5905     const VkValidationCacheCreateInfoEXT*       pCreateInfo,
5906     const VkAllocationCallbacks*                pAllocator,
5907     VkValidationCacheEXT*                       pValidationCache)
5908 {
5909     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
5910     if (!wrap_handles) return layer_data->device_dispatch_table.CreateValidationCacheEXT(device, pCreateInfo, pAllocator, pValidationCache);
5911     VkResult result = layer_data->device_dispatch_table.CreateValidationCacheEXT(device, pCreateInfo, pAllocator, pValidationCache);
5912     if (VK_SUCCESS == result) {
5913         *pValidationCache = layer_data->WrapNew(*pValidationCache);
5914     }
5915     return result;
5916 }
5917 
DispatchDestroyValidationCacheEXT(VkDevice device,VkValidationCacheEXT validationCache,const VkAllocationCallbacks * pAllocator)5918 void DispatchDestroyValidationCacheEXT(
5919     VkDevice                                    device,
5920     VkValidationCacheEXT                        validationCache,
5921     const VkAllocationCallbacks*                pAllocator)
5922 {
5923     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
5924     if (!wrap_handles) return layer_data->device_dispatch_table.DestroyValidationCacheEXT(device, validationCache, pAllocator);
5925     uint64_t validationCache_id = reinterpret_cast<uint64_t &>(validationCache);
5926     auto iter = unique_id_mapping.pop(validationCache_id);
5927     if (iter != unique_id_mapping.end()) {
5928         validationCache = (VkValidationCacheEXT)iter->second;
5929     } else {
5930         validationCache = (VkValidationCacheEXT)0;
5931     }
5932     layer_data->device_dispatch_table.DestroyValidationCacheEXT(device, validationCache, pAllocator);
5933 
5934 }
5935 
DispatchMergeValidationCachesEXT(VkDevice device,VkValidationCacheEXT dstCache,uint32_t srcCacheCount,const VkValidationCacheEXT * pSrcCaches)5936 VkResult DispatchMergeValidationCachesEXT(
5937     VkDevice                                    device,
5938     VkValidationCacheEXT                        dstCache,
5939     uint32_t                                    srcCacheCount,
5940     const VkValidationCacheEXT*                 pSrcCaches)
5941 {
5942     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
5943     if (!wrap_handles) return layer_data->device_dispatch_table.MergeValidationCachesEXT(device, dstCache, srcCacheCount, pSrcCaches);
5944     VkValidationCacheEXT *local_pSrcCaches = NULL;
5945     {
5946         dstCache = layer_data->Unwrap(dstCache);
5947         if (pSrcCaches) {
5948             local_pSrcCaches = new VkValidationCacheEXT[srcCacheCount];
5949             for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
5950                 local_pSrcCaches[index0] = layer_data->Unwrap(pSrcCaches[index0]);
5951             }
5952         }
5953     }
5954     VkResult result = layer_data->device_dispatch_table.MergeValidationCachesEXT(device, dstCache, srcCacheCount, (const VkValidationCacheEXT*)local_pSrcCaches);
5955     if (local_pSrcCaches)
5956         delete[] local_pSrcCaches;
5957     return result;
5958 }
5959 
DispatchGetValidationCacheDataEXT(VkDevice device,VkValidationCacheEXT validationCache,size_t * pDataSize,void * pData)5960 VkResult DispatchGetValidationCacheDataEXT(
5961     VkDevice                                    device,
5962     VkValidationCacheEXT                        validationCache,
5963     size_t*                                     pDataSize,
5964     void*                                       pData)
5965 {
5966     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
5967     if (!wrap_handles) return layer_data->device_dispatch_table.GetValidationCacheDataEXT(device, validationCache, pDataSize, pData);
5968     {
5969         validationCache = layer_data->Unwrap(validationCache);
5970     }
5971     VkResult result = layer_data->device_dispatch_table.GetValidationCacheDataEXT(device, validationCache, pDataSize, pData);
5972 
5973     return result;
5974 }
5975 
DispatchCmdBindShadingRateImageNV(VkCommandBuffer commandBuffer,VkImageView imageView,VkImageLayout imageLayout)5976 void DispatchCmdBindShadingRateImageNV(
5977     VkCommandBuffer                             commandBuffer,
5978     VkImageView                                 imageView,
5979     VkImageLayout                               imageLayout)
5980 {
5981     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
5982     if (!wrap_handles) return layer_data->device_dispatch_table.CmdBindShadingRateImageNV(commandBuffer, imageView, imageLayout);
5983     {
5984         imageView = layer_data->Unwrap(imageView);
5985     }
5986     layer_data->device_dispatch_table.CmdBindShadingRateImageNV(commandBuffer, imageView, imageLayout);
5987 
5988 }
5989 
DispatchCmdSetViewportShadingRatePaletteNV(VkCommandBuffer commandBuffer,uint32_t firstViewport,uint32_t viewportCount,const VkShadingRatePaletteNV * pShadingRatePalettes)5990 void DispatchCmdSetViewportShadingRatePaletteNV(
5991     VkCommandBuffer                             commandBuffer,
5992     uint32_t                                    firstViewport,
5993     uint32_t                                    viewportCount,
5994     const VkShadingRatePaletteNV*               pShadingRatePalettes)
5995 {
5996     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
5997     layer_data->device_dispatch_table.CmdSetViewportShadingRatePaletteNV(commandBuffer, firstViewport, viewportCount, pShadingRatePalettes);
5998 
5999 }
6000 
DispatchCmdSetCoarseSampleOrderNV(VkCommandBuffer commandBuffer,VkCoarseSampleOrderTypeNV sampleOrderType,uint32_t customSampleOrderCount,const VkCoarseSampleOrderCustomNV * pCustomSampleOrders)6001 void DispatchCmdSetCoarseSampleOrderNV(
6002     VkCommandBuffer                             commandBuffer,
6003     VkCoarseSampleOrderTypeNV                   sampleOrderType,
6004     uint32_t                                    customSampleOrderCount,
6005     const VkCoarseSampleOrderCustomNV*          pCustomSampleOrders)
6006 {
6007     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
6008     layer_data->device_dispatch_table.CmdSetCoarseSampleOrderNV(commandBuffer, sampleOrderType, customSampleOrderCount, pCustomSampleOrders);
6009 
6010 }
6011 
DispatchCreateAccelerationStructureNV(VkDevice device,const VkAccelerationStructureCreateInfoNV * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkAccelerationStructureNV * pAccelerationStructure)6012 VkResult DispatchCreateAccelerationStructureNV(
6013     VkDevice                                    device,
6014     const VkAccelerationStructureCreateInfoNV*  pCreateInfo,
6015     const VkAllocationCallbacks*                pAllocator,
6016     VkAccelerationStructureNV*                  pAccelerationStructure)
6017 {
6018     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
6019     if (!wrap_handles) return layer_data->device_dispatch_table.CreateAccelerationStructureNV(device, pCreateInfo, pAllocator, pAccelerationStructure);
6020     safe_VkAccelerationStructureCreateInfoNV *local_pCreateInfo = NULL;
6021     {
6022         if (pCreateInfo) {
6023             local_pCreateInfo = new safe_VkAccelerationStructureCreateInfoNV(pCreateInfo);
6024             if (local_pCreateInfo->info.pGeometries) {
6025                 for (uint32_t index2 = 0; index2 < local_pCreateInfo->info.geometryCount; ++index2) {
6026                     if (pCreateInfo->info.pGeometries[index2].geometry.triangles.vertexData) {
6027                         local_pCreateInfo->info.pGeometries[index2].geometry.triangles.vertexData = layer_data->Unwrap(pCreateInfo->info.pGeometries[index2].geometry.triangles.vertexData);
6028                     }
6029                     if (pCreateInfo->info.pGeometries[index2].geometry.triangles.indexData) {
6030                         local_pCreateInfo->info.pGeometries[index2].geometry.triangles.indexData = layer_data->Unwrap(pCreateInfo->info.pGeometries[index2].geometry.triangles.indexData);
6031                     }
6032                     if (pCreateInfo->info.pGeometries[index2].geometry.triangles.transformData) {
6033                         local_pCreateInfo->info.pGeometries[index2].geometry.triangles.transformData = layer_data->Unwrap(pCreateInfo->info.pGeometries[index2].geometry.triangles.transformData);
6034                     }
6035                     if (pCreateInfo->info.pGeometries[index2].geometry.aabbs.aabbData) {
6036                         local_pCreateInfo->info.pGeometries[index2].geometry.aabbs.aabbData = layer_data->Unwrap(pCreateInfo->info.pGeometries[index2].geometry.aabbs.aabbData);
6037                     }
6038                 }
6039             }
6040         }
6041     }
6042     VkResult result = layer_data->device_dispatch_table.CreateAccelerationStructureNV(device, (const VkAccelerationStructureCreateInfoNV*)local_pCreateInfo, pAllocator, pAccelerationStructure);
6043     if (local_pCreateInfo) {
6044         delete local_pCreateInfo;
6045     }
6046     if (VK_SUCCESS == result) {
6047         *pAccelerationStructure = layer_data->WrapNew(*pAccelerationStructure);
6048     }
6049     return result;
6050 }
6051 
DispatchDestroyAccelerationStructureNV(VkDevice device,VkAccelerationStructureNV accelerationStructure,const VkAllocationCallbacks * pAllocator)6052 void DispatchDestroyAccelerationStructureNV(
6053     VkDevice                                    device,
6054     VkAccelerationStructureNV                   accelerationStructure,
6055     const VkAllocationCallbacks*                pAllocator)
6056 {
6057     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
6058     if (!wrap_handles) return layer_data->device_dispatch_table.DestroyAccelerationStructureNV(device, accelerationStructure, pAllocator);
6059     uint64_t accelerationStructure_id = reinterpret_cast<uint64_t &>(accelerationStructure);
6060     auto iter = unique_id_mapping.pop(accelerationStructure_id);
6061     if (iter != unique_id_mapping.end()) {
6062         accelerationStructure = (VkAccelerationStructureNV)iter->second;
6063     } else {
6064         accelerationStructure = (VkAccelerationStructureNV)0;
6065     }
6066     layer_data->device_dispatch_table.DestroyAccelerationStructureNV(device, accelerationStructure, pAllocator);
6067 
6068 }
6069 
DispatchGetAccelerationStructureMemoryRequirementsNV(VkDevice device,const VkAccelerationStructureMemoryRequirementsInfoNV * pInfo,VkMemoryRequirements2KHR * pMemoryRequirements)6070 void DispatchGetAccelerationStructureMemoryRequirementsNV(
6071     VkDevice                                    device,
6072     const VkAccelerationStructureMemoryRequirementsInfoNV* pInfo,
6073     VkMemoryRequirements2KHR*                   pMemoryRequirements)
6074 {
6075     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
6076     if (!wrap_handles) return layer_data->device_dispatch_table.GetAccelerationStructureMemoryRequirementsNV(device, pInfo, pMemoryRequirements);
6077     safe_VkAccelerationStructureMemoryRequirementsInfoNV *local_pInfo = NULL;
6078     {
6079         if (pInfo) {
6080             local_pInfo = new safe_VkAccelerationStructureMemoryRequirementsInfoNV(pInfo);
6081             if (pInfo->accelerationStructure) {
6082                 local_pInfo->accelerationStructure = layer_data->Unwrap(pInfo->accelerationStructure);
6083             }
6084         }
6085     }
6086     layer_data->device_dispatch_table.GetAccelerationStructureMemoryRequirementsNV(device, (const VkAccelerationStructureMemoryRequirementsInfoNV*)local_pInfo, pMemoryRequirements);
6087     if (local_pInfo) {
6088         delete local_pInfo;
6089     }
6090 }
6091 
DispatchBindAccelerationStructureMemoryNV(VkDevice device,uint32_t bindInfoCount,const VkBindAccelerationStructureMemoryInfoNV * pBindInfos)6092 VkResult DispatchBindAccelerationStructureMemoryNV(
6093     VkDevice                                    device,
6094     uint32_t                                    bindInfoCount,
6095     const VkBindAccelerationStructureMemoryInfoNV* pBindInfos)
6096 {
6097     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
6098     if (!wrap_handles) return layer_data->device_dispatch_table.BindAccelerationStructureMemoryNV(device, bindInfoCount, pBindInfos);
6099     safe_VkBindAccelerationStructureMemoryInfoNV *local_pBindInfos = NULL;
6100     {
6101         if (pBindInfos) {
6102             local_pBindInfos = new safe_VkBindAccelerationStructureMemoryInfoNV[bindInfoCount];
6103             for (uint32_t index0 = 0; index0 < bindInfoCount; ++index0) {
6104                 local_pBindInfos[index0].initialize(&pBindInfos[index0]);
6105                 if (pBindInfos[index0].accelerationStructure) {
6106                     local_pBindInfos[index0].accelerationStructure = layer_data->Unwrap(pBindInfos[index0].accelerationStructure);
6107                 }
6108                 if (pBindInfos[index0].memory) {
6109                     local_pBindInfos[index0].memory = layer_data->Unwrap(pBindInfos[index0].memory);
6110                 }
6111             }
6112         }
6113     }
6114     VkResult result = layer_data->device_dispatch_table.BindAccelerationStructureMemoryNV(device, bindInfoCount, (const VkBindAccelerationStructureMemoryInfoNV*)local_pBindInfos);
6115     if (local_pBindInfos) {
6116         delete[] local_pBindInfos;
6117     }
6118     return result;
6119 }
6120 
DispatchCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,const VkAccelerationStructureInfoNV * pInfo,VkBuffer instanceData,VkDeviceSize instanceOffset,VkBool32 update,VkAccelerationStructureNV dst,VkAccelerationStructureNV src,VkBuffer scratch,VkDeviceSize scratchOffset)6121 void DispatchCmdBuildAccelerationStructureNV(
6122     VkCommandBuffer                             commandBuffer,
6123     const VkAccelerationStructureInfoNV*        pInfo,
6124     VkBuffer                                    instanceData,
6125     VkDeviceSize                                instanceOffset,
6126     VkBool32                                    update,
6127     VkAccelerationStructureNV                   dst,
6128     VkAccelerationStructureNV                   src,
6129     VkBuffer                                    scratch,
6130     VkDeviceSize                                scratchOffset)
6131 {
6132     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
6133     if (!wrap_handles) return layer_data->device_dispatch_table.CmdBuildAccelerationStructureNV(commandBuffer, pInfo, instanceData, instanceOffset, update, dst, src, scratch, scratchOffset);
6134     safe_VkAccelerationStructureInfoNV *local_pInfo = NULL;
6135     {
6136         if (pInfo) {
6137             local_pInfo = new safe_VkAccelerationStructureInfoNV(pInfo);
6138             if (local_pInfo->pGeometries) {
6139                 for (uint32_t index1 = 0; index1 < local_pInfo->geometryCount; ++index1) {
6140                     if (pInfo->pGeometries[index1].geometry.triangles.vertexData) {
6141                         local_pInfo->pGeometries[index1].geometry.triangles.vertexData = layer_data->Unwrap(pInfo->pGeometries[index1].geometry.triangles.vertexData);
6142                     }
6143                     if (pInfo->pGeometries[index1].geometry.triangles.indexData) {
6144                         local_pInfo->pGeometries[index1].geometry.triangles.indexData = layer_data->Unwrap(pInfo->pGeometries[index1].geometry.triangles.indexData);
6145                     }
6146                     if (pInfo->pGeometries[index1].geometry.triangles.transformData) {
6147                         local_pInfo->pGeometries[index1].geometry.triangles.transformData = layer_data->Unwrap(pInfo->pGeometries[index1].geometry.triangles.transformData);
6148                     }
6149                     if (pInfo->pGeometries[index1].geometry.aabbs.aabbData) {
6150                         local_pInfo->pGeometries[index1].geometry.aabbs.aabbData = layer_data->Unwrap(pInfo->pGeometries[index1].geometry.aabbs.aabbData);
6151                     }
6152                 }
6153             }
6154         }
6155         instanceData = layer_data->Unwrap(instanceData);
6156         dst = layer_data->Unwrap(dst);
6157         src = layer_data->Unwrap(src);
6158         scratch = layer_data->Unwrap(scratch);
6159     }
6160     layer_data->device_dispatch_table.CmdBuildAccelerationStructureNV(commandBuffer, (const VkAccelerationStructureInfoNV*)local_pInfo, instanceData, instanceOffset, update, dst, src, scratch, scratchOffset);
6161     if (local_pInfo) {
6162         delete local_pInfo;
6163     }
6164 }
6165 
DispatchCmdCopyAccelerationStructureNV(VkCommandBuffer commandBuffer,VkAccelerationStructureNV dst,VkAccelerationStructureNV src,VkCopyAccelerationStructureModeNV mode)6166 void DispatchCmdCopyAccelerationStructureNV(
6167     VkCommandBuffer                             commandBuffer,
6168     VkAccelerationStructureNV                   dst,
6169     VkAccelerationStructureNV                   src,
6170     VkCopyAccelerationStructureModeNV           mode)
6171 {
6172     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
6173     if (!wrap_handles) return layer_data->device_dispatch_table.CmdCopyAccelerationStructureNV(commandBuffer, dst, src, mode);
6174     {
6175         dst = layer_data->Unwrap(dst);
6176         src = layer_data->Unwrap(src);
6177     }
6178     layer_data->device_dispatch_table.CmdCopyAccelerationStructureNV(commandBuffer, dst, src, mode);
6179 
6180 }
6181 
DispatchCmdTraceRaysNV(VkCommandBuffer commandBuffer,VkBuffer raygenShaderBindingTableBuffer,VkDeviceSize raygenShaderBindingOffset,VkBuffer missShaderBindingTableBuffer,VkDeviceSize missShaderBindingOffset,VkDeviceSize missShaderBindingStride,VkBuffer hitShaderBindingTableBuffer,VkDeviceSize hitShaderBindingOffset,VkDeviceSize hitShaderBindingStride,VkBuffer callableShaderBindingTableBuffer,VkDeviceSize callableShaderBindingOffset,VkDeviceSize callableShaderBindingStride,uint32_t width,uint32_t height,uint32_t depth)6182 void DispatchCmdTraceRaysNV(
6183     VkCommandBuffer                             commandBuffer,
6184     VkBuffer                                    raygenShaderBindingTableBuffer,
6185     VkDeviceSize                                raygenShaderBindingOffset,
6186     VkBuffer                                    missShaderBindingTableBuffer,
6187     VkDeviceSize                                missShaderBindingOffset,
6188     VkDeviceSize                                missShaderBindingStride,
6189     VkBuffer                                    hitShaderBindingTableBuffer,
6190     VkDeviceSize                                hitShaderBindingOffset,
6191     VkDeviceSize                                hitShaderBindingStride,
6192     VkBuffer                                    callableShaderBindingTableBuffer,
6193     VkDeviceSize                                callableShaderBindingOffset,
6194     VkDeviceSize                                callableShaderBindingStride,
6195     uint32_t                                    width,
6196     uint32_t                                    height,
6197     uint32_t                                    depth)
6198 {
6199     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
6200     if (!wrap_handles) return layer_data->device_dispatch_table.CmdTraceRaysNV(commandBuffer, raygenShaderBindingTableBuffer, raygenShaderBindingOffset, missShaderBindingTableBuffer, missShaderBindingOffset, missShaderBindingStride, hitShaderBindingTableBuffer, hitShaderBindingOffset, hitShaderBindingStride, callableShaderBindingTableBuffer, callableShaderBindingOffset, callableShaderBindingStride, width, height, depth);
6201     {
6202         raygenShaderBindingTableBuffer = layer_data->Unwrap(raygenShaderBindingTableBuffer);
6203         missShaderBindingTableBuffer = layer_data->Unwrap(missShaderBindingTableBuffer);
6204         hitShaderBindingTableBuffer = layer_data->Unwrap(hitShaderBindingTableBuffer);
6205         callableShaderBindingTableBuffer = layer_data->Unwrap(callableShaderBindingTableBuffer);
6206     }
6207     layer_data->device_dispatch_table.CmdTraceRaysNV(commandBuffer, raygenShaderBindingTableBuffer, raygenShaderBindingOffset, missShaderBindingTableBuffer, missShaderBindingOffset, missShaderBindingStride, hitShaderBindingTableBuffer, hitShaderBindingOffset, hitShaderBindingStride, callableShaderBindingTableBuffer, callableShaderBindingOffset, callableShaderBindingStride, width, height, depth);
6208 
6209 }
6210 
DispatchCreateRayTracingPipelinesNV(VkDevice device,VkPipelineCache pipelineCache,uint32_t createInfoCount,const VkRayTracingPipelineCreateInfoNV * pCreateInfos,const VkAllocationCallbacks * pAllocator,VkPipeline * pPipelines)6211 VkResult DispatchCreateRayTracingPipelinesNV(
6212     VkDevice                                    device,
6213     VkPipelineCache                             pipelineCache,
6214     uint32_t                                    createInfoCount,
6215     const VkRayTracingPipelineCreateInfoNV*     pCreateInfos,
6216     const VkAllocationCallbacks*                pAllocator,
6217     VkPipeline*                                 pPipelines)
6218 {
6219     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
6220     if (!wrap_handles) return layer_data->device_dispatch_table.CreateRayTracingPipelinesNV(device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines);
6221     safe_VkRayTracingPipelineCreateInfoNV *local_pCreateInfos = NULL;
6222     {
6223         pipelineCache = layer_data->Unwrap(pipelineCache);
6224         if (pCreateInfos) {
6225             local_pCreateInfos = new safe_VkRayTracingPipelineCreateInfoNV[createInfoCount];
6226             for (uint32_t index0 = 0; index0 < createInfoCount; ++index0) {
6227                 local_pCreateInfos[index0].initialize(&pCreateInfos[index0]);
6228                 if (local_pCreateInfos[index0].pStages) {
6229                     for (uint32_t index1 = 0; index1 < local_pCreateInfos[index0].stageCount; ++index1) {
6230                         if (pCreateInfos[index0].pStages[index1].module) {
6231                             local_pCreateInfos[index0].pStages[index1].module = layer_data->Unwrap(pCreateInfos[index0].pStages[index1].module);
6232                         }
6233                     }
6234                 }
6235                 if (pCreateInfos[index0].layout) {
6236                     local_pCreateInfos[index0].layout = layer_data->Unwrap(pCreateInfos[index0].layout);
6237                 }
6238                 if (pCreateInfos[index0].basePipelineHandle) {
6239                     local_pCreateInfos[index0].basePipelineHandle = layer_data->Unwrap(pCreateInfos[index0].basePipelineHandle);
6240                 }
6241             }
6242         }
6243     }
6244     VkResult result = layer_data->device_dispatch_table.CreateRayTracingPipelinesNV(device, pipelineCache, createInfoCount, (const VkRayTracingPipelineCreateInfoNV*)local_pCreateInfos, pAllocator, pPipelines);
6245     if (local_pCreateInfos) {
6246         delete[] local_pCreateInfos;
6247     }
6248     if (VK_SUCCESS == result) {
6249         for (uint32_t index0 = 0; index0 < createInfoCount; index0++) {
6250             pPipelines[index0] = layer_data->WrapNew(pPipelines[index0]);
6251         }
6252     }
6253     return result;
6254 }
6255 
DispatchGetRayTracingShaderGroupHandlesNV(VkDevice device,VkPipeline pipeline,uint32_t firstGroup,uint32_t groupCount,size_t dataSize,void * pData)6256 VkResult DispatchGetRayTracingShaderGroupHandlesNV(
6257     VkDevice                                    device,
6258     VkPipeline                                  pipeline,
6259     uint32_t                                    firstGroup,
6260     uint32_t                                    groupCount,
6261     size_t                                      dataSize,
6262     void*                                       pData)
6263 {
6264     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
6265     if (!wrap_handles) return layer_data->device_dispatch_table.GetRayTracingShaderGroupHandlesNV(device, pipeline, firstGroup, groupCount, dataSize, pData);
6266     {
6267         pipeline = layer_data->Unwrap(pipeline);
6268     }
6269     VkResult result = layer_data->device_dispatch_table.GetRayTracingShaderGroupHandlesNV(device, pipeline, firstGroup, groupCount, dataSize, pData);
6270 
6271     return result;
6272 }
6273 
DispatchGetAccelerationStructureHandleNV(VkDevice device,VkAccelerationStructureNV accelerationStructure,size_t dataSize,void * pData)6274 VkResult DispatchGetAccelerationStructureHandleNV(
6275     VkDevice                                    device,
6276     VkAccelerationStructureNV                   accelerationStructure,
6277     size_t                                      dataSize,
6278     void*                                       pData)
6279 {
6280     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
6281     if (!wrap_handles) return layer_data->device_dispatch_table.GetAccelerationStructureHandleNV(device, accelerationStructure, dataSize, pData);
6282     {
6283         accelerationStructure = layer_data->Unwrap(accelerationStructure);
6284     }
6285     VkResult result = layer_data->device_dispatch_table.GetAccelerationStructureHandleNV(device, accelerationStructure, dataSize, pData);
6286 
6287     return result;
6288 }
6289 
DispatchCmdWriteAccelerationStructuresPropertiesNV(VkCommandBuffer commandBuffer,uint32_t accelerationStructureCount,const VkAccelerationStructureNV * pAccelerationStructures,VkQueryType queryType,VkQueryPool queryPool,uint32_t firstQuery)6290 void DispatchCmdWriteAccelerationStructuresPropertiesNV(
6291     VkCommandBuffer                             commandBuffer,
6292     uint32_t                                    accelerationStructureCount,
6293     const VkAccelerationStructureNV*            pAccelerationStructures,
6294     VkQueryType                                 queryType,
6295     VkQueryPool                                 queryPool,
6296     uint32_t                                    firstQuery)
6297 {
6298     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
6299     if (!wrap_handles) return layer_data->device_dispatch_table.CmdWriteAccelerationStructuresPropertiesNV(commandBuffer, accelerationStructureCount, pAccelerationStructures, queryType, queryPool, firstQuery);
6300     VkAccelerationStructureNV *local_pAccelerationStructures = NULL;
6301     {
6302         if (pAccelerationStructures) {
6303             local_pAccelerationStructures = new VkAccelerationStructureNV[accelerationStructureCount];
6304             for (uint32_t index0 = 0; index0 < accelerationStructureCount; ++index0) {
6305                 local_pAccelerationStructures[index0] = layer_data->Unwrap(pAccelerationStructures[index0]);
6306             }
6307         }
6308         queryPool = layer_data->Unwrap(queryPool);
6309     }
6310     layer_data->device_dispatch_table.CmdWriteAccelerationStructuresPropertiesNV(commandBuffer, accelerationStructureCount, (const VkAccelerationStructureNV*)local_pAccelerationStructures, queryType, queryPool, firstQuery);
6311     if (local_pAccelerationStructures)
6312         delete[] local_pAccelerationStructures;
6313 }
6314 
DispatchCompileDeferredNV(VkDevice device,VkPipeline pipeline,uint32_t shader)6315 VkResult DispatchCompileDeferredNV(
6316     VkDevice                                    device,
6317     VkPipeline                                  pipeline,
6318     uint32_t                                    shader)
6319 {
6320     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
6321     if (!wrap_handles) return layer_data->device_dispatch_table.CompileDeferredNV(device, pipeline, shader);
6322     {
6323         pipeline = layer_data->Unwrap(pipeline);
6324     }
6325     VkResult result = layer_data->device_dispatch_table.CompileDeferredNV(device, pipeline, shader);
6326 
6327     return result;
6328 }
6329 
DispatchGetMemoryHostPointerPropertiesEXT(VkDevice device,VkExternalMemoryHandleTypeFlagBits handleType,const void * pHostPointer,VkMemoryHostPointerPropertiesEXT * pMemoryHostPointerProperties)6330 VkResult DispatchGetMemoryHostPointerPropertiesEXT(
6331     VkDevice                                    device,
6332     VkExternalMemoryHandleTypeFlagBits          handleType,
6333     const void*                                 pHostPointer,
6334     VkMemoryHostPointerPropertiesEXT*           pMemoryHostPointerProperties)
6335 {
6336     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
6337     VkResult result = layer_data->device_dispatch_table.GetMemoryHostPointerPropertiesEXT(device, handleType, pHostPointer, pMemoryHostPointerProperties);
6338 
6339     return result;
6340 }
6341 
DispatchCmdWriteBufferMarkerAMD(VkCommandBuffer commandBuffer,VkPipelineStageFlagBits pipelineStage,VkBuffer dstBuffer,VkDeviceSize dstOffset,uint32_t marker)6342 void DispatchCmdWriteBufferMarkerAMD(
6343     VkCommandBuffer                             commandBuffer,
6344     VkPipelineStageFlagBits                     pipelineStage,
6345     VkBuffer                                    dstBuffer,
6346     VkDeviceSize                                dstOffset,
6347     uint32_t                                    marker)
6348 {
6349     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
6350     if (!wrap_handles) return layer_data->device_dispatch_table.CmdWriteBufferMarkerAMD(commandBuffer, pipelineStage, dstBuffer, dstOffset, marker);
6351     {
6352         dstBuffer = layer_data->Unwrap(dstBuffer);
6353     }
6354     layer_data->device_dispatch_table.CmdWriteBufferMarkerAMD(commandBuffer, pipelineStage, dstBuffer, dstOffset, marker);
6355 
6356 }
6357 
DispatchGetPhysicalDeviceCalibrateableTimeDomainsEXT(VkPhysicalDevice physicalDevice,uint32_t * pTimeDomainCount,VkTimeDomainEXT * pTimeDomains)6358 VkResult DispatchGetPhysicalDeviceCalibrateableTimeDomainsEXT(
6359     VkPhysicalDevice                            physicalDevice,
6360     uint32_t*                                   pTimeDomainCount,
6361     VkTimeDomainEXT*                            pTimeDomains)
6362 {
6363     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
6364     VkResult result = layer_data->instance_dispatch_table.GetPhysicalDeviceCalibrateableTimeDomainsEXT(physicalDevice, pTimeDomainCount, pTimeDomains);
6365 
6366     return result;
6367 }
6368 
DispatchGetCalibratedTimestampsEXT(VkDevice device,uint32_t timestampCount,const VkCalibratedTimestampInfoEXT * pTimestampInfos,uint64_t * pTimestamps,uint64_t * pMaxDeviation)6369 VkResult DispatchGetCalibratedTimestampsEXT(
6370     VkDevice                                    device,
6371     uint32_t                                    timestampCount,
6372     const VkCalibratedTimestampInfoEXT*         pTimestampInfos,
6373     uint64_t*                                   pTimestamps,
6374     uint64_t*                                   pMaxDeviation)
6375 {
6376     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
6377     VkResult result = layer_data->device_dispatch_table.GetCalibratedTimestampsEXT(device, timestampCount, pTimestampInfos, pTimestamps, pMaxDeviation);
6378 
6379     return result;
6380 }
6381 
DispatchCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer,uint32_t taskCount,uint32_t firstTask)6382 void DispatchCmdDrawMeshTasksNV(
6383     VkCommandBuffer                             commandBuffer,
6384     uint32_t                                    taskCount,
6385     uint32_t                                    firstTask)
6386 {
6387     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
6388     layer_data->device_dispatch_table.CmdDrawMeshTasksNV(commandBuffer, taskCount, firstTask);
6389 
6390 }
6391 
DispatchCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer,VkBuffer buffer,VkDeviceSize offset,uint32_t drawCount,uint32_t stride)6392 void DispatchCmdDrawMeshTasksIndirectNV(
6393     VkCommandBuffer                             commandBuffer,
6394     VkBuffer                                    buffer,
6395     VkDeviceSize                                offset,
6396     uint32_t                                    drawCount,
6397     uint32_t                                    stride)
6398 {
6399     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
6400     if (!wrap_handles) return layer_data->device_dispatch_table.CmdDrawMeshTasksIndirectNV(commandBuffer, buffer, offset, drawCount, stride);
6401     {
6402         buffer = layer_data->Unwrap(buffer);
6403     }
6404     layer_data->device_dispatch_table.CmdDrawMeshTasksIndirectNV(commandBuffer, buffer, offset, drawCount, stride);
6405 
6406 }
6407 
DispatchCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer,VkBuffer buffer,VkDeviceSize offset,VkBuffer countBuffer,VkDeviceSize countBufferOffset,uint32_t maxDrawCount,uint32_t stride)6408 void DispatchCmdDrawMeshTasksIndirectCountNV(
6409     VkCommandBuffer                             commandBuffer,
6410     VkBuffer                                    buffer,
6411     VkDeviceSize                                offset,
6412     VkBuffer                                    countBuffer,
6413     VkDeviceSize                                countBufferOffset,
6414     uint32_t                                    maxDrawCount,
6415     uint32_t                                    stride)
6416 {
6417     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
6418     if (!wrap_handles) return layer_data->device_dispatch_table.CmdDrawMeshTasksIndirectCountNV(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride);
6419     {
6420         buffer = layer_data->Unwrap(buffer);
6421         countBuffer = layer_data->Unwrap(countBuffer);
6422     }
6423     layer_data->device_dispatch_table.CmdDrawMeshTasksIndirectCountNV(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride);
6424 
6425 }
6426 
DispatchCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,uint32_t firstExclusiveScissor,uint32_t exclusiveScissorCount,const VkRect2D * pExclusiveScissors)6427 void DispatchCmdSetExclusiveScissorNV(
6428     VkCommandBuffer                             commandBuffer,
6429     uint32_t                                    firstExclusiveScissor,
6430     uint32_t                                    exclusiveScissorCount,
6431     const VkRect2D*                             pExclusiveScissors)
6432 {
6433     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
6434     layer_data->device_dispatch_table.CmdSetExclusiveScissorNV(commandBuffer, firstExclusiveScissor, exclusiveScissorCount, pExclusiveScissors);
6435 
6436 }
6437 
DispatchCmdSetCheckpointNV(VkCommandBuffer commandBuffer,const void * pCheckpointMarker)6438 void DispatchCmdSetCheckpointNV(
6439     VkCommandBuffer                             commandBuffer,
6440     const void*                                 pCheckpointMarker)
6441 {
6442     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
6443     layer_data->device_dispatch_table.CmdSetCheckpointNV(commandBuffer, pCheckpointMarker);
6444 
6445 }
6446 
DispatchGetQueueCheckpointDataNV(VkQueue queue,uint32_t * pCheckpointDataCount,VkCheckpointDataNV * pCheckpointData)6447 void DispatchGetQueueCheckpointDataNV(
6448     VkQueue                                     queue,
6449     uint32_t*                                   pCheckpointDataCount,
6450     VkCheckpointDataNV*                         pCheckpointData)
6451 {
6452     auto layer_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map);
6453     layer_data->device_dispatch_table.GetQueueCheckpointDataNV(queue, pCheckpointDataCount, pCheckpointData);
6454 
6455 }
6456 
DispatchInitializePerformanceApiINTEL(VkDevice device,const VkInitializePerformanceApiInfoINTEL * pInitializeInfo)6457 VkResult DispatchInitializePerformanceApiINTEL(
6458     VkDevice                                    device,
6459     const VkInitializePerformanceApiInfoINTEL*  pInitializeInfo)
6460 {
6461     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
6462     VkResult result = layer_data->device_dispatch_table.InitializePerformanceApiINTEL(device, pInitializeInfo);
6463 
6464     return result;
6465 }
6466 
DispatchUninitializePerformanceApiINTEL(VkDevice device)6467 void DispatchUninitializePerformanceApiINTEL(
6468     VkDevice                                    device)
6469 {
6470     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
6471     layer_data->device_dispatch_table.UninitializePerformanceApiINTEL(device);
6472 
6473 }
6474 
DispatchCmdSetPerformanceMarkerINTEL(VkCommandBuffer commandBuffer,const VkPerformanceMarkerInfoINTEL * pMarkerInfo)6475 VkResult DispatchCmdSetPerformanceMarkerINTEL(
6476     VkCommandBuffer                             commandBuffer,
6477     const VkPerformanceMarkerInfoINTEL*         pMarkerInfo)
6478 {
6479     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
6480     VkResult result = layer_data->device_dispatch_table.CmdSetPerformanceMarkerINTEL(commandBuffer, pMarkerInfo);
6481 
6482     return result;
6483 }
6484 
DispatchCmdSetPerformanceStreamMarkerINTEL(VkCommandBuffer commandBuffer,const VkPerformanceStreamMarkerInfoINTEL * pMarkerInfo)6485 VkResult DispatchCmdSetPerformanceStreamMarkerINTEL(
6486     VkCommandBuffer                             commandBuffer,
6487     const VkPerformanceStreamMarkerInfoINTEL*   pMarkerInfo)
6488 {
6489     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
6490     VkResult result = layer_data->device_dispatch_table.CmdSetPerformanceStreamMarkerINTEL(commandBuffer, pMarkerInfo);
6491 
6492     return result;
6493 }
6494 
DispatchCmdSetPerformanceOverrideINTEL(VkCommandBuffer commandBuffer,const VkPerformanceOverrideInfoINTEL * pOverrideInfo)6495 VkResult DispatchCmdSetPerformanceOverrideINTEL(
6496     VkCommandBuffer                             commandBuffer,
6497     const VkPerformanceOverrideInfoINTEL*       pOverrideInfo)
6498 {
6499     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
6500     VkResult result = layer_data->device_dispatch_table.CmdSetPerformanceOverrideINTEL(commandBuffer, pOverrideInfo);
6501 
6502     return result;
6503 }
6504 
DispatchAcquirePerformanceConfigurationINTEL(VkDevice device,const VkPerformanceConfigurationAcquireInfoINTEL * pAcquireInfo,VkPerformanceConfigurationINTEL * pConfiguration)6505 VkResult DispatchAcquirePerformanceConfigurationINTEL(
6506     VkDevice                                    device,
6507     const VkPerformanceConfigurationAcquireInfoINTEL* pAcquireInfo,
6508     VkPerformanceConfigurationINTEL*            pConfiguration)
6509 {
6510     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
6511     if (!wrap_handles) return layer_data->device_dispatch_table.AcquirePerformanceConfigurationINTEL(device, pAcquireInfo, pConfiguration);
6512     {
6513         pConfiguration = layer_data->Unwrap(pConfiguration);
6514     }
6515     VkResult result = layer_data->device_dispatch_table.AcquirePerformanceConfigurationINTEL(device, pAcquireInfo, pConfiguration);
6516 
6517     return result;
6518 }
6519 
DispatchReleasePerformanceConfigurationINTEL(VkDevice device,VkPerformanceConfigurationINTEL configuration)6520 VkResult DispatchReleasePerformanceConfigurationINTEL(
6521     VkDevice                                    device,
6522     VkPerformanceConfigurationINTEL             configuration)
6523 {
6524     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
6525     if (!wrap_handles) return layer_data->device_dispatch_table.ReleasePerformanceConfigurationINTEL(device, configuration);
6526     {
6527         configuration = layer_data->Unwrap(configuration);
6528     }
6529     VkResult result = layer_data->device_dispatch_table.ReleasePerformanceConfigurationINTEL(device, configuration);
6530 
6531     return result;
6532 }
6533 
DispatchQueueSetPerformanceConfigurationINTEL(VkQueue queue,VkPerformanceConfigurationINTEL configuration)6534 VkResult DispatchQueueSetPerformanceConfigurationINTEL(
6535     VkQueue                                     queue,
6536     VkPerformanceConfigurationINTEL             configuration)
6537 {
6538     auto layer_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map);
6539     if (!wrap_handles) return layer_data->device_dispatch_table.QueueSetPerformanceConfigurationINTEL(queue, configuration);
6540     {
6541         configuration = layer_data->Unwrap(configuration);
6542     }
6543     VkResult result = layer_data->device_dispatch_table.QueueSetPerformanceConfigurationINTEL(queue, configuration);
6544 
6545     return result;
6546 }
6547 
DispatchGetPerformanceParameterINTEL(VkDevice device,VkPerformanceParameterTypeINTEL parameter,VkPerformanceValueINTEL * pValue)6548 VkResult DispatchGetPerformanceParameterINTEL(
6549     VkDevice                                    device,
6550     VkPerformanceParameterTypeINTEL             parameter,
6551     VkPerformanceValueINTEL*                    pValue)
6552 {
6553     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
6554     VkResult result = layer_data->device_dispatch_table.GetPerformanceParameterINTEL(device, parameter, pValue);
6555 
6556     return result;
6557 }
6558 
DispatchSetLocalDimmingAMD(VkDevice device,VkSwapchainKHR swapChain,VkBool32 localDimmingEnable)6559 void DispatchSetLocalDimmingAMD(
6560     VkDevice                                    device,
6561     VkSwapchainKHR                              swapChain,
6562     VkBool32                                    localDimmingEnable)
6563 {
6564     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
6565     if (!wrap_handles) return layer_data->device_dispatch_table.SetLocalDimmingAMD(device, swapChain, localDimmingEnable);
6566     {
6567         swapChain = layer_data->Unwrap(swapChain);
6568     }
6569     layer_data->device_dispatch_table.SetLocalDimmingAMD(device, swapChain, localDimmingEnable);
6570 
6571 }
6572 
6573 #ifdef VK_USE_PLATFORM_FUCHSIA
6574 
DispatchCreateImagePipeSurfaceFUCHSIA(VkInstance instance,const VkImagePipeSurfaceCreateInfoFUCHSIA * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSurfaceKHR * pSurface)6575 VkResult DispatchCreateImagePipeSurfaceFUCHSIA(
6576     VkInstance                                  instance,
6577     const VkImagePipeSurfaceCreateInfoFUCHSIA*  pCreateInfo,
6578     const VkAllocationCallbacks*                pAllocator,
6579     VkSurfaceKHR*                               pSurface)
6580 {
6581     auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
6582     if (!wrap_handles) return layer_data->instance_dispatch_table.CreateImagePipeSurfaceFUCHSIA(instance, pCreateInfo, pAllocator, pSurface);
6583     VkResult result = layer_data->instance_dispatch_table.CreateImagePipeSurfaceFUCHSIA(instance, pCreateInfo, pAllocator, pSurface);
6584     if (VK_SUCCESS == result) {
6585         *pSurface = layer_data->WrapNew(*pSurface);
6586     }
6587     return result;
6588 }
6589 #endif // VK_USE_PLATFORM_FUCHSIA
6590 
6591 #ifdef VK_USE_PLATFORM_METAL_EXT
6592 
DispatchCreateMetalSurfaceEXT(VkInstance instance,const VkMetalSurfaceCreateInfoEXT * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSurfaceKHR * pSurface)6593 VkResult DispatchCreateMetalSurfaceEXT(
6594     VkInstance                                  instance,
6595     const VkMetalSurfaceCreateInfoEXT*          pCreateInfo,
6596     const VkAllocationCallbacks*                pAllocator,
6597     VkSurfaceKHR*                               pSurface)
6598 {
6599     auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
6600     if (!wrap_handles) return layer_data->instance_dispatch_table.CreateMetalSurfaceEXT(instance, pCreateInfo, pAllocator, pSurface);
6601     VkResult result = layer_data->instance_dispatch_table.CreateMetalSurfaceEXT(instance, pCreateInfo, pAllocator, pSurface);
6602     if (VK_SUCCESS == result) {
6603         *pSurface = layer_data->WrapNew(*pSurface);
6604     }
6605     return result;
6606 }
6607 #endif // VK_USE_PLATFORM_METAL_EXT
6608 
DispatchGetBufferDeviceAddressEXT(VkDevice device,const VkBufferDeviceAddressInfoEXT * pInfo)6609 VkDeviceAddress DispatchGetBufferDeviceAddressEXT(
6610     VkDevice                                    device,
6611     const VkBufferDeviceAddressInfoEXT*         pInfo)
6612 {
6613     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
6614     if (!wrap_handles) return layer_data->device_dispatch_table.GetBufferDeviceAddressEXT(device, pInfo);
6615     safe_VkBufferDeviceAddressInfoEXT *local_pInfo = NULL;
6616     {
6617         if (pInfo) {
6618             local_pInfo = new safe_VkBufferDeviceAddressInfoEXT(pInfo);
6619             if (pInfo->buffer) {
6620                 local_pInfo->buffer = layer_data->Unwrap(pInfo->buffer);
6621             }
6622         }
6623     }
6624     VkDeviceAddress result = layer_data->device_dispatch_table.GetBufferDeviceAddressEXT(device, (const VkBufferDeviceAddressInfoEXT*)local_pInfo);
6625     if (local_pInfo) {
6626         delete local_pInfo;
6627     }
6628     return result;
6629 }
6630 
DispatchGetPhysicalDeviceCooperativeMatrixPropertiesNV(VkPhysicalDevice physicalDevice,uint32_t * pPropertyCount,VkCooperativeMatrixPropertiesNV * pProperties)6631 VkResult DispatchGetPhysicalDeviceCooperativeMatrixPropertiesNV(
6632     VkPhysicalDevice                            physicalDevice,
6633     uint32_t*                                   pPropertyCount,
6634     VkCooperativeMatrixPropertiesNV*            pProperties)
6635 {
6636     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
6637     VkResult result = layer_data->instance_dispatch_table.GetPhysicalDeviceCooperativeMatrixPropertiesNV(physicalDevice, pPropertyCount, pProperties);
6638 
6639     return result;
6640 }
6641 
DispatchGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV(VkPhysicalDevice physicalDevice,uint32_t * pCombinationCount,VkFramebufferMixedSamplesCombinationNV * pCombinations)6642 VkResult DispatchGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV(
6643     VkPhysicalDevice                            physicalDevice,
6644     uint32_t*                                   pCombinationCount,
6645     VkFramebufferMixedSamplesCombinationNV*     pCombinations)
6646 {
6647     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
6648     VkResult result = layer_data->instance_dispatch_table.GetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV(physicalDevice, pCombinationCount, pCombinations);
6649 
6650     return result;
6651 }
6652 
6653 #ifdef VK_USE_PLATFORM_WIN32_KHR
6654 
DispatchGetPhysicalDeviceSurfacePresentModes2EXT(VkPhysicalDevice physicalDevice,const VkPhysicalDeviceSurfaceInfo2KHR * pSurfaceInfo,uint32_t * pPresentModeCount,VkPresentModeKHR * pPresentModes)6655 VkResult DispatchGetPhysicalDeviceSurfacePresentModes2EXT(
6656     VkPhysicalDevice                            physicalDevice,
6657     const VkPhysicalDeviceSurfaceInfo2KHR*      pSurfaceInfo,
6658     uint32_t*                                   pPresentModeCount,
6659     VkPresentModeKHR*                           pPresentModes)
6660 {
6661     auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
6662     if (!wrap_handles) return layer_data->instance_dispatch_table.GetPhysicalDeviceSurfacePresentModes2EXT(physicalDevice, pSurfaceInfo, pPresentModeCount, pPresentModes);
6663     safe_VkPhysicalDeviceSurfaceInfo2KHR *local_pSurfaceInfo = NULL;
6664     {
6665         if (pSurfaceInfo) {
6666             local_pSurfaceInfo = new safe_VkPhysicalDeviceSurfaceInfo2KHR(pSurfaceInfo);
6667             if (pSurfaceInfo->surface) {
6668                 local_pSurfaceInfo->surface = layer_data->Unwrap(pSurfaceInfo->surface);
6669             }
6670         }
6671     }
6672     VkResult result = layer_data->instance_dispatch_table.GetPhysicalDeviceSurfacePresentModes2EXT(physicalDevice, (const VkPhysicalDeviceSurfaceInfo2KHR*)local_pSurfaceInfo, pPresentModeCount, pPresentModes);
6673     if (local_pSurfaceInfo) {
6674         delete local_pSurfaceInfo;
6675     }
6676     return result;
6677 }
6678 #endif // VK_USE_PLATFORM_WIN32_KHR
6679 
6680 #ifdef VK_USE_PLATFORM_WIN32_KHR
6681 
DispatchAcquireFullScreenExclusiveModeEXT(VkDevice device,VkSwapchainKHR swapchain)6682 VkResult DispatchAcquireFullScreenExclusiveModeEXT(
6683     VkDevice                                    device,
6684     VkSwapchainKHR                              swapchain)
6685 {
6686     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
6687     if (!wrap_handles) return layer_data->device_dispatch_table.AcquireFullScreenExclusiveModeEXT(device, swapchain);
6688     {
6689         swapchain = layer_data->Unwrap(swapchain);
6690     }
6691     VkResult result = layer_data->device_dispatch_table.AcquireFullScreenExclusiveModeEXT(device, swapchain);
6692 
6693     return result;
6694 }
6695 #endif // VK_USE_PLATFORM_WIN32_KHR
6696 
6697 #ifdef VK_USE_PLATFORM_WIN32_KHR
6698 
DispatchReleaseFullScreenExclusiveModeEXT(VkDevice device,VkSwapchainKHR swapchain)6699 VkResult DispatchReleaseFullScreenExclusiveModeEXT(
6700     VkDevice                                    device,
6701     VkSwapchainKHR                              swapchain)
6702 {
6703     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
6704     if (!wrap_handles) return layer_data->device_dispatch_table.ReleaseFullScreenExclusiveModeEXT(device, swapchain);
6705     {
6706         swapchain = layer_data->Unwrap(swapchain);
6707     }
6708     VkResult result = layer_data->device_dispatch_table.ReleaseFullScreenExclusiveModeEXT(device, swapchain);
6709 
6710     return result;
6711 }
6712 #endif // VK_USE_PLATFORM_WIN32_KHR
6713 
6714 #ifdef VK_USE_PLATFORM_WIN32_KHR
6715 
DispatchGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,const VkPhysicalDeviceSurfaceInfo2KHR * pSurfaceInfo,VkDeviceGroupPresentModeFlagsKHR * pModes)6716 VkResult DispatchGetDeviceGroupSurfacePresentModes2EXT(
6717     VkDevice                                    device,
6718     const VkPhysicalDeviceSurfaceInfo2KHR*      pSurfaceInfo,
6719     VkDeviceGroupPresentModeFlagsKHR*           pModes)
6720 {
6721     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
6722     if (!wrap_handles) return layer_data->device_dispatch_table.GetDeviceGroupSurfacePresentModes2EXT(device, pSurfaceInfo, pModes);
6723     safe_VkPhysicalDeviceSurfaceInfo2KHR *local_pSurfaceInfo = NULL;
6724     {
6725         if (pSurfaceInfo) {
6726             local_pSurfaceInfo = new safe_VkPhysicalDeviceSurfaceInfo2KHR(pSurfaceInfo);
6727             if (pSurfaceInfo->surface) {
6728                 local_pSurfaceInfo->surface = layer_data->Unwrap(pSurfaceInfo->surface);
6729             }
6730         }
6731     }
6732     VkResult result = layer_data->device_dispatch_table.GetDeviceGroupSurfacePresentModes2EXT(device, (const VkPhysicalDeviceSurfaceInfo2KHR*)local_pSurfaceInfo, pModes);
6733     if (local_pSurfaceInfo) {
6734         delete local_pSurfaceInfo;
6735     }
6736     return result;
6737 }
6738 #endif // VK_USE_PLATFORM_WIN32_KHR
6739 
DispatchCreateHeadlessSurfaceEXT(VkInstance instance,const VkHeadlessSurfaceCreateInfoEXT * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSurfaceKHR * pSurface)6740 VkResult DispatchCreateHeadlessSurfaceEXT(
6741     VkInstance                                  instance,
6742     const VkHeadlessSurfaceCreateInfoEXT*       pCreateInfo,
6743     const VkAllocationCallbacks*                pAllocator,
6744     VkSurfaceKHR*                               pSurface)
6745 {
6746     auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
6747     if (!wrap_handles) return layer_data->instance_dispatch_table.CreateHeadlessSurfaceEXT(instance, pCreateInfo, pAllocator, pSurface);
6748     VkResult result = layer_data->instance_dispatch_table.CreateHeadlessSurfaceEXT(instance, pCreateInfo, pAllocator, pSurface);
6749     if (VK_SUCCESS == result) {
6750         *pSurface = layer_data->WrapNew(*pSurface);
6751     }
6752     return result;
6753 }
6754 
DispatchCmdSetLineStippleEXT(VkCommandBuffer commandBuffer,uint32_t lineStippleFactor,uint16_t lineStipplePattern)6755 void DispatchCmdSetLineStippleEXT(
6756     VkCommandBuffer                             commandBuffer,
6757     uint32_t                                    lineStippleFactor,
6758     uint16_t                                    lineStipplePattern)
6759 {
6760     auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
6761     layer_data->device_dispatch_table.CmdSetLineStippleEXT(commandBuffer, lineStippleFactor, lineStipplePattern);
6762 
6763 }
6764 
DispatchResetQueryPoolEXT(VkDevice device,VkQueryPool queryPool,uint32_t firstQuery,uint32_t queryCount)6765 void DispatchResetQueryPoolEXT(
6766     VkDevice                                    device,
6767     VkQueryPool                                 queryPool,
6768     uint32_t                                    firstQuery,
6769     uint32_t                                    queryCount)
6770 {
6771     auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
6772     if (!wrap_handles) return layer_data->device_dispatch_table.ResetQueryPoolEXT(device, queryPool, firstQuery, queryCount);
6773     {
6774         queryPool = layer_data->Unwrap(queryPool);
6775     }
6776     layer_data->device_dispatch_table.ResetQueryPoolEXT(device, queryPool, firstQuery, queryCount);
6777 
6778 }