From dad4703ec577adccd252151fc893a24e023ec587 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 26 Jun 2018 11:38:27 +0200 Subject: [PATCH] Fix T55320: Sculpt Mode with dyntopo and smooth shading drawing bug. We have to discard the batch in smooth case, because we are modifying the index buffer (flat shading don't need it, only changes vertex buffer on redraw, which is safe). Many thanks to @fclem for his help on debuging/understanding what was wrong here! --- source/blender/gpu/intern/gpu_buffers.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index df8dbb03284..462785a5dcb 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -791,11 +791,14 @@ void GPU_pbvh_bmesh_buffers_update( tottri = gpu_bmesh_face_visible_count(bm_faces); if (buffers->smooth) { + /* Smooth needs to recreate index buffer, so we have to invalidate the batch. */ + GWN_BATCH_DISCARD_SAFE(buffers->triangles); /* Count visible vertices */ totvert = gpu_bmesh_vert_visible_count(bm_unique_verts, bm_other_verts); } - else + else { totvert = tottri * 3; + } if (!tottri) { buffers->tot_tri = 0;