Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
dev_pixelpipe.h File Reference
#include "caches/pixelpipe_cache_wait.h"
#include <inttypes.h>
#include <stdint.h>
#include <glib.h>
#include "develop/pixelpipe_hb.h"
+ Include dependency graph for dev_pixelpipe.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define dt_dev_pixelpipe_rebuild_all(dev)   DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_DEV, dt_dev_pixelpipe_rebuild_all_real, (dev))
 
#define dt_dev_pixelpipe_update_history_main(dev)   DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_DEV, dt_dev_pixelpipe_update_history_main_real, (dev))
 
#define dt_dev_pixelpipe_update_history_preview(dev)   DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_DEV, dt_dev_pixelpipe_update_history_preview_real, (dev))
 
#define dt_dev_pixelpipe_update_history_all(dev)   DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_DEV, dt_dev_pixelpipe_update_history_all_real, (dev))
 
#define dt_dev_pixelpipe_update_zoom_main(dev)   DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_DEV, dt_dev_pixelpipe_update_zoom_main_real, (dev))
 
#define dt_dev_pixelpipe_update_zoom_preview(dev)   DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_DEV, dt_dev_pixelpipe_update_zoom_preview_real, (dev))
 
#define dt_dev_pixelpipe_resync_history_all(dev)   DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_DEV, dt_dev_pixelpipe_resync_history_all_real, (dev))
 
#define dt_dev_pixelpipe_resync_history_main(dev)   DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_DEV, dt_dev_pixelpipe_resync_history_main_real, (dev))
 
#define dt_dev_pixelpipe_resync_history_preview(dev)   DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_DEV, dt_dev_pixelpipe_resync_history_preview_real, (dev))
 

Typedefs

typedef dt_pixelpipe_cache_ready_callback_t dt_dev_pixelpipe_cache_ready_callback_t
 
typedef dt_pixelpipe_cache_wait_t dt_dev_pixelpipe_cache_wait_t
 

Functions

void dt_dev_pixelpipe_rebuild_all_real (struct dt_develop_t *dev)
 
void dt_dev_pixelpipe_update_history_main_real (struct dt_develop_t *dev)
 
void dt_dev_pixelpipe_update_history_preview_real (struct dt_develop_t *dev)
 
void dt_dev_pixelpipe_update_history_all_real (struct dt_develop_t *dev)
 
void dt_dev_pixelpipe_update_zoom_main_real (struct dt_develop_t *dev)
 
void dt_dev_pixelpipe_update_zoom_preview_real (struct dt_develop_t *dev)
 
void dt_dev_pixelpipe_resync_history_all_real (struct dt_develop_t *dev)
 
void dt_dev_pixelpipe_resync_history_main_real (struct dt_develop_t *dev)
 
void dt_dev_pixelpipe_resync_history_preview_real (struct dt_develop_t *dev)
 
void dt_dev_pixelpipe_reset_all (struct dt_develop_t *dev)
 
void dt_dev_pixelpipe_change_zoom_main (struct dt_develop_t *dev)
 
void dt_dev_pixelpipe_get_roi_out (struct dt_dev_pixelpipe_t *pipe, const int width_in, const int height_in, int *width, int *height)
 
void dt_dev_pixelpipe_get_roi_in (struct dt_dev_pixelpipe_t *pipe, const struct dt_iop_roi_t roi_out)
 
gboolean dt_dev_pixelpipe_activemodule_disables_currentmodule (struct dt_develop_t *dev, struct dt_iop_module_t *current_module)
 
void dt_dev_pixelpipe_change (struct dt_dev_pixelpipe_t *pipe)
 
uint64_t dt_dev_pixelpipe_node_hash (struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, const struct dt_iop_roi_t, const int pos)
 
const struct dt_dev_pixelpipe_iop_tdt_dev_pixelpipe_get_module_piece (const struct dt_dev_pixelpipe_t *pipe, const struct dt_iop_module_t *module)
 Return the enabled piece owned by module in pipe.
 
const struct dt_dev_pixelpipe_iop_tdt_dev_pixelpipe_get_prev_enabled_piece (const struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece)
 Return the closest enabled piece located immediately before piece in pipe.
 
void dt_dev_pixelpipe_cache_wait_cleanup (dt_dev_pixelpipe_cache_wait_t *wait, const char *reason)
 Cancel one pending GUI cache wait request and clear its runtime state.
 
void dt_dev_pixelpipe_cache_wait_dump_pending (const char *reason)
 Dump pending GUI cache wait requests for lifecycle debugging.
 
