Fix race condition with Vulkan validation layers
This commit is contained in:
@@ -302,6 +302,7 @@ VkBool32 application::vulkan_debug_report_callback(
|
|||||||
const char * pMessage,
|
const char * pMessage,
|
||||||
void * pUserData)
|
void * pUserData)
|
||||||
{
|
{
|
||||||
|
std::lock_guard lock(instance().debug_report_mutex);
|
||||||
if (instance().debug_report_ignored_objects.contains(object))
|
if (instance().debug_report_ignored_objects.contains(object))
|
||||||
return VK_FALSE;
|
return VK_FALSE;
|
||||||
|
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ class application : public singleton<application>
|
|||||||
|
|
||||||
void loop();
|
void loop();
|
||||||
|
|
||||||
|
std::mutex debug_report_mutex;
|
||||||
static VkBool32 vulkan_debug_report_callback(VkDebugReportFlagsEXT flags,
|
static VkBool32 vulkan_debug_report_callback(VkDebugReportFlagsEXT flags,
|
||||||
VkDebugReportObjectTypeEXT objectType,
|
VkDebugReportObjectTypeEXT objectType,
|
||||||
uint64_t object,
|
uint64_t object,
|
||||||
@@ -297,6 +298,7 @@ public:
|
|||||||
static void ignore_debug_reports_for(void * object)
|
static void ignore_debug_reports_for(void * object)
|
||||||
{
|
{
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
std::lock_guard lock(instance().debug_report_mutex);
|
||||||
instance().debug_report_ignored_objects.emplace((uint64_t)object);
|
instance().debug_report_ignored_objects.emplace((uint64_t)object);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -304,6 +306,7 @@ public:
|
|||||||
static void unignore_debug_reports_for(void * object)
|
static void unignore_debug_reports_for(void * object)
|
||||||
{
|
{
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
std::lock_guard lock(instance().debug_report_mutex);
|
||||||
instance().debug_report_ignored_objects.erase((uint64_t)object);
|
instance().debug_report_ignored_objects.erase((uint64_t)object);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user