Skip to content

Commit 8f52e41

Browse files
Introduce and use dt_dev_pixelpipe_piece_shutdown()
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, cacheline integrity is kept by invalidating incorrect output.
1 parent 938a5f9 commit 8f52e41

3 files changed

Lines changed: 30 additions & 2 deletions

File tree

src/develop/pixelpipe_hb.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,6 +1329,31 @@ static inline gboolean _module_pipe_stop(dt_dev_pixelpipe_t *pipe,
13291329
return TRUE;
13301330
}
13311331

1332+
gboolean dt_dev_pixelpipe_piece_shutdown(dt_dev_pixelpipe_iop_t *piece)
1333+
{
1334+
dt_dev_pixelpipe_t *pipe = piece->pipe;
1335+
const dt_dev_pixelpipe_stopper_t stopper = dt_atomic_get_int(&pipe->shutdown);
1336+
if(stopper <= DT_DEV_PIXELPIPE_STOP_NO)
1337+
return FALSE;
1338+
1339+
/* We check for any UI action requesting an early pipe shutdown as
1340+
DT_DEV_PIXELPIPE_STOP_NODES or DT_DEV_PIXELPIPE_STOP_HQ, we
1341+
- stop further processing the module thus it's output will be incorrect
1342+
- change the shutdown mode to the modules's iop_order so _module_pipe_stop()
1343+
can take care of cacheline validation.
1344+
*/
1345+
if(stopper == DT_DEV_PIXELPIPE_STOP_NODES || stopper == DT_DEV_PIXELPIPE_STOP_HQ)
1346+
{
1347+
dt_print_pipe(DT_DEBUG_PIPE, "modify piece shutdown",
1348+
pipe, piece->module, pipe->devid, NULL, NULL, "%s",
1349+
dt_dev_pixelpipe_shutdown_to_str(stopper));
1350+
1351+
dt_atomic_set_int(&pipe->shutdown, piece->module->iop_order);
1352+
}
1353+
1354+
return TRUE;
1355+
}
1356+
13321357
void dt_dev_prepare_piece_cfa(dt_dev_pixelpipe_iop_t *piece, const dt_iop_roi_t *roi)
13331358
{
13341359
dt_iop_module_t *module = piece->module;

src/develop/pixelpipe_hb.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,9 @@ void dt_dev_pixelpipe_disable_after(dt_dev_pixelpipe_t *pipe, const char *op);
423423
// disable given op and all that comes before it in the pipe:
424424
void dt_dev_pixelpipe_disable_before(dt_dev_pixelpipe_t *pipe, const char *op);
425425

426+
// pieces can test for a pipe shutdown request within module->process().
427+
gboolean dt_dev_pixelpipe_piece_shutdown(dt_dev_pixelpipe_iop_t *piece);
428+
426429
// helper function to pass a raster mask through a (so far) processed pipe
427430
float *dt_dev_get_raster_mask(dt_dev_pixelpipe_iop_t *piece,
428431
const struct dt_iop_module_t *raster_mask_source,

src/iop/diffuse.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,7 +1414,7 @@ void process(dt_iop_module_t *self,
14141414
in = temp1;
14151415
}
14161416

1417-
for(int it = 0; it < iterations; it++)
1417+
for(int it = 0; it < iterations && !dt_dev_pixelpipe_piece_shutdown(piece); it++)
14181418
{
14191419
if(it == 0)
14201420
{
@@ -1680,7 +1680,7 @@ int process_cl(dt_iop_module_t *self,
16801680
in = temp1;
16811681
}
16821682

1683-
for(int it = 0; it < iterations && err == CL_SUCCESS; it++)
1683+
for(int it = 0; it < iterations && err == CL_SUCCESS && !dt_dev_pixelpipe_piece_shutdown(piece); it++)
16841684
{
16851685
if(it == 0)
16861686
{

0 commit comments

Comments
 (0)