void dt_dev_pixelpipe_cache_wait_set_owner (dt_dev_pixelpipe_cache_wait_t *wait, const char *owner_tag, gpointer owner_object)
 Attach debug ownership metadata to one cache wait request.
 
gboolean dt_dev_pixelpipe_cache_peek_gui (dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, void **data, struct dt_pixel_cache_entry_t **cache_entry, dt_dev_pixelpipe_cache_wait_t *wait, dt_dev_pixelpipe_cache_ready_callback_t restart, gpointer restart_data)
 Reopen one GUI-visible host cacheline, or queue the minimal pipe recompute needed to publish it.
 
gboolean dt_dev_pixelpipe_cache_peek_gui_retained (dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, void **data, struct dt_pixel_cache_entry_t **cache_entry, dt_dev_pixelpipe_cache_wait_t *wait, dt_dev_pixelpipe_cache_ready_callback_t restart, gpointer restart_data)
 dt_dev_pixelpipe_cache_peek_gui(), but the cacheline comes back RETAINED.
 
void dt_dev_pixelpipe_propagate_formats (struct dt_dev_pixelpipe_t *pipe)
 
void dt_pixelpipe_get_global_hash (struct dt_dev_pixelpipe_t *pipe)
 
gboolean dt_dev_pixelpipe_is_backbufer_valid (struct dt_dev_pixelpipe_t *pipe)
 
gboolean dt_dev_pixelpipe_is_pipeline_valid (struct dt_dev_pixelpipe_t *pipe)
 

Macro Definition Documentation

◆ dt_dev_pixelpipe_rebuild_all

#define dt_dev_pixelpipe_rebuild_all (   dev)    DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_DEV, dt_dev_pixelpipe_rebuild_all_real, (dev))

Definition at line 38 of file dev_pixelpipe.h.

◆ dt_dev_pixelpipe_resync_history_all

#define dt_dev_pixelpipe_resync_history_all (   dev)    DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_DEV, dt_dev_pixelpipe_resync_history_all_real, (dev))

Definition at line 67 of file dev_pixelpipe.h.

◆ dt_dev_pixelpipe_resync_history_main

#define dt_dev_pixelpipe_resync_history_main (   dev)    DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_DEV, dt_dev_pixelpipe_resync_history_main_real, (dev))

Definition at line 72 of file dev_pixelpipe.h.

◆ dt_dev_pixelpipe_resync_history_preview

#define dt_dev_pixelpipe_resync_history_preview (   dev)    DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_DEV, dt_dev_pixelpipe_resync_history_preview_real, (dev))

Definition at line 77 of file dev_pixelpipe.h.

◆ dt_dev_pixelpipe_update_history_all

#define dt_dev_pixelpipe_update_history_all (   dev)    DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_DEV, dt_dev_pixelpipe_update_history_all_real, (dev))

Definition at line 52 of file dev_pixelpipe.h.

◆ dt_dev_pixelpipe_update_history_main

#define dt_dev_pixelpipe_update_history_main (   dev)    DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_DEV, dt_dev_pixelpipe_update_history_main_real, (dev))

Definition at line 44 of file dev_pixelpipe.h.

◆ dt_dev_pixelpipe_update_history_preview

#define dt_dev_pixelpipe_update_history_preview (   dev)    DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_DEV, dt_dev_pixelpipe_update_history_preview_real, (dev))

Definition at line 48 of file dev_pixelpipe.h.

◆ dt_dev_pixelpipe_update_zoom_main

#define dt_dev_pixelpipe_update_zoom_main (   dev)    DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_DEV, dt_dev_pixelpipe_update_zoom_main_real, (dev))

Definition at line 57 of file dev_pixelpipe.h.

◆ dt_dev_pixelpipe_update_zoom_preview

#define dt_dev_pixelpipe_update_zoom_preview (   dev)    DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_DEV, dt_dev_pixelpipe_update_zoom_preview_real, (dev))

Definition at line 62 of file dev_pixelpipe.h.

Typedef Documentation

◆ dt_dev_pixelpipe_cache_ready_callback_t

◆ dt_dev_pixelpipe_cache_wait_t

Function Documentation

◆ dt_dev_pixelpipe_activemodule_disables_currentmodule()

gboolean dt_dev_pixelpipe_activemodule_disables_currentmodule ( struct dt_develop_t dev,
struct dt_iop_module_t current_module 
)

◆ dt_dev_pixelpipe_cache_peek_gui()

