From 109ef278cc294b9f4068a7fc0fb65fada54012b6 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 7 May 2019 16:51:33 +0200 Subject: Fix deadlock in recent Cycles colorspace changes This code is not used yet so didn't affect anyone. --- intern/cycles/render/colorspace.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/intern/cycles/render/colorspace.cpp b/intern/cycles/render/colorspace.cpp index 265a0d90b2a..cdce1f70188 100644 --- a/intern/cycles/render/colorspace.cpp +++ b/intern/cycles/render/colorspace.cpp @@ -38,7 +38,8 @@ ustring u_colorspace_srgb("__builtin_srgb"); /* Cached data. */ #ifdef WITH_OCIO -static thread_mutex cache_mutex; +static thread_mutex cache_colorspaces_mutex; +static thread_mutex cache_processors_mutex; static unordered_map cached_colorspaces; static unordered_map cached_processors; #endif @@ -60,7 +61,7 @@ ColorSpaceProcessor *ColorSpaceManager::get_processor(ustring colorspace) /* Cache processor until free_memory(), memory overhead is expected to be * small and the processor is likely to be reused. */ - thread_scoped_lock cache_lock(cache_mutex); + thread_scoped_lock cache_processors_lock(cache_processors_mutex); if (cached_processors.find(colorspace) == cached_processors.end()) { try { cached_processors[colorspace] = config->getProcessor(colorspace.c_str(), "scene_linear"); @@ -106,7 +107,7 @@ ustring ColorSpaceManager::detect_known_colorspace(ustring colorspace, /* Use OpenColorIO. */ #ifdef WITH_OCIO { - thread_scoped_lock cache_lock(cache_mutex); + thread_scoped_lock cache_lock(cache_colorspaces_mutex); /* Cached lookup. */ if (cached_colorspaces.find(colorspace) != cached_colorspaces.end()) { return cached_colorspaces[colorspace]; @@ -117,7 +118,7 @@ ustring ColorSpaceManager::detect_known_colorspace(ustring colorspace, bool is_scene_linear, is_srgb; is_builtin_colorspace(colorspace, is_scene_linear, is_srgb); - thread_scoped_lock cache_lock(cache_mutex); + thread_scoped_lock cache_lock(cache_colorspaces_mutex); if (is_scene_linear) { VLOG(1) << "Colorspace " << colorspace.string() << " is no-op"; cached_colorspaces[colorspace] = u_colorspace_raw; -- cgit v1.2.3