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>2019-04-05 18:48:14 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-04-05 18:48:56 +0300
commite559074c4e5d5c17b00f6b7e2466c179f05034d8 (patch)
tree2296b9b227096ba9d584f80be2b430e382fe39b6
parentd140e597a6a8f2bef8cbc2626effef41025b5688 (diff)
Fix T61035 Draw manager crash opening file with curves
Move free callback call to GPU_batch_discard to prevent the crash. The issue was that clearing can happen after referencing to an instance buffer and that's perfectly legal.
-rw-r--r--source/blender/gpu/GPU_batch.h2
-rw-r--r--source/blender/gpu/intern/gpu_batch.c8
2 files changed, 5 insertions, 5 deletions
diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch.h
index 3d013eb8af4..d789a65a3a4 100644
--- a/source/blender/gpu/GPU_batch.h
+++ b/source/blender/gpu/GPU_batch.h
@@ -106,7 +106,7 @@ void GPU_batch_copy(GPUBatch *batch_dst, GPUBatch *batch_src);
#define GPU_batch_init(batch, prim, verts, elem) \
GPU_batch_init_ex(batch, prim, verts, elem, 0)
-void GPU_batch_clear(GPUBatch *); /* Same as discard but does not free. */
+void GPU_batch_clear(GPUBatch *); /* Same as discard but does not free. (does not clal free callback) */
void GPU_batch_discard(GPUBatch *); /* verts & elem are not discarded */
void GPU_batch_vao_cache_clear(GPUBatch *);
diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c
index 5f00fec7c88..ddd1b056ee7 100644
--- a/source/blender/gpu/intern/gpu_batch.c
+++ b/source/blender/gpu/intern/gpu_batch.c
@@ -120,10 +120,6 @@ void GPU_batch_copy(GPUBatch *batch_dst, GPUBatch *batch_src)
void GPU_batch_clear(GPUBatch *batch)
{
- if (batch->free_callback) {
- batch->free_callback(batch, batch->callback_data);
- }
-
if (batch->owns_flag & GPU_BATCH_OWNS_INDEX) {
GPU_indexbuf_discard(batch->elem);
}
@@ -145,6 +141,10 @@ void GPU_batch_clear(GPUBatch *batch)
void GPU_batch_discard(GPUBatch *batch)
{
+ if (batch->free_callback) {
+ batch->free_callback(batch, batch->callback_data);
+ }
+
GPU_batch_clear(batch);
MEM_freeN(batch);
}