[Bf-blender-cvs] [c13aa95eda8] master: Fix T75288: crash in Cycles image loading with multithreaded shader compilation
Brecht Van Lommel
noreply at git.blender.org
Wed Apr 8 22:09:28 CEST 2020
Commit: c13aa95eda888c61514693c33ec506bf182257a1
Author: Brecht Van Lommel
Date: Wed Apr 8 21:57:40 2020 +0200
Branches: master
https://developer.blender.org/rBc13aa95eda888c61514693c33ec506bf182257a1
Fix T75288: crash in Cycles image loading with multithreaded shader compilation
===================================================================
M intern/cycles/render/image.cpp
M intern/cycles/render/image.h
===================================================================
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp
index 67ed1176171..75050b66bf2 100644
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@ -283,6 +283,7 @@ void ImageManager::set_osl_texture_system(void *texture_system)
bool ImageManager::set_animation_frame_update(int frame)
{
if (frame != animation_frame) {
+ thread_scoped_lock device_lock(images_mutex);
animation_frame = frame;
for (size_t slot = 0; slot < images.size(); slot++) {
@@ -377,7 +378,7 @@ int ImageManager::add_image_slot(ImageLoader *loader,
Image *img;
size_t slot;
- thread_scoped_lock device_lock(device_mutex);
+ thread_scoped_lock device_lock(images_mutex);
/* Fnd existing image. */
for (slot = 0; slot < images.size(); slot++) {
@@ -418,6 +419,7 @@ int ImageManager::add_image_slot(ImageLoader *loader,
void ImageManager::add_image_user(int slot)
{
+ thread_scoped_lock device_lock(images_mutex);
Image *image = images[slot];
assert(image && image->users >= 1);
@@ -426,6 +428,7 @@ void ImageManager::add_image_user(int slot)
void ImageManager::remove_image_user(int slot)
{
+ thread_scoped_lock device_lock(images_mutex);
Image *image = images[slot];
assert(image && image->users >= 1);
diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h
index 00ab12afd7a..2000582ce70 100644
--- a/intern/cycles/render/image.h
+++ b/intern/cycles/render/image.h
@@ -206,6 +206,7 @@ class ImageManager {
bool has_half_images;
thread_mutex device_mutex;
+ thread_mutex images_mutex;
int animation_frame;
vector<Image *> images;
More information about the Bf-blender-cvs
mailing list