Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
pixelpipe_hb.c File Reference
#include "common/colorspaces.h"
#include "common/darktable.h"
#include "common/histogram.h"
#include "common/imageio.h"
#include "common/atomic.h"
#include "common/opencl.h"
#include "common/iop_order.h"
#include "control/control.h"
#include "control/conf.h"
#include "control/signal.h"
#include "develop/blend.h"
#include "develop/dev_pixelpipe.h"
#include "develop/format.h"
#include "develop/imageop_math.h"
#include "develop/pixelpipe.h"
#include "develop/pixelpipe_cache.h"
#include "develop/pixelpipe_cpu.h"
#include "develop/pixelpipe_gpu.h"
#include "develop/pixelpipe_gui.h"
#include "develop/pixelpipe_process.h"
#include "develop/tiling.h"
#include "develop/masks.h"
#include "gui/gtk.h"
#include "libs/colorpicker.h"
#include "libs/lib.h"
#include "gui/color_picker_proxy.h"
#include <assert.h>
#include <inttypes.h>
#include <math.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include "develop/pixelpipe_gui.c"
#include "develop/pixelpipe_raster_masks.c"
#include "develop/pixelpipe_rawdetail.c"
+ Include dependency graph for pixelpipe_hb.c:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define KILL_SWITCH_ABORT
 
#define KILL_SWITCH_AND_FLUSH_CACHE
 
#define KILL_SWITCH_PIPE
 

Functions

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)
 
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)
 
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)
 
static gboolean _is_focused_realtime_gui_module (const dt_dev_pixelpipe_t *pipe, const dt_develop_t *dev, const dt_iop_module_t *module)
 
gboolean dt_dev_pixelpipe_cache_gpu_device_buffer (const dt_dev_pixelpipe_t *pipe, const dt_pixel_cache_entry_t *cache_entry)
 
char * dt_pixelpipe_get_pipe_name (dt_dev_pixelpipe_type_t pipe_type)
 
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)
 
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)
 
static const char * _debug_cst_to_string (const int cst)
 
static const char * _debug_type_to_string (const dt_iop_buffer_type_t type)
 
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)
 
int dt_dev_pixelpipe_init_export (dt_dev_pixelpipe_t *pipe, int levels, gboolean store_masks)
 
int dt_dev_pixelpipe_init_thumbnail (dt_dev_pixelpipe_t *pipe)
 
int dt_dev_pixelpipe_init_dummy (dt_dev_pixelpipe_t *pipe)
 
int dt_dev_pixelpipe_init_preview (dt_dev_pixelpipe_t *pipe)
 
int dt_dev_pixelpipe_init (dt_dev_pixelpipe_t *pipe)
 
int dt_dev_pixelpipe_init_cached (dt_dev_pixelpipe_t *pipe)
 
void dt_dev_pixelpipe_set_realtime (dt_dev_pixelpipe_t *pipe, gboolean state)
 
gboolean dt_dev_pixelpipe_get_realtime (const dt_dev_pixelpipe_t *pipe)
 
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)
 
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)
 
void dt_dev_pixelpipe_cleanup (dt_dev_pixelpipe_t *pipe)
 
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 with cache disabled, but without flushing the whole cache. This was designed for cases where raster masks references are lost on pipeline, for example when going to lighttable and re-entering darkroom (pipe caches are not flushed for performance, if re-entering the same image), as to trigger a full pipe run and reinit references.
 
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. See dt_dev_pixelpipe_set_reentry.
 
gboolean dt_dev_pixelpipe_has_reentry (dt_dev_pixelpipe_t *pipe)
 
void dt_dev_pixelpipe_reset_reentry (dt_dev_pixelpipe_t *pipe)
 
void dt_dev_pixelpipe_cleanup_nodes (dt_dev_pixelpipe_t *pipe)
 
void dt_dev_pixelpipe_create_nodes (dt_dev_pixelpipe_t *pipe, dt_develop_t *dev)
 
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)
 
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)
 
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)
 
static dt_iop_roi_t_get_first_roi (dt_dev_pixelpipe_t *pipe)
 
static int _init_base_buffer (dt_dev_pixelpipe_t *pipe)
 
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)
 
void dt_dev_pixelpipe_disable_after (dt_dev_pixelpipe_t *pipe, const char *op)
 
void dt_dev_pixelpipe_disable_before (dt_dev_pixelpipe_t *pipe, const char *op)
 