gboolean dt_dev_pixelpipe_cache_peek_gui ( dt_dev_pixelpipe_t pipe,
const struct dt_dev_pixelpipe_iop_t piece,
void **  data,
struct dt_pixel_cache_entry_t **  cache_entry,
dt_dev_pixelpipe_cache_wait_t wait,
dt_dev_pixelpipe_cache_ready_callback_t  restart,
gpointer  restart_data 
)

Reopen one GUI-visible host cacheline, or queue the minimal pipe recompute needed to publish it.

GUI samplers only consume host-visible buffers. This wrapper first tries to reopen the requested cacheline:

  • piece output if piece is not NULL,
  • the pipe final backbuffer cacheline if piece is NULL.

If that cacheline does not exist yet, or only exists as a device-side OpenCL payload, the wrapper schedules one dedicated pipe run:

  • module requests stop recursion at that module and force one host cacheline there,
  • NULL requests ask for the final pipe backbuffer.

The request uses a dedicated pipe state instead of pretending history changed, so the worker can rerun just enough of the current synchronized graph to satisfy the GUI reader.

Parameters
pipeCurrent live pipe.
pieceTarget module piece, or NULL for the final backbuffer.
dataReturned host-visible pixel buffer on success.
cache_entryReturned cache entry owning data on success.
waitOptional one-shot cacheline-ready watcher owned by the caller.
restartOptional restart callback used with wait when the cacheline must be published asynchronously.
restart_dataOpaque pointer forwarded to restart.
Returns
TRUE when a host buffer is immediately available, FALSE when the caller must retry after the queued pipe update completed.

◆ dt_dev_pixelpipe_cache_peek_gui_retained()

gboolean dt_dev_pixelpipe_cache_peek_gui_retained ( dt_dev_pixelpipe_t pipe,
const struct dt_dev_pixelpipe_iop_t piece,
void **  data,
struct dt_pixel_cache_entry_t **  cache_entry,
dt_dev_pixelpipe_cache_wait_t wait,
dt_dev_pixelpipe_cache_ready_callback_t  restart,
gpointer  restart_data 
)

dt_dev_pixelpipe_cache_peek_gui(), but the cacheline comes back RETAINED.

Same lookup and same queue-on-miss behaviour; the difference is ownership. The plain form hands back an unreferenced entry, which is correct only for a consumer covered by somebody else's keepalive reference – the darkroom surface, the navigation thumbnail and the scopes all borrow a published backbuffer whose publisher holds one for them.

A consumer sampling an INTERMEDIATE module cacheline has no such cover: those entries sit at refcount 0 between renders, so the pipeline may evict one at any moment. Taking the reference after the lookup returned is too late – the entry can be freed in between, and the sampling pass then reads a dangling buffer. Here the lookup and the reference happen under one hold of the cache lock. Use this one, and do NOT call dt_dev_pixelpipe_cache_ref_count_entry(TRUE, ...) on top of it.

On success the caller owns exactly one reference and must release it with dt_dev_pixelpipe_cache_ref_count_entry(FALSE, entry) on every exit path. On failure nothing is retained.

◆ dt_dev_pixelpipe_cache_wait_cleanup()

void dt_dev_pixelpipe_cache_wait_cleanup ( dt_dev_pixelpipe_cache_wait_t wait,
const char *  reason 
)

Cancel one pending GUI cache wait request and clear its runtime state.

This removes wait from the shared pending queue (if connected), emits a lifecycle debug log and resets the wait object to an inert state. Callers should pass a short static reason string to make cancellations traceable in logs.

Parameters
waitCaller-owned wait object.
reasonShort static cancellation context label for debug traces.

Definition at line 1022 of file dev_pixelpipe.c.

References _cache_wait_connected, _cache_wait_cursor_active, _cache_wait_cursor_restore(), _dt_dev_pixelpipe_cache_wait_ready_callback(), dt_pixelpipe_cache_wait_t::connected, dt_control_signal_get_global(), DT_DEBUG_CONTROL_SIGNAL_DISCONNECT, DT_DEBUG_PIPECACHE, DT_PIXELPIPE_CACHE_HASH_INVALID, dt_pixelpipe_cache_wait_cancel(), dt_print(), dt_supervisor_active(), dt_supervisor_cache_wait(), DT_SV_DELETE, FALSE, dt_pixelpipe_cache_wait_t::hash, IS_NULL_PTR, dt_pixelpipe_cache_wait_t::module_multi_priority, dt_pixelpipe_cache_wait_t::module_op, dt_pixelpipe_cache_wait_t::owner_tag, dt_pixelpipe_cache_wait_t::pipe, dt_pixelpipe_cache_wait_t::pipe_imgid, dt_pixelpipe_cache_wait_t::pipe_type, dt_pixelpipe_cache_wait_t::request_id, dt_pixelpipe_cache_wait_t::restart, dt_pixelpipe_cache_wait_t::target_node_key, TRUE, and dt_pixelpipe_cache_wait_t::user_data.

