95 const char *phase,
const char *slot,
const uint64_t requested_hash,
97 const gboolean verbose)
103 "[pixelpipe_owner] pipe=%s module=%s phase=%s slot=%s req=%" PRIu64
104 " entry=%" PRIu64
"/%" PRIu64
" refs=%i auto=%i data=%p buf=%p name=%s\n",
106 module ? module->op : "base",
110 entry ? entry->hash : DT_PIXELPIPE_CACHE_HASH_INVALID,
111 entry ? entry->serial : 0,
112 entry ? dt_atomic_get_int((dt_atomic_int *)&entry->refcount) : -1,
113 entry ? entry->auto_destroy : -1,
114 entry ? entry->data : NULL,
116 (entry && entry->name) ? entry->name : "-");
121 const char *phase,
const void *buffer,
126 if(!buffer || !format || !roi)
return;
129 const size_t pixels = (size_t)roi->
width * (
size_t)roi->
height;
130 const unsigned int channels = format->
channels;
134 const float *in = (
const float *)buffer;
135 float minv[4] = { FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX };
136 float maxv[4] = { -FLT_MAX, -FLT_MAX, -FLT_MAX, -FLT_MAX };
137 size_t nonfinite = 0;
138 size_t near_black = 0;
140 for(
size_t k = 0; k < pixels; k++, in += channels)
142 gboolean finite =
TRUE;
143 for(
unsigned int c = 0;
c <
MIN(channels, 4U);
c++)
150 minv[
c] = fminf(minv[
c], in[
c]);
151 maxv[
c] = fmaxf(maxv[
c], in[
c]);
160 const float energy = fabsf(in[0]) + ((channels > 1) ? fabsf(in[1]) : 0.0f)
161 + ((channels > 2) ? fabsf(in[2]) : 0.0f);
162 if(energy < 1e-6f) near_black++;
166 "[pixelpipe_stats] pipe=%s module=%s phase=%s type=float ch=%u roi=%dx%d "
167 "rgb_min=(%g,%g,%g) rgb_max=(%g,%g,%g) a_min=%g a_max=%g near_black=%zu/%zu nonfinite=%zu\n",
170 minv[0], (channels > 1) ? minv[1] : 0.0f, (channels > 2) ? minv[2] : 0.0f,
171 maxv[0], (channels > 1) ? maxv[1] : 0.0f, (channels > 2) ? maxv[2] : 0.0f,
172 (channels > 3) ? minv[3] : 0.0f, (channels > 3) ? maxv[3] : 0.0f,
173 near_black, pixels, nonfinite);
177 const uint8_t *in = (
const uint8_t *)buffer;
178 int minv[4] = { 255, 255, 255, 255 };
179 int maxv[4] = { 0, 0, 0, 0 };
180 size_t near_black = 0;
182 for(
size_t k = 0; k < pixels; k++, in += channels)
184 for(
unsigned int c = 0;
c <
MIN(channels, 4U);
c++)
186 minv[
c] =
MIN(minv[
c], in[
c]);
187 maxv[
c] =
MAX(maxv[
c], in[
c]);
190 const int energy = in[0] + ((channels > 1) ? in[1] : 0) + ((channels > 2) ? in[2] : 0);
191 if(energy == 0) near_black++;
195 "[pixelpipe_stats] pipe=%s module=%s phase=%s type=u8 ch=%u roi=%dx%d "
196 "rgb_min=(%d,%d,%d) rgb_max=(%d,%d,%d) a_min=%d a_max=%d near_black=%zu/%zu\n",
199 minv[0], (channels > 1) ? minv[1] : 0, (channels > 2) ? minv[2] : 0,
200 maxv[0], (channels > 1) ? maxv[1] : 0, (channels > 2) ? maxv[2] : 0,
201 (channels > 3) ? minv[3] : 0, (channels > 3) ? maxv[3] : 0,
209 const uint64_t output_hash,
void **output,
214 output ? *output : NULL, output_entry,
FALSE);
232 if(output) *output = NULL;
234 if(*cl_mem_output != NULL)
283inline static void _copy_buffer(
const char *
const restrict input,
char *
const restrict output,
284 const size_t height,
const size_t o_width,
const size_t i_width,
285 const size_t x_offset,
const size_t y_offset,
286 const size_t stride,
const size_t bpp)
289#pragma omp parallel for default(none) \
290 dt_omp_firstprivate(input, output, bpp, o_width, i_width, height, x_offset, y_offset, stride) \
293 for(
size_t j = 0; j <
height; j++)
295 memcpy(output +
bpp * j * o_width,
296 input +
bpp * (x_offset + (y_offset + j) * i_width),
302 const size_t width,
const size_t height,
const size_t chan)
305#pragma omp parallel for simd default(none) \
306 aligned(input, output: 64) \
307 dt_omp_firstprivate(input, output, width, height, chan) \
312 const size_t index = k * chan;
314 output[index + 0] = (float)input[index + 2] / 255.f;
315 output[index + 1] = (float)input[index + 1] / 255.f;
316 output[index + 2] = (float)input[index + 0] / 255.f;
317 output[index + 3] = 0.f;
361 const gboolean is_cl,
364 const size_t in_bpp,
const size_t out_bpp,
365 const int cst_before,
const int cst_after)
369 const char *module_name =
module ? module->op : "base";
371 const char *stage_name = stage ? stage :
"process";
373 if(in_dsc && out_dsc)
376 "[pixelpipe] %s %s %s %s: in cst=%s->%s ch=%d type=%s bpp=%zu roi=%dx%d | "
377 "out cst=%s ch=%d type=%s bpp=%zu roi=%dx%d\n",
378 pipe_name, module_name, is_cl ?
"cl" :
"cpu", stage_name,
381 roi_in ? roi_in->
width : 0, roi_in ? roi_in->
height : 0,
383 out_bpp, roi_out ? roi_out->
width : 0, roi_out ? roi_out->
height : 0);
388 "[pixelpipe] %s %s %s %s: out cst=%s ch=%d type=%s bpp=%zu roi=%dx%d\n",
389 pipe_name, module_name, is_cl ?
"cl" :
"cpu", stage_name,
391 out_bpp, roi_out ? roi_out->
width : 0, roi_out ? roi_out->
height : 0);
497 pipe->
icc_filename = g_strdup(icc_filename ? icc_filename :
"");
577 for(GList *nodes = g_list_first(pipe->
nodes); nodes; nodes = g_list_next(nodes))
580 if(piece == NULL)
continue;
586 g_list_free(pipe->
nodes);
596 g_assert(pipe->
nodes == NULL);
601 for(GList *modules = g_list_first(dev->
iop); modules; modules = g_list_next(modules))
606 piece->
enabled =
module->enabled;
608 piece->histogram_params.bins_count = 256;
609 piece->iwidth = pipe->
iwidth;
610 piece->iheight = pipe->
iheight;
611 piece->module =
module;
617 piece->force_opencl_cache =
TRUE;
621 piece->dsc_mask.channels = 1;
627 pipe->
nodes = g_list_append(pipe->
nodes, piece);
644 if(output_dsc->
cst != blend_cst)
650#define KILL_SWITCH_ABORT \
651 if(dt_atomic_get_int(&pipe->shutdown)) \
653 if(cl_mem_output != NULL) \
655 dt_dev_pixelpipe_gpu_clear_buffer(&cl_mem_output, NULL, NULL, FALSE); \
658 pipe->status = DT_DEV_PIXELPIPE_DIRTY; \
664#define KILL_SWITCH_AND_FLUSH_CACHE \
665 if(dt_atomic_get_int(&pipe->shutdown)) \
667 return _abort_module_shutdown_cleanup(pipe, piece, module, input_hash, input, input_entry, hash, &output, \
668 &cl_mem_output, output_entry); \
673 const gboolean recycled_output_cacheline,
dt_times_t *start)
675 char histogram_log[32] =
"";
678 snprintf(histogram_log,
sizeof(histogram_log),
", collected histogram on %s",
686 start,
"[dev_pixelpipe]",
"processed `%s' on %s%s%s%s, blended on %s [%s]", module_label,
691 recycled_output_cacheline ?
", recycled cacheline" :
"",
715 int hasinf = 0, hasnan = 0;
716 dt_aligned_pixel_t
min = { FLT_MAX };
717 dt_aligned_pixel_t
max = { FLT_MIN };
719 for(
int k = 0; k < 4 * roi_out->
width * roi_out->
height; k++)
723 float f = ((
float *)(output))[k];
730 min[k & 3] = fmin(
f,
min[k & 3]);
731 max[k & 3] = fmax(
f,
max[k & 3]);
736 fprintf(stderr,
"[dev_pixelpipe] module `%s' outputs NaNs! [%s]\n", module_label,
739 fprintf(stderr,
"[dev_pixelpipe] module `%s' outputs non-finite floats! [%s]\n", module_label,
741 fprintf(stderr,
"[dev_pixelpipe] module `%s' min: (%f; %f; %f) max: (%f; %f; %f) [%s]\n", module_label,
746 int hasinf = 0, hasnan = 0;
750 for(
int k = 0; k < roi_out->
width * roi_out->
height; k++)
752 float f = ((
float *)(output))[k];
764 fprintf(stderr,
"[dev_pixelpipe] module `%s' outputs NaNs! [%s]\n", module_label,
767 fprintf(stderr,
"[dev_pixelpipe] module `%s' outputs non-finite floats! [%s]\n", module_label,
769 fprintf(stderr,
"[dev_pixelpipe] module `%s' min: (%f) max: (%f) [%s]\n", module_label,
min,
max,
779 for(GList *node = g_list_first(pipe->
nodes); node; node = g_list_next(node))
795 const size_t bpp = out_format->
bpp;
804 TRUE, &output, &cache_entry);
805 if(cache_entry == NULL)
return 1;
808 gboolean host_rewritten =
FALSE;
837 const int in_x =
MAX(roi.
x, 0);
838 const int in_y =
MAX(roi.
y, 0);
844 host_rewritten =
TRUE;
865 if(!err && host_rewritten)
887 GList *pieces,
int pos)
894 void *cl_mem_output = NULL;
921 module = piece->module;
935 void *existing_output = NULL;
936 const gboolean exact_output_cache_hit
941 if(exact_output_cache_hit)
957 "[picker/rec] module=%s child recursion failed input_hash=%" PRIu64
" output_hash=%" PRIu64
"\n",
958 module->op, input_hash, hash);
972 "[picker/rec] module=%s input cache entry missing input_hash=%" PRIu64
" output_hash=%" PRIu64
973 " prev_module=%s prev_hash=%" PRIu64
"\n",
974 module->op, input_hash, hash,
975 previous_piece ? previous_piece->module->op :
"base",
984 const size_t bufsize = (size_t)piece->dsc_out.bpp * piece->roi_out.width * piece->roi_out.height;
999 && (piece->dsc_in.bpp == piece->dsc_out.bpp)
1000 && !memcmp(&piece->roi_in, &piece->roi_out,
sizeof(
struct dt_iop_roi_t)))
1007 *out_hash = input_hash;
1008 *out_piece = previous_piece;
1016 darktable.
main_message = g_strdup_printf(_(
"Processing module `%s` for pipeline %s (%ix%i px @ %0.f%%)..."),
1018 piece->roi_out.width, piece->roi_out.height, piece->roi_out.scale * 100.f);
1028 gchar *
name = g_strdup_printf(
"module %s (%s) for pipe %s", module->op, module->multi_name,
type);
1029 gboolean cache_output = piece->force_opencl_cache;
1035 const gboolean allow_rekey_reuse = dev &&
_requests_cache(pipe, piece) && allow_cache_reuse
1039 cache_output, allow_rekey_reuse,
1040 allow_rekey_reuse ? &piece->cache_entry : NULL,
1041 &output, &output_entry);
1054 "[picker/rec] module=%s exact-hit entry missing output_hash=%" PRIu64
"\n",
1076 "[picker/rec] module=%s writable output acquisition failed output_hash=%" PRIu64
1077 " acquire_status=%d\n",
1078 module->op, hash, acquire_status);
1084 : (new_entry ?
"acquire-new" :
"acquire-existing"),
1085 "output", hash, output, output_entry,
FALSE);
1090 module->tiling_callback(module, pipe, piece, &tiling);
1114 assert(
tiling.factor > 0.0f);
1115 assert(
tiling.factor_cl > 0.0f);
1127 input_entry, output_entry);
1131 input_entry, output_entry);
1145 "[picker/rec] module=%s backend processing failed input_hash=%" PRIu64
" output_hash=%" PRIu64
1146 " input_cst=%d output_cst=%d roi_in=%dx%d roi_out=%dx%d\n",
1147 module->op, input_hash, hash, piece->dsc_in.cst, piece->dsc_out.cst,
1148 piece->roi_in.width, piece->roi_in.height, piece->roi_out.width, piece->roi_out.height);
1169 if(piece && allow_rekey_reuse && output_entry && !cache_output)
1171 piece->cache_entry = *output_entry;
1176 if(output_entry && output != NULL
1187 if(cl_mem_output != NULL)
1226 _print_nan_debug(pipe, cl_mem_output, output, &piece->roi_out, &piece->dsc_out, module);
1239 GList *nodes = g_list_last(pipe->
nodes);
1241 while(strcmp(piece->module->op, op))
1245 nodes = g_list_previous(nodes);
1253 GList *nodes = pipe->
nodes;
1255 while(strcmp(piece->module->op, op))
1259 nodes = g_list_next(nodes);
1265#define KILL_SWITCH_PIPE \
1266 if(dt_atomic_get_int(&pipe->shutdown)) \
1268 if(pipe->devid >= 0) \
1270 dt_opencl_unlock_device(pipe->devid); \
1273 pipe->status = DT_DEV_PIXELPIPE_DIRTY; \
1276 g_list_free_full(pipe->forms, (void (*)(void *))dt_masks_free_form); \
1277 pipe->forms = NULL; \
1279 dt_pthread_mutex_unlock(&darktable.pipeline_threadsafe); \
1294 "[opencl] Too many opencl errors; disabling opencl for this session!\n");
1295 dt_control_log(_(
"Ansel discovered problems with your OpenCL setup; disabling OpenCL for this session!"));
1308 entry ? entry->
data : NULL, entry,
FALSE);
1312 || entry_hash != requested_hash)
1345 fprintf(stderr,
"[memory] before pixelpipe process\n");
1362 const guint pos = g_list_length(dev->
iop);
1391 GList *pieces = g_list_last(pipe->
nodes);
1410 gboolean keep_running =
TRUE;
1412 int opencl_error = 0;
1415 while(keep_running && runs < 3)
1446 keep_running = (oclerr || (err && pipe->
opencl_error));
1473 void *final_buf = NULL;
1475 &final_entry, pipe->
devid, NULL)
1476 && final_buf != NULL)
1480 "[picker/rec] final output cache missing pipe=%s hash=%" PRIu64
" history=%" PRIu64
1481 " devid=%d err=%d\n",
1498 if(pipe->
devid >= 0)
static void error(char *msg)
Definition ashift_lsd.c:202
#define TRUE
Definition ashift_lsd.c:162
#define FALSE
Definition ashift_lsd.c:158
void dt_atomic_set_int(dt_atomic_int *var, int value)
Definition atomic.h:65
int dt_atomic_get_int(dt_atomic_int *var)
Definition atomic.h:66
atomic_int dt_atomic_int
Definition atomic.h:63
int levels(struct dt_imageio_module_data_t *data)
Definition avif.c:694
int width
Definition bilateral.h:1
int height
Definition bilateral.h:1
void tiling_callback_blendop(struct dt_iop_module_t *self, const struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, struct dt_develop_tiling_t *tiling)
Definition blend.c:1512
dt_iop_colorspace_type_t dt_develop_blend_colorspace(const dt_dev_pixelpipe_iop_t *const piece, dt_iop_colorspace_type_t cst)
Definition blend.c:184
@ DEVELOP_MASK_DISABLED
Definition blend.h:112
dt_iop_colorspace_type_t
Definition color_conversion.h:30
@ IOP_CS_RAW
Definition color_conversion.h:32
@ IOP_CS_LCH
Definition color_conversion.h:35
@ IOP_CS_JZCZHZ
Definition color_conversion.h:37
@ IOP_CS_RGB
Definition color_conversion.h:34
@ IOP_CS_HSL
Definition color_conversion.h:36
@ IOP_CS_LAB
Definition color_conversion.h:33
@ IOP_CS_NONE
Definition color_conversion.h:31
dt_iop_color_intent_t
Definition colorspaces.h:63
@ DT_INTENT_LAST
Definition colorspaces.h:68
dt_colorspaces_color_profile_type_t
Definition colorspaces.h:81
@ DT_COLORSPACE_NONE
Definition colorspaces.h:82
const float c
Definition colorspaces_inline_conversions.h:1365
const dt_aligned_pixel_t f
Definition colorspaces_inline_conversions.h:256
const float d
Definition colorspaces_inline_conversions.h:931
static const float const float const float min
Definition colorspaces_inline_conversions.h:667
const float r
Definition colorspaces_inline_conversions.h:1324
const float max
Definition colorspaces_inline_conversions.h:721
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
void dt_control_log(const char *msg,...)
Definition control.c:530
void dt_control_queue_redraw_center()
request redraw of center window. This redraws the center view within a gdk critical section to preven...
Definition control.c:630
void dt_show_times(const dt_times_t *start, const char *prefix)
Definition darktable.c:1568
darktable_t darktable
Definition darktable.c:178
void dt_print_mem_usage()
Definition darktable.c:1795
void dt_capabilities_remove(char *capability)
Definition darktable.c:1778
void dt_show_times_f(const dt_times_t *start, const char *prefix, const char *suffix,...)
Definition darktable.c:1582
void dt_print(dt_debug_thread_t thread, const char *msg,...)
Definition darktable.c:1530
#define UNKNOWN_IMAGE
Definition darktable.h:181
@ DT_DEBUG_OPENCL
Definition darktable.h:642
@ DT_DEBUG_PIPE
Definition darktable.h:661
@ DT_DEBUG_NAN
Definition darktable.h:646
@ DT_DEBUG_MEMORY
Definition darktable.h:644
@ DT_DEBUG_VERBOSE
Definition darktable.h:663
@ DT_DEBUG_CACHE
Definition darktable.h:636
@ DT_DEBUG_DEV
Definition darktable.h:638
@ DT_DEBUG_NOCACHE_REUSE
Definition darktable.h:665
static void dt_free_gpointer(gpointer ptr)
Definition darktable.h:387
#define dt_free(ptr)
Definition darktable.h:380
static void dt_get_times(dt_times_t *t)
Definition darktable.h:853
uint64_t dt_dev_pixelpipe_node_hash(dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, const dt_iop_roi_t roi_out, const int pos)
Definition dev_pixelpipe.c:315
void dt_dev_pixelpipe_get_roi_in(dt_dev_pixelpipe_t *pipe, struct dt_develop_t *dev, const struct dt_iop_roi_t roi_out)
Definition dev_pixelpipe.c:259
void dt_pixelpipe_get_global_hash(dt_dev_pixelpipe_t *pipe, dt_develop_t *dev)
Definition dev_pixelpipe.c:543
void dt_dev_set_backbuf(dt_backbuf_t *backbuf, const int width, const int height, const size_t bpp, const int64_t hash, const int64_t history_hash)
Definition develop.c:1709
gchar * dt_history_item_get_name(const struct dt_iop_module_t *module)
Definition develop.c:1354
@ DT_DEV_PIXELPIPE_DISPLAY_NONE
Definition develop.h:111
static int dt_pthread_mutex_unlock(dt_pthread_mutex_t *mutex) RELEASE(mutex) NO_THREAD_SAFETY_ANALYSIS
Definition dtpthread.h:374
static int dt_pthread_mutex_init(dt_pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr)
Definition dtpthread.h:359
static int dt_pthread_mutex_destroy(dt_pthread_mutex_t *mutex)
Definition dtpthread.h:379
#define dt_pthread_rwlock_unlock
Definition dtpthread.h:392
static int dt_pthread_mutex_lock(dt_pthread_mutex_t *mutex) ACQUIRE(mutex) NO_THREAD_SAFETY_ANALYSIS
Definition dtpthread.h:364
#define dt_pthread_rwlock_rdlock
Definition dtpthread.h:393
@ IMAGEIO_RGB
Definition imageio.h:69
@ IMAGEIO_INT8
Definition imageio.h:61
void dt_iop_init_pipe(struct dt_iop_module_t *module, struct dt_dev_pixelpipe_t *pipe, struct dt_dev_pixelpipe_iop_t *piece)
Definition imageop.c:535
void dt_iop_nap(int32_t usec)
Definition imageop.c:2578
void dt_iop_cleanup_pipe(struct dt_iop_module_t *module, struct dt_dev_pixelpipe_t *pipe, struct dt_dev_pixelpipe_iop_t *piece)
Definition imageop.c:542
@ IOP_FLAGS_SUPPORTS_BLENDING
Definition imageop.h:144
@ IOP_TAG_DISTORT
Definition imageop.h:128
GList * dt_ioppr_iop_order_copy_deep(GList *iop_order_list)
Deep-copy an order list.
Definition iop_order.c:1669
GList * dt_masks_dup_forms_deep(GList *forms, dt_masks_form_t *form)
Duplicate the list of forms, replacing a single item by formid match.
Definition develop/masks/masks.c:718
void dt_masks_free_form(dt_masks_form_t *form)
Definition develop/masks/masks.c:1997
size_t size
Definition mipmap_cache.c:3
#define dt_mipmap_cache_get(A, B, C, D, E, F)
Definition mipmap_cache.h:120
@ DT_MIPMAP_BLOCKING
Definition mipmap_cache.h:60
#define dt_mipmap_cache_release(A, B)
Definition mipmap_cache.h:142
dt_mipmap_size_t
Definition mipmap_cache.h:40
static void dt_opencl_events_reset(const int devid)
Definition opencl.h:626
static void dt_opencl_unlock_device(const int dev)
Definition opencl.h:538
static int dt_opencl_update_settings(void)
Definition opencl.h:594
static void dt_opencl_check_tuning(const int devid)
Definition opencl.h:607
#define DT_OPENCL_MAX_ERRORS
Definition opencl.h:49
static int dt_opencl_lock_device(const int dev)
Definition opencl.h:534
static int dt_opencl_events_flush(const int devid, const int reset)
Definition opencl.h:632
void dt_pixelpipe_raster_cleanup(GHashTable *raster_masks)
Definition pixelpipe.c:55
GHashTable * dt_pixelpipe_raster_alloc()
Definition pixelpipe.c:50
@ DT_REQUEST_ON
Definition pixelpipe.h:48
@ DT_REQUEST_ONLY_IN_GUI
Definition pixelpipe.h:49
dt_dev_pixelpipe_type_t
Definition pixelpipe.h:36
@ DT_DEV_PIXELPIPE_THUMBNAIL
Definition pixelpipe.h:41
@ DT_DEV_PIXELPIPE_EXPORT
Definition pixelpipe.h:38
@ DT_DEV_PIXELPIPE_PREVIEW
Definition pixelpipe.h:40
@ DT_DEV_PIXELPIPE_FULL
Definition pixelpipe.h:39
void dt_pixel_cache_clmem_flush(dt_pixel_cache_entry_t *entry)
Definition pixelpipe_cache.c:735
void * dt_pixel_cache_entry_get_data(dt_pixel_cache_entry_t *entry)
Definition pixelpipe_cache.c:1081
void dt_dev_pixelpipe_cache_ref_count_entry(dt_dev_pixelpipe_cache_t *cache, gboolean lock, dt_pixel_cache_entry_t *cache_entry)
Increase/Decrease the reference count on the cache line as to prevent LRU item removal....
Definition pixelpipe_cache.c:1871
void dt_dev_pixelpipe_cache_print(dt_dev_pixelpipe_cache_t *cache)
Definition pixelpipe_cache.c:2116
void dt_dev_pixelpipe_cache_unref_hash(dt_dev_pixelpipe_cache_t *cache, const uint64_t hash)
Find the entry matching hash, and decrease its ref_count if found.
Definition pixelpipe_cache.c:2016
void dt_dev_pixelpipe_cache_flag_auto_destroy(dt_dev_pixelpipe_cache_t *cache, dt_pixel_cache_entry_t *cache_entry)
Flag the cache entry as "auto_destroy". This is useful for short-lived/disposable cache entries,...
Definition pixelpipe_cache.c:1912
void dt_dev_pixelpipe_cache_auto_destroy_apply(dt_dev_pixelpipe_cache_t *cache, dt_pixel_cache_entry_t *cache_entry)
Free the entry if it has the flag "auto_destroy". See dt_dev_pixelpipe_cache_flag_auto_destroy()....
Definition pixelpipe_cache.c:1928
void dt_dev_pixelpipe_cache_flush_clmem(dt_dev_pixelpipe_cache_t *cache, const int devid, void *keep)
Release cached OpenCL buffers for a device (-1 for all).
Definition pixelpipe_cache.c:461
gboolean dt_dev_pixelpipe_cache_peek(dt_dev_pixelpipe_cache_t *cache, const uint64_t hash, void **data, dt_pixel_cache_entry_t **entry, const int preferred_devid, void **cl_mem_output)
Non-owning lookup of an existing cache line.
Definition pixelpipe_cache.c:1704
dt_pixel_cache_entry_t * dt_dev_pixelpipe_cache_get_entry(dt_dev_pixelpipe_cache_t *cache, const uint64_t hash)
Get an internal reference to the cache entry matching hash. If you are going to access this entry mor...
Definition pixelpipe_cache.c:136
int dt_dev_pixelpipe_cache_get(dt_dev_pixelpipe_cache_t *cache, const uint64_t hash, const size_t size, const char *name, const int id, const gboolean alloc, void **data, dt_pixel_cache_entry_t **entry)
Get a cache line from the cache.
Definition pixelpipe_cache.c:1438
int dt_dev_pixelpipe_cache_remove(dt_dev_pixelpipe_cache_t *cache, const gboolean force, dt_pixel_cache_entry_t *cache_entry)
Arbitrarily remove the cache entry matching hash. Entries having a reference count > 0 (inter-thread ...
Definition pixelpipe_cache.c:209
dt_dev_pixelpipe_cache_writable_status_t dt_dev_pixelpipe_cache_get_writable(dt_dev_pixelpipe_cache_t *cache, const uint64_t hash, const size_t size, const char *name, const int id, const gboolean alloc, const gboolean allow_rekey_reuse, const dt_pixel_cache_entry_t *reuse_hint, void **data, dt_pixel_cache_entry_t **entry)
Definition pixelpipe_cache.c:1508
void dt_dev_pixelpipe_cache_wrlock_entry(dt_dev_pixelpipe_cache_t *cache, gboolean lock, dt_pixel_cache_entry_t *cache_entry)
Lock or release the write lock on the entry.
Definition pixelpipe_cache.c:1880
size_t dt_pixel_cache_entry_get_size(dt_pixel_cache_entry_t *entry)
Peek the size (in bytes) reserved for the host buffer of a cache entry.
Definition pixelpipe_cache.c:1086
void dt_dev_pixelpipe_cache_rdlock_entry(dt_dev_pixelpipe_cache_t *cache, gboolean lock, dt_pixel_cache_entry_t *cache_entry)
Lock or release the read lock on the entry.
Definition pixelpipe_cache.c:1896
const char * dt_pixelpipe_cache_set_current_module(const char *module)
Set the current module name for cache diagnostics (thread-local).
Definition pixelpipe_cache.c:76
Pixelpipe cache for storing intermediate results in the pixelpipe.
#define DT_PIXELPIPE_CACHE_HASH_INVALID
Definition pixelpipe_cache.h:41
dt_dev_pixelpipe_cache_writable_status_t
Definition pixelpipe_cache.h:69
@ DT_DEV_PIXELPIPE_CACHE_WRITABLE_REKEYED
Definition pixelpipe_cache.h:73
@ DT_DEV_PIXELPIPE_CACHE_WRITABLE_CREATED
Definition pixelpipe_cache.h:72
@ DT_DEV_PIXELPIPE_CACHE_WRITABLE_EXACT_HIT
Definition pixelpipe_cache.h:71
int pixelpipe_process_on_CPU(dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, const dt_dev_pixelpipe_iop_t *previous_piece, dt_develop_tiling_t *tiling, dt_pixelpipe_flow_t *pixelpipe_flow, gboolean *const cache_output, dt_pixel_cache_entry_t *input_entry, dt_pixel_cache_entry_t *output_entry)
Definition pixelpipe_cpu.c:15
int pixelpipe_process_on_GPU(dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, const dt_dev_pixelpipe_iop_t *previous_piece, dt_develop_tiling_t *tiling, dt_pixelpipe_flow_t *pixelpipe_flow, gboolean *const cache_output, dt_pixel_cache_entry_t *input_entry, dt_pixel_cache_entry_t *output_entry)
Definition pixelpipe_gpu.c:728
void dt_dev_pixelpipe_gpu_clear_buffer(void **cl_mem_buffer, dt_pixel_cache_entry_t *cache_entry, void *host_ptr, gboolean allow_reuse)
Definition pixelpipe_gpu.c:18
void dt_dev_pixelpipe_gpu_flush_host_pinned_images(dt_dev_pixelpipe_t *pipe, void *host_ptr, dt_pixel_cache_entry_t *cache_entry, const char *reason)
Definition pixelpipe_gpu.c:24
GUI-side histogram sampling from preview cache.
dt_pixelpipe_blend_transform_t dt_dev_pixelpipe_transform_for_blend(const dt_iop_module_t *const self, const dt_dev_pixelpipe_iop_t *const piece, const dt_iop_buffer_dsc_t *const output_dsc)
Definition pixelpipe_hb.c:631
static void _trace_buffer_content(const dt_dev_pixelpipe_t *pipe, const dt_iop_module_t *module, const char *phase, const void *buffer, const dt_iop_buffer_dsc_t *format, const dt_iop_roi_t *roi)
Definition pixelpipe_hb.c:120
void dt_dev_pixelpipe_disable_before(dt_dev_pixelpipe_t *pipe, const char *op)
Definition pixelpipe_hb.c:1251
int dt_dev_pixelpipe_init_preview(dt_dev_pixelpipe_t *pipe)
Definition pixelpipe_hb.c:422
void dt_dev_pixelpipe_set_input(dt_dev_pixelpipe_t *pipe, dt_develop_t *dev, int32_t imgid, int width, int height, dt_mipmap_size_t size)
Definition pixelpipe_hb.c:482
static gboolean _is_focused_realtime_gui_module(const dt_dev_pixelpipe_t *pipe, const dt_develop_t *dev, const dt_iop_module_t *module)
Definition pixelpipe_hb.c:242
static dt_iop_roi_t * _get_first_roi(dt_dev_pixelpipe_t *pipe)
Definition pixelpipe_hb.c:777
int dt_dev_pixelpipe_process(dt_dev_pixelpipe_t *pipe, dt_develop_t *dev, dt_iop_roi_t roi)
Definition pixelpipe_hb.c:1341
void dt_dev_pixelpipe_reset_reentry(dt_dev_pixelpipe_t *pipe)
Definition pixelpipe_hb.c:567
int dt_dev_pixelpipe_init_cached(dt_dev_pixelpipe_t *pipe)
Definition pixelpipe_hb.c:444
static void _update_backbuf_cache_reference(dt_dev_pixelpipe_t *pipe, dt_iop_roi_t roi, dt_pixel_cache_entry_t *entry)
Definition pixelpipe_hb.c:1302
gboolean dt_dev_pixelpipe_has_reentry(dt_dev_pixelpipe_t *pipe)
Definition pixelpipe_hb.c:562
void dt_dev_pixelpipe_disable_after(dt_dev_pixelpipe_t *pipe, const char *op)
Definition pixelpipe_hb.c:1237
int dt_dev_pixelpipe_init_export(dt_dev_pixelpipe_t *pipe, int levels, gboolean store_masks)
Definition pixelpipe_hb.c:396
int dt_dev_pixelpipe_init_thumbnail(dt_dev_pixelpipe_t *pipe)
Definition pixelpipe_hb.c:406
int dt_dev_pixelpipe_init_dummy(dt_dev_pixelpipe_t *pipe)
Definition pixelpipe_hb.c:414
gboolean dt_dev_pixelpipe_cache_gpu_device_buffer(const dt_dev_pixelpipe_t *pipe, const dt_pixel_cache_entry_t *cache_entry)
Definition pixelpipe_hb.c:251
gboolean dt_dev_pixelpipe_get_realtime(const dt_dev_pixelpipe_t *pipe)
Definition pixelpipe_hb.c:477
static const char * _debug_type_to_string(const dt_iop_buffer_type_t type)
Definition pixelpipe_hb.c:344
static const char * _debug_cst_to_string(const int cst)
Definition pixelpipe_hb.c:321
#define KILL_SWITCH_ABORT
Definition pixelpipe_hb.c:650
void dt_dev_pixelpipe_set_icc(dt_dev_pixelpipe_t *pipe, dt_colorspaces_color_profile_type_t icc_type, const gchar *icc_filename, dt_iop_color_intent_t icc_intent)
Definition pixelpipe_hb.c:492
void dt_dev_pixelpipe_create_nodes(dt_dev_pixelpipe_t *pipe, dt_develop_t *dev)
Definition pixelpipe_hb.c:593
static int _abort_module_shutdown_cleanup(dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece, dt_iop_module_t *module, const uint64_t input_hash, const void *input, dt_pixel_cache_entry_t *input_entry, const uint64_t output_hash, void **output, void **cl_mem_output, dt_pixel_cache_entry_t *output_entry)
Definition pixelpipe_hb.c:206
char * dt_pixelpipe_get_pipe_name(dt_dev_pixelpipe_type_t pipe_type)
Definition pixelpipe_hb.c:259
static void _print_opencl_errors(int error, dt_dev_pixelpipe_t *pipe)
Definition pixelpipe_hb.c:1284
static void _trace_cache_owner(const dt_dev_pixelpipe_t *pipe, const dt_iop_module_t *module, const char *phase, const char *slot, const uint64_t requested_hash, const void *buffer, const dt_pixel_cache_entry_t *entry, const gboolean verbose)
Definition pixelpipe_hb.c:94
static void _print_nan_debug(dt_dev_pixelpipe_t *pipe, void *cl_mem_output, void *output, const dt_iop_roi_t *roi_out, dt_iop_buffer_dsc_t *out_format, dt_iop_module_t *module)
Definition pixelpipe_hb.c:703
static int _init_base_buffer(dt_dev_pixelpipe_t *pipe)
Definition pixelpipe_hb.c:790
#define KILL_SWITCH_PIPE
Definition pixelpipe_hb.c:1265
static int dt_dev_pixelpipe_process_rec(dt_dev_pixelpipe_t *pipe, dt_develop_t *dev, uint64_t *out_hash, const dt_dev_pixelpipe_iop_t **out_piece, GList *pieces, int pos)
Definition pixelpipe_hb.c:885
void dt_dev_pixelpipe_cleanup(dt_dev_pixelpipe_t *pipe)
Definition pixelpipe_hb.c:501
gboolean dt_dev_pixelpipe_unset_reentry(dt_dev_pixelpipe_t *pipe, uint64_t hash)
Remove the re-entry pipeline flag, only if the object identifier is the one that set it....
Definition pixelpipe_hb.c:549
static void _copy_buffer(const char *const restrict input, char *const restrict output, const size_t height, const size_t o_width, const size_t i_width, const size_t x_offset, const size_t y_offset, const size_t stride, const size_t bpp)
Definition pixelpipe_hb.c:283
static void _print_perf_debug(dt_dev_pixelpipe_t *pipe, const dt_pixelpipe_flow_t pixelpipe_flow, dt_dev_pixelpipe_iop_t *piece, dt_iop_module_t *module, const gboolean recycled_output_cacheline, dt_times_t *start)
Definition pixelpipe_hb.c:671
int dt_dev_pixelpipe_init(dt_dev_pixelpipe_t *pipe)
Definition pixelpipe_hb.c:434
static void _uint8_to_float(const uint8_t *const input, float *const output, const size_t width, const size_t height, const size_t chan)
Definition pixelpipe_hb.c:301
void dt_dev_pixelpipe_debug_dump_module_io(dt_dev_pixelpipe_t *pipe, dt_iop_module_t *module, const char *stage, const gboolean is_cl, const dt_iop_buffer_dsc_t *in_dsc, const dt_iop_buffer_dsc_t *out_dsc, const dt_iop_roi_t *roi_in, const dt_iop_roi_t *roi_out, const size_t in_bpp, const size_t out_bpp, const int cst_before, const int cst_after)
Definition pixelpipe_hb.c:360
#define KILL_SWITCH_AND_FLUSH_CACHE
Definition pixelpipe_hb.c:664
gboolean dt_dev_pixelpipe_set_reentry(dt_dev_pixelpipe_t *pipe, uint64_t hash)
Set the re-entry pipeline flag, only if no object is already capturing it. Re-entered pipelines run w...
Definition pixelpipe_hb.c:535
void dt_dev_pixelpipe_set_realtime(dt_dev_pixelpipe_t *pipe, gboolean state)
Definition pixelpipe_hb.c:471
void dt_dev_pixelpipe_cleanup_nodes(dt_dev_pixelpipe_t *pipe)
Definition pixelpipe_hb.c:574
static void dt_dev_pixelpipe_set_hash(dt_dev_pixelpipe_t *pipe, const uint64_t hash)
Definition pixelpipe_hb.h:355
static uint64_t dt_dev_pixelpipe_get_hash(const dt_dev_pixelpipe_t *pipe)
Definition pixelpipe_hb.h:350
@ DT_DEV_PIPE_UNCHANGED
Definition pixelpipe_hb.h:164
static uint64_t dt_dev_pixelpipe_get_history_hash(const dt_dev_pixelpipe_t *pipe)
Definition pixelpipe_hb.h:360
static void dt_dev_pixelpipe_set_history_hash(dt_dev_pixelpipe_t *pipe, const uint64_t history_hash)
Definition pixelpipe_hb.h:365
static uint64_t dt_dev_backbuf_get_hash(const dt_backbuf_t *backbuf)
Definition pixelpipe_hb.h:195
static void dt_dev_pixelpipe_set_changed(dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_change_t v)
Definition pixelpipe_hb.h:375
@ DT_DEV_PIXELPIPE_DIRTY
Definition pixelpipe_hb.h:174
void dt_dev_clear_rawdetail_mask(dt_dev_pixelpipe_t *pipe)
Definition pixelpipe_rawdetail.c:11
dt_pixelpipe_flow_t
Definition pixelpipe_process.h:14
@ PIXELPIPE_FLOW_HISTOGRAM_ON_GPU
Definition pixelpipe_process.h:18
@ PIXELPIPE_FLOW_HISTOGRAM_NONE
Definition pixelpipe_process.h:16
@ PIXELPIPE_FLOW_PROCESSED_ON_CPU
Definition pixelpipe_process.h:19
@ PIXELPIPE_FLOW_PROCESSED_WITH_TILING
Definition pixelpipe_process.h:21
@ PIXELPIPE_FLOW_PROCESSED_ON_GPU
Definition pixelpipe_process.h:20
@ PIXELPIPE_FLOW_NONE
Definition pixelpipe_process.h:15
@ PIXELPIPE_FLOW_BLENDED_ON_CPU
Definition pixelpipe_process.h:22
@ PIXELPIPE_FLOW_HISTOGRAM_ON_CPU
Definition pixelpipe_process.h:17
@ PIXELPIPE_FLOW_BLENDED_ON_GPU
Definition pixelpipe_process.h:23
static void _reset_piece_cache_entry(dt_dev_pixelpipe_iop_t *piece)
Drop the writable-reuse snapshot attached to a pipeline piece.
Definition pixelpipe_process.h:73
static gboolean _requests_cache(const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece)
Tell whether cache lookups and published cachelines are allowed for the current pipeline state.
Definition pixelpipe_process.h:59
static gboolean _bypass_cache(const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece)
Tell whether the current pipeline state forbids keeping this module output in cache.
Definition pixelpipe_process.h:45
dt_pixelpipe_blend_transform_t
Definition pixelpipe_process.h:27
@ DT_DEV_PIXELPIPE_BLEND_TRANSFORM_INPUT
Definition pixelpipe_process.h:29
@ DT_DEV_PIXELPIPE_BLEND_TRANSFORM_NONE
Definition pixelpipe_process.h:28
@ DT_DEV_PIXELPIPE_BLEND_TRANSFORM_OUTPUT
Definition pixelpipe_process.h:30
Raster-mask retrieval and transport through already-processed pipeline nodes.
Raw-detail mask production and transport helpers.
unsigned __int64 uint64_t
Definition strptime.c:74
struct dt_dev_pixelpipe_cache_t * pixelpipe_cache
Definition darktable.h:718
struct dt_mipmap_cache_t * mipmap_cache
Definition darktable.h:704
struct dt_opencl_t * opencl
Definition darktable.h:713
int32_t unmuted
Definition darktable.h:688
dt_pthread_mutex_t pipeline_threadsafe
Definition darktable.h:736
char * main_message
Definition darktable.h:766
Definition pixelpipe_hb.h:95
gboolean enabled
Definition pixelpipe_hb.h:110
dt_dev_request_flags_t request_histogram
Definition pixelpipe_hb.h:112
uint64_t global_hash
Definition pixelpipe_hb.h:123
dt_iop_buffer_dsc_t dsc_in
Definition pixelpipe_hb.h:140
struct dt_iop_module_t *void * data
Definition pixelpipe_hb.h:96
dt_iop_roi_t roi_in
Definition pixelpipe_hb.h:130
GHashTable * raster_masks
Definition pixelpipe_hb.h:159
void * blendop_data
Definition pixelpipe_hb.h:109
Definition pixelpipe_hb.h:216
dt_colorspaces_color_profile_type_t icc_type
Definition pixelpipe_hb.h:296
int iwidth
Definition pixelpipe_hb.h:222
int opencl_error
Definition pixelpipe_hb.h:275
gboolean gui_observable_source
Definition pixelpipe_hb.h:288
gchar * icc_filename
Definition pixelpipe_hb.h:297
uint64_t last_history_hash
Definition pixelpipe_hb.h:309
dt_pthread_mutex_t busy_mutex
Definition pixelpipe_hb.h:251
gboolean flush_cache
Definition pixelpipe_hb.h:335
int mask_display
Definition pixelpipe_hb.h:279
GList * nodes
Definition pixelpipe_hb.h:237
dt_dev_pixelpipe_status_t status
Definition pixelpipe_hb.h:227
dt_imageio_levels_t levels
Definition pixelpipe_hb.h:290
dt_atomic_int realtime
Definition pixelpipe_hb.h:271
dt_backbuf_t backbuf
Definition pixelpipe_hb.h:242
gboolean reentry
Definition pixelpipe_hb.h:323
dt_mipmap_size_t size
Definition pixelpipe_hb.h:219
dt_iop_color_intent_t icc_intent
Definition pixelpipe_hb.h:298
dt_image_t image
Definition pixelpipe_hb.h:294
dt_atomic_int shutdown
Definition pixelpipe_hb.h:265
uint64_t reentry_hash
Definition pixelpipe_hb.h:329
int opencl_enabled
Definition pixelpipe_hb.h:273
dt_dev_pixelpipe_type_t type
Definition pixelpipe_hb.h:284
int32_t imgid
Definition pixelpipe_hb.h:218
gboolean no_cache
Definition pixelpipe_hb.h:343
gboolean store_all_raster_masks
Definition pixelpipe_hb.h:304
int iheight
Definition pixelpipe_hb.h:222
GList * forms
Definition pixelpipe_hb.h:302
int devid
Definition pixelpipe_hb.h:292
int output_imgid
Definition pixelpipe_hb.h:259
GList * iop_order_list
Definition pixelpipe_hb.h:300
int32_t gui_attached
Definition develop.h:158
GList * iop_order_list
Definition develop.h:269
dt_image_t image_storage
Definition develop.h:243
struct dt_develop_t::@19 color_picker
Authoritative darkroom color-picker state.
GList * iop
Definition develop.h:263
struct dt_iop_module_t * pending_module
Definition develop.h:369
int completed
Definition develop.h:455
struct dt_iop_module_t * gui_module
Definition develop.h:161
struct dt_dev_pixelpipe_t * pending_pipe
Definition develop.h:370
dt_pthread_rwlock_t masks_mutex
Definition develop.h:299
struct dt_develop_t::@26 progress
uint64_t piece_hash
Definition develop.h:367
int total
Definition develop.h:455
GList * forms
Definition develop.h:287
float factor
Definition tiling.h:41
unsigned overhead
Definition tiling.h:49
float maxbuf
Definition tiling.h:45
dt_iop_buffer_dsc_t dsc
Definition common/image.h:297
Definition develop/format.h:48
int cst
Definition develop/format.h:76
unsigned int channels
Definition develop/format.h:50
size_t bpp
Definition develop/format.h:54
dt_iop_buffer_type_t datatype
Definition develop/format.h:52
GModule *dt_dev_operation_t op
Definition imageop.h:226
int x
Definition imageop.h:68
int width
Definition imageop.h:68
int height
Definition imageop.h:68
int y
Definition imageop.h:68
Definition mipmap_cache.h:68
int32_t height
Definition mipmap_cache.h:71
uint8_t * buf
Definition mipmap_cache.h:73
int32_t width
Definition mipmap_cache.h:71
int error_count
Definition opencl.h:512
int stopped
Definition opencl.h:511
Definition pixelpipe_cache.h:86
uint64_t hash
Definition pixelpipe_cache.h:87
void * data
Definition pixelpipe_cache.h:89
Definition darktable.h:770
#define MIN(a, b)
Definition thinplate.c:32
#define MAX(a, b)
Definition thinplate.c:29