@@ -546,7 +546,7 @@ static size_t _get_mipmap_size()
546546 dt_sys_resources_t * res = & darktable .dtresources ;
547547 const int level = res -> level ;
548548 if (level < 0 )
549- return res -> refresource [4 * (- level - 1 ) + 2 ] * 1024lu * 1024lu ;
549+ return res -> refresource [4 * (- level - 1 ) + 2 ] * DT_MEGA ;
550550 const int fraction = res -> fractions [4 * level + 2 ];
551551 return res -> total_memory / 1024lu * fraction ;
552552}
@@ -1169,6 +1169,7 @@ int dt_init(int argc, char *argv[], const gboolean init_gui, const gboolean load
11691169 CHKSIGDBG (DT_SIGNAL_CONTROL_TOAST_REDRAW );
11701170 CHKSIGDBG (DT_SIGNAL_CONTROL_PICKERDATA_READY );
11711171 CHKSIGDBG (DT_SIGNAL_METADATA_UPDATE );
1172+ CHKSIGDBG (DT_SIGNAL_PRESET_APPLIED );
11721173 else
11731174 {
11741175 dt_print (DT_DEBUG_SIGNAL ,
@@ -1694,7 +1695,9 @@ int dt_init(int argc, char *argv[], const gboolean init_gui, const gboolean load
16941695 dt_sys_resources_t * res = & darktable .dtresources ;
16951696 res -> fractions = fractions ;
16961697 res -> refresource = ref_resources ;
1697- res -> total_memory = _get_total_memory () * 1024lu ;
1698+ size_t total_mb = _get_total_memory () / 1024lu ;
1699+ if (total_mb < 8192 ) total_mb -= 1024 ;
1700+ res -> total_memory = total_mb * DT_MEGA ;
16981701
16991702 char * config_info = calloc (1 , DT_PERF_INFOSIZE );
17001703 if (last_configure_version != DT_CURRENT_PERFORMANCE_CONFIGURE_VERSION
@@ -1706,7 +1709,7 @@ int dt_init(int argc, char *argv[], const gboolean init_gui, const gboolean load
17061709 dt_get_sysresource_level ();
17071710 res -> mipmap_memory = _get_mipmap_size ();
17081711 dt_print (DT_DEBUG_MEMORY | DT_DEBUG_DEV ,
1709- " mipmap cache: %luMB" , res -> mipmap_memory / 1024lu / 1024lu );
1712+ " mipmap cache: %luMB" , res -> mipmap_memory / DT_MEGA );
17101713 // initialize collection query
17111714 darktable .collection = dt_collection_new (NULL );
17121715
@@ -2007,11 +2010,11 @@ void dt_get_sysresource_level()
20072010 dt_print (DT_DEBUG_MEMORY | DT_DEBUG_DEV ,
20082011 "[dt_get_sysresource_level] switched to `%s'" , config );
20092012 dt_print (DT_DEBUG_MEMORY | DT_DEBUG_DEV ,
2010- " total mem: %luMB" , res -> total_memory / 1024lu / 1024lu );
2013+ " total mem: %luMB" , res -> total_memory / DT_MEGA );
20112014 dt_print (DT_DEBUG_MEMORY | DT_DEBUG_DEV ,
2012- " available mem: %luMB" , dt_get_available_mem () / 1024lu / 1024lu );
2015+ " available mem: %luMB" , dt_get_available_mem () / DT_MEGA );
20132016 dt_print (DT_DEBUG_MEMORY | DT_DEBUG_DEV ,
2014- " singlebuff: %luMB" , dt_get_singlebuffer_mem () / 1024lu / 1024lu );
2017+ " singlebuff: %luMB" , dt_get_singlebuffer_mem () / DT_MEGA );
20152018 }
20162019}
20172020
@@ -2340,27 +2343,27 @@ size_t dt_get_available_mem()
23402343 dt_sys_resources_t * res = & darktable .dtresources ;
23412344 const int level = res -> level ;
23422345 if (level < 0 )
2343- return res -> refresource [4 * (- level - 1 )] * 1024lu * 1024lu ;
2346+ return res -> refresource [4 * (- level - 1 )] * DT_MEGA ;
23442347
23452348 const int fraction = res -> fractions [4 * level ];
2346- return MAX (512lu * 1024lu * 1024lu , res -> total_memory / 1024lu * fraction );
2349+ return MAX (512lu * DT_MEGA , res -> total_memory / 1024lu * fraction );
23472350}
23482351
23492352size_t dt_get_singlebuffer_mem ()
23502353{
23512354 dt_sys_resources_t * res = & darktable .dtresources ;
23522355 const int level = res -> level ;
23532356 if (level < 0 )
2354- return res -> refresource [4 * (- level - 1 ) + 1 ] * 1024lu * 1024lu ;
2357+ return res -> refresource [4 * (- level - 1 ) + 1 ] * DT_MEGA ;
23552358
23562359 const int fraction = res -> fractions [4 * level + 1 ];
2357- return MAX (2lu * 1024lu * 1024lu , res -> total_memory / 1024lu * fraction );
2360+ return MAX (2lu * DT_MEGA , res -> total_memory / 1024lu * fraction );
23582361}
23592362
23602363void dt_configure_runtime_performance (const int old , char * info )
23612364{
23622365 const size_t threads = dt_get_num_procs ();
2363- const size_t mem = darktable .dtresources .total_memory / 1024lu / 1024lu ;
2366+ const size_t mem = darktable .dtresources .total_memory / DT_MEGA ;
23642367 const size_t bits = CHAR_BIT * sizeof (void * );
23652368 const gboolean sufficient = mem >= 4096 && threads >= 2 ;
23662369
0 commit comments