Referenced by _color_picker_callback_button_press(), _color_picker_widget_destroy(), _dt_iop_autoset_finish(), _peek_gui(), _refresh_preview_cursor_sample(), _release_expose_source_caches(), _studio_dev_teardown(), cleanup(), dt_iop_autoset_build_list(), dt_iop_color_picker_reset(), gui_cleanup(), gui_cleanup(), gui_focus(), leave(), and view_leave().

◆ dt_dev_pixelpipe_cache_wait_dump_pending()

void dt_dev_pixelpipe_cache_wait_dump_pending ( const char *  reason)

Dump pending GUI cache wait requests for lifecycle debugging.

This reports the current queue of not-yet-served cache wait requests, with ownership tags, request ids and target hashes. Callers should use it right before teardown phases (view leave / app shutdown) to identify abandoned waits that never received a cacheline-ready event.

Parameters
reasonShort caller-provided context label for the log entry.

Definition at line 100 of file dev_pixelpipe.c.

References _dump_one_pending(), DT_DEBUG_PIPECACHE, dt_pixelpipe_cache_wait_foreach_pending(), dt_pixelpipe_cache_wait_get_stats(), dt_pixelpipe_cache_wait_pending_count(), dt_print(), and IS_NULL_PTR.

Referenced by dt_cleanup(), and leave().

◆ dt_dev_pixelpipe_cache_wait_set_owner()

void dt_dev_pixelpipe_cache_wait_set_owner ( dt_dev_pixelpipe_cache_wait_t wait,
const char *  owner_tag,
gpointer  owner_object 
)

Attach debug ownership metadata to one cache wait request.

The cache wait manager tracks heterogeneous GUI consumers (pickers, histograms, autoset, darkroom surfaces) in a shared pending queue. This setter lets each caller stamp the wait object with:

  • a stable textual tag ( owner_tag) used in logs,
  • the originating runtime object pointer ( owner_object) used to correlate repeated requests from the same caller.

Ownership metadata does not affect scheduling or locking decisions. It only improves traceability when diagnosing missed/served requests and UI/pipeline desynchronization.

Parameters
waitCaller-owned wait object to annotate.
owner_tagShort static owner label for debug traces.
owner_objectCaller instance pointer associated with the request.

Definition at line 1090 of file dev_pixelpipe.c.

References IS_NULL_PTR, dt_pixelpipe_cache_wait_t::owner_object, and dt_pixelpipe_cache_wait_t::owner_tag.

Referenced by _lib_navigation_draw_callback(), _lib_navigation_history_resync_callback(), _pixelpipe_pick_from_image(), _process_histogram(), _process_vectorscope(), _refresh_preview_cursor_sample(), _refresh_preview_module_histogram_for_hash(), _sample_picker_from_cache(), dt_dev_lock_pipe_surface(), and dt_iop_autoset_advance().

◆ dt_dev_pixelpipe_change()

void dt_dev_pixelpipe_change ( struct dt_dev_pixelpipe_t pipe)

Consume and clear pending change flags in one atomic step.

The previous get-then-store sequence could lose updates when another thread OR-ed a new flag between the load and the reset. That made history resync requests randomly disappear, especially under fast GUI actions such as toggles or consecutive parameter commits.

Definition at line 1771 of file dev_pixelpipe.c.

References _get_debug_pipe_name(), _refresh_pipe_detail_mask_state(), _seal_opencl_cache_policy(), _sync_focused_in_place(), _synch_all_snapshot(), _synch_top_snapshot(), dt_dev_pixelpipe_t::bypass_blendif, dt_dev_pixelpipe_t::changed, dt_dev_pixelpipe_t::dev, dt_atomic_exch_int(), DT_DEBUG_DEV, DT_DEBUG_HISTORY, DT_DEV_DETAIL_MASK_NONE, dt_dev_history_snapshot_release(), dt_dev_history_snapshot_take(), DT_DEV_PIPE_CACHE_REQUEST, DT_DEV_PIPE_REENTRY, DT_DEV_PIPE_REMOVE, DT_DEV_PIPE_SYNCH, DT_DEV_PIPE_TOP_CHANGED, DT_DEV_PIPE_UNCHANGED, DT_DEV_PIPE_ZOOMED, dt_dev_pixelpipe_cleanup_nodes(), dt_dev_pixelpipe_create_nodes(), DT_DEV_PIXELPIPE_DISPLAY_NONE, dt_dev_pixelpipe_get_roi_out(), dt_dev_pixelpipe_propagate_formats(), dt_dev_pixelpipe_set_history_hash(), dt_dev_pixelpipe_sync_no_history(), dt_free, dt_get_times(), dt_get_wtime(), dt_print(), dt_pthread_rwlock_rdlock(), dt_pthread_rwlock_unlock(), dt_show_times_f(), FALSE, dt_dev_history_snapshot_t::history_hash, dt_develop_t::history_mutex, dt_dev_pixelpipe_t::iheight, dt_dev_pixelpipe_t::iwidth, dt_dev_pixelpipe_t::mask_display, dt_dev_pixelpipe_t::nodes, dt_dev_pixelpipe_t::processed_height, dt_dev_pixelpipe_t::processed_width, status, TRUE, type, and dt_dev_pixelpipe_t::want_detail_mask.

