@@ -256,12 +256,17 @@ gboolean dt_dev_pixelpipe_init_cached(dt_dev_pixelpipe_t *pipe,
256
256
return dt_dev_pixelpipe_cache_init (pipe , entries , size , memlimit );
257
257
}
258
258
259
- static void get_output_format (
260
- dt_iop_module_t * module ,
261
- dt_dev_pixelpipe_t * pipe ,
262
- dt_dev_pixelpipe_iop_t * piece ,
263
- dt_develop_t * dev ,
264
- dt_iop_buffer_dsc_t * dsc )
259
+ size_t dt_get_available_pipe_mem (const dt_dev_pixelpipe_t * pipe )
260
+ {
261
+ size_t allmem = dt_get_available_mem ();
262
+ return MAX (1lu * 1024lu * 1024lu , allmem / (pipe -> type & DT_DEV_PIXELPIPE_THUMBNAIL ? 3 : 1 ));
263
+ }
264
+
265
+ static void get_output_format (dt_iop_module_t * module ,
266
+ dt_dev_pixelpipe_t * pipe ,
267
+ dt_dev_pixelpipe_iop_t * piece ,
268
+ dt_develop_t * dev ,
269
+ dt_iop_buffer_dsc_t * dsc )
265
270
{
266
271
if (module ) return module -> output_format (module , pipe , piece , dsc );
267
272
@@ -662,15 +667,14 @@ void dt_dev_pixelpipe_usedetails(dt_dev_pixelpipe_t *pipe)
662
667
pipe -> want_detail_mask = TRUE;
663
668
}
664
669
665
- static void _dump_pipe_pfm_diff (
666
- const char * mod ,
667
- const void * indata ,
668
- const dt_iop_roi_t * roi_in ,
669
- const int inbpp ,
670
- const void * outdata ,
671
- const dt_iop_roi_t * roi_out ,
672
- const int outbpp ,
673
- const char * pipe )
670
+ static void _dump_pipe_pfm_diff (const char * mod ,
671
+ const void * indata ,
672
+ const dt_iop_roi_t * roi_in ,
673
+ const int inbpp ,
674
+ const void * outdata ,
675
+ const dt_iop_roi_t * roi_out ,
676
+ const int outbpp ,
677
+ const char * pipe )
674
678
{
675
679
if (!darktable .dump_pfm_pipe ) return ;
676
680
if (!mod ) return ;
@@ -1089,19 +1093,18 @@ static void _collect_histogram_on_CPU(dt_dev_pixelpipe_t *pipe,
1089
1093
}
1090
1094
}
1091
1095
1092
- static gboolean _pixelpipe_process_on_CPU (
1093
- dt_dev_pixelpipe_t * pipe ,
1094
- dt_develop_t * dev ,
1095
- float * input ,
1096
- dt_iop_buffer_dsc_t * input_format ,
1097
- const dt_iop_roi_t * roi_in ,
1098
- void * * output ,
1099
- dt_iop_buffer_dsc_t * * out_format ,
1100
- const dt_iop_roi_t * roi_out ,
1101
- dt_iop_module_t * module ,
1102
- dt_dev_pixelpipe_iop_t * piece ,
1103
- dt_develop_tiling_t * tiling ,
1104
- dt_pixelpipe_flow_t * pixelpipe_flow )
1096
+ static gboolean _pixelpipe_process_on_CPU (dt_dev_pixelpipe_t * pipe ,
1097
+ dt_develop_t * dev ,
1098
+ float * input ,
1099
+ dt_iop_buffer_dsc_t * input_format ,
1100
+ const dt_iop_roi_t * roi_in ,
1101
+ void * * output ,
1102
+ dt_iop_buffer_dsc_t * * out_format ,
1103
+ const dt_iop_roi_t * roi_out ,
1104
+ dt_iop_module_t * module ,
1105
+ dt_dev_pixelpipe_iop_t * piece ,
1106
+ dt_develop_tiling_t * tiling ,
1107
+ dt_pixelpipe_flow_t * pixelpipe_flow )
1105
1108
{
1106
1109
if (dt_atomic_get_int (& pipe -> shutdown ))
1107
1110
return TRUE;
@@ -1162,7 +1165,7 @@ static gboolean _pixelpipe_process_on_CPU(
1162
1165
const size_t m_width = MAX (roi_in -> width , roi_out -> width );
1163
1166
const size_t m_height = MAX (roi_in -> height , roi_out -> height );
1164
1167
1165
- const gboolean fitting = dt_tiling_piece_fits_host_memory (m_width , m_height , m_bpp , tiling -> factor , tiling -> overhead );
1168
+ const gboolean fitting = dt_tiling_piece_fits_host_memory (piece , m_width , m_height , m_bpp , tiling -> factor , tiling -> overhead );
1166
1169
/* process module on cpu. use tiling if needed and possible. */
1167
1170
1168
1171
const gboolean pfm_dump = darktable .dump_pfm_pipe
@@ -1330,16 +1333,15 @@ static inline gboolean _skip_piece_on_tags(const dt_dev_pixelpipe_iop_t *piece)
1330
1333
}
1331
1334
1332
1335
// recursive helper for process, returns TRUE in case of unfinished work or error
1333
- static gboolean _dev_pixelpipe_process_rec (
1334
- dt_dev_pixelpipe_t * pipe ,
1335
- dt_develop_t * dev ,
1336
- void * * output ,
1337
- void * * cl_mem_output ,
1338
- dt_iop_buffer_dsc_t * * out_format ,
1339
- const dt_iop_roi_t * roi_out ,
1340
- GList * modules ,
1341
- GList * pieces ,
1342
- const int pos )
1336
+ static gboolean _dev_pixelpipe_process_rec (dt_dev_pixelpipe_t * pipe ,
1337
+ dt_develop_t * dev ,
1338
+ void * * output ,
1339
+ void * * cl_mem_output ,
1340
+ dt_iop_buffer_dsc_t * * out_format ,
1341
+ const dt_iop_roi_t * roi_out ,
1342
+ GList * modules ,
1343
+ GList * pieces ,
1344
+ const int pos )
1343
1345
{
1344
1346
if (dt_atomic_get_int (& pipe -> shutdown ))
1345
1347
return TRUE;
@@ -1917,13 +1919,13 @@ static gboolean _dev_pixelpipe_process_rec(
1917
1919
&& (cho == 1 || cho == 4 )
1918
1920
&& dt_str_commasubstring (darktable .dump_diff_pipe , module -> op ))
1919
1921
{
1920
- const size_t ow = roi_out -> width ;
1921
- const size_t oh = roi_out -> height ;
1922
- const size_t iw = roi_in .width ;
1923
- const size_t ih = roi_in .height ;
1924
- float * clindata = dt_alloc_align_float (iw * ih * ch );
1925
- float * cloutdata = dt_alloc_align_float (ow * oh * cho );
1926
- float * cpudata = dt_alloc_align_float (ow * oh * cho );
1922
+ const int ow = roi_out -> width ;
1923
+ const int oh = roi_out -> height ;
1924
+ const int iw = roi_in .width ;
1925
+ const int ih = roi_in .height ;
1926
+ float * clindata = dt_alloc_align_float (( size_t ) iw * ih * ch );
1927
+ float * cloutdata = dt_alloc_align_float (( size_t ) ow * oh * cho );
1928
+ float * cpudata = dt_alloc_align_float (( size_t ) ow * oh * cho );
1927
1929
if (clindata && cloutdata && cpudata )
1928
1930
{
1929
1931
cl_int terr = dt_opencl_read_host_from_device (pipe -> devid , cloutdata , * cl_mem_output , ow , oh , cho * sizeof (float ));
@@ -2582,14 +2584,13 @@ static gboolean _dev_pixelpipe_process_rec(
2582
2584
}
2583
2585
2584
2586
2585
- gboolean dt_dev_pixelpipe_process_no_gamma (
2586
- dt_dev_pixelpipe_t * pipe ,
2587
- dt_develop_t * dev ,
2588
- const int x ,
2589
- const int y ,
2590
- const int width ,
2591
- const int height ,
2592
- const float scale )
2587
+ gboolean dt_dev_pixelpipe_process_no_gamma (dt_dev_pixelpipe_t * pipe ,
2588
+ dt_develop_t * dev ,
2589
+ const int x ,
2590
+ const int y ,
2591
+ const int width ,
2592
+ const int height ,
2593
+ const float scale )
2593
2594
{
2594
2595
// temporarily disable gamma mapping.
2595
2596
GList * gammap = g_list_last (pipe -> nodes );
@@ -2638,16 +2639,15 @@ void dt_dev_pixelpipe_disable_before(dt_dev_pixelpipe_t *pipe, const char *op)
2638
2639
}
2639
2640
2640
2641
// returns TRUE in case of error or early exit
2641
- static gboolean _dev_pixelpipe_process_rec_and_backcopy (
2642
- dt_dev_pixelpipe_t * pipe ,
2643
- dt_develop_t * dev ,
2644
- void * * output ,
2645
- void * * cl_mem_output ,
2646
- dt_iop_buffer_dsc_t * * out_format ,
2647
- const dt_iop_roi_t * roi_out ,
2648
- GList * modules ,
2649
- GList * pieces ,
2650
- const int pos )
2642
+ static gboolean _dev_pixelpipe_process_rec_and_backcopy (dt_dev_pixelpipe_t * pipe ,
2643
+ dt_develop_t * dev ,
2644
+ void * * output ,
2645
+ void * * cl_mem_output ,
2646
+ dt_iop_buffer_dsc_t * * out_format ,
2647
+ const dt_iop_roi_t * roi_out ,
2648
+ GList * modules ,
2649
+ GList * pieces ,
2650
+ const int pos )
2651
2651
{
2652
2652
dt_pthread_mutex_lock (& pipe -> busy_mutex );
2653
2653
darktable .dtresources .group = 4 * darktable .dtresources .level ;
@@ -2691,15 +2691,14 @@ static gboolean _dev_pixelpipe_process_rec_and_backcopy(
2691
2691
return ret ;
2692
2692
}
2693
2693
2694
- gboolean dt_dev_pixelpipe_process (
2695
- dt_dev_pixelpipe_t * pipe ,
2696
- dt_develop_t * dev ,
2697
- const int x ,
2698
- const int y ,
2699
- const int width ,
2700
- const int height ,
2701
- const float scale ,
2702
- const int devid )
2694
+ gboolean dt_dev_pixelpipe_process (dt_dev_pixelpipe_t * pipe ,
2695
+ dt_develop_t * dev ,
2696
+ const int x ,
2697
+ const int y ,
2698
+ const int width ,
2699
+ const int height ,
2700
+ const float scale ,
2701
+ const int devid )
2703
2702
{
2704
2703
pipe -> processing = TRUE;
2705
2704
pipe -> nocache = (pipe -> type & DT_DEV_PIXELPIPE_IMAGE ) != 0 ;
@@ -2713,9 +2712,6 @@ gboolean dt_dev_pixelpipe_process(
2713
2712
if (!claimed ) // don't free cachelines as the caller is using them
2714
2713
dt_dev_pixelpipe_cache_checkmem (pipe );
2715
2714
2716
- dt_print (DT_DEBUG_MEMORY , "[memory] before pixelpipe process" );
2717
- dt_print_mem_usage ();
2718
-
2719
2715
if (pipe -> devid > DT_DEVICE_CPU ) dt_opencl_events_reset (pipe -> devid );
2720
2716
2721
2717
dt_iop_roi_t roi = (dt_iop_roi_t ){ x , y , width , height , scale };
@@ -2758,9 +2754,13 @@ gboolean dt_dev_pixelpipe_process(
2758
2754
pipe -> image .id ,
2759
2755
darktable .opencl -> dev [pipe -> devid ].cname );
2760
2756
else
2761
- #endif
2762
2757
dt_print_pipe (DT_DEBUG_PIPE , "pipe starting" , pipe , NULL , pipe -> devid , & roi , & roi , "ID=%i" ,
2763
2758
pipe -> image .id );
2759
+ #else
2760
+ dt_print_pipe (DT_DEBUG_PIPE , "pipe starting" , pipe , NULL , pipe -> devid , & roi , & roi , "ID=%i" ,
2761
+ pipe -> image .id );
2762
+ #endif
2763
+ dt_print_mem_usage ("before pixelpipe process" );
2764
2764
2765
2765
// run pixelpipe recursively and get error status
2766
2766
const gboolean err = _dev_pixelpipe_process_rec_and_backcopy (pipe , dev , & buf ,
@@ -2772,10 +2772,9 @@ gboolean dt_dev_pixelpipe_process(
2772
2772
? (dt_opencl_events_flush (pipe -> devid , TRUE) != 0 )
2773
2773
: FALSE;
2774
2774
2775
- // Check if we had opencl errors,
2776
- // remark: opencl errors can come in two ways:
2777
- // processed pipe->opencl_error checked via 'err'
2778
- // OpenCL events so oclerr is TRUE
2775
+ // Check if we had opencl errors, those can come in two ways:
2776
+ // processed pipe->opencl_error checked via 'err'
2777
+ // OpenCL events so oclerr is TRUE
2779
2778
const int old_devid = pipe -> devid ;
2780
2779
if (oclerr || (err && pipe -> opencl_error ))
2781
2780
{
@@ -2874,8 +2873,9 @@ gboolean dt_dev_pixelpipe_process(
2874
2873
if (!claimed )
2875
2874
dt_dev_pixelpipe_cache_report (pipe );
2876
2875
2877
- dt_print_pipe (DT_DEBUG_PIPE , "pipe finished" , pipe , NULL , old_devid , & roi , & roi , "ID=%i\n " ,
2876
+ dt_print_pipe (DT_DEBUG_PIPE , "pipe finished" , pipe , NULL , old_devid , & roi , & roi , "ID=%i" ,
2878
2877
pipe -> image .id );
2878
+ dt_print_mem_usage ("after pixelpipe process" );
2879
2879
2880
2880
pipe -> processing = FALSE;
2881
2881
return FALSE;
0 commit comments