diff options
author | Joseph Eagar <joeedh@gmail.com> | 2022-02-21 18:46:25 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2022-02-21 18:46:25 +0300 |
commit | 13f84446731b07153ddf6a87967df7c883c18ae1 (patch) | |
tree | 10e46d91ca94d5fe025f11cf142c355a2d885d5b /source/blender/draw | |
parent | c12313cfa88c6216695afe1e066c4f19aab15e04 (diff) |
temp-sculpt-colors: Fix GPU memory leak where vertex
colors weren't always being released following switch
to PBVH drawing
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/engines/workbench/workbench_engine.c | 8 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_extract.h | 3 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_mesh.c | 11 |
3 files changed, 22 insertions, 0 deletions
diff --git a/source/blender/draw/engines/workbench/workbench_engine.c b/source/blender/draw/engines/workbench/workbench_engine.c index 95546a84379..43107b403ad 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.c +++ b/source/blender/draw/engines/workbench/workbench_engine.c @@ -18,6 +18,7 @@ #include "BKE_object.h" #include "BKE_paint.h" #include "BKE_particle.h" +#include "BKE_pbvh.h" #include "DNA_curves_types.h" #include "DNA_fluid_types.h" @@ -262,6 +263,13 @@ static eV3DShadingColorType workbench_color_type_get(WORKBENCH_PrivateData *wpd, const bool is_texpaint_mode = is_active && (wpd->ctx_mode == CTX_MODE_PAINT_TEXTURE); const bool is_vertpaint_mode = is_active && (wpd->ctx_mode == CTX_MODE_PAINT_VERTEX); + /* Needed for mesh cache validation, to prevent two copies of + of vertex color arrays from being sent to the GPU (e.g. + when switching from eevee to workbench). */ + if (ob->sculpt && ob->sculpt->pbvh) { + BKE_pbvh_is_drawing_set(ob->sculpt->pbvh, is_sculpt_pbvh); + } + if (color_type == V3D_SHADING_TEXTURE_COLOR) { if (ob->dt < OB_TEXTURE) { color_type = V3D_SHADING_MATERIAL_COLOR; diff --git a/source/blender/draw/intern/draw_cache_extract.h b/source/blender/draw/intern/draw_cache_extract.h index aaec47b4dce..4567e470146 100644 --- a/source/blender/draw/intern/draw_cache_extract.h +++ b/source/blender/draw/intern/draw_cache_extract.h @@ -308,6 +308,9 @@ typedef struct MeshBatchCache { float tot_area, tot_uv_area; bool no_loose_wire; + + eV3DShadingColorType color_type; + bool pbvh_is_drawing; } MeshBatchCache; #define MBC_EDITUV \ diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index 2cda44ada82..ddb8486e2d1 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -870,6 +870,13 @@ static bool mesh_batch_cache_valid(Object *object, Mesh *me) return false; } + if (object->sculpt && object->sculpt->pbvh) { + if (cache->pbvh_is_drawing != BKE_pbvh_is_drawing(object->sculpt->pbvh)) { + printf("PBVH induced mesh cache invalidation!\n"); + return false; + } + } + if (cache->is_editmode != (me->edit_mesh != NULL)) { return false; } @@ -898,6 +905,10 @@ static void mesh_batch_cache_init(Object *object, Mesh *me) cache->is_editmode = me->edit_mesh != NULL; + if (object->sculpt && object->sculpt->pbvh) { + cache->pbvh_is_drawing = BKE_pbvh_is_drawing(object->sculpt->pbvh); + } + if (cache->is_editmode == false) { // cache->edge_len = mesh_render_edges_len_get(me); // cache->tri_len = mesh_render_looptri_len_get(me); |