Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-11-12 20:06:32 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-11-12 20:07:01 +0300
commitd941f40c21f9b7eae861914db5b24427413044c9 (patch)
tree416052d8e52b2a2505075130501da0e14631bcd6 /source/blender/gpu/intern/gpu_batch_presets.c
parent7f2401532e8ce30e5142ac9236bc32db988f9a6e (diff)
Fix T57571: Blender crashes on UV transformation
That was caused by a thread safety issue on gpu_batch_presets_unregister() which was not designed to be used for this kind of situation (managing 3D meshes batches).
Diffstat (limited to 'source/blender/gpu/intern/gpu_batch_presets.c')
-rw-r--r--source/blender/gpu/intern/gpu_batch_presets.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/gpu/intern/gpu_batch_presets.c b/source/blender/gpu/intern/gpu_batch_presets.c
index 126897ac8bf..562971c760d 100644
--- a/source/blender/gpu/intern/gpu_batch_presets.c
+++ b/source/blender/gpu/intern/gpu_batch_presets.c
@@ -57,6 +57,8 @@ static struct {
struct {
uint pos, nor;
} attr_id;
+
+ ThreadMutex mutex;
} g_presets_3d = {{0}};
static ListBase presets_list = {NULL, NULL};
@@ -214,33 +216,42 @@ void gpu_batch_presets_init(void)
g_presets_3d.batch.sphere_wire_med = batch_sphere_wire(8, 16);
gpu_batch_presets_register(g_presets_3d.batch.sphere_wire_med);
+
+ BLI_mutex_init(&g_presets_3d.mutex);
}
void gpu_batch_presets_register(GPUBatch *preset_batch)
{
+ BLI_mutex_lock(&g_presets_3d.mutex);
BLI_addtail(&presets_list, BLI_genericNodeN(preset_batch));
+ BLI_mutex_unlock(&g_presets_3d.mutex);
}
bool gpu_batch_presets_unregister(GPUBatch *preset_batch)
{
+ BLI_mutex_lock(&g_presets_3d.mutex);
for (LinkData *link = presets_list.last; link; link = link->prev) {
if (preset_batch == link->data) {
BLI_remlink(&presets_list, link);
+ BLI_mutex_unlock(&g_presets_3d.mutex);
MEM_freeN(link);
return true;
}
}
+ BLI_mutex_unlock(&g_presets_3d.mutex);
return false;
}
void gpu_batch_presets_reset(void)
{
+ BLI_mutex_lock(&g_presets_3d.mutex);
/* Reset vao caches for these every time we switch opengl context.
* This way they will draw correctly for each window. */
for (LinkData *link = presets_list.first; link; link = link->next) {
GPUBatch *preset = link->data;
GPU_batch_vao_cache_clear(preset);
}
+ BLI_mutex_unlock(&g_presets_3d.mutex);
}
void gpu_batch_presets_exit(void)
@@ -251,4 +262,6 @@ void gpu_batch_presets_exit(void)
GPU_batch_discard(preset);
MEM_freeN(link);
}
+
+ BLI_mutex_end(&g_presets_3d.mutex);
}