Skip to content

Three ways to increase pixelpipe UI responsiveness #21274

Open
jenshannoschwalm wants to merge 3 commits into
darktable-org:masterfrom
jenshannoschwalm:pixelpipe_zoom_knocking
Open

Three ways to increase pixelpipe UI responsiveness #21274
jenshannoschwalm wants to merge 3 commits into
darktable-org:masterfrom
jenshannoschwalm:pixelpipe_zoom_knocking

Conversation

@jenshannoschwalm

Copy link
Copy Markdown
Collaborator

In short, this is all about how fast the UI responds to user actions while already processing the pipes, collected work ...

  1. 15a4a67 fixes two bugs when processing the pipe, a) there was a missing "stop pixelpipe check" in CPU code path thus in CPU code the response to changes in history was delayed , b) in very rare cornercases we didn't write back input cl_mem to the pixelpipe cache. Thus we were not completely sure about valid input data represented in cache. That was the reason for the two cache invalidations @masterpiga spotted. My code comments were slightly wrong and i was not completeöy sure why they seemed necessary ... Now all is good and those invalidations could go with this commit.
    @TurboGit those two are genuine bugs. The first mentioned would be safe and good to be fixed for 5.6, i would do another PR for 5.6 if you want. The second case is not important - i have never spotted that "in the wild" so with invalidation we are absolutely safe, just not as fast as we could ...
  2. 626d2d4 handles faster response to history changes if we are in the middle of a long diffuse process.
  3. 7cb21b7 can reduce UI responsiveness for drags & zooms quite a lot.

@jenshannoschwalm jenshannoschwalm added this to the 5.8 milestone Jun 7, 2026
@jenshannoschwalm jenshannoschwalm added feature: enhancement current features to improve scope: UI user interface and interactions scope: image processing correcting pixels scope: performance doing everything the same but faster scope: codebase making darktable source code easier to manage OpenCL Related to darktable OpenCL code labels Jun 7, 2026
- Major _module_pipe_stop() work
  If we find pipe shutdown reflecting an iop_order we must invalidate cachelines for the
  specified iop_order as output is unsafe.
  As the input cacheline either
    - requires updating as we possibly have done some colorspace conversion since then
    - or it does not hold any valid data at all
  we have to write back the cl_mem to host so we have valid cacheline data for the next pixelpipe run.
  As input cl_mem is not used any more we release it.
- avoid two other cache invalidations for input data, added comments
- The pixelpipe CPU path missed a _module_pipe_stop()
- Added and use dt_dev_pixelpipe_cache_invalidate_iop()
- Activate DT_PIPE_CAS_SHUTDOWN, now we only can set shutdown mode once per pixelpipe run.
- Some readability maintenance, comments ...
For a fast UI response when switching darkroom HQ processing mode or changing history (setting pipe
shutdown to DT_DEV_PIXELPIPE_STOP_NODES) we may use dt_dev_pixelpipe_set_shutdown() *while* processing
a module to enforce a clean pipe shutdown asap.

The pixelpipe tests for those UI induced shutdown requests for an early exit at safe locations.
Yet a few heavy processing modules with high number of iterations (most notably diffuse) can lead
to a significant delay until such a safe point has been reached.

With this commit they can test for a requested shutdown via dt_dev_pixelpipe_piece_shutdown() and
possibly stop iterating.
If that happened the processed output is just bad, so how do we care?

dt_dev_pixelpipe_piece_shutdown() checks the shutdown mode and possibly modifies it to ensure that
input data and the the used iop cacheline is invalidated, this modification is logged via -d pipe.
Currently we use dt_dev_pixelpipe_set_shutdown() to stop a running pixelpipe asap, this is
used for changing the nodes involved in the pipe (history changes) or when toggling between
darkroom HQ mode on/off as examples, we do this for UI responsiveness.

Being in darkroom mode **while** the dt_dev_pixelpipe_process() is still running, a UI move of the
the displayed part of the main canvas or zooming-in/out results in a new control job which is
currently processed *after the complete* dt_dev_pixelpipe_process().

This commit adds an early-exit & restart pipe mechanism for a faster UI response, avoiding up to
one pixelpipe run with a good chance of finding valid pixelpipe cache data.

1. A new shutdown mode DT_DEV_PIXELPIPE_STOP_KNOCK has been added to dt_dev_pixelpipe_stopper_t.
   It is
   a) checked, reported and handled in dt_dev_process_image_job()
   b) tested in dt_dev_pixelpipe_process() via _module_pipe_stop() making sure the pipe
      possibly exits with TRUE state and a shutdown mode.
   In all cases we ensure pixelpipe cache integrity via _module_pipe_stop().

2. How is this shutdown mode induced?
   If we zoom in/out or reposition the main canvas we set shutdown to DT_DEV_PIXELPIPE_STOP_KNOCK
   in dt_dev_zoom_move() enforcing the pipe restart.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: enhancement current features to improve OpenCL Related to darktable OpenCL code scope: codebase making darktable source code easier to manage scope: image processing correcting pixels scope: performance doing everything the same but faster scope: UI user interface and interactions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant