Skip to content

Conversation

@jenshannoschwalm
Copy link
Collaborator

@jenshannoschwalm jenshannoschwalm commented Jan 24, 2026

UPDATED (2)
These commits

  • adds xtrans/filters data to the piece struct
  • provides dt_dev_prepare_piece_cfa() setting correct filters and xtrans pattern to piece data
    according to specified roi if the piece module works in IOP_CS_RAW
  • makes sure pixelpipe and tiling code provide corrected CFA patterns in the piece struct before
    calling process(), process_cl() or any tiling variant
  • allows all IOP_CS_RAW modules to choose CFA filter/xtrans data either from piece or pipe
    without need to calculate those internally thus reducing code complexity.

Why doing so?
Snapping to a sensor pattern restricts precision of roi dimensions and displacements if distorting
modules (like lens, rotate&perspective...) or even simple crop or orientation also set roi.
In darkroom mode this is of very little significance, for exports there is a clear benefit.
Performance gains are neglectable.


Modules working in IOP_CS_RAW regularly need to know the photosite color channel for a given location,
for this they require correct CFA pattern information via filters or the xtrans pattern.

We have inline functions or macros as FC() or FCxtrans(), they:

  • can use xtrans/filters data in pipe->dsc provided by rawprepare (pipe data).
    While doing so, they must use the roi_in->x/y displacements with a subtle performance cost
  • can use corrected filters/xtrans data (piece data) and possibly use more performant inline functions

Fixed and checked for OpenCL/CPU and both sensors:

  1. All demosaicers, cacorrect, hotpixels, rawdenoise and highlights reconstruction modes use piece data
  2. invert is safe as it uses pipe data correctly
  3. rasterfile is safe as is doesn't use CFA data
  4. temperature now uses piece data

Reminder:
Generic tiling still uses CFA snappers for overlapping, not required any more.


The second commit is about OpenCL VNG performance

@jenshannoschwalm jenshannoschwalm added scope: image processing correcting pixels scope: codebase making darktable source code easier to manage OpenCL Related to darktable OpenCL code labels Jan 24, 2026
@jenshannoschwalm jenshannoschwalm added this to the 5.6 milestone Jan 24, 2026
@jenshannoschwalm
Copy link
Collaborator Author

@TurboGit a pretty large single commit. No visible differences but for sure we will have subtle differences when exporting if lens, flip or alike is included so the integration tests will remind you. This would be reference now :-)

@jenshannoschwalm jenshannoschwalm force-pushed the avoid_cfa_snapping_46 branch 3 times, most recently from 8d06ed1 to d6a8f57 Compare January 25, 2026 08:01
@jenshannoschwalm jenshannoschwalm added the feature: enhancement current features to improve label Jan 25, 2026
@jenshannoschwalm jenshannoschwalm force-pushed the avoid_cfa_snapping_46 branch 3 times, most recently from 969f86d to 84c74d0 Compare February 1, 2026 14:29
@jenshannoschwalm
Copy link
Collaborator Author

The second commit significantly improves OpenCL VNG performance as it avoids kernel calls.

@jenshannoschwalm jenshannoschwalm added the scope: performance doing everything the same but faster label Feb 1, 2026
@jenshannoschwalm jenshannoschwalm force-pushed the avoid_cfa_snapping_46 branch 3 times, most recently from 0c49f38 to 1f8b9c9 Compare February 1, 2026 18:32
@jenshannoschwalm
Copy link
Collaborator Author

Release notes:

  1. Redesign of the pixelpipe allows positioning, distortion and crops with precision to a single pixel
  2. Performance gains for all OpenCL VNG (dual) demosaicers

@jenshannoschwalm jenshannoschwalm force-pushed the avoid_cfa_snapping_46 branch 8 times, most recently from 3e75637 to e735edc Compare February 3, 2026 12:49
This commit
- adds xtrans/filters data to the piece struct
- provides dt_dev_prepare_piece_cfa() setting correct filters and xtrans pattern to piece data
  according to specified roi if the piece module works in IOP_CS_RAW
- makes sure pixelpipe and tiling code provide corrected CFA patterns in the piece struct before
  calling process(), process_cl() or any tiling variant
- allows all IOP_CS_RAW modules to choose CFA filter/xtrans data either from piece or pipe
  without need to calculate those internally thus reducing code complexity.

Why doing so?
Snapping to a sensor pattern restricts precision of roi dimensions and displacements if distorting
modules (like lens, rotate&perspective...) or even simple crop or orientation also set roi.
In darkroom mode this is of minor significance, for exports there is a clear benefit.
Performance gains are neglectable.

Modules working in IOP_CS_RAW regularly need to know the photosite color channel for a given location,
for this they require correct CFA pattern information via `filters` or the `xtrans` pattern.

We have inline functions or macros as FC() or FCxtrans(), they:
- can use xtrans/filters data in pipe->dsc provided by rawprepare (pipe data).
  While doing so, they must use the roi_in->x/y displacements with a subtle performance cost
- can use corrected filters/xtrans data (piece data) and possibly use more performant inline functions

Fixed and checked for OpenCL/CPU and both sensors:
1. All demosaicers, cacorrect, hotpixels, rawdenoise and highlights reconstruction modes use piece data
2. invert is safe as it uses pipe data correctly
3. rasterfile is safe as is doesn't use CFA data
4. temperature now uses piece data
5. raw overexposed uses original pattern data as provided by image
For OpenCL VNG performance the border interpolation and the bayer green equilibrate
have both been integrated into the main kernels thus reducing the called kernels by 3
for bayer and 2 for xtrans sensors.

Due to these changes we can also avoid an image copy for more performance and can reduce
cl_mem usage for only-linear mode used for dual demosaicing.
It now fills the border area with interpolated data from input besides clearing the
central part so we can get rid of the costly initial vng part.
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant