From 7cd6b280269ba815edd743b44feece5205fbe13d Mon Sep 17 00:00:00 2001 From: Mike Stroyan Date: Fri, 5 Feb 2016 09:11:32 -0700 Subject: layers: allow one thread multiple uses of object A single call in a thread may use an object more than once. This first appeared with vkCmdExecuteCommands and buffer pools. That is not distinguishable from recursive vulkan calls. The error that this was looking for only happens if calling vulkan while within another vulkan call. Such calls from signal handlers or callbacks should be very rare errors. So just allow one thread to have multiple uses of an object and keep accurate counters. --- layers/threading.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/layers/threading.h b/layers/threading.h index a45069fa..23d44c2d 100644 --- a/layers/threading.h +++ b/layers/threading.h @@ -98,13 +98,11 @@ template class counter { use_data->writer_count = 1; } else { // Continue with an unsafe use of the object. + use_data->thread = tid ; use_data->writer_count += 1; } } else { - skipCall |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, objectType, reinterpret_cast(object), - /*location*/ 0, THREADING_CHECKER_MULTIPLE_THREADS, "THREADING", - "THREADING ERROR : object of type %s is recursively used in thread %ld", - typeName, tid); + // This is either safe multiple use in one call, or recursive use. // There is no way to make recursion safe. Just forge ahead. use_data->writer_count += 1; } @@ -127,13 +125,11 @@ template class counter { use_data->writer_count = 1; } else { // Continue with an unsafe use of the object. + use_data->thread = tid ; use_data->writer_count += 1; } } else { - skipCall |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, objectType, reinterpret_cast(object), - /*location*/ 0, THREADING_CHECKER_MULTIPLE_THREADS, "THREADING", - "THREADING ERROR : object of type %s is recursively used in thread %ld", - typeName, tid); + // This is either safe multiple use in one call, or recursive use. // There is no way to make recursion safe. Just forge ahead. use_data->writer_count += 1; } @@ -165,7 +161,7 @@ template class counter { use_data->reader_count = 1; use_data->writer_count = 0; use_data->thread = tid; - } else if (uses[object].writer_count > 0) { + } else if (uses[object].writer_count > 0 && uses[object].thread != tid) { // There is a writer of the object. skipCall |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, objectType, reinterpret_cast(object), /*location*/ 0, THREADING_CHECKER_MULTIPLE_THREADS, "THREADING", -- cgit v1.2.3