static void _print_opencl_errors (int error, dt_dev_pixelpipe_t *pipe)
 
static void _update_backbuf_cache_reference (dt_dev_pixelpipe_t *pipe, dt_iop_roi_t roi, dt_pixel_cache_entry_t *entry)
 
int dt_dev_pixelpipe_process (dt_dev_pixelpipe_t *pipe, dt_develop_t *dev, dt_iop_roi_t roi)
 

Macro Definition Documentation

◆ KILL_SWITCH_ABORT

#define KILL_SWITCH_ABORT
Value:
if(dt_atomic_get_int(&pipe->shutdown)) \
{ \
if(cl_mem_output != NULL) \
{ \
dt_dev_pixelpipe_gpu_clear_buffer(&cl_mem_output, NULL, NULL, FALSE); \
} \
dt_iop_nap(5000); \
pipe->status = DT_DEV_PIXELPIPE_DIRTY; \
return 1; \
}
#define FALSE
Definition ashift_lsd.c:158
int dt_atomic_get_int(dt_atomic_int *var)
Definition atomic.h:66
@ DT_DEV_PIXELPIPE_DIRTY
Definition pixelpipe_hb.h:174

◆ KILL_SWITCH_AND_FLUSH_CACHE

#define KILL_SWITCH_AND_FLUSH_CACHE
Value:
if(dt_atomic_get_int(&pipe->shutdown)) \
{ \
return _abort_module_shutdown_cleanup(pipe, piece, module, input_hash, input, input_entry, hash, &output, \
&cl_mem_output, output_entry); \
}
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

◆ KILL_SWITCH_PIPE

#define KILL_SWITCH_PIPE
Value:
if(dt_atomic_get_int(&pipe->shutdown)) \
{ \
if(pipe->devid >= 0) \
{ \
dt_opencl_unlock_device(pipe->devid); \
pipe->devid = -1; \
} \
pipe->status = DT_DEV_PIXELPIPE_DIRTY; \
if(pipe->forms) \
{ \
g_list_free_full(pipe->forms, (void (*)(void *))dt_masks_free_form); \
pipe->forms = NULL; \
} \
dt_pthread_mutex_unlock(&darktable.pipeline_threadsafe); \
return 1; \
}
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
darktable_t darktable
Definition darktable.c:178
void dt_masks_free_form(dt_masks_form_t *form)
Definition develop/masks/masks.c:1997
dt_pthread_mutex_t pipeline_threadsafe
Definition darktable.h:736

Function Documentation

◆ _abort_module_shutdown_cleanup()

◆ _copy_buffer()

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 
)
inlinestatic

References bpp, and height.

Referenced by _init_base_buffer().

◆ _debug_cst_to_string()

static const char * _debug_cst_to_string ( const int  cst)
static

◆ _debug_type_to_string()

static const char * _debug_type_to_string ( const dt_iop_buffer_type_t  type)
static

◆ _get_first_roi()

◆ _init_base_buffer()

◆ _is_focused_realtime_gui_module()

static gboolean _is_focused_realtime_gui_module ( const dt_dev_pixelpipe_t pipe,
const dt_develop_t dev,
const dt_iop_module_t module 
)
inlinestatic

◆ _print_nan_debug()

◆ _print_opencl_errors()

static void _print_opencl_errors ( int  error,
dt_dev_pixelpipe_t pipe 
)
static

◆ _print_perf_debug()

◆ _trace_buffer_content()

◆ _trace_cache_owner()

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 
)
static

◆ _uint8_to_float()

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 
)
inlinestatic

References height, and width.

◆ _update_backbuf_cache_reference()

◆ dt_dev_pixelpipe_cache_gpu_device_buffer()

gboolean dt_dev_pixelpipe_cache_gpu_device_buffer ( const dt_dev_pixelpipe_t pipe,
const dt_pixel_cache_entry_t cache_entry 
)

◆ dt_dev_pixelpipe_cleanup()

◆ dt_dev_pixelpipe_cleanup_nodes()

◆ dt_dev_pixelpipe_create_nodes()

◆ dt_dev_pixelpipe_debug_dump_module_io()

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 
)

◆ dt_dev_pixelpipe_disable_after()

void dt_dev_pixelpipe_disable_after ( dt_dev_pixelpipe_t pipe,
const char *  op 
)

◆ dt_dev_pixelpipe_disable_before()

