diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-04-19 19:52:38 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-04-19 19:52:38 +0300 |
commit | 3368df4ab6eab69cc7aec30fccb2ac806c45bbe4 (patch) | |
tree | 715f82a4b6909f427e283b870199ea3d7b340c35 /source/blender/draw | |
parent | 7e4db169f2ab8dd62281f0b42a6f7e33be5f32d6 (diff) |
DRW: Expose VBO garbage collection timings
This adds user side options to tweak the behavior
of the vbo garbage collection.
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_mesh.c | 11 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 11 |
2 files changed, 12 insertions, 10 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index 41de51fde96..a433135e8b9 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -2004,6 +2004,8 @@ typedef struct MeshBatchCache { DRW_MeshCDMask cd_used, cd_needed, cd_used_over_time; + int lastmatch; + /* XXX, only keep for as long as sculpt mode uses shaded drawing. */ bool is_sculpt_points_tag; @@ -4727,16 +4729,21 @@ static void mesh_create_uvedit_buffers(MeshRenderData *rdata, /* Thread safety need to be assured by caller. Don't call this during drawing. * Note: For now this only free the shading batches / vbo if any cd layers is * not needed anymore. */ -void DRW_mesh_batch_cache_free_old(Mesh *me, int UNUSED(ctime)) +void DRW_mesh_batch_cache_free_old(Mesh *me, int ctime) { MeshBatchCache *cache = me->runtime.batch_cache; if (cache == NULL) return; - if (mesh_cd_layers_type_equal(cache->cd_used_over_time, cache->cd_used) == false) { + if (mesh_cd_layers_type_equal(cache->cd_used_over_time, cache->cd_used)) { + cache->lastmatch = ctime; + } + + if (ctime - cache->lastmatch > U.vbotimeout) { mesh_batch_cache_discard_shaded_tri(cache); } + mesh_cd_layers_type_clear(&cache->cd_used_over_time); } diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 394cb6a144f..6c3bc7eb021 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -967,11 +967,9 @@ static void drw_drawdata_unlink_dupli(ID *id) /** \} */ /* -------------------------------------------------------------------- */ -/** \name Rendering (DRW_engines) +/** \name Garbage Collection * \{ */ -#define DRW_BATCH_COLLECTION_RATE 60 /* in sec */ - void DRW_cache_free_old_batches(Main *bmain) { Scene *scene; @@ -979,7 +977,7 @@ void DRW_cache_free_old_batches(Main *bmain) static int lasttime = 0; int ctime = (int)PIL_check_seconds_timer(); - if (ctime % DRW_BATCH_COLLECTION_RATE || ctime == lasttime) + if (U.vbotimeout == 0 || (ctime - lasttime) < U.vbocollectrate || ctime == lasttime) return; lasttime = ctime; @@ -2496,10 +2494,7 @@ void DRW_draw_depth_loop_gpencil(struct Depsgraph *depsgraph, /** * Clears the Depth Buffer and draws only the specified object. */ -void DRW_draw_depth_object(ARegion *ar, - View3D *v3d, - GPUViewport *viewport, - Object *object) +void DRW_draw_depth_object(ARegion *ar, View3D *v3d, GPUViewport *viewport, Object *object) { RegionView3D *rv3d = ar->regiondata; |