Referenced by _process_at_roi(), and _resync_pipe_with_history().

◆ dt_dev_pixelpipe_change_zoom_main()

◆ dt_dev_pixelpipe_get_module_piece()

const struct dt_dev_pixelpipe_iop_t * dt_dev_pixelpipe_get_module_piece ( const struct dt_dev_pixelpipe_t pipe,
const struct dt_iop_module_t module 
)

Return the enabled piece owned by module in pipe.

GUI-side cache readers must resolve the current live piece from the current pipe graph every time they sample. Piece pointers are not stable across history resyncs or pipe rebuilds, so callers should never persist them.

Parameters
pipeCurrent pipe graph.
moduleModule instance to look up.
Returns
The enabled piece matching module, or NULL if none exists in the current pipe graph.

◆ dt_dev_pixelpipe_get_prev_enabled_piece()

const struct dt_dev_pixelpipe_iop_t * dt_dev_pixelpipe_get_prev_enabled_piece ( const struct dt_dev_pixelpipe_t pipe,
const struct dt_dev_pixelpipe_iop_t piece 
)

Return the closest enabled piece located immediately before piece in pipe.

Cache readers that need the input buffer of one module must reopen the previous enabled module output, not simply the previous list node, because disabled pieces keep their place in pipe->nodes while not producing any cacheline. This utility keeps that rule centralized at the pixelpipe level.

Parameters
pipeCurrent pipe graph.
pieceReference piece inside pipe.
Returns
The previous enabled piece, or NULL if piece is the first enabled node or if either input is invalid.

◆ dt_dev_pixelpipe_get_roi_in()

◆ dt_dev_pixelpipe_get_roi_out()

◆ dt_dev_pixelpipe_is_backbufer_valid()

◆ dt_dev_pixelpipe_is_pipeline_valid()

gboolean dt_dev_pixelpipe_is_pipeline_valid ( struct dt_dev_pixelpipe_t pipe)

◆ dt_dev_pixelpipe_node_hash()

uint64_t dt_dev_pixelpipe_node_hash ( struct dt_dev_pixelpipe_t pipe,
const struct dt_dev_pixelpipe_iop_t piece,
const struct dt_iop_roi_t  ,
const int  pos 
)

◆ dt_dev_pixelpipe_propagate_formats()

◆ dt_dev_pixelpipe_rebuild_all_real()

◆ dt_dev_pixelpipe_reset_all()

◆ dt_dev_pixelpipe_resync_history_all_real()

void dt_dev_pixelpipe_resync_history_all_real ( struct dt_develop_t dev)

◆ dt_dev_pixelpipe_resync_history_main_real()

void dt_dev_pixelpipe_resync_history_main_real ( struct dt_develop_t dev)

◆ dt_dev_pixelpipe_resync_history_preview_real()

void dt_dev_pixelpipe_resync_history_preview_real ( struct dt_develop_t dev)

◆ dt_dev_pixelpipe_update_history_all_real()

void dt_dev_pixelpipe_update_history_all_real ( struct dt_develop_t dev)

◆ dt_dev_pixelpipe_update_history_main_real()

void dt_dev_pixelpipe_update_history_main_real ( struct dt_develop_t dev)

◆ dt_dev_pixelpipe_update_history_preview_real()

void dt_dev_pixelpipe_update_history_preview_real ( struct dt_develop_t dev)

◆ dt_dev_pixelpipe_update_zoom_main_real()

◆ dt_dev_pixelpipe_update_zoom_preview_real()

void dt_dev_pixelpipe_update_zoom_preview_real ( struct dt_develop_t dev)

◆ dt_pixelpipe_get_global_hash()