void dt_dev_pixelpipe_disable_before ( dt_dev_pixelpipe_t pipe,
const char *  op 
)

◆ dt_dev_pixelpipe_get_realtime()

◆ dt_dev_pixelpipe_has_reentry()

gboolean dt_dev_pixelpipe_has_reentry ( dt_dev_pixelpipe_t pipe)

◆ dt_dev_pixelpipe_init()

◆ dt_dev_pixelpipe_init_cached()

◆ dt_dev_pixelpipe_init_dummy()

◆ dt_dev_pixelpipe_init_export()

◆ dt_dev_pixelpipe_init_preview()

◆ dt_dev_pixelpipe_init_thumbnail()

◆ dt_dev_pixelpipe_process()

int dt_dev_pixelpipe_process ( dt_dev_pixelpipe_t pipe,
dt_develop_t dev,
dt_iop_roi_t  roi 
)

References _print_opencl_errors(), _requests_cache(), _update_backbuf_cache_reference(), dt_dev_pixelpipe_t::backbuf, dt_develop_t::color_picker, darktable, dt_dev_pixelpipe_t::devid, dt_atomic_get_int(), dt_capabilities_remove(), DT_DEBUG_DEV, DT_DEBUG_MEMORY, DT_DEBUG_OPENCL, dt_dev_backbuf_get_hash(), dt_dev_pixelpipe_cache_peek(), dt_dev_pixelpipe_cache_print(), dt_dev_pixelpipe_cache_unref_hash(), DT_DEV_PIXELPIPE_DISPLAY_NONE, dt_dev_pixelpipe_get_hash(), dt_dev_pixelpipe_get_history_hash(), dt_dev_pixelpipe_get_roi_in(), dt_dev_pixelpipe_process_rec(), dt_free, dt_get_times(), dt_masks_dup_forms_deep(), dt_masks_free_form(), dt_opencl_check_tuning(), dt_opencl_events_flush(), dt_opencl_events_reset(), dt_opencl_lock_device(), DT_OPENCL_MAX_ERRORS, dt_opencl_unlock_device(), dt_opencl_update_settings(), DT_PIXELPIPE_CACHE_HASH_INVALID, dt_pixelpipe_get_global_hash(), dt_pixelpipe_get_pipe_name(), dt_print(), dt_print_mem_usage(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_pthread_rwlock_rdlock, dt_pthread_rwlock_unlock, dt_show_times(), dt_opencl_t::error_count, FALSE, dt_dev_pixelpipe_t::flush_cache, dt_develop_t::forms, dt_dev_pixelpipe_t::forms, dt_develop_t::gui_attached, dt_iop_roi_t::height, dt_develop_t::iop, KILL_SWITCH_PIPE, dt_dev_pixelpipe_t::mask_display, dt_develop_t::masks_mutex, dt_dev_pixelpipe_t::nodes, darktable_t::opencl, dt_dev_pixelpipe_t::opencl_enabled, dt_dev_pixelpipe_t::opencl_error, dt_develop_t::pending_module, dt_develop_t::pending_pipe, dt_develop_t::piece_hash, darktable_t::pipeline_threadsafe, darktable_t::pixelpipe_cache, dt_dev_pixelpipe_t::shutdown, dt_opencl_t::stopped, TRUE, dt_dev_pixelpipe_t::type, darktable_t::unmuted, void(), and dt_iop_roi_t::width.

Referenced by dt_dev_darkroom_pipeline(), and dt_imageio_export_with_flags().

◆ dt_dev_pixelpipe_process_rec()

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 
)
static

