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:
authorBastien Montagne <montagne29@wanadoo.fr>2016-06-02 16:57:58 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2016-06-02 17:14:21 +0300
commit68d1348ca2f4ae7fcd6eff5b7bdbd84d75988ae8 (patch)
treee8ee1c93ebc2fa36ed72330ac8f3ae9e4eddfde5 /source/blender/blenkernel/intern/pbvh.c
parentac8246cd893c417d89dfde9704cc0ae2edbbc936 (diff)
Fix T47637: Multiple multires objects in Sculpt mode make blender crash.
That was a nice and funny hunt, albeit rather time consumming! To summarize, so far code was using a static global gpu_buffer for pbvh vbo drawing of 'grid' types (multires mostly?). There were two issues here: 1) Global gpu buffer was assigned to GPU_PBVH_Buffers->index_buf, but then nearly no check was done when freeing that buffer, to ensure we were not freeing the global one (not totally sure this one was actually causing any issue, but was bad and unsafe anyway). Was solved by adding a flag to GPU_PBVH_Buffers to indicate when we are using some 'common' buffer here, which freeing is handled separately. 2) Main issue: if several multires objects in sculpt mode with different grid size were present simultaneously, the global gpu buffer had to be resized for each object draw (i.e., freed and re-allocated), but then the pbvh nodes from other objects storing freed reference to that global buffer had no way to know that it had been freed, which was causing the segfault & crash. Was solved by getting rid of that global buffer, and instead allocating one 'grid_commmon_gpu_buffer' per pbvh. Told ya baby, globals are *PURE EVIL*!
Diffstat (limited to 'source/blender/blenkernel/intern/pbvh.c')
-rw-r--r--source/blender/blenkernel/intern/pbvh.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index d73f087a3fe..58ec75dc706 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -637,6 +637,7 @@ void BKE_pbvh_free(PBVH *bvh)
BLI_gset_free(node->bm_other_verts, NULL);
}
}
+ GPU_free_pbvh_buffer_multires(&bvh->grid_common_gpu_buffer);
if (bvh->deformed) {
if (bvh->verts) {
@@ -1100,7 +1101,7 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode)
node->totprim,
bvh->grid_hidden,
bvh->gridkey.grid_size,
- &bvh->gridkey);
+ &bvh->gridkey, &bvh->grid_common_gpu_buffer);
break;
case PBVH_FACES:
node->draw_buffers =