VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table;
pTable->DestroyInstance(instance, pAllocator);
+ loader_platform_thread_lock_mutex(&globalLock);
// Clean up logging callback, if any
while (my_data->logging_callback.size() > 0) {
VkDebugReportCallbackEXT callback = my_data->logging_callback.back();
layer_debug_report_destroy_instance(my_data->report_data);
delete my_data->instance_dispatch_table;
layer_data_map.erase(key);
+ loader_platform_thread_unlock_mutex(&globalLock);
if (layer_data_map.empty()) {
// Release mutex when destroying last instance
loader_platform_thread_delete_mutex(&globalLock);
VkBool32 skipCall = VK_FALSE;
layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
+ loader_platform_thread_lock_mutex(&globalLock);
skipCall |= validateAndCopyNoncoherentMemoryToDriver(my_data, memRangeCount, pMemRanges);
skipCall |= validateMemoryIsMapped(my_data, memRangeCount, pMemRanges);
+ loader_platform_thread_unlock_mutex(&globalLock);
if (VK_FALSE == skipCall ) {
result = my_data->device_dispatch_table->FlushMappedMemoryRanges(device, memRangeCount, pMemRanges);
}
VkBool32 skipCall = VK_FALSE;
layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
+ loader_platform_thread_lock_mutex(&globalLock);
skipCall |= validateMemoryIsMapped(my_data, memRangeCount, pMemRanges);
+ loader_platform_thread_unlock_mutex(&globalLock);
if (VK_FALSE == skipCall) {
result = my_data->device_dispatch_table->InvalidateMappedMemoryRanges(device, memRangeCount, pMemRanges);
}
VkFence fence)
{
layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
+ loader_platform_thread_lock_mutex(&globalLock);
VkBool32 skipCall = verifyFenceStatus(device, fence, "vkGetFenceStatus");
+ loader_platform_thread_unlock_mutex(&globalLock);
if (skipCall)
return VK_ERROR_VALIDATION_FAILED_EXT;
VkResult result = my_data->device_dispatch_table->GetFenceStatus(device, fence);
layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
VkBool32 skipCall = VK_FALSE;
// Verify fence status of submitted fences
+ loader_platform_thread_lock_mutex(&globalLock);
for(uint32_t i = 0; i < fenceCount; i++) {
skipCall |= verifyFenceStatus(device, pFences[i], "vkWaitForFences");
}
+ loader_platform_thread_unlock_mutex(&globalLock);
if (skipCall)
return VK_ERROR_VALIDATION_FAILED_EXT;
VkResult result = my_data->device_dispatch_table->WaitForFences(device, fenceCount, pFences, waitAll, timeout);
- loader_platform_thread_lock_mutex(&globalLock);
if (VK_SUCCESS == result) {
+ loader_platform_thread_lock_mutex(&globalLock);
if (waitAll || fenceCount == 1) { // Clear all the fences
for(uint32_t i = 0; i < fenceCount; i++) {
update_fence_tracking(my_data, pFences[i]);
}
}
+ loader_platform_thread_unlock_mutex(&globalLock);
}
- loader_platform_thread_unlock_mutex(&globalLock);
return result;
}
VkBool32 skipCall = VK_FALSE;
// Verify that command buffers in pool are complete (not in-flight)
layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
+ loader_platform_thread_lock_mutex(&globalLock);
for (auto it = my_data->commandPoolMap[commandPool].pCommandBuffers.begin();
it != my_data->commandPoolMap[commandPool].pCommandBuffers.end(); it++) {
commandBufferComplete = VK_FALSE;
reinterpret_cast<uint64_t>(*it));
}
}
+ loader_platform_thread_unlock_mutex(&globalLock);
if (VK_FALSE == skipCall) {
my_data->device_dispatch_table->DestroyCommandPool(device, commandPool, pAllocator);
VkBool32 skipCall = VK_FALSE;
VkResult result = VK_ERROR_VALIDATION_FAILED_EXT;
+ loader_platform_thread_lock_mutex(&globalLock);
auto it = my_data->commandPoolMap[commandPool].pCommandBuffers.begin();
// Verify that CB's in pool are complete (not in-flight)
while (it != my_data->commandPoolMap[commandPool].pCommandBuffers.end()) {
MEMTRACK_RESET_CB_WHILE_IN_FLIGHT, "MEM", "Resetting CB %p before it has completed. You must check CB "
"flag before calling vkResetCommandBuffer().", (*it));
} else {
- loader_platform_thread_lock_mutex(&globalLock);
// Clear memory references at this point.
skipCall |= clear_cmd_buf_and_mem_references(my_data, (*it));
- loader_platform_thread_unlock_mutex(&globalLock);
}
++it;
}
+ loader_platform_thread_unlock_mutex(&globalLock);
if (VK_FALSE == skipCall) {
result = my_data->device_dispatch_table->ResetCommandPool(device, commandPool, flags);
VkPipeline pipeline)
{
layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map);
-#if 0
+#if 0 // FIXME: NEED TO FIX THE FOLLOWING CODE AND REMOVE THIS #if 0
// TODO : If memory bound to pipeline, then need to tie that mem to commandBuffer
if (getPipeline(pipeline)) {
MT_CB_INFO *pCBInfo = get_cmd_buf_info(my_data, commandBuffer);
{
layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map);
VkBool32 skip_call = false;
+ loader_platform_thread_lock_mutex(&globalLock);
for (uint32_t i = 0; i < bindingCount; ++i) {
VkDeviceMemory mem;
skip_call |= get_mem_binding_from_object(my_data, commandBuffer, (uint64_t)(pBuffers[i]),
cb_data->second.validate_functions.push_back(function);
}
}
+ loader_platform_thread_unlock_mutex(&globalLock);
// TODO : Somewhere need to verify that VBs have correct usage state flagged
if (!skip_call)
my_data->device_dispatch_table->CmdBindVertexBuffers(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets);
{
layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map);
VkDeviceMemory mem;
+ loader_platform_thread_lock_mutex(&globalLock);
VkBool32 skip_call = get_mem_binding_from_object(my_data, commandBuffer, (uint64_t)(buffer), VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, &mem);
auto cb_data = my_data->cbMap.find(commandBuffer);
if (cb_data != my_data->cbMap.end()) {
std::function<VkBool32()> function = [=]() { return validate_memory_is_valid(my_data, mem, "vkCmdBindIndexBuffer()"); };
cb_data->second.validate_functions.push_back(function);
}
+ loader_platform_thread_unlock_mutex(&globalLock);
// TODO : Somewhere need to verify that IBs have correct usage state flagged
if (!skip_call)
my_data->device_dispatch_table->CmdBindIndexBuffer(commandBuffer, buffer, offset, indexType);
VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table;
VkResult res = pTable->CreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pMsgCallback);
if (res == VK_SUCCESS) {
+ loader_platform_thread_lock_mutex(&globalLock);
res = layer_create_msg_callback(my_data->report_data, pCreateInfo, pAllocator, pMsgCallback);
+ loader_platform_thread_unlock_mutex(&globalLock);
}
return res;
}
layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map);
VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table;
pTable->DestroyDebugReportCallbackEXT(instance, msgCallback, pAllocator);
+ loader_platform_thread_lock_mutex(&globalLock);
layer_destroy_msg_callback(my_data->report_data, msgCallback, pAllocator);
+ loader_platform_thread_unlock_mutex(&globalLock);
}
VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDebugReportMessageEXT(
layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
VkResult result = my_data->device_dispatch_table->GetSwapchainImagesKHR(device, swapchain, pCount, pSwapchainImages);
+ loader_platform_thread_lock_mutex(&globalLock);
if (result == VK_SUCCESS && pSwapchainImages != NULL) {
const size_t count = *pCount;
MT_SWAP_CHAIN_INFO *pInfo = my_data->swapchainMap[swapchain];
}
}
}
+ loader_platform_thread_unlock_mutex(&globalLock);
return result;
}
layer_data *my_data = get_my_data_ptr(get_dispatch_key(queue), layer_data_map);
VkBool32 skip_call = false;
VkDeviceMemory mem;
+ loader_platform_thread_lock_mutex(&globalLock);
for (uint32_t i = 0; i < pPresentInfo->swapchainCount; ++i) {
MT_SWAP_CHAIN_INFO *pInfo = my_data->swapchainMap[pPresentInfo->pSwapchains[i]];
VkImage image = pInfo->images[pPresentInfo->pImageIndices[i]];
skip_call |= get_mem_binding_from_object(my_data, queue, (uint64_t)(image), VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, &mem);
skip_call |= validate_memory_is_valid(my_data, mem, "vkQueuePresentKHR()", image);
}
+ loader_platform_thread_unlock_mutex(&globalLock);
if (!skip_call) {
result = my_data->device_dispatch_table->QueuePresentKHR(queue, pPresentInfo);
}
{
layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
VkResult result = my_data->device_dispatch_table->CreateFramebuffer(device, pCreateInfo, pAllocator, pFramebuffer);
+ loader_platform_thread_lock_mutex(&globalLock);
for (uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) {
VkImageView view = pCreateInfo->pAttachments[i];
- loader_platform_thread_lock_mutex(&globalLock);
auto view_data = my_data->imageViewMap.find(view);
if (view_data == my_data->imageViewMap.end()) {
- loader_platform_thread_unlock_mutex(&globalLock);
continue;
}
MT_FB_ATTACHMENT_INFO fb_info;
get_mem_binding_from_object(my_data, device, (uint64_t)(view_data->second.image), VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, &fb_info.mem);
fb_info.image = view_data->second.image;
my_data->fbMap[*pFramebuffer].attachments.push_back(fb_info);
- loader_platform_thread_unlock_mutex(&globalLock);
}
+ loader_platform_thread_unlock_mutex(&globalLock);
return result;
}
{
layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
- auto item = my_data->fbMap.find(framebuffer);
loader_platform_thread_lock_mutex(&globalLock);
+ auto item = my_data->fbMap.find(framebuffer);
if (item != my_data->fbMap.end()) {
my_data->fbMap.erase(framebuffer);
}
{
layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
VkResult result = my_data->device_dispatch_table->CreateRenderPass(device, pCreateInfo, pAllocator, pRenderPass);
+ loader_platform_thread_lock_mutex(&globalLock);
for (uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) {
VkAttachmentDescription desc = pCreateInfo->pAttachments[i];
MT_PASS_ATTACHMENT_INFO pass_info;
pass_info.load_op = desc.loadOp;
pass_info.store_op = desc.storeOp;
pass_info.attachment = i;
- loader_platform_thread_lock_mutex(&globalLock);
my_data->passMap[*pRenderPass].attachments.push_back(pass_info);
- loader_platform_thread_unlock_mutex(&globalLock);
}
//TODO: Maybe fill list and then copy instead of locking
- loader_platform_thread_lock_mutex(&globalLock);
std::unordered_map<uint32_t, bool>& attachment_first_read = my_data->passMap[*pRenderPass].attachment_first_read;
std::unordered_map<uint32_t, VkImageLayout>& attachment_first_layout = my_data->passMap[*pRenderPass].attachment_first_layout;
for (uint32_t i = 0; i < pCreateInfo->subpassCount; ++i) {
VkCommandBuffer cmdBuffer)
{
layer_data *my_data = get_my_data_ptr(get_dispatch_key(cmdBuffer), layer_data_map);
+ loader_platform_thread_lock_mutex(&globalLock);
auto cb_data = my_data->cbMap.find(cmdBuffer);
if (cb_data != my_data->cbMap.end()) {
auto pass_data = my_data->passMap.find(cb_data->second.pass);
}
}
}
+ loader_platform_thread_unlock_mutex(&globalLock);
my_data->device_dispatch_table->CmdEndRenderPass(cmdBuffer);
}