References _bypass_cache(), _get_first_roi(), _init_base_buffer(), _print_nan_debug(), _print_perf_debug(), _requests_cache(), _reset_piece_cache_entry(), _trace_buffer_content(), _trace_cache_owner(), dt_develop_t::completed, darktable, dt_dev_pixelpipe_iop_t::data, DEVELOP_MASK_DISABLED, dt_control_queue_redraw_center(), DT_DEBUG_DEV, DT_DEBUG_NAN, DT_DEBUG_NOCACHE_REUSE, dt_dev_pixelpipe_cache_auto_destroy_apply(), dt_dev_pixelpipe_cache_flag_auto_destroy(), dt_dev_pixelpipe_cache_get_entry(), dt_dev_pixelpipe_cache_get_writable(), dt_dev_pixelpipe_cache_gpu_device_buffer(), dt_dev_pixelpipe_cache_peek(), dt_dev_pixelpipe_cache_rdlock_entry(), dt_dev_pixelpipe_cache_ref_count_entry(), dt_dev_pixelpipe_cache_remove(), DT_DEV_PIXELPIPE_CACHE_WRITABLE_CREATED, DT_DEV_PIXELPIPE_CACHE_WRITABLE_EXACT_HIT, DT_DEV_PIXELPIPE_CACHE_WRITABLE_REKEYED, dt_dev_pixelpipe_cache_wrlock_entry(), DT_DEV_PIXELPIPE_DISPLAY_NONE, dt_dev_pixelpipe_get_hash(), dt_dev_pixelpipe_gpu_clear_buffer(), dt_dev_pixelpipe_gpu_flush_host_pinned_images(), dt_dev_pixelpipe_node_hash(), dt_dev_pixelpipe_process_rec(), dt_free, dt_get_times(), dt_history_item_get_name(), dt_pixel_cache_clmem_flush(), dt_pixel_cache_entry_get_data(), DT_PIXELPIPE_CACHE_HASH_INVALID, dt_pixelpipe_cache_set_current_module(), dt_pixelpipe_get_pipe_name(), dt_print(), dt_show_times_f(), error(), dt_develop_tiling_t::factor, FALSE, dt_dev_pixelpipe_iop_t::global_hash, dt_develop_t::gui_attached, IOP_TAG_DISTORT, KILL_SWITCH_ABORT, KILL_SWITCH_AND_FLUSH_CACHE, darktable_t::main_message, dt_dev_pixelpipe_t::mask_display, dt_develop_tiling_t::maxbuf, name, dt_develop_tiling_t::overhead, darktable_t::pixelpipe_cache, PIXELPIPE_FLOW_HISTOGRAM_NONE, PIXELPIPE_FLOW_NONE, PIXELPIPE_FLOW_PROCESSED_ON_CPU, PIXELPIPE_FLOW_PROCESSED_WITH_TILING, pixelpipe_process_on_CPU(), pixelpipe_process_on_GPU(), dt_develop_t::progress, tiling_callback_blendop(), dt_develop_t::total, TRUE, type, dt_dev_pixelpipe_t::type, and darktable_t::unmuted.

Referenced by dt_dev_pixelpipe_process(), and dt_dev_pixelpipe_process_rec().

◆ dt_dev_pixelpipe_reset_reentry()

◆ dt_dev_pixelpipe_set_icc()

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 
)

◆ dt_dev_pixelpipe_set_input()

◆ dt_dev_pixelpipe_set_realtime()

◆ dt_dev_pixelpipe_set_reentry()

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 with cache disabled, but without flushing the whole cache. This was designed for cases where raster masks references are lost on pipeline, for example when going to lighttable and re-entering darkroom (pipe caches are not flushed for performance, if re-entering the same image), as to trigger a full pipe run and reinit references.

It can be used for any case where a full pipeline recompute is needed once, based on runtime module requirements, but a full cache flush would be overkill.

NOTE: in main darkroom pipe, the coordinates of the ROI can change between runs from the same thread.

Parameters
pipe
hashUnique ID of the object attempting capture the re-entry flag. This should stay constant between 2 pipeline runs from the same thread.
Returns
gboolean TRUE if the object could capture the flag

References DT_DEBUG_DEV, DT_PIXELPIPE_CACHE_HASH_INVALID, dt_print(), FALSE, dt_dev_pixelpipe_t::reentry, dt_dev_pixelpipe_t::reentry_hash, and TRUE.

Referenced by dt_dev_get_raster_mask().

◆ dt_dev_pixelpipe_transform_for_blend()

◆ dt_dev_pixelpipe_unset_reentry()

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. See dt_dev_pixelpipe_set_reentry.

Parameters
pipe
hashUnique ID of the object attempting capture the re-entry flag. This should stay constant between 2 pipeline runs from the same thread.
Returns
gboolean TRUE if the object could capture the flag

References DT_DEBUG_DEV, DT_PIXELPIPE_CACHE_HASH_INVALID, dt_print(), FALSE, dt_dev_pixelpipe_t::reentry, dt_dev_pixelpipe_t::reentry_hash, and TRUE.

Referenced by dt_dev_get_raster_mask().

◆ dt_pixelpipe_get_pipe_name()