void VKAPI_CALL vkFreeCommandBuffers( VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, const VkCommandBuffer* pCommandBuffers) { dispatch_key key = get_dispatch_key(device); layer_data *my_data = get_my_data_ptr(key, layer_data_map); VkLayerDispatchTable *pTable = my_data->device_dispatch_table; const bool lockCommandPool = false; // pool is already directly locked startReadObject(my_data, device); startWriteObject(my_data, commandPool); for (int index=0;index<commandBufferCount;index++) { startWriteObject(my_data, pCommandBuffers[index], lockCommandPool); } pTable->FreeCommandBuffers(device,commandPool,commandBufferCount,pCommandBuffers); finishReadObject(my_data, device); finishWriteObject(my_data, commandPool); for (int index=0;index<commandBufferCount;index++) { finishWriteObject(my_data, pCommandBuffers[index], lockCommandPool); loader_platform_thread_lock_mutex(&threadingLock); command_pool_map.erase(pCommandBuffers[index]); loader_platform_thread_unlock_mutex(&threadingLock); } }
VkResult VKAPI_CALL vkAllocateCommandBuffers( VkDevice device, const VkCommandBufferAllocateInfo* pAllocateInfo, VkCommandBuffer* pCommandBuffers) { dispatch_key key = get_dispatch_key(device); layer_data *my_data = get_my_data_ptr(key, layer_data_map); VkLayerDispatchTable *pTable = my_data->device_dispatch_table; VkResult result; startReadObject(my_data, device); startWriteObject(my_data, pAllocateInfo->commandPool); result = pTable->AllocateCommandBuffers(device, pAllocateInfo, pCommandBuffers); finishReadObject(my_data, device); finishWriteObject(my_data, pAllocateInfo->commandPool); // Record mapping from command buffer to command pool if (VK_SUCCESS == result) { for (int index=0;index<pAllocateInfo->commandBufferCount;index++) { loader_platform_thread_lock_mutex(&threadingLock); command_pool_map[pCommandBuffers[index]] = pAllocateInfo->commandPool; loader_platform_thread_unlock_mutex(&threadingLock); } } return result; }
VKAPI_ATTR void VKAPI_CALL DestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks *pAllocator) { layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); startReadObject(my_data, instance); startWriteObject(my_data, callback); my_data->instance_dispatch_table->DestroyDebugReportCallbackEXT(instance, callback, pAllocator); layer_destroy_msg_callback(my_data->report_data, callback, pAllocator); finishReadObject(my_data, instance); finishWriteObject(my_data, callback); }
VKAPI_ATTR VkResult VKAPI_CALL CreateDebugReportCallbackEXT(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT *pMsgCallback) { layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); startReadObject(my_data, instance); VkResult result = my_data->instance_dispatch_table->CreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pMsgCallback); if (VK_SUCCESS == result) { result = layer_create_msg_callback(my_data->report_data, false, pCreateInfo, pAllocator, pMsgCallback); } finishReadObject(my_data, instance); return result; }
VKAPI_ATTR VkResult VKAPI_CALL AllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, VkCommandBuffer *pCommandBuffers) { dispatch_key key = get_dispatch_key(device); layer_data *my_data = get_my_data_ptr(key, layer_data_map); VkLayerDispatchTable *pTable = my_data->device_dispatch_table; VkResult result; startReadObject(my_data, device); startWriteObject(my_data, pAllocateInfo->commandPool); result = pTable->AllocateCommandBuffers(device, pAllocateInfo, pCommandBuffers); finishReadObject(my_data, device); finishWriteObject(my_data, pAllocateInfo->commandPool); // Record mapping from command buffer to command pool if (VK_SUCCESS == result) { for (uint32_t index = 0; index < pAllocateInfo->commandBufferCount; index++) { std::lock_guard<std::mutex> lock(global_lock); command_pool_map[pCommandBuffers[index]] = pAllocateInfo->commandPool; } } return result; }