blob: 833e23f77ade5b401700f49901af1843a9ee28b3 [file] [log] [blame]
// This file is ***GENERATED***. Do Not Edit.
// See layer_chassis_dispatch_generator.py for modifications.
/* Copyright (c) 2015-2019 The Khronos Group Inc.
* Copyright (c) 2015-2019 Valve Corporation
* Copyright (c) 2015-2019 LunarG, Inc.
* Copyright (c) 2015-2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Author: Mark Lobodzinski <mark@lunarg.com>
*/
#include <mutex>
#include "chassis.h"
#include "layer_chassis_dispatch.h"
#include "vk_layer_utils.h"
// This intentionally includes a cpp file
#include "vk_safe_struct.cpp"
ReadWriteLock dispatch_lock;
// Unique Objects pNext extension handling function
void WrapPnextChainHandles(ValidationObject *layer_data, const void *pNext) {
void *cur_pnext = const_cast<void *>(pNext);
while (cur_pnext != NULL) {
VkBaseOutStructure *header = reinterpret_cast<VkBaseOutStructure *>(cur_pnext);
switch (header->sType) {
#ifdef VK_USE_PLATFORM_WIN32_KHR
case VK_STRUCTURE_TYPE_WIN32_KEYED_MUTEX_ACQUIRE_RELEASE_INFO_KHR: {
safe_VkWin32KeyedMutexAcquireReleaseInfoKHR *safe_struct = reinterpret_cast<safe_VkWin32KeyedMutexAcquireReleaseInfoKHR *>(cur_pnext);
if (safe_struct->pAcquireSyncs) {
for (uint32_t index0 = 0; index0 < safe_struct->acquireCount; ++index0) {
safe_struct->pAcquireSyncs[index0] = layer_data->Unwrap(safe_struct->pAcquireSyncs[index0]);
}
}
if (safe_struct->pReleaseSyncs) {
for (uint32_t index0 = 0; index0 < safe_struct->releaseCount; ++index0) {
safe_struct->pReleaseSyncs[index0] = layer_data->Unwrap(safe_struct->pReleaseSyncs[index0]);
}
}
} break;
#endif // VK_USE_PLATFORM_WIN32_KHR
#ifdef VK_USE_PLATFORM_WIN32_KHR
case VK_STRUCTURE_TYPE_WIN32_KEYED_MUTEX_ACQUIRE_RELEASE_INFO_NV: {
safe_VkWin32KeyedMutexAcquireReleaseInfoNV *safe_struct = reinterpret_cast<safe_VkWin32KeyedMutexAcquireReleaseInfoNV *>(cur_pnext);
if (safe_struct->pAcquireSyncs) {
for (uint32_t index0 = 0; index0 < safe_struct->acquireCount; ++index0) {
safe_struct->pAcquireSyncs[index0] = layer_data->Unwrap(safe_struct->pAcquireSyncs[index0]);
}
}
if (safe_struct->pReleaseSyncs) {
for (uint32_t index0 = 0; index0 < safe_struct->releaseCount; ++index0) {
safe_struct->pReleaseSyncs[index0] = layer_data->Unwrap(safe_struct->pReleaseSyncs[index0]);
}
}
} break;
#endif // VK_USE_PLATFORM_WIN32_KHR
case VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV: {
safe_VkDedicatedAllocationMemoryAllocateInfoNV *safe_struct = reinterpret_cast<safe_VkDedicatedAllocationMemoryAllocateInfoNV *>(cur_pnext);
if (safe_struct->image) {
safe_struct->image = layer_data->Unwrap(safe_struct->image);
}
if (safe_struct->buffer) {
safe_struct->buffer = layer_data->Unwrap(safe_struct->buffer);
}
} break;
case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO: {
safe_VkMemoryDedicatedAllocateInfo *safe_struct = reinterpret_cast<safe_VkMemoryDedicatedAllocateInfo *>(cur_pnext);
if (safe_struct->image) {
safe_struct->image = layer_data->Unwrap(safe_struct->image);
}
if (safe_struct->buffer) {
safe_struct->buffer = layer_data->Unwrap(safe_struct->buffer);
}
} break;
case VK_STRUCTURE_TYPE_IMAGE_SWAPCHAIN_CREATE_INFO_KHR: {
safe_VkImageSwapchainCreateInfoKHR *safe_struct = reinterpret_cast<safe_VkImageSwapchainCreateInfoKHR *>(cur_pnext);
if (safe_struct->swapchain) {
safe_struct->swapchain = layer_data->Unwrap(safe_struct->swapchain);
}
} break;
case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO: {
safe_VkSamplerYcbcrConversionInfo *safe_struct = reinterpret_cast<safe_VkSamplerYcbcrConversionInfo *>(cur_pnext);
if (safe_struct->conversion) {
safe_struct->conversion = layer_data->Unwrap(safe_struct->conversion);
}
} break;
case VK_STRUCTURE_TYPE_SHADER_MODULE_VALIDATION_CACHE_CREATE_INFO_EXT: {
safe_VkShaderModuleValidationCacheCreateInfoEXT *safe_struct = reinterpret_cast<safe_VkShaderModuleValidationCacheCreateInfoEXT *>(cur_pnext);
if (safe_struct->validationCache) {
safe_struct->validationCache = layer_data->Unwrap(safe_struct->validationCache);
}
} break;
case VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_NV: {
safe_VkWriteDescriptorSetAccelerationStructureNV *safe_struct = reinterpret_cast<safe_VkWriteDescriptorSetAccelerationStructureNV *>(cur_pnext);
if (safe_struct->pAccelerationStructures) {
for (uint32_t index0 = 0; index0 < safe_struct->accelerationStructureCount; ++index0) {
safe_struct->pAccelerationStructures[index0] = layer_data->Unwrap(safe_struct->pAccelerationStructures[index0]);
}
}
} break;
case VK_STRUCTURE_TYPE_RENDER_PASS_ATTACHMENT_BEGIN_INFO_KHR: {
safe_VkRenderPassAttachmentBeginInfoKHR *safe_struct = reinterpret_cast<safe_VkRenderPassAttachmentBeginInfoKHR *>(cur_pnext);
if (safe_struct->pAttachments) {
for (uint32_t index0 = 0; index0 < safe_struct->attachmentCount; ++index0) {
safe_struct->pAttachments[index0] = layer_data->Unwrap(safe_struct->pAttachments[index0]);
}
}
} break;
case VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR: {
safe_VkBindImageMemorySwapchainInfoKHR *safe_struct = reinterpret_cast<safe_VkBindImageMemorySwapchainInfoKHR *>(cur_pnext);
if (safe_struct->swapchain) {
safe_struct->swapchain = layer_data->Unwrap(safe_struct->swapchain);
}
} break;
default:
break;
}
// Process the next structure in the chain
cur_pnext = header->pNext;
}
}
// Manually written Dispatch routines
#define DISPATCH_MAX_STACK_ALLOCATIONS 32
// The VK_EXT_pipeline_creation_feedback extension returns data from the driver -- we've created a copy of the pnext chain, so
// copy the returned data to the caller before freeing the copy's data.
void CopyCreatePipelineFeedbackData(const void *src_chain, const void *dst_chain) {
auto src_feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(src_chain);
if (!src_feedback_struct) return;
auto dst_feedback_struct = const_cast<VkPipelineCreationFeedbackCreateInfoEXT *>(
lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(dst_chain));
*dst_feedback_struct->pPipelineCreationFeedback = *src_feedback_struct->pPipelineCreationFeedback;
for (uint32_t i = 0; i < src_feedback_struct->pipelineStageCreationFeedbackCount; i++) {
dst_feedback_struct->pPipelineStageCreationFeedbacks[i] = src_feedback_struct->pPipelineStageCreationFeedbacks[i];
}
}
VkResult DispatchCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
const VkGraphicsPipelineCreateInfo *pCreateInfos,
const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.CreateGraphicsPipelines(device, pipelineCache, createInfoCount,
pCreateInfos, pAllocator, pPipelines);
safe_VkGraphicsPipelineCreateInfo *local_pCreateInfos = nullptr;
if (pCreateInfos) {
local_pCreateInfos = new safe_VkGraphicsPipelineCreateInfo[createInfoCount];
read_lock_guard_t lock(dispatch_lock);
for (uint32_t idx0 = 0; idx0 < createInfoCount; ++idx0) {
bool uses_color_attachment = false;
bool uses_depthstencil_attachment = false;
{
const auto subpasses_uses_it = layer_data->renderpasses_states.find(layer_data->Unwrap(pCreateInfos[idx0].renderPass));
if (subpasses_uses_it != layer_data->renderpasses_states.end()) {
const auto &subpasses_uses = subpasses_uses_it->second;
if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[idx0].subpass))
uses_color_attachment = true;
if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[idx0].subpass))
uses_depthstencil_attachment = true;
}
}
local_pCreateInfos[idx0].initialize(&pCreateInfos[idx0], uses_color_attachment, uses_depthstencil_attachment);
if (pCreateInfos[idx0].basePipelineHandle) {
local_pCreateInfos[idx0].basePipelineHandle = layer_data->Unwrap(pCreateInfos[idx0].basePipelineHandle);
}
if (pCreateInfos[idx0].layout) {
local_pCreateInfos[idx0].layout = layer_data->Unwrap(pCreateInfos[idx0].layout);
}
if (pCreateInfos[idx0].pStages) {
for (uint32_t idx1 = 0; idx1 < pCreateInfos[idx0].stageCount; ++idx1) {
if (pCreateInfos[idx0].pStages[idx1].module) {
local_pCreateInfos[idx0].pStages[idx1].module = layer_data->Unwrap(pCreateInfos[idx0].pStages[idx1].module);
}
}
}
if (pCreateInfos[idx0].renderPass) {
local_pCreateInfos[idx0].renderPass = layer_data->Unwrap(pCreateInfos[idx0].renderPass);
}
}
}
if (pipelineCache) {
pipelineCache = layer_data->Unwrap(pipelineCache);
}
VkResult result = layer_data->device_dispatch_table.CreateGraphicsPipelines(device, pipelineCache, createInfoCount,
local_pCreateInfos->ptr(), pAllocator, pPipelines);
for (uint32_t i = 0; i < createInfoCount; ++i) {
if (pCreateInfos[i].pNext != VK_NULL_HANDLE) {
CopyCreatePipelineFeedbackData(local_pCreateInfos[i].pNext, pCreateInfos[i].pNext);
}
}
delete[] local_pCreateInfos;
{
for (uint32_t i = 0; i < createInfoCount; ++i) {
if (pPipelines[i] != VK_NULL_HANDLE) {
pPipelines[i] = layer_data->WrapNew(pPipelines[i]);
}
}
}
return result;
}
template <typename T>
static void UpdateCreateRenderPassState(ValidationObject *layer_data, const T *pCreateInfo, VkRenderPass renderPass) {
auto &renderpass_state = layer_data->renderpasses_states[renderPass];
for (uint32_t subpass = 0; subpass < pCreateInfo->subpassCount; ++subpass) {
bool uses_color = false;
for (uint32_t i = 0; i < pCreateInfo->pSubpasses[subpass].colorAttachmentCount && !uses_color; ++i)
if (pCreateInfo->pSubpasses[subpass].pColorAttachments[i].attachment != VK_ATTACHMENT_UNUSED) uses_color = true;
bool uses_depthstencil = false;
if (pCreateInfo->pSubpasses[subpass].pDepthStencilAttachment)
if (pCreateInfo->pSubpasses[subpass].pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED)
uses_depthstencil = true;
if (uses_color) renderpass_state.subpasses_using_color_attachment.insert(subpass);
if (uses_depthstencil) renderpass_state.subpasses_using_depthstencil_attachment.insert(subpass);
}
}
VkResult DispatchCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
VkResult result = layer_data->device_dispatch_table.CreateRenderPass(device, pCreateInfo, pAllocator, pRenderPass);
if (!wrap_handles) return result;
if (VK_SUCCESS == result) {
write_lock_guard_t lock(dispatch_lock);
UpdateCreateRenderPassState(layer_data, pCreateInfo, *pRenderPass);
*pRenderPass = layer_data->WrapNew(*pRenderPass);
}
return result;
}
VkResult DispatchCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
VkResult result = layer_data->device_dispatch_table.CreateRenderPass2KHR(device, pCreateInfo, pAllocator, pRenderPass);
if (!wrap_handles) return result;
if (VK_SUCCESS == result) {
write_lock_guard_t lock(dispatch_lock);
UpdateCreateRenderPassState(layer_data, pCreateInfo, *pRenderPass);
*pRenderPass = layer_data->WrapNew(*pRenderPass);
}
return result;
}
void DispatchDestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks *pAllocator) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.DestroyRenderPass(device, renderPass, pAllocator);
uint64_t renderPass_id = reinterpret_cast<uint64_t &>(renderPass);
auto iter = unique_id_mapping.pop(renderPass_id);
if (iter != unique_id_mapping.end()) {
renderPass = (VkRenderPass)iter->second;
} else {
renderPass = (VkRenderPass)0;
}
layer_data->device_dispatch_table.DestroyRenderPass(device, renderPass, pAllocator);
write_lock_guard_t lock(dispatch_lock);
layer_data->renderpasses_states.erase(renderPass);
}
VkResult DispatchCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain);
safe_VkSwapchainCreateInfoKHR *local_pCreateInfo = NULL;
if (pCreateInfo) {
local_pCreateInfo = new safe_VkSwapchainCreateInfoKHR(pCreateInfo);
local_pCreateInfo->oldSwapchain = layer_data->Unwrap(pCreateInfo->oldSwapchain);
// Surface is instance-level object
local_pCreateInfo->surface = layer_data->Unwrap(pCreateInfo->surface);
}
VkResult result = layer_data->device_dispatch_table.CreateSwapchainKHR(device, local_pCreateInfo->ptr(), pAllocator, pSwapchain);
delete local_pCreateInfo;
if (VK_SUCCESS == result) {
*pSwapchain = layer_data->WrapNew(*pSwapchain);
}
return result;
}
VkResult DispatchCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount, const VkSwapchainCreateInfoKHR *pCreateInfos,
const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchains) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles)
return layer_data->device_dispatch_table.CreateSharedSwapchainsKHR(device, swapchainCount, pCreateInfos, pAllocator,
pSwapchains);
safe_VkSwapchainCreateInfoKHR *local_pCreateInfos = NULL;
{
if (pCreateInfos) {
local_pCreateInfos = new safe_VkSwapchainCreateInfoKHR[swapchainCount];
for (uint32_t i = 0; i < swapchainCount; ++i) {
local_pCreateInfos[i].initialize(&pCreateInfos[i]);
if (pCreateInfos[i].surface) {
// Surface is instance-level object
local_pCreateInfos[i].surface = layer_data->Unwrap(pCreateInfos[i].surface);
}
if (pCreateInfos[i].oldSwapchain) {
local_pCreateInfos[i].oldSwapchain = layer_data->Unwrap(pCreateInfos[i].oldSwapchain);
}
}
}
}
VkResult result = layer_data->device_dispatch_table.CreateSharedSwapchainsKHR(device, swapchainCount, local_pCreateInfos->ptr(),
pAllocator, pSwapchains);
delete[] local_pCreateInfos;
if (VK_SUCCESS == result) {
for (uint32_t i = 0; i < swapchainCount; i++) {
pSwapchains[i] = layer_data->WrapNew(pSwapchains[i]);
}
}
return result;
}
VkResult DispatchGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount,
VkImage *pSwapchainImages) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles)
return layer_data->device_dispatch_table.GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages);
VkSwapchainKHR wrapped_swapchain_handle = swapchain;
if (VK_NULL_HANDLE != swapchain) {
swapchain = layer_data->Unwrap(swapchain);
}
VkResult result =
layer_data->device_dispatch_table.GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages);
if ((VK_SUCCESS == result) || (VK_INCOMPLETE == result)) {
if ((*pSwapchainImageCount > 0) && pSwapchainImages) {
write_lock_guard_t lock(dispatch_lock);
auto &wrapped_swapchain_image_handles = layer_data->swapchain_wrapped_image_handle_map[wrapped_swapchain_handle];
for (uint32_t i = static_cast<uint32_t>(wrapped_swapchain_image_handles.size()); i < *pSwapchainImageCount; i++) {
wrapped_swapchain_image_handles.emplace_back(layer_data->WrapNew(pSwapchainImages[i]));
}
for (uint32_t i = 0; i < *pSwapchainImageCount; i++) {
pSwapchainImages[i] = wrapped_swapchain_image_handles[i];
}
}
}
return result;
}
void DispatchDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks *pAllocator) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.DestroySwapchainKHR(device, swapchain, pAllocator);
write_lock_guard_t lock(dispatch_lock);
auto &image_array = layer_data->swapchain_wrapped_image_handle_map[swapchain];
for (auto &image_handle : image_array) {
unique_id_mapping.erase(HandleToUint64(image_handle));
}
layer_data->swapchain_wrapped_image_handle_map.erase(swapchain);
lock.unlock();
uint64_t swapchain_id = HandleToUint64(swapchain);
auto iter = unique_id_mapping.pop(swapchain_id);
if (iter != unique_id_mapping.end()) {
swapchain = (VkSwapchainKHR)iter->second;
} else {
swapchain = (VkSwapchainKHR)0;
}
layer_data->device_dispatch_table.DestroySwapchainKHR(device, swapchain, pAllocator);
}
VkResult DispatchQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.QueuePresentKHR(queue, pPresentInfo);
safe_VkPresentInfoKHR *local_pPresentInfo = NULL;
{
if (pPresentInfo) {
local_pPresentInfo = new safe_VkPresentInfoKHR(pPresentInfo);
if (local_pPresentInfo->pWaitSemaphores) {
for (uint32_t index1 = 0; index1 < local_pPresentInfo->waitSemaphoreCount; ++index1) {
local_pPresentInfo->pWaitSemaphores[index1] = layer_data->Unwrap(pPresentInfo->pWaitSemaphores[index1]);
}
}
if (local_pPresentInfo->pSwapchains) {
for (uint32_t index1 = 0; index1 < local_pPresentInfo->swapchainCount; ++index1) {
local_pPresentInfo->pSwapchains[index1] = layer_data->Unwrap(pPresentInfo->pSwapchains[index1]);
}
}
}
}
VkResult result = layer_data->device_dispatch_table.QueuePresentKHR(queue, local_pPresentInfo->ptr());
// pResults is an output array embedded in a structure. The code generator neglects to copy back from the safe_* version,
// so handle it as a special case here:
if (pPresentInfo && pPresentInfo->pResults) {
for (uint32_t i = 0; i < pPresentInfo->swapchainCount; i++) {
pPresentInfo->pResults[i] = local_pPresentInfo->pResults[i];
}
}
delete local_pPresentInfo;
return result;
}
void DispatchDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks *pAllocator) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.DestroyDescriptorPool(device, descriptorPool, pAllocator);
write_lock_guard_t lock(dispatch_lock);
// remove references to implicitly freed descriptor sets
for(auto descriptor_set : layer_data->pool_descriptor_sets_map[descriptorPool]) {
unique_id_mapping.erase(reinterpret_cast<uint64_t &>(descriptor_set));
}
layer_data->pool_descriptor_sets_map.erase(descriptorPool);
lock.unlock();
uint64_t descriptorPool_id = reinterpret_cast<uint64_t &>(descriptorPool);
auto iter = unique_id_mapping.pop(descriptorPool_id);
if (iter != unique_id_mapping.end()) {
descriptorPool = (VkDescriptorPool)iter->second;
} else {
descriptorPool = (VkDescriptorPool)0;
}
layer_data->device_dispatch_table.DestroyDescriptorPool(device, descriptorPool, pAllocator);
}
VkResult DispatchResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.ResetDescriptorPool(device, descriptorPool, flags);
VkDescriptorPool local_descriptor_pool = VK_NULL_HANDLE;
{
local_descriptor_pool = layer_data->Unwrap(descriptorPool);
}
VkResult result = layer_data->device_dispatch_table.ResetDescriptorPool(device, local_descriptor_pool, flags);
if (VK_SUCCESS == result) {
write_lock_guard_t lock(dispatch_lock);
// remove references to implicitly freed descriptor sets
for(auto descriptor_set : layer_data->pool_descriptor_sets_map[descriptorPool]) {
unique_id_mapping.erase(reinterpret_cast<uint64_t &>(descriptor_set));
}
layer_data->pool_descriptor_sets_map[descriptorPool].clear();
}
return result;
}
VkResult DispatchAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo,
VkDescriptorSet *pDescriptorSets) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.AllocateDescriptorSets(device, pAllocateInfo, pDescriptorSets);
safe_VkDescriptorSetAllocateInfo *local_pAllocateInfo = NULL;
{
if (pAllocateInfo) {
local_pAllocateInfo = new safe_VkDescriptorSetAllocateInfo(pAllocateInfo);
if (pAllocateInfo->descriptorPool) {
local_pAllocateInfo->descriptorPool = layer_data->Unwrap(pAllocateInfo->descriptorPool);
}
if (local_pAllocateInfo->pSetLayouts) {
for (uint32_t index1 = 0; index1 < local_pAllocateInfo->descriptorSetCount; ++index1) {
local_pAllocateInfo->pSetLayouts[index1] = layer_data->Unwrap(local_pAllocateInfo->pSetLayouts[index1]);
}
}
}
}
VkResult result = layer_data->device_dispatch_table.AllocateDescriptorSets(
device, (const VkDescriptorSetAllocateInfo *)local_pAllocateInfo, pDescriptorSets);
if (local_pAllocateInfo) {
delete local_pAllocateInfo;
}
if (VK_SUCCESS == result) {
write_lock_guard_t lock(dispatch_lock);
auto &pool_descriptor_sets = layer_data->pool_descriptor_sets_map[pAllocateInfo->descriptorPool];
for (uint32_t index0 = 0; index0 < pAllocateInfo->descriptorSetCount; index0++) {
pDescriptorSets[index0] = layer_data->WrapNew(pDescriptorSets[index0]);
pool_descriptor_sets.insert(pDescriptorSets[index0]);
}
}
return result;
}
VkResult DispatchFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount,
const VkDescriptorSet *pDescriptorSets) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles)
return layer_data->device_dispatch_table.FreeDescriptorSets(device, descriptorPool, descriptorSetCount, pDescriptorSets);
VkDescriptorSet *local_pDescriptorSets = NULL;
VkDescriptorPool local_descriptor_pool = VK_NULL_HANDLE;
{
local_descriptor_pool = layer_data->Unwrap(descriptorPool);
if (pDescriptorSets) {
local_pDescriptorSets = new VkDescriptorSet[descriptorSetCount];
for (uint32_t index0 = 0; index0 < descriptorSetCount; ++index0) {
local_pDescriptorSets[index0] = layer_data->Unwrap(pDescriptorSets[index0]);
}
}
}
VkResult result = layer_data->device_dispatch_table.FreeDescriptorSets(device, local_descriptor_pool, descriptorSetCount,
(const VkDescriptorSet *)local_pDescriptorSets);
if (local_pDescriptorSets) delete[] local_pDescriptorSets;
if ((VK_SUCCESS == result) && (pDescriptorSets)) {
write_lock_guard_t lock(dispatch_lock);
auto &pool_descriptor_sets = layer_data->pool_descriptor_sets_map[descriptorPool];
for (uint32_t index0 = 0; index0 < descriptorSetCount; index0++) {
VkDescriptorSet handle = pDescriptorSets[index0];
pool_descriptor_sets.erase(handle);
uint64_t unique_id = reinterpret_cast<uint64_t &>(handle);
unique_id_mapping.erase(unique_id);
}
}
return result;
}
// This is the core version of this routine. The extension version is below.
VkResult DispatchCreateDescriptorUpdateTemplate(VkDevice device, const VkDescriptorUpdateTemplateCreateInfoKHR *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkDescriptorUpdateTemplateKHR *pDescriptorUpdateTemplate) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles)
return layer_data->device_dispatch_table.CreateDescriptorUpdateTemplate(device, pCreateInfo, pAllocator,
pDescriptorUpdateTemplate);
safe_VkDescriptorUpdateTemplateCreateInfo var_local_pCreateInfo;
safe_VkDescriptorUpdateTemplateCreateInfo *local_pCreateInfo = NULL;
if (pCreateInfo) {
local_pCreateInfo = &var_local_pCreateInfo;
local_pCreateInfo->initialize(pCreateInfo);
if (pCreateInfo->templateType == VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET) {
local_pCreateInfo->descriptorSetLayout = layer_data->Unwrap(pCreateInfo->descriptorSetLayout);
}
if (pCreateInfo->templateType == VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR) {
local_pCreateInfo->pipelineLayout = layer_data->Unwrap(pCreateInfo->pipelineLayout);
}
}
VkResult result = layer_data->device_dispatch_table.CreateDescriptorUpdateTemplate(device, local_pCreateInfo->ptr(), pAllocator,
pDescriptorUpdateTemplate);
if (VK_SUCCESS == result) {
*pDescriptorUpdateTemplate = layer_data->WrapNew(*pDescriptorUpdateTemplate);
// Shadow template createInfo for later updates
if (local_pCreateInfo) {
write_lock_guard_t lock(dispatch_lock);
std::unique_ptr<TEMPLATE_STATE> template_state(new TEMPLATE_STATE(*pDescriptorUpdateTemplate, local_pCreateInfo));
layer_data->desc_template_createinfo_map[(uint64_t)*pDescriptorUpdateTemplate] = std::move(template_state);
}
}
return result;
}
// This is the extension version of this routine. The core version is above.
VkResult DispatchCreateDescriptorUpdateTemplateKHR(VkDevice device, const VkDescriptorUpdateTemplateCreateInfoKHR *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkDescriptorUpdateTemplateKHR *pDescriptorUpdateTemplate) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles)
return layer_data->device_dispatch_table.CreateDescriptorUpdateTemplateKHR(device, pCreateInfo, pAllocator,
pDescriptorUpdateTemplate);
safe_VkDescriptorUpdateTemplateCreateInfo var_local_pCreateInfo;
safe_VkDescriptorUpdateTemplateCreateInfo *local_pCreateInfo = NULL;
if (pCreateInfo) {
local_pCreateInfo = &var_local_pCreateInfo;
local_pCreateInfo->initialize(pCreateInfo);
if (pCreateInfo->templateType == VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET) {
local_pCreateInfo->descriptorSetLayout = layer_data->Unwrap(pCreateInfo->descriptorSetLayout);
}
if (pCreateInfo->templateType == VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR) {
local_pCreateInfo->pipelineLayout = layer_data->Unwrap(pCreateInfo->pipelineLayout);
}
}
VkResult result = layer_data->device_dispatch_table.CreateDescriptorUpdateTemplateKHR(device, local_pCreateInfo->ptr(),
pAllocator, pDescriptorUpdateTemplate);
if (VK_SUCCESS == result) {
*pDescriptorUpdateTemplate = layer_data->WrapNew(*pDescriptorUpdateTemplate);
// Shadow template createInfo for later updates
if (local_pCreateInfo) {
write_lock_guard_t lock(dispatch_lock);
std::unique_ptr<TEMPLATE_STATE> template_state(new TEMPLATE_STATE(*pDescriptorUpdateTemplate, local_pCreateInfo));
layer_data->desc_template_createinfo_map[(uint64_t)*pDescriptorUpdateTemplate] = std::move(template_state);
}
}
return result;
}
// This is the core version of this routine. The extension version is below.
void DispatchDestroyDescriptorUpdateTemplate(VkDevice device, VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate,
const VkAllocationCallbacks *pAllocator) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles)
return layer_data->device_dispatch_table.DestroyDescriptorUpdateTemplate(device, descriptorUpdateTemplate, pAllocator);
write_lock_guard_t lock(dispatch_lock);
uint64_t descriptor_update_template_id = reinterpret_cast<uint64_t &>(descriptorUpdateTemplate);
layer_data->desc_template_createinfo_map.erase(descriptor_update_template_id);
lock.unlock();
auto iter = unique_id_mapping.pop(descriptor_update_template_id);
if (iter != unique_id_mapping.end()) {
descriptorUpdateTemplate = (VkDescriptorUpdateTemplate)iter->second;
} else {
descriptorUpdateTemplate = (VkDescriptorUpdateTemplate)0;
}
layer_data->device_dispatch_table.DestroyDescriptorUpdateTemplate(device, descriptorUpdateTemplate, pAllocator);
}
// This is the extension version of this routine. The core version is above.
void DispatchDestroyDescriptorUpdateTemplateKHR(VkDevice device, VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate,
const VkAllocationCallbacks *pAllocator) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles)
return layer_data->device_dispatch_table.DestroyDescriptorUpdateTemplateKHR(device, descriptorUpdateTemplate, pAllocator);
write_lock_guard_t lock(dispatch_lock);
uint64_t descriptor_update_template_id = reinterpret_cast<uint64_t &>(descriptorUpdateTemplate);
layer_data->desc_template_createinfo_map.erase(descriptor_update_template_id);
lock.unlock();
auto iter = unique_id_mapping.pop(descriptor_update_template_id);
if (iter != unique_id_mapping.end()) {
descriptorUpdateTemplate = (VkDescriptorUpdateTemplate)iter->second;
} else {
descriptorUpdateTemplate = (VkDescriptorUpdateTemplate)0;
}
layer_data->device_dispatch_table.DestroyDescriptorUpdateTemplateKHR(device, descriptorUpdateTemplate, pAllocator);
}
void *BuildUnwrappedUpdateTemplateBuffer(ValidationObject *layer_data, uint64_t descriptorUpdateTemplate, const void *pData) {
auto const template_map_entry = layer_data->desc_template_createinfo_map.find(descriptorUpdateTemplate);
auto const &create_info = template_map_entry->second->create_info;
size_t allocation_size = 0;
std::vector<std::tuple<size_t, VulkanObjectType, uint64_t, size_t>> template_entries;
for (uint32_t i = 0; i < create_info.descriptorUpdateEntryCount; i++) {
for (uint32_t j = 0; j < create_info.pDescriptorUpdateEntries[i].descriptorCount; j++) {
size_t offset = create_info.pDescriptorUpdateEntries[i].offset + j * create_info.pDescriptorUpdateEntries[i].stride;
char *update_entry = (char *)(pData) + offset;
switch (create_info.pDescriptorUpdateEntries[i].descriptorType) {
case VK_DESCRIPTOR_TYPE_SAMPLER:
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT: {
auto image_entry = reinterpret_cast<VkDescriptorImageInfo *>(update_entry);
allocation_size = std::max(allocation_size, offset + sizeof(VkDescriptorImageInfo));
VkDescriptorImageInfo *wrapped_entry = new VkDescriptorImageInfo(*image_entry);
wrapped_entry->sampler = layer_data->Unwrap(image_entry->sampler);
wrapped_entry->imageView = layer_data->Unwrap(image_entry->imageView);
template_entries.emplace_back(offset, kVulkanObjectTypeImage, CastToUint64(wrapped_entry), 0);
} break;
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: {
auto buffer_entry = reinterpret_cast<VkDescriptorBufferInfo *>(update_entry);
allocation_size = std::max(allocation_size, offset + sizeof(VkDescriptorBufferInfo));
VkDescriptorBufferInfo *wrapped_entry = new VkDescriptorBufferInfo(*buffer_entry);
wrapped_entry->buffer = layer_data->Unwrap(buffer_entry->buffer);
template_entries.emplace_back(offset, kVulkanObjectTypeBuffer, CastToUint64(wrapped_entry), 0);
} break;
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: {
auto buffer_view_handle = reinterpret_cast<VkBufferView *>(update_entry);
allocation_size = std::max(allocation_size, offset + sizeof(VkBufferView));
VkBufferView wrapped_entry = layer_data->Unwrap(*buffer_view_handle);
template_entries.emplace_back(offset, kVulkanObjectTypeBufferView, CastToUint64(wrapped_entry), 0);
} break;
case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT: {
size_t numBytes = create_info.pDescriptorUpdateEntries[i].descriptorCount;
allocation_size = std::max(allocation_size, offset + numBytes);
// nothing to unwrap, just plain data
template_entries.emplace_back(offset, kVulkanObjectTypeUnknown, CastToUint64(update_entry),
numBytes);
// to break out of the loop
j = create_info.pDescriptorUpdateEntries[i].descriptorCount;
} break;
default:
assert(0);
break;
}
}
}
// Allocate required buffer size and populate with source/unwrapped data
void *unwrapped_data = malloc(allocation_size);
for (auto &this_entry : template_entries) {
VulkanObjectType type = std::get<1>(this_entry);
void *destination = (char *)unwrapped_data + std::get<0>(this_entry);
uint64_t source = std::get<2>(this_entry);
size_t size = std::get<3>(this_entry);
if (size != 0) {
assert(type == kVulkanObjectTypeUnknown);
memcpy(destination, CastFromUint64<void *>(source), size);
} else {
switch (type) {
case kVulkanObjectTypeImage:
*(reinterpret_cast<VkDescriptorImageInfo *>(destination)) =
*(reinterpret_cast<VkDescriptorImageInfo *>(source));
delete CastFromUint64<VkDescriptorImageInfo *>(source);
break;
case kVulkanObjectTypeBuffer:
*(reinterpret_cast<VkDescriptorBufferInfo *>(destination)) =
*(CastFromUint64<VkDescriptorBufferInfo *>(source));
delete CastFromUint64<VkDescriptorBufferInfo *>(source);
break;
case kVulkanObjectTypeBufferView:
*(reinterpret_cast<VkBufferView *>(destination)) = CastFromUint64<VkBufferView>(source);
break;
default:
assert(0);
break;
}
}
}
return (void *)unwrapped_data;
}
void DispatchUpdateDescriptorSetWithTemplate(VkDevice device, VkDescriptorSet descriptorSet,
VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate, const void *pData) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles)
return layer_data->device_dispatch_table.UpdateDescriptorSetWithTemplate(device, descriptorSet, descriptorUpdateTemplate,
pData);
uint64_t template_handle = reinterpret_cast<uint64_t &>(descriptorUpdateTemplate);
void *unwrapped_buffer = nullptr;
{
read_lock_guard_t lock(dispatch_lock);
descriptorSet = layer_data->Unwrap(descriptorSet);
descriptorUpdateTemplate = (VkDescriptorUpdateTemplate)layer_data->Unwrap(descriptorUpdateTemplate);
unwrapped_buffer = BuildUnwrappedUpdateTemplateBuffer(layer_data, template_handle, pData);
}
layer_data->device_dispatch_table.UpdateDescriptorSetWithTemplate(device, descriptorSet, descriptorUpdateTemplate, unwrapped_buffer);
free(unwrapped_buffer);
}
void DispatchUpdateDescriptorSetWithTemplateKHR(VkDevice device, VkDescriptorSet descriptorSet,
VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate, const void *pData) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles)
return layer_data->device_dispatch_table.UpdateDescriptorSetWithTemplateKHR(device, descriptorSet, descriptorUpdateTemplate,
pData);
uint64_t template_handle = reinterpret_cast<uint64_t &>(descriptorUpdateTemplate);
void *unwrapped_buffer = nullptr;
{
read_lock_guard_t lock(dispatch_lock);
descriptorSet = layer_data->Unwrap(descriptorSet);
descriptorUpdateTemplate = layer_data->Unwrap(descriptorUpdateTemplate);
unwrapped_buffer = BuildUnwrappedUpdateTemplateBuffer(layer_data, template_handle, pData);
}
layer_data->device_dispatch_table.UpdateDescriptorSetWithTemplateKHR(device, descriptorSet, descriptorUpdateTemplate, unwrapped_buffer);
free(unwrapped_buffer);
}
void DispatchCmdPushDescriptorSetWithTemplateKHR(VkCommandBuffer commandBuffer,
VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate, VkPipelineLayout layout,
uint32_t set, const void *pData) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
if (!wrap_handles)
return layer_data->device_dispatch_table.CmdPushDescriptorSetWithTemplateKHR(commandBuffer, descriptorUpdateTemplate,
layout, set, pData);
uint64_t template_handle = reinterpret_cast<uint64_t &>(descriptorUpdateTemplate);
void *unwrapped_buffer = nullptr;
{
read_lock_guard_t lock(dispatch_lock);
descriptorUpdateTemplate = layer_data->Unwrap(descriptorUpdateTemplate);
layout = layer_data->Unwrap(layout);
unwrapped_buffer = BuildUnwrappedUpdateTemplateBuffer(layer_data, template_handle, pData);
}
layer_data->device_dispatch_table.CmdPushDescriptorSetWithTemplateKHR(commandBuffer, descriptorUpdateTemplate, layout, set,
unwrapped_buffer);
free(unwrapped_buffer);
}
VkResult DispatchGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
VkDisplayPropertiesKHR *pProperties) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
VkResult result =
layer_data->instance_dispatch_table.GetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, pPropertyCount, pProperties);
if (!wrap_handles) return result;
if ((result == VK_SUCCESS || result == VK_INCOMPLETE) && pProperties) {
for (uint32_t idx0 = 0; idx0 < *pPropertyCount; ++idx0) {
pProperties[idx0].display = layer_data->MaybeWrapDisplay(pProperties[idx0].display, layer_data);
}
}
return result;
}
VkResult DispatchGetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
VkDisplayProperties2KHR *pProperties) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
VkResult result =
layer_data->instance_dispatch_table.GetPhysicalDeviceDisplayProperties2KHR(physicalDevice, pPropertyCount, pProperties);
if (!wrap_handles) return result;
if ((result == VK_SUCCESS || result == VK_INCOMPLETE) && pProperties) {
for (uint32_t idx0 = 0; idx0 < *pPropertyCount; ++idx0) {
pProperties[idx0].displayProperties.display =
layer_data->MaybeWrapDisplay(pProperties[idx0].displayProperties.display, layer_data);
}
}
return result;
}
VkResult DispatchGetPhysicalDeviceDisplayPlanePropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
VkDisplayPlanePropertiesKHR *pProperties) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
VkResult result =
layer_data->instance_dispatch_table.GetPhysicalDeviceDisplayPlanePropertiesKHR(physicalDevice, pPropertyCount, pProperties);
if (!wrap_handles) return result;
if ((result == VK_SUCCESS || result == VK_INCOMPLETE) && pProperties) {
for (uint32_t idx0 = 0; idx0 < *pPropertyCount; ++idx0) {
VkDisplayKHR &opt_display = pProperties[idx0].currentDisplay;
if (opt_display) opt_display = layer_data->MaybeWrapDisplay(opt_display, layer_data);
}
}
return result;
}
VkResult DispatchGetPhysicalDeviceDisplayPlaneProperties2KHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
VkDisplayPlaneProperties2KHR *pProperties) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
VkResult result = layer_data->instance_dispatch_table.GetPhysicalDeviceDisplayPlaneProperties2KHR(physicalDevice,
pPropertyCount, pProperties);
if (!wrap_handles) return result;
if ((result == VK_SUCCESS || result == VK_INCOMPLETE) && pProperties) {
for (uint32_t idx0 = 0; idx0 < *pPropertyCount; ++idx0) {
VkDisplayKHR &opt_display = pProperties[idx0].displayPlaneProperties.currentDisplay;
if (opt_display) opt_display = layer_data->MaybeWrapDisplay(opt_display, layer_data);
}
}
return result;
}
VkResult DispatchGetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, uint32_t planeIndex, uint32_t *pDisplayCount,
VkDisplayKHR *pDisplays) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
VkResult result = layer_data->instance_dispatch_table.GetDisplayPlaneSupportedDisplaysKHR(physicalDevice, planeIndex,
pDisplayCount, pDisplays);
if ((result == VK_SUCCESS || result == VK_INCOMPLETE) && pDisplays) {
if (!wrap_handles) return result;
for (uint32_t i = 0; i < *pDisplayCount; ++i) {
if (pDisplays[i]) pDisplays[i] = layer_data->MaybeWrapDisplay(pDisplays[i], layer_data);
}
}
return result;
}
VkResult DispatchGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t *pPropertyCount,
VkDisplayModePropertiesKHR *pProperties) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
if (!wrap_handles)
return layer_data->instance_dispatch_table.GetDisplayModePropertiesKHR(physicalDevice, display, pPropertyCount,
pProperties);
{
display = layer_data->Unwrap(display);
}
VkResult result = layer_data->instance_dispatch_table.GetDisplayModePropertiesKHR(physicalDevice, display, pPropertyCount, pProperties);
if ((result == VK_SUCCESS || result == VK_INCOMPLETE) && pProperties) {
for (uint32_t idx0 = 0; idx0 < *pPropertyCount; ++idx0) {
pProperties[idx0].displayMode = layer_data->WrapNew(pProperties[idx0].displayMode);
}
}
return result;
}
VkResult DispatchGetDisplayModeProperties2KHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t *pPropertyCount,
VkDisplayModeProperties2KHR *pProperties) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
if (!wrap_handles)
return layer_data->instance_dispatch_table.GetDisplayModeProperties2KHR(physicalDevice, display, pPropertyCount,
pProperties);
{
display = layer_data->Unwrap(display);
}
VkResult result =
layer_data->instance_dispatch_table.GetDisplayModeProperties2KHR(physicalDevice, display, pPropertyCount, pProperties);
if ((result == VK_SUCCESS || result == VK_INCOMPLETE) && pProperties) {
for (uint32_t idx0 = 0; idx0 < *pPropertyCount; ++idx0) {
pProperties[idx0].displayModeProperties.displayMode = layer_data->WrapNew(pProperties[idx0].displayModeProperties.displayMode);
}
}
return result;
}
VkResult DispatchDebugMarkerSetObjectTagEXT(VkDevice device, const VkDebugMarkerObjectTagInfoEXT *pTagInfo) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.DebugMarkerSetObjectTagEXT(device, pTagInfo);
safe_VkDebugMarkerObjectTagInfoEXT local_tag_info(pTagInfo);
{
auto it = unique_id_mapping.find(reinterpret_cast<uint64_t &>(local_tag_info.object));
if (it != unique_id_mapping.end()) {
local_tag_info.object = it->second;
}
}
VkResult result = layer_data->device_dispatch_table.DebugMarkerSetObjectTagEXT(device,
reinterpret_cast<VkDebugMarkerObjectTagInfoEXT *>(&local_tag_info));
return result;
}
VkResult DispatchDebugMarkerSetObjectNameEXT(VkDevice device, const VkDebugMarkerObjectNameInfoEXT *pNameInfo) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.DebugMarkerSetObjectNameEXT(device, pNameInfo);
safe_VkDebugMarkerObjectNameInfoEXT local_name_info(pNameInfo);
{
auto it = unique_id_mapping.find(reinterpret_cast<uint64_t &>(local_name_info.object));
if (it != unique_id_mapping.end()) {
local_name_info.object = it->second;
}
}
VkResult result = layer_data->device_dispatch_table.DebugMarkerSetObjectNameEXT(
device, reinterpret_cast<VkDebugMarkerObjectNameInfoEXT *>(&local_name_info));
return result;
}
// VK_EXT_debug_utils
VkResult DispatchSetDebugUtilsObjectTagEXT(VkDevice device, const VkDebugUtilsObjectTagInfoEXT *pTagInfo) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.SetDebugUtilsObjectTagEXT(device, pTagInfo);
safe_VkDebugUtilsObjectTagInfoEXT local_tag_info(pTagInfo);
{
auto it = unique_id_mapping.find(reinterpret_cast<uint64_t &>(local_tag_info.objectHandle));
if (it != unique_id_mapping.end()) {
local_tag_info.objectHandle = it->second;
}
}
VkResult result = layer_data->device_dispatch_table.SetDebugUtilsObjectTagEXT(
device, reinterpret_cast<const VkDebugUtilsObjectTagInfoEXT *>(&local_tag_info));
return result;
}
VkResult DispatchSetDebugUtilsObjectNameEXT(VkDevice device, const VkDebugUtilsObjectNameInfoEXT *pNameInfo) {
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.SetDebugUtilsObjectNameEXT(device, pNameInfo);
safe_VkDebugUtilsObjectNameInfoEXT local_name_info(pNameInfo);
{
auto it = unique_id_mapping.find(reinterpret_cast<uint64_t &>(local_name_info.objectHandle));
if (it != unique_id_mapping.end()) {
local_name_info.objectHandle = it->second;
}
}
VkResult result = layer_data->device_dispatch_table.SetDebugUtilsObjectNameEXT(
device, reinterpret_cast<const VkDebugUtilsObjectNameInfoEXT *>(&local_name_info));
return result;
}
// Skip vkCreateInstance dispatch, manually generated
// Skip vkDestroyInstance dispatch, manually generated
VkResult DispatchEnumeratePhysicalDevices(
VkInstance instance,
uint32_t* pPhysicalDeviceCount,
VkPhysicalDevice* pPhysicalDevices)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
VkResult result = layer_data->instance_dispatch_table.EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices);
return result;
}
void DispatchGetPhysicalDeviceFeatures(
VkPhysicalDevice physicalDevice,
VkPhysicalDeviceFeatures* pFeatures)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
layer_data->instance_dispatch_table.GetPhysicalDeviceFeatures(physicalDevice, pFeatures);
}
void DispatchGetPhysicalDeviceFormatProperties(
VkPhysicalDevice physicalDevice,
VkFormat format,
VkFormatProperties* pFormatProperties)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
layer_data->instance_dispatch_table.GetPhysicalDeviceFormatProperties(physicalDevice, format, pFormatProperties);
}
VkResult DispatchGetPhysicalDeviceImageFormatProperties(
VkPhysicalDevice physicalDevice,
VkFormat format,
VkImageType type,
VkImageTiling tiling,
VkImageUsageFlags usage,
VkImageCreateFlags flags,
VkImageFormatProperties* pImageFormatProperties)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
VkResult result = layer_data->instance_dispatch_table.GetPhysicalDeviceImageFormatProperties(physicalDevice, format, type, tiling, usage, flags, pImageFormatProperties);
return result;
}
void DispatchGetPhysicalDeviceProperties(
VkPhysicalDevice physicalDevice,
VkPhysicalDeviceProperties* pProperties)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
layer_data->instance_dispatch_table.GetPhysicalDeviceProperties(physicalDevice, pProperties);
}
void DispatchGetPhysicalDeviceQueueFamilyProperties(
VkPhysicalDevice physicalDevice,
uint32_t* pQueueFamilyPropertyCount,
VkQueueFamilyProperties* pQueueFamilyProperties)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
layer_data->instance_dispatch_table.GetPhysicalDeviceQueueFamilyProperties(physicalDevice, pQueueFamilyPropertyCount, pQueueFamilyProperties);
}
void DispatchGetPhysicalDeviceMemoryProperties(
VkPhysicalDevice physicalDevice,
VkPhysicalDeviceMemoryProperties* pMemoryProperties)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
layer_data->instance_dispatch_table.GetPhysicalDeviceMemoryProperties(physicalDevice, pMemoryProperties);
}
PFN_vkVoidFunction DispatchGetInstanceProcAddr(
VkInstance instance,
const char* pName)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map);
PFN_vkVoidFunction result = layer_data->instance_dispatch_table.GetInstanceProcAddr(instance, pName);
return result;
}
PFN_vkVoidFunction DispatchGetDeviceProcAddr(
VkDevice device,
const char* pName)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
PFN_vkVoidFunction result = layer_data->device_dispatch_table.GetDeviceProcAddr(device, pName);
return result;
}
// Skip vkCreateDevice dispatch, manually generated
// Skip vkDestroyDevice dispatch, manually generated
// Skip vkEnumerateInstanceExtensionProperties dispatch, manually generated
// Skip vkEnumerateDeviceExtensionProperties dispatch, manually generated
// Skip vkEnumerateInstanceLayerProperties dispatch, manually generated
// Skip vkEnumerateDeviceLayerProperties dispatch, manually generated
void DispatchGetDeviceQueue(
VkDevice device,
uint32_t queueFamilyIndex,
uint32_t queueIndex,
VkQueue* pQueue)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
layer_data->device_dispatch_table.GetDeviceQueue(device, queueFamilyIndex, queueIndex, pQueue);
}
VkResult DispatchQueueSubmit(
VkQueue queue,
uint32_t submitCount,
const VkSubmitInfo* pSubmits,
VkFence fence)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.QueueSubmit(queue, submitCount, pSubmits, fence);
safe_VkSubmitInfo *local_pSubmits = NULL;
{
if (pSubmits) {
local_pSubmits = new safe_VkSubmitInfo[submitCount];
for (uint32_t index0 = 0; index0 < submitCount; ++index0) {
local_pSubmits[index0].initialize(&pSubmits[index0]);
WrapPnextChainHandles(layer_data, local_pSubmits[index0].pNext);
if (local_pSubmits[index0].pWaitSemaphores) {
for (uint32_t index1 = 0; index1 < local_pSubmits[index0].waitSemaphoreCount; ++index1) {
local_pSubmits[index0].pWaitSemaphores[index1] = layer_data->Unwrap(local_pSubmits[index0].pWaitSemaphores[index1]);
}
}
if (local_pSubmits[index0].pSignalSemaphores) {
for (uint32_t index1 = 0; index1 < local_pSubmits[index0].signalSemaphoreCount; ++index1) {
local_pSubmits[index0].pSignalSemaphores[index1] = layer_data->Unwrap(local_pSubmits[index0].pSignalSemaphores[index1]);
}
}
}
}
fence = layer_data->Unwrap(fence);
}
VkResult result = layer_data->device_dispatch_table.QueueSubmit(queue, submitCount, (const VkSubmitInfo*)local_pSubmits, fence);
if (local_pSubmits) {
delete[] local_pSubmits;
}
return result;
}
VkResult DispatchQueueWaitIdle(
VkQueue queue)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map);
VkResult result = layer_data->device_dispatch_table.QueueWaitIdle(queue);
return result;
}
VkResult DispatchDeviceWaitIdle(
VkDevice device)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
VkResult result = layer_data->device_dispatch_table.DeviceWaitIdle(device);
return result;
}
VkResult DispatchAllocateMemory(
VkDevice device,
const VkMemoryAllocateInfo* pAllocateInfo,
const VkAllocationCallbacks* pAllocator,
VkDeviceMemory* pMemory)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.AllocateMemory(device, pAllocateInfo, pAllocator, pMemory);
safe_VkMemoryAllocateInfo var_local_pAllocateInfo;
safe_VkMemoryAllocateInfo *local_pAllocateInfo = NULL;
{
if (pAllocateInfo) {
local_pAllocateInfo = &var_local_pAllocateInfo;
local_pAllocateInfo->initialize(pAllocateInfo);
WrapPnextChainHandles(layer_data, local_pAllocateInfo->pNext);
}
}
VkResult result = layer_data->device_dispatch_table.AllocateMemory(device, (const VkMemoryAllocateInfo*)local_pAllocateInfo, pAllocator, pMemory);
if (VK_SUCCESS == result) {
*pMemory = layer_data->WrapNew(*pMemory);
}
return result;
}
void DispatchFreeMemory(
VkDevice device,
VkDeviceMemory memory,
const VkAllocationCallbacks* pAllocator)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.FreeMemory(device, memory, pAllocator);
uint64_t memory_id = reinterpret_cast<uint64_t &>(memory);
auto iter = unique_id_mapping.pop(memory_id);
if (iter != unique_id_mapping.end()) {
memory = (VkDeviceMemory)iter->second;
} else {
memory = (VkDeviceMemory)0;
}
layer_data->device_dispatch_table.FreeMemory(device, memory, pAllocator);
}
VkResult DispatchMapMemory(
VkDevice device,
VkDeviceMemory memory,
VkDeviceSize offset,
VkDeviceSize size,
VkMemoryMapFlags flags,
void** ppData)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.MapMemory(device, memory, offset, size, flags, ppData);
{
memory = layer_data->Unwrap(memory);
}
VkResult result = layer_data->device_dispatch_table.MapMemory(device, memory, offset, size, flags, ppData);
return result;
}
void DispatchUnmapMemory(
VkDevice device,
VkDeviceMemory memory)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.UnmapMemory(device, memory);
{
memory = layer_data->Unwrap(memory);
}
layer_data->device_dispatch_table.UnmapMemory(device, memory);
}
VkResult DispatchFlushMappedMemoryRanges(
VkDevice device,
uint32_t memoryRangeCount,
const VkMappedMemoryRange* pMemoryRanges)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.FlushMappedMemoryRanges(device, memoryRangeCount, pMemoryRanges);
safe_VkMappedMemoryRange *local_pMemoryRanges = NULL;
{
if (pMemoryRanges) {
local_pMemoryRanges = new safe_VkMappedMemoryRange[memoryRangeCount];
for (uint32_t index0 = 0; index0 < memoryRangeCount; ++index0) {
local_pMemoryRanges[index0].initialize(&pMemoryRanges[index0]);
if (pMemoryRanges[index0].memory) {
local_pMemoryRanges[index0].memory = layer_data->Unwrap(pMemoryRanges[index0].memory);
}
}
}
}
VkResult result = layer_data->device_dispatch_table.FlushMappedMemoryRanges(device, memoryRangeCount, (const VkMappedMemoryRange*)local_pMemoryRanges);
if (local_pMemoryRanges) {
delete[] local_pMemoryRanges;
}
return result;
}
VkResult DispatchInvalidateMappedMemoryRanges(
VkDevice device,
uint32_t memoryRangeCount,
const VkMappedMemoryRange* pMemoryRanges)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.InvalidateMappedMemoryRanges(device, memoryRangeCount, pMemoryRanges);
safe_VkMappedMemoryRange *local_pMemoryRanges = NULL;
{
if (pMemoryRanges) {
local_pMemoryRanges = new safe_VkMappedMemoryRange[memoryRangeCount];
for (uint32_t index0 = 0; index0 < memoryRangeCount; ++index0) {
local_pMemoryRanges[index0].initialize(&pMemoryRanges[index0]);
if (pMemoryRanges[index0].memory) {
local_pMemoryRanges[index0].memory = layer_data->Unwrap(pMemoryRanges[index0].memory);
}
}
}
}
VkResult result = layer_data->device_dispatch_table.InvalidateMappedMemoryRanges(device, memoryRangeCount, (const VkMappedMemoryRange*)local_pMemoryRanges);
if (local_pMemoryRanges) {
delete[] local_pMemoryRanges;
}
return result;
}
void DispatchGetDeviceMemoryCommitment(
VkDevice device,
VkDeviceMemory memory,
VkDeviceSize* pCommittedMemoryInBytes)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.GetDeviceMemoryCommitment(device, memory, pCommittedMemoryInBytes);
{
memory = layer_data->Unwrap(memory);
}
layer_data->device_dispatch_table.GetDeviceMemoryCommitment(device, memory, pCommittedMemoryInBytes);
}
VkResult DispatchBindBufferMemory(
VkDevice device,
VkBuffer buffer,
VkDeviceMemory memory,
VkDeviceSize memoryOffset)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.BindBufferMemory(device, buffer, memory, memoryOffset);
{
buffer = layer_data->Unwrap(buffer);
memory = layer_data->Unwrap(memory);
}
VkResult result = layer_data->device_dispatch_table.BindBufferMemory(device, buffer, memory, memoryOffset);
return result;
}
VkResult DispatchBindImageMemory(
VkDevice device,
VkImage image,
VkDeviceMemory memory,
VkDeviceSize memoryOffset)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.BindImageMemory(device, image, memory, memoryOffset);
{
image = layer_data->Unwrap(image);
memory = layer_data->Unwrap(memory);
}
VkResult result = layer_data->device_dispatch_table.BindImageMemory(device, image, memory, memoryOffset);
return result;
}
void DispatchGetBufferMemoryRequirements(
VkDevice device,
VkBuffer buffer,
VkMemoryRequirements* pMemoryRequirements)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.GetBufferMemoryRequirements(device, buffer, pMemoryRequirements);
{
buffer = layer_data->Unwrap(buffer);
}
layer_data->device_dispatch_table.GetBufferMemoryRequirements(device, buffer, pMemoryRequirements);
}
void DispatchGetImageMemoryRequirements(
VkDevice device,
VkImage image,
VkMemoryRequirements* pMemoryRequirements)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.GetImageMemoryRequirements(device, image, pMemoryRequirements);
{
image = layer_data->Unwrap(image);
}
layer_data->device_dispatch_table.GetImageMemoryRequirements(device, image, pMemoryRequirements);
}
void DispatchGetImageSparseMemoryRequirements(
VkDevice device,
VkImage image,
uint32_t* pSparseMemoryRequirementCount,
VkSparseImageMemoryRequirements* pSparseMemoryRequirements)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.GetImageSparseMemoryRequirements(device, image, pSparseMemoryRequirementCount, pSparseMemoryRequirements);
{
image = layer_data->Unwrap(image);
}
layer_data->device_dispatch_table.GetImageSparseMemoryRequirements(device, image, pSparseMemoryRequirementCount, pSparseMemoryRequirements);
}
void DispatchGetPhysicalDeviceSparseImageFormatProperties(
VkPhysicalDevice physicalDevice,
VkFormat format,
VkImageType type,
VkSampleCountFlagBits samples,
VkImageUsageFlags usage,
VkImageTiling tiling,
uint32_t* pPropertyCount,
VkSparseImageFormatProperties* pProperties)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map);
layer_data->instance_dispatch_table.GetPhysicalDeviceSparseImageFormatProperties(physicalDevice, format, type, samples, usage, tiling, pPropertyCount, pProperties);
}
VkResult DispatchQueueBindSparse(
VkQueue queue,
uint32_t bindInfoCount,
const VkBindSparseInfo* pBindInfo,
VkFence fence)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.QueueBindSparse(queue, bindInfoCount, pBindInfo, fence);
safe_VkBindSparseInfo *local_pBindInfo = NULL;
{
if (pBindInfo) {
local_pBindInfo = new safe_VkBindSparseInfo[bindInfoCount];
for (uint32_t index0 = 0; index0 < bindInfoCount; ++index0) {
local_pBindInfo[index0].initialize(&pBindInfo[index0]);
WrapPnextChainHandles(layer_data, local_pBindInfo[index0].pNext);
if (local_pBindInfo[index0].pWaitSemaphores) {
for (uint32_t index1 = 0; index1 < local_pBindInfo[index0].waitSemaphoreCount; ++index1) {
local_pBindInfo[index0].pWaitSemaphores[index1] = layer_data->Unwrap(local_pBindInfo[index0].pWaitSemaphores[index1]);
}
}
if (local_pBindInfo[index0].pBufferBinds) {
for (uint32_t index1 = 0; index1 < local_pBindInfo[index0].bufferBindCount; ++index1) {
if (pBindInfo[index0].pBufferBinds[index1].buffer) {
local_pBindInfo[index0].pBufferBinds[index1].buffer = layer_data->Unwrap(pBindInfo[index0].pBufferBinds[index1].buffer);
}
if (local_pBindInfo[index0].pBufferBinds[index1].pBinds) {
for (uint32_t index2 = 0; index2 < local_pBindInfo[index0].pBufferBinds[index1].bindCount; ++index2) {
if (pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory) {
local_pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory = layer_data->Unwrap(pBindInfo[index0].pBufferBinds[index1].pBinds[index2].memory);
}
}
}
}
}
if (local_pBindInfo[index0].pImageOpaqueBinds) {
for (uint32_t index1 = 0; index1 < local_pBindInfo[index0].imageOpaqueBindCount; ++index1) {
if (pBindInfo[index0].pImageOpaqueBinds[index1].image) {
local_pBindInfo[index0].pImageOpaqueBinds[index1].image = layer_data->Unwrap(pBindInfo[index0].pImageOpaqueBinds[index1].image);
}
if (local_pBindInfo[index0].pImageOpaqueBinds[index1].pBinds) {
for (uint32_t index2 = 0; index2 < local_pBindInfo[index0].pImageOpaqueBinds[index1].bindCount; ++index2) {
if (pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory) {
local_pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory = layer_data->Unwrap(pBindInfo[index0].pImageOpaqueBinds[index1].pBinds[index2].memory);
}
}
}
}
}
if (local_pBindInfo[index0].pImageBinds) {
for (uint32_t index1 = 0; index1 < local_pBindInfo[index0].imageBindCount; ++index1) {
if (pBindInfo[index0].pImageBinds[index1].image) {
local_pBindInfo[index0].pImageBinds[index1].image = layer_data->Unwrap(pBindInfo[index0].pImageBinds[index1].image);
}
if (local_pBindInfo[index0].pImageBinds[index1].pBinds) {
for (uint32_t index2 = 0; index2 < local_pBindInfo[index0].pImageBinds[index1].bindCount; ++index2) {
if (pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory) {
local_pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory = layer_data->Unwrap(pBindInfo[index0].pImageBinds[index1].pBinds[index2].memory);
}
}
}
}
}
if (local_pBindInfo[index0].pSignalSemaphores) {
for (uint32_t index1 = 0; index1 < local_pBindInfo[index0].signalSemaphoreCount; ++index1) {
local_pBindInfo[index0].pSignalSemaphores[index1] = layer_data->Unwrap(local_pBindInfo[index0].pSignalSemaphores[index1]);
}
}
}
}
fence = layer_data->Unwrap(fence);
}
VkResult result = layer_data->device_dispatch_table.QueueBindSparse(queue, bindInfoCount, (const VkBindSparseInfo*)local_pBindInfo, fence);
if (local_pBindInfo) {
delete[] local_pBindInfo;
}
return result;
}
VkResult DispatchCreateFence(
VkDevice device,
const VkFenceCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkFence* pFence)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.CreateFence(device, pCreateInfo, pAllocator, pFence);
VkResult result = layer_data->device_dispatch_table.CreateFence(device, pCreateInfo, pAllocator, pFence);
if (VK_SUCCESS == result) {
*pFence = layer_data->WrapNew(*pFence);
}
return result;
}
void DispatchDestroyFence(
VkDevice device,
VkFence fence,
const VkAllocationCallbacks* pAllocator)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.DestroyFence(device, fence, pAllocator);
uint64_t fence_id = reinterpret_cast<uint64_t &>(fence);
auto iter = unique_id_mapping.pop(fence_id);
if (iter != unique_id_mapping.end()) {
fence = (VkFence)iter->second;
} else {
fence = (VkFence)0;
}
layer_data->device_dispatch_table.DestroyFence(device, fence, pAllocator);
}
VkResult DispatchResetFences(
VkDevice device,
uint32_t fenceCount,
const VkFence* pFences)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.ResetFences(device, fenceCount, pFences);
VkFence var_local_pFences[DISPATCH_MAX_STACK_ALLOCATIONS];
VkFence *local_pFences = NULL;
{
if (pFences) {
local_pFences = fenceCount > DISPATCH_MAX_STACK_ALLOCATIONS ? new VkFence[fenceCount] : var_local_pFences;
for (uint32_t index0 = 0; index0 < fenceCount; ++index0) {
local_pFences[index0] = layer_data->Unwrap(pFences[index0]);
}
}
}
VkResult result = layer_data->device_dispatch_table.ResetFences(device, fenceCount, (const VkFence*)local_pFences);
if (local_pFences != var_local_pFences)
delete[] local_pFences;
return result;
}
VkResult DispatchGetFenceStatus(
VkDevice device,
VkFence fence)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.GetFenceStatus(device, fence);
{
fence = layer_data->Unwrap(fence);
}
VkResult result = layer_data->device_dispatch_table.GetFenceStatus(device, fence);
return result;
}
VkResult DispatchWaitForFences(
VkDevice device,
uint32_t fenceCount,
const VkFence* pFences,
VkBool32 waitAll,
uint64_t timeout)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.WaitForFences(device, fenceCount, pFences, waitAll, timeout);
VkFence var_local_pFences[DISPATCH_MAX_STACK_ALLOCATIONS];
VkFence *local_pFences = NULL;
{
if (pFences) {
local_pFences = fenceCount > DISPATCH_MAX_STACK_ALLOCATIONS ? new VkFence[fenceCount] : var_local_pFences;
for (uint32_t index0 = 0; index0 < fenceCount; ++index0) {
local_pFences[index0] = layer_data->Unwrap(pFences[index0]);
}
}
}
VkResult result = layer_data->device_dispatch_table.WaitForFences(device, fenceCount, (const VkFence*)local_pFences, waitAll, timeout);
if (local_pFences != var_local_pFences)
delete[] local_pFences;
return result;
}
VkResult DispatchCreateSemaphore(
VkDevice device,
const VkSemaphoreCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSemaphore* pSemaphore)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.CreateSemaphore(device, pCreateInfo, pAllocator, pSemaphore);
VkResult result = layer_data->device_dispatch_table.CreateSemaphore(device, pCreateInfo, pAllocator, pSemaphore);
if (VK_SUCCESS == result) {
*pSemaphore = layer_data->WrapNew(*pSemaphore);
}
return result;
}
void DispatchDestroySemaphore(
VkDevice device,
VkSemaphore semaphore,
const VkAllocationCallbacks* pAllocator)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.DestroySemaphore(device, semaphore, pAllocator);
uint64_t semaphore_id = reinterpret_cast<uint64_t &>(semaphore);
auto iter = unique_id_mapping.pop(semaphore_id);
if (iter != unique_id_mapping.end()) {
semaphore = (VkSemaphore)iter->second;
} else {
semaphore = (VkSemaphore)0;
}
layer_data->device_dispatch_table.DestroySemaphore(device, semaphore, pAllocator);
}
VkResult DispatchCreateEvent(
VkDevice device,
const VkEventCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkEvent* pEvent)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.CreateEvent(device, pCreateInfo, pAllocator, pEvent);
VkResult result = layer_data->device_dispatch_table.CreateEvent(device, pCreateInfo, pAllocator, pEvent);
if (VK_SUCCESS == result) {
*pEvent = layer_data->WrapNew(*pEvent);
}
return result;
}
void DispatchDestroyEvent(
VkDevice device,
VkEvent event,
const VkAllocationCallbacks* pAllocator)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.DestroyEvent(device, event, pAllocator);
uint64_t event_id = reinterpret_cast<uint64_t &>(event);
auto iter = unique_id_mapping.pop(event_id);
if (iter != unique_id_mapping.end()) {
event = (VkEvent)iter->second;
} else {
event = (VkEvent)0;
}
layer_data->device_dispatch_table.DestroyEvent(device, event, pAllocator);
}
VkResult DispatchGetEventStatus(
VkDevice device,
VkEvent event)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.GetEventStatus(device, event);
{
event = layer_data->Unwrap(event);
}
VkResult result = layer_data->device_dispatch_table.GetEventStatus(device, event);
return result;
}
VkResult DispatchSetEvent(
VkDevice device,
VkEvent event)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.SetEvent(device, event);
{
event = layer_data->Unwrap(event);
}
VkResult result = layer_data->device_dispatch_table.SetEvent(device, event);
return result;
}
VkResult DispatchResetEvent(
VkDevice device,
VkEvent event)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.ResetEvent(device, event);
{
event = layer_data->Unwrap(event);
}
VkResult result = layer_data->device_dispatch_table.ResetEvent(device, event);
return result;
}
VkResult DispatchCreateQueryPool(
VkDevice device,
const VkQueryPoolCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkQueryPool* pQueryPool)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.CreateQueryPool(device, pCreateInfo, pAllocator, pQueryPool);
VkResult result = layer_data->device_dispatch_table.CreateQueryPool(device, pCreateInfo, pAllocator, pQueryPool);
if (VK_SUCCESS == result) {
*pQueryPool = layer_data->WrapNew(*pQueryPool);
}
return result;
}
void DispatchDestroyQueryPool(
VkDevice device,
VkQueryPool queryPool,
const VkAllocationCallbacks* pAllocator)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.DestroyQueryPool(device, queryPool, pAllocator);
uint64_t queryPool_id = reinterpret_cast<uint64_t &>(queryPool);
auto iter = unique_id_mapping.pop(queryPool_id);
if (iter != unique_id_mapping.end()) {
queryPool = (VkQueryPool)iter->second;
} else {
queryPool = (VkQueryPool)0;
}
layer_data->device_dispatch_table.DestroyQueryPool(device, queryPool, pAllocator);
}
VkResult DispatchGetQueryPoolResults(
VkDevice device,
VkQueryPool queryPool,
uint32_t firstQuery,
uint32_t queryCount,
size_t dataSize,
void* pData,
VkDeviceSize stride,
VkQueryResultFlags flags)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.GetQueryPoolResults(device, queryPool, firstQuery, queryCount, dataSize, pData, stride, flags);
{
queryPool = layer_data->Unwrap(queryPool);
}
VkResult result = layer_data->device_dispatch_table.GetQueryPoolResults(device, queryPool, firstQuery, queryCount, dataSize, pData, stride, flags);
return result;
}
VkResult DispatchCreateBuffer(
VkDevice device,
const VkBufferCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkBuffer* pBuffer)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.CreateBuffer(device, pCreateInfo, pAllocator, pBuffer);
VkResult result = layer_data->device_dispatch_table.CreateBuffer(device, pCreateInfo, pAllocator, pBuffer);
if (VK_SUCCESS == result) {
*pBuffer = layer_data->WrapNew(*pBuffer);
}
return result;
}
void DispatchDestroyBuffer(
VkDevice device,
VkBuffer buffer,
const VkAllocationCallbacks* pAllocator)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.DestroyBuffer(device, buffer, pAllocator);
uint64_t buffer_id = reinterpret_cast<uint64_t &>(buffer);
auto iter = unique_id_mapping.pop(buffer_id);
if (iter != unique_id_mapping.end()) {
buffer = (VkBuffer)iter->second;
} else {
buffer = (VkBuffer)0;
}
layer_data->device_dispatch_table.DestroyBuffer(device, buffer, pAllocator);
}
VkResult DispatchCreateBufferView(
VkDevice device,
const VkBufferViewCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkBufferView* pView)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.CreateBufferView(device, pCreateInfo, pAllocator, pView);
safe_VkBufferViewCreateInfo var_local_pCreateInfo;
safe_VkBufferViewCreateInfo *local_pCreateInfo = NULL;
{
if (pCreateInfo) {
local_pCreateInfo = &var_local_pCreateInfo;
local_pCreateInfo->initialize(pCreateInfo);
if (pCreateInfo->buffer) {
local_pCreateInfo->buffer = layer_data->Unwrap(pCreateInfo->buffer);
}
}
}
VkResult result = layer_data->device_dispatch_table.CreateBufferView(device, (const VkBufferViewCreateInfo*)local_pCreateInfo, pAllocator, pView);
if (VK_SUCCESS == result) {
*pView = layer_data->WrapNew(*pView);
}
return result;
}
void DispatchDestroyBufferView(
VkDevice device,
VkBufferView bufferView,
const VkAllocationCallbacks* pAllocator)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.DestroyBufferView(device, bufferView, pAllocator);
uint64_t bufferView_id = reinterpret_cast<uint64_t &>(bufferView);
auto iter = unique_id_mapping.pop(bufferView_id);
if (iter != unique_id_mapping.end()) {
bufferView = (VkBufferView)iter->second;
} else {
bufferView = (VkBufferView)0;
}
layer_data->device_dispatch_table.DestroyBufferView(device, bufferView, pAllocator);
}
VkResult DispatchCreateImage(
VkDevice device,
const VkImageCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkImage* pImage)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.CreateImage(device, pCreateInfo, pAllocator, pImage);
safe_VkImageCreateInfo var_local_pCreateInfo;
safe_VkImageCreateInfo *local_pCreateInfo = NULL;
{
if (pCreateInfo) {
local_pCreateInfo = &var_local_pCreateInfo;
local_pCreateInfo->initialize(pCreateInfo);
WrapPnextChainHandles(layer_data, local_pCreateInfo->pNext);
}
}
VkResult result = layer_data->device_dispatch_table.CreateImage(device, (const VkImageCreateInfo*)local_pCreateInfo, pAllocator, pImage);
if (VK_SUCCESS == result) {
*pImage = layer_data->WrapNew(*pImage);
}
return result;
}
void DispatchDestroyImage(
VkDevice device,
VkImage image,
const VkAllocationCallbacks* pAllocator)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.DestroyImage(device, image, pAllocator);
uint64_t image_id = reinterpret_cast<uint64_t &>(image);
auto iter = unique_id_mapping.pop(image_id);
if (iter != unique_id_mapping.end()) {
image = (VkImage)iter->second;
} else {
image = (VkImage)0;
}
layer_data->device_dispatch_table.DestroyImage(device, image, pAllocator);
}
void DispatchGetImageSubresourceLayout(
VkDevice device,
VkImage image,
const VkImageSubresource* pSubresource,
VkSubresourceLayout* pLayout)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.GetImageSubresourceLayout(device, image, pSubresource, pLayout);
{
image = layer_data->Unwrap(image);
}
layer_data->device_dispatch_table.GetImageSubresourceLayout(device, image, pSubresource, pLayout);
}
VkResult DispatchCreateImageView(
VkDevice device,
const VkImageViewCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkImageView* pView)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.CreateImageView(device, pCreateInfo, pAllocator, pView);
safe_VkImageViewCreateInfo var_local_pCreateInfo;
safe_VkImageViewCreateInfo *local_pCreateInfo = NULL;
{
if (pCreateInfo) {
local_pCreateInfo = &var_local_pCreateInfo;
local_pCreateInfo->initialize(pCreateInfo);
if (pCreateInfo->image) {
local_pCreateInfo->image = layer_data->Unwrap(pCreateInfo->image);
}
WrapPnextChainHandles(layer_data, local_pCreateInfo->pNext);
}
}
VkResult result = layer_data->device_dispatch_table.CreateImageView(device, (const VkImageViewCreateInfo*)local_pCreateInfo, pAllocator, pView);
if (VK_SUCCESS == result) {
*pView = layer_data->WrapNew(*pView);
}
return result;
}
void DispatchDestroyImageView(
VkDevice device,
VkImageView imageView,
const VkAllocationCallbacks* pAllocator)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.DestroyImageView(device, imageView, pAllocator);
uint64_t imageView_id = reinterpret_cast<uint64_t &>(imageView);
auto iter = unique_id_mapping.pop(imageView_id);
if (iter != unique_id_mapping.end()) {
imageView = (VkImageView)iter->second;
} else {
imageView = (VkImageView)0;
}
layer_data->device_dispatch_table.DestroyImageView(device, imageView, pAllocator);
}
VkResult DispatchCreateShaderModule(
VkDevice device,
const VkShaderModuleCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkShaderModule* pShaderModule)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.CreateShaderModule(device, pCreateInfo, pAllocator, pShaderModule);
safe_VkShaderModuleCreateInfo var_local_pCreateInfo;
safe_VkShaderModuleCreateInfo *local_pCreateInfo = NULL;
{
if (pCreateInfo) {
local_pCreateInfo = &var_local_pCreateInfo;
local_pCreateInfo->initialize(pCreateInfo);
WrapPnextChainHandles(layer_data, local_pCreateInfo->pNext);
}
}
VkResult result = layer_data->device_dispatch_table.CreateShaderModule(device, (const VkShaderModuleCreateInfo*)local_pCreateInfo, pAllocator, pShaderModule);
if (VK_SUCCESS == result) {
*pShaderModule = layer_data->WrapNew(*pShaderModule);
}
return result;
}
void DispatchDestroyShaderModule(
VkDevice device,
VkShaderModule shaderModule,
const VkAllocationCallbacks* pAllocator)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.DestroyShaderModule(device, shaderModule, pAllocator);
uint64_t shaderModule_id = reinterpret_cast<uint64_t &>(shaderModule);
auto iter = unique_id_mapping.pop(shaderModule_id);
if (iter != unique_id_mapping.end()) {
shaderModule = (VkShaderModule)iter->second;
} else {
shaderModule = (VkShaderModule)0;
}
layer_data->device_dispatch_table.DestroyShaderModule(device, shaderModule, pAllocator);
}
VkResult DispatchCreatePipelineCache(
VkDevice device,
const VkPipelineCacheCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkPipelineCache* pPipelineCache)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.CreatePipelineCache(device, pCreateInfo, pAllocator, pPipelineCache);
VkResult result = layer_data->device_dispatch_table.CreatePipelineCache(device, pCreateInfo, pAllocator, pPipelineCache);
if (VK_SUCCESS == result) {
*pPipelineCache = layer_data->WrapNew(*pPipelineCache);
}
return result;
}
void DispatchDestroyPipelineCache(
VkDevice device,
VkPipelineCache pipelineCache,
const VkAllocationCallbacks* pAllocator)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.DestroyPipelineCache(device, pipelineCache, pAllocator);
uint64_t pipelineCache_id = reinterpret_cast<uint64_t &>(pipelineCache);
auto iter = unique_id_mapping.pop(pipelineCache_id);
if (iter != unique_id_mapping.end()) {
pipelineCache = (VkPipelineCache)iter->second;
} else {
pipelineCache = (VkPipelineCache)0;
}
layer_data->device_dispatch_table.DestroyPipelineCache(device, pipelineCache, pAllocator);
}
VkResult DispatchGetPipelineCacheData(
VkDevice device,
VkPipelineCache pipelineCache,
size_t* pDataSize,
void* pData)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.GetPipelineCacheData(device, pipelineCache, pDataSize, pData);
{
pipelineCache = layer_data->Unwrap(pipelineCache);
}
VkResult result = layer_data->device_dispatch_table.GetPipelineCacheData(device, pipelineCache, pDataSize, pData);
return result;
}
VkResult DispatchMergePipelineCaches(
VkDevice device,
VkPipelineCache dstCache,
uint32_t srcCacheCount,
const VkPipelineCache* pSrcCaches)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.MergePipelineCaches(device, dstCache, srcCacheCount, pSrcCaches);
VkPipelineCache var_local_pSrcCaches[DISPATCH_MAX_STACK_ALLOCATIONS];
VkPipelineCache *local_pSrcCaches = NULL;
{
dstCache = layer_data->Unwrap(dstCache);
if (pSrcCaches) {
local_pSrcCaches = srcCacheCount > DISPATCH_MAX_STACK_ALLOCATIONS ? new VkPipelineCache[srcCacheCount] : var_local_pSrcCaches;
for (uint32_t index0 = 0; index0 < srcCacheCount; ++index0) {
local_pSrcCaches[index0] = layer_data->Unwrap(pSrcCaches[index0]);
}
}
}
VkResult result = layer_data->device_dispatch_table.MergePipelineCaches(device, dstCache, srcCacheCount, (const VkPipelineCache*)local_pSrcCaches);
if (local_pSrcCaches != var_local_pSrcCaches)
delete[] local_pSrcCaches;
return result;
}
// Skip vkCreateGraphicsPipelines dispatch, manually generated
VkResult DispatchCreateComputePipelines(
VkDevice device,
VkPipelineCache pipelineCache,
uint32_t createInfoCount,
const VkComputePipelineCreateInfo* pCreateInfos,
const VkAllocationCallbacks* pAllocator,
VkPipeline* pPipelines)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.CreateComputePipelines(device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines);
safe_VkComputePipelineCreateInfo *local_pCreateInfos = NULL;
{
pipelineCache = layer_data->Unwrap(pipelineCache);
if (pCreateInfos) {
local_pCreateInfos = new safe_VkComputePipelineCreateInfo[createInfoCount];
for (uint32_t index0 = 0; index0 < createInfoCount; ++index0) {
local_pCreateInfos[index0].initialize(&pCreateInfos[index0]);
if (pCreateInfos[index0].stage.module) {
local_pCreateInfos[index0].stage.module = layer_data->Unwrap(pCreateInfos[index0].stage.module);
}
if (pCreateInfos[index0].layout) {
local_pCreateInfos[index0].layout = layer_data->Unwrap(pCreateInfos[index0].layout);
}
if (pCreateInfos[index0].basePipelineHandle) {
local_pCreateInfos[index0].basePipelineHandle = layer_data->Unwrap(pCreateInfos[index0].basePipelineHandle);
}
}
}
}
VkResult result = layer_data->device_dispatch_table.CreateComputePipelines(device, pipelineCache, createInfoCount, (const VkComputePipelineCreateInfo*)local_pCreateInfos, pAllocator, pPipelines);
for (uint32_t i = 0; i < createInfoCount; ++i) {
if (pCreateInfos[i].pNext != VK_NULL_HANDLE) {
CopyCreatePipelineFeedbackData(local_pCreateInfos[i].pNext, pCreateInfos[i].pNext);
}
}
if (local_pCreateInfos) {
delete[] local_pCreateInfos;
}
{
for (uint32_t index0 = 0; index0 < createInfoCount; index0++) {
if (pPipelines[index0] != VK_NULL_HANDLE) {
pPipelines[index0] = layer_data->WrapNew(pPipelines[index0]);
}
}
}
return result;
}
void DispatchDestroyPipeline(
VkDevice device,
VkPipeline pipeline,
const VkAllocationCallbacks* pAllocator)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.DestroyPipeline(device, pipeline, pAllocator);
uint64_t pipeline_id = reinterpret_cast<uint64_t &>(pipeline);
auto iter = unique_id_mapping.pop(pipeline_id);
if (iter != unique_id_mapping.end()) {
pipeline = (VkPipeline)iter->second;
} else {
pipeline = (VkPipeline)0;
}
layer_data->device_dispatch_table.DestroyPipeline(device, pipeline, pAllocator);
}
VkResult DispatchCreatePipelineLayout(
VkDevice device,
const VkPipelineLayoutCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkPipelineLayout* pPipelineLayout)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.CreatePipelineLayout(device, pCreateInfo, pAllocator, pPipelineLayout);
safe_VkPipelineLayoutCreateInfo var_local_pCreateInfo;
safe_VkPipelineLayoutCreateInfo *local_pCreateInfo = NULL;
{
if (pCreateInfo) {
local_pCreateInfo = &var_local_pCreateInfo;
local_pCreateInfo->initialize(pCreateInfo);
if (local_pCreateInfo->pSetLayouts) {
for (uint32_t index1 = 0; index1 < local_pCreateInfo->setLayoutCount; ++index1) {
local_pCreateInfo->pSetLayouts[index1] = layer_data->Unwrap(local_pCreateInfo->pSetLayouts[index1]);
}
}
}
}
VkResult result = layer_data->device_dispatch_table.CreatePipelineLayout(device, (const VkPipelineLayoutCreateInfo*)local_pCreateInfo, pAllocator, pPipelineLayout);
if (VK_SUCCESS == result) {
*pPipelineLayout = layer_data->WrapNew(*pPipelineLayout);
}
return result;
}
void DispatchDestroyPipelineLayout(
VkDevice device,
VkPipelineLayout pipelineLayout,
const VkAllocationCallbacks* pAllocator)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.DestroyPipelineLayout(device, pipelineLayout, pAllocator);
uint64_t pipelineLayout_id = reinterpret_cast<uint64_t &>(pipelineLayout);
auto iter = unique_id_mapping.pop(pipelineLayout_id);
if (iter != unique_id_mapping.end()) {
pipelineLayout = (VkPipelineLayout)iter->second;
} else {
pipelineLayout = (VkPipelineLayout)0;
}
layer_data->device_dispatch_table.DestroyPipelineLayout(device, pipelineLayout, pAllocator);
}
VkResult DispatchCreateSampler(
VkDevice device,
const VkSamplerCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSampler* pSampler)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.CreateSampler(device, pCreateInfo, pAllocator, pSampler);
safe_VkSamplerCreateInfo var_local_pCreateInfo;
safe_VkSamplerCreateInfo *local_pCreateInfo = NULL;
{
if (pCreateInfo) {
local_pCreateInfo = &var_local_pCreateInfo;
local_pCreateInfo->initialize(pCreateInfo);
WrapPnextChainHandles(layer_data, local_pCreateInfo->pNext);
}
}
VkResult result = layer_data->device_dispatch_table.CreateSampler(device, (const VkSamplerCreateInfo*)local_pCreateInfo, pAllocator, pSampler);
if (VK_SUCCESS == result) {
*pSampler = layer_data->WrapNew(*pSampler);
}
return result;
}
void DispatchDestroySampler(
VkDevice device,
VkSampler sampler,
const VkAllocationCallbacks* pAllocator)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.DestroySampler(device, sampler, pAllocator);
uint64_t sampler_id = reinterpret_cast<uint64_t &>(sampler);
auto iter = unique_id_mapping.pop(sampler_id);
if (iter != unique_id_mapping.end()) {
sampler = (VkSampler)iter->second;
} else {
sampler = (VkSampler)0;
}
layer_data->device_dispatch_table.DestroySampler(device, sampler, pAllocator);
}
VkResult DispatchCreateDescriptorSetLayout(
VkDevice device,
const VkDescriptorSetLayoutCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkDescriptorSetLayout* pSetLayout)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.CreateDescriptorSetLayout(device, pCreateInfo, pAllocator, pSetLayout);
safe_VkDescriptorSetLayoutCreateInfo var_local_pCreateInfo;
safe_VkDescriptorSetLayoutCreateInfo *local_pCreateInfo = NULL;
{
if (pCreateInfo) {
local_pCreateInfo = &var_local_pCreateInfo;
local_pCreateInfo->initialize(pCreateInfo);
if (local_pCreateInfo->pBindings) {
for (uint32_t index1 = 0; index1 < local_pCreateInfo->bindingCount; ++index1) {
if (local_pCreateInfo->pBindings[index1].pImmutableSamplers) {
for (uint32_t index2 = 0; index2 < local_pCreateInfo->pBindings[index1].descriptorCount; ++index2) {
local_pCreateInfo->pBindings[index1].pImmutableSamplers[index2] = layer_data->Unwrap(local_pCreateInfo->pBindings[index1].pImmutableSamplers[index2]);
}
}
}
}
}
}
VkResult result = layer_data->device_dispatch_table.CreateDescriptorSetLayout(device, (const VkDescriptorSetLayoutCreateInfo*)local_pCreateInfo, pAllocator, pSetLayout);
if (VK_SUCCESS == result) {
*pSetLayout = layer_data->WrapNew(*pSetLayout);
}
return result;
}
void DispatchDestroyDescriptorSetLayout(
VkDevice device,
VkDescriptorSetLayout descriptorSetLayout,
const VkAllocationCallbacks* pAllocator)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.DestroyDescriptorSetLayout(device, descriptorSetLayout, pAllocator);
uint64_t descriptorSetLayout_id = reinterpret_cast<uint64_t &>(descriptorSetLayout);
auto iter = unique_id_mapping.pop(descriptorSetLayout_id);
if (iter != unique_id_mapping.end()) {
descriptorSetLayout = (VkDescriptorSetLayout)iter->second;
} else {
descriptorSetLayout = (VkDescriptorSetLayout)0;
}
layer_data->device_dispatch_table.DestroyDescriptorSetLayout(device, descriptorSetLayout, pAllocator);
}
VkResult DispatchCreateDescriptorPool(
VkDevice device,
const VkDescriptorPoolCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkDescriptorPool* pDescriptorPool)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.CreateDescriptorPool(device, pCreateInfo, pAllocator, pDescriptorPool);
VkResult result = layer_data->device_dispatch_table.CreateDescriptorPool(device, pCreateInfo, pAllocator, pDescriptorPool);
if (VK_SUCCESS == result) {
*pDescriptorPool = layer_data->WrapNew(*pDescriptorPool);
}
return result;
}
// Skip vkDestroyDescriptorPool dispatch, manually generated
// Skip vkResetDescriptorPool dispatch, manually generated
// Skip vkAllocateDescriptorSets dispatch, manually generated
// Skip vkFreeDescriptorSets dispatch, manually generated
void DispatchUpdateDescriptorSets(
VkDevice device,
uint32_t descriptorWriteCount,
const VkWriteDescriptorSet* pDescriptorWrites,
uint32_t descriptorCopyCount,
const VkCopyDescriptorSet* pDescriptorCopies)
{
auto layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
if (!wrap_handles) return layer_data->device_dispatch_table.UpdateDescriptorSets(device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies);
safe_VkWriteDescriptorSet *local_pDescriptorWrites = NULL;
safe_VkCopyDescriptorSet *local_pDescriptorCopies = NULL;
{
if (pDescriptorWrites) {
local_pDescriptorWrites = new safe_VkWriteDescriptorSet[descriptorWriteCount];
for (uint32_t index0 = 0; index0 < descriptorWriteCount; ++index0) {
local_pDescriptorWrites[index0].initialize(&pDescriptorWrites[index0]);
WrapPnextChainHandles(layer_data, local_pDescriptorWrites[index0].pNext);
if (pDescriptorWrites[index0].dstSet) {
local_pDescriptorWrites[index0].dstSet = layer_data->Unwrap(pDescriptorWrites[index0].dstSet);
}
if (local_pDescriptorWrites[index0].pImageInfo) {
for (uint32_t index1 = 0; index1 < local_pDescriptorWrites[index0].descriptorCount; ++index1) {
if (pDescriptorWrites[index0].pImageInfo[index1].sampler) {
local_pDescriptorWrites[index0].pImageInfo[index1].sampler = layer_data->Unwrap(pDescriptorWrites[index0].pImageInfo[index1].sampler);
}
if (pDescriptorWrites[index0].pImageInfo[index1].imageView) {
local_pDescriptorWrites[index0].pImageInfo[index1].imageView = layer_data->Unwrap(pDescriptorWrites[index0].pImageInfo[index1].imageView);
}
}
}
if (local_pDescriptorWrites[index0].pBufferInfo) {
for (uint32_t index1 = 0; index1 < local_pDescriptorWrites[index0].descriptorCount; ++index1) {
if (pDescriptorWrites[index0].pBufferInfo[index1].buffer) {
local_pDescriptorWrites[index0].pBufferInfo[index1].buffer = layer_data->Unwrap(pDescriptorWrites[index0].pBufferInfo[index1].buffer);
}
}
}
if (local_pDescriptorWrites[index0].pTexelBufferView) {
for (uint32_t index1 = 0; index1 < local_pDescriptorWrites[index0].descriptorCount; ++index1) {
local_pDescriptorWrites[index0].pTexelBufferView[index1] = layer_data->Unwrap(local_pDescriptorWrites[index0].pTexelBufferView[index1]);
}
}