diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-04-23 21:34:26 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-04-23 21:35:02 +0300 |
commit | 148c0aa0faa66b44ad26f2c4703d59e9a133ff71 (patch) | |
tree | 82a7c4fc5b88d9ec20c724abeac231bbce0cf88a /source/blender/gpu/intern/gpu_draw.c | |
parent | d10205c1a7d6d595db600842c9c2ed343d9f51aa (diff) |
Fix T63178 Eevee animation render crash
If image buffer is not loaded and blender attempts to reload it (during
`BKE_image_acquire_ibuf`) over and over for each frame rendered.
When attempting this reload, image_load_image_file is calling
`BKE_image_free_buffers` and tag the Image to the (GPU) image_free_queue
(because this run on the rendering thread).
If the main thread decide to redraw the UI and go through `GPU_free_unused_buffers` they all get deleted and if that happens before the rendering thread use them ... segfault.
If I replace the environment textures with correct ones (the file does not seems to contain them), there is no crash when rendering.
I used a list of GPUTexture from blender Image to increase and decrease the
reference counter correctly.
This add very little memory and computation overhead.
Diffstat (limited to 'source/blender/gpu/intern/gpu_draw.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index e25c7d7f11e..edc2f2171a5 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -1199,12 +1199,13 @@ void GPU_free_smoke_velocity(SmokeModifierData *smd) } static LinkNode *image_free_queue = NULL; +static ThreadMutex img_queue_mutex = BLI_MUTEX_INITIALIZER; static void gpu_queue_image_for_free(Image *ima) { - BLI_thread_lock(LOCK_OPENGL); + BLI_mutex_lock(&img_queue_mutex); BLI_linklist_prepend(&image_free_queue, ima); - BLI_thread_unlock(LOCK_OPENGL); + BLI_mutex_unlock(&img_queue_mutex); } void GPU_free_unused_buffers(Main *bmain) @@ -1213,7 +1214,7 @@ void GPU_free_unused_buffers(Main *bmain) return; } - BLI_thread_lock(LOCK_OPENGL); + BLI_mutex_lock(&img_queue_mutex); /* images */ for (LinkNode *node = image_free_queue; node; node = node->next) { @@ -1228,7 +1229,7 @@ void GPU_free_unused_buffers(Main *bmain) BLI_linklist_free(image_free_queue, NULL); image_free_queue = NULL; - BLI_thread_unlock(LOCK_OPENGL); + BLI_mutex_unlock(&img_queue_mutex); } static void gpu_free_image_immediate(Image *ima) |