Fix T75288: crash in Cycles image loading with multithreaded shader compilation

This commit is contained in:
Brecht Van Lommel 2020-04-08 21:57:40 +02:00
parent cc53c9e476
commit c13aa95eda
Notes: blender-bot 2023-02-14 11:35:46 +01:00
Referenced by issue #75288, Cycles/Tests: Crash in image_log test
2 changed files with 5 additions and 1 deletions

View File

@ -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);

View File

@ -206,6 +206,7 @@ class ImageManager {
bool has_half_images;
thread_mutex device_mutex;
thread_mutex images_mutex;
int animation_frame;
vector<Image *> images;