DRW: Expose VBO garbage collection timings

This adds user side options to tweak the behavior
of the vbo garbage collection.
This commit is contained in:
2019-04-19 18:52:38 +02:00
parent 7e4db169f2
commit 3368df4ab6
6 changed files with 42 additions and 12 deletions

View File

@@ -685,6 +685,13 @@ class USERPREF_PT_system_memory(PreferencePanel, Panel):
flow.prop(system, "texture_time_out", text="Texture Time Out")
flow.prop(system, "texture_collection_rate", text="Garbage Collection Rate")
layout.separator()
flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
flow.prop(system, "vbo_time_out", text="Vbo Time Out")
flow.prop(system, "vbo_collection_rate", text="Garbage Collection Rate")
class USERPREF_MT_interface_theme_presets(Menu):
bl_label = "Presets"

View File

@@ -496,6 +496,10 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
*/
{
/* (keep this block even if it becomes empty). */
if (userdef->vbotimeout == 0) {
userdef->vbocollectrate = 60;
userdef->vbotimeout = 120;
}
}
if (userdef->pixelsize == 0.0f)

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -643,9 +643,9 @@ typedef struct UserDef {
char _pad3[4];
short gizmo_flag, gizmo_size;
short edit_studio_light;
char _pad6[4];
char _pad6[2];
short vbotimeout, vbocollectrate;
short textimeout, texcollectrate;
char _pad14[2];
int memcachelimit;
int prefetchframes;
/** Control the rotation step of the view when PAD2, PAD4, PAD6&PAD8 is use. */

View File

@@ -4766,6 +4766,23 @@ static void rna_def_userdef_system(BlenderRNA *brna)
"Texture Collection Rate",
"Number of seconds between each run of the GL texture garbage collector");
prop = RNA_def_property(srna, "vbo_time_out", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "vbotimeout");
RNA_def_property_range(prop, 0, 3600);
RNA_def_property_ui_text(
prop,
"VBO Time Out",
"Time since last access of a GL Vertex buffer object in seconds after which it is freed "
"(set to 0 to keep vbo allocated)");
prop = RNA_def_property(srna, "vbo_collection_rate", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "vbocollectrate");
RNA_def_property_range(prop, 1, 3600);
RNA_def_property_ui_text(
prop,
"VBO Collection Rate",
"Number of seconds between each run of the GL Vertex buffer object garbage collector");
/* Select */
prop = RNA_def_property(srna, "use_select_pick_depth", PROP_BOOLEAN, PROP_NONE);