| Message ID | 20260716222515.251464-1-mzamazal@redhat.com |
|---|---|
| Headers | show |
| Series |
|
| Related | show |
Hi Milan, thanks for working on this! I just tried to apply the patches in order to play around with them - however it looks like they haven't yet rebased on top of 0.7.2 / doesn't apply to master. When you have time would you mind sending a rebased version? Best regards, Robert On 17.07.26 00:25, Milan Zamazal wrote: > Lens shading correction for software GPU ISP. Based on the initial work > by Hans’s students, taken over and significantly modified and eventually > reworked to use LSC from libipa (the ongoing work by Jacopo and others). > > The LSC is not implemented for CPU ISP within this series; it may be > added later if needed. > > It’s RFC because: > > - It’s not yet completely tested although it seems to be working in my > environment. > - It’s based on the libipa patches not yet merged. > - Further changes will be needed once GPU ISP multipass is merged. > > Example YAML for grid based LSC, no-op values, place it after Awb: > > - Lsc: > sets: > - ct: 6500 > r: [ > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 > ] > g: [ > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 > ] > b: [ > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, > 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 > ] > > Example YAML for polynomial based LSC, no-op values, place it after Awb: > > - Lsc: > type: "polynomial" > sets: > - ct: 6500 > r: > cx: 0.0 > cy: 0.0 > k0: 0.0 > k1: 0.0 > k2: 0.0 > k3: 0.0 > k4: 0.0 > g: > cx: 0.0 > cy: 0.0 > k0: 0.0 > k1: 0.0 > k2: 0.0 > k3: 0.0 > k4: 0.0 > b: > cx: 0.0 > cy: 0.0 > k0: 0.0 > k1: 0.0 > k2: 0.0 > k3: 0.0 > k4: 0.0 > > Changes in v8: > - LscValueType removed. > - A named constant introduced for minimum temperature change. > - A clarification comment added to the LUT value computation. > - lsc-enabled shader flag and the related variables removed. > - Wording corrections suggested by Bryan. > > Changes in v7: > - Updated for libipa patches v5 (temperature access). > > Changes in v6: > - Rebased on Jacopo’s libipa patches (v3). > - Not updating LSC tables on small or no temperature changes. > - Using libipa LSC algorithms; the implementation in ‘simple’ IPA > algorithm reduced to the minimum needed. > - Grid tables are defined using integers rather than floats, because > libipa LSC supports only quantised values and not floats. > - New boolean uniform to enable or disable LSC dynamically, rather than > only in shaders compile time; to be able to honour the LSC control. > - Specific handling of polynomial LSC removed. Polynomial LSC is > already handled by libipa, by making a grid-based LSC from it. While > a direct polynomial computation may be a bit faster with a minimum > number of the polynomial coefficients, the simplicity wins. If we > liked to have direct polynomial LSC computation, it should be > implemented with help of libipa. > > Changes in v5: > - ‘grids’ tuning file item renamed to ‘sets’ for consistency with rkisp1. > - Underscores appended to Lsc::lsc* names. > - Other minor stylistic changes. > - Proof-of-concept polynomial LSC implemented. > > Changes in v4: > - glFilterParam -> param > - Indentation changes in the shaders. > - A commit message part about temperature reworded. > - Updated for YamlObject -> ValueNode. > - New constant kLscValuesPerCell to distinguish between the constants > for the params array size (values) and for the stride (bytes). > - The lookup array switched to floats and the texture to half-floats. > > Changes in v3: > - LSC scripts patch dropped due to missing licences. > - DO_LSC -> APPLY_LSC > - textureUniformLsc_ is assigned unconditionally now. > - New constant DebayerParams::kLscBytesPerCell. > - LSC values in the tuning file are floats now and converted to bytes internally. > - Source code comments added to clarify the usage of the byte LUTs. > > Changes in v2: > - Remaining issues from the reviews (hopefully) addressed. > - Especially there is only a single texture now and LSC is fully > conditional. > - Major cleanup, hacks removed or replaced, typo fixes, cosmetic > changes, making linters happy, etc. > - See > https://lists.libcamera.org/pipermail/libcamera-devel/2026-January/056883.html > for an example how to add the grid data. > > Milan Zamazal (1): > libcamera: software_isp: Pass LSC availability to debayering > > Xander Pronk (5): > libcamera: software_isp: egl: Add filter parameter to > createTexture2D() > libcamera: software_isp: Add LSC data to DebayerParams > ipa: simple: Add LSC algorithm > libcamera: shaders: Add LSC support > libcamera: software_isp: debayer_egl: Add LSC support > > include/libcamera/internal/egl.h | 6 +- > .../internal/software_isp/debayer_params.h | 9 ++ > .../internal/software_isp/software_isp.h | 1 + > include/libcamera/ipa/soft.mojom | 4 +- > src/ipa/simple/algorithms/lsc.cpp | 100 ++++++++++++++++++ > src/ipa/simple/algorithms/lsc.h | 50 +++++++++ > src/ipa/simple/algorithms/meson.build | 1 + > src/ipa/simple/ipa_context.h | 6 ++ > src/ipa/simple/soft_simple.cpp | 7 +- > src/libcamera/egl.cpp | 17 ++- > src/libcamera/shaders/bayer_1x_packed.frag | 8 ++ > src/libcamera/shaders/bayer_unpacked.frag | 8 ++ > src/libcamera/software_isp/debayer.cpp | 29 +++++ > src/libcamera/software_isp/debayer.h | 3 +- > src/libcamera/software_isp/debayer_cpu.cpp | 3 +- > src/libcamera/software_isp/debayer_cpu.h | 3 +- > src/libcamera/software_isp/debayer_egl.cpp | 34 +++++- > src/libcamera/software_isp/debayer_egl.h | 10 +- > src/libcamera/software_isp/software_isp.cpp | 5 +- > 19 files changed, 286 insertions(+), 18 deletions(-) > create mode 100644 src/ipa/simple/algorithms/lsc.cpp > create mode 100644 src/ipa/simple/algorithms/lsc.h >
Robert Mader <robert.mader@collabora.com> writes: > Hi Milan, thanks for working on this! > > I just tried to apply the patches in order to play around with them - however it looks like they haven't > yet rebased on top of 0.7.2 / doesn't apply to master. When you have time would you mind sending a rebased > version? Hi Robert, the patches are on top of Jacopo's libipa patches (v5 currently), so I can rebase only there. > Best regards, > > Robert > > On 17.07.26 00:25, Milan Zamazal wrote: >> Lens shading correction for software GPU ISP. Based on the initial work >> by Hans’s students, taken over and significantly modified and eventually >> reworked to use LSC from libipa (the ongoing work by Jacopo and others). >> >> The LSC is not implemented for CPU ISP within this series; it may be >> added later if needed. >> >> It’s RFC because: >> >> - It’s not yet completely tested although it seems to be working in my >> environment. >> - It’s based on the libipa patches not yet merged. >> - Further changes will be needed once GPU ISP multipass is merged. >> >> Example YAML for grid based LSC, no-op values, place it after Awb: >> >> - Lsc: >> sets: >> - ct: 6500 >> r: [ >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 >> ] >> g: [ >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 >> ] >> b: [ >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 >> ] >> >> Example YAML for polynomial based LSC, no-op values, place it after Awb: >> >> - Lsc: >> type: "polynomial" >> sets: >> - ct: 6500 >> r: >> cx: 0.0 >> cy: 0.0 >> k0: 0.0 >> k1: 0.0 >> k2: 0.0 >> k3: 0.0 >> k4: 0.0 >> g: >> cx: 0.0 >> cy: 0.0 >> k0: 0.0 >> k1: 0.0 >> k2: 0.0 >> k3: 0.0 >> k4: 0.0 >> b: >> cx: 0.0 >> cy: 0.0 >> k0: 0.0 >> k1: 0.0 >> k2: 0.0 >> k3: 0.0 >> k4: 0.0 >> >> Changes in v8: >> - LscValueType removed. >> - A named constant introduced for minimum temperature change. >> - A clarification comment added to the LUT value computation. >> - lsc-enabled shader flag and the related variables removed. >> - Wording corrections suggested by Bryan. >> >> Changes in v7: >> - Updated for libipa patches v5 (temperature access). >> >> Changes in v6: >> - Rebased on Jacopo’s libipa patches (v3). >> - Not updating LSC tables on small or no temperature changes. >> - Using libipa LSC algorithms; the implementation in ‘simple’ IPA >> algorithm reduced to the minimum needed. >> - Grid tables are defined using integers rather than floats, because >> libipa LSC supports only quantised values and not floats. >> - New boolean uniform to enable or disable LSC dynamically, rather than >> only in shaders compile time; to be able to honour the LSC control. >> - Specific handling of polynomial LSC removed. Polynomial LSC is >> already handled by libipa, by making a grid-based LSC from it. While >> a direct polynomial computation may be a bit faster with a minimum >> number of the polynomial coefficients, the simplicity wins. If we >> liked to have direct polynomial LSC computation, it should be >> implemented with help of libipa. >> >> Changes in v5: >> - ‘grids’ tuning file item renamed to ‘sets’ for consistency with rkisp1. >> - Underscores appended to Lsc::lsc* names. >> - Other minor stylistic changes. >> - Proof-of-concept polynomial LSC implemented. >> >> Changes in v4: >> - glFilterParam -> param >> - Indentation changes in the shaders. >> - A commit message part about temperature reworded. >> - Updated for YamlObject -> ValueNode. >> - New constant kLscValuesPerCell to distinguish between the constants >> for the params array size (values) and for the stride (bytes). >> - The lookup array switched to floats and the texture to half-floats. >> >> Changes in v3: >> - LSC scripts patch dropped due to missing licences. >> - DO_LSC -> APPLY_LSC >> - textureUniformLsc_ is assigned unconditionally now. >> - New constant DebayerParams::kLscBytesPerCell. >> - LSC values in the tuning file are floats now and converted to bytes internally. >> - Source code comments added to clarify the usage of the byte LUTs. >> >> Changes in v2: >> - Remaining issues from the reviews (hopefully) addressed. >> - Especially there is only a single texture now and LSC is fully >> conditional. >> - Major cleanup, hacks removed or replaced, typo fixes, cosmetic >> changes, making linters happy, etc. >> - See >> https://lists.libcamera.org/pipermail/libcamera-devel/2026-January/056883.html >> for an example how to add the grid data. >> >> Milan Zamazal (1): >> libcamera: software_isp: Pass LSC availability to debayering >> >> Xander Pronk (5): >> libcamera: software_isp: egl: Add filter parameter to >> createTexture2D() >> libcamera: software_isp: Add LSC data to DebayerParams >> ipa: simple: Add LSC algorithm >> libcamera: shaders: Add LSC support >> libcamera: software_isp: debayer_egl: Add LSC support >> >> include/libcamera/internal/egl.h | 6 +- >> .../internal/software_isp/debayer_params.h | 9 ++ >> .../internal/software_isp/software_isp.h | 1 + >> include/libcamera/ipa/soft.mojom | 4 +- >> src/ipa/simple/algorithms/lsc.cpp | 100 ++++++++++++++++++ >> src/ipa/simple/algorithms/lsc.h | 50 +++++++++ >> src/ipa/simple/algorithms/meson.build | 1 + >> src/ipa/simple/ipa_context.h | 6 ++ >> src/ipa/simple/soft_simple.cpp | 7 +- >> src/libcamera/egl.cpp | 17 ++- >> src/libcamera/shaders/bayer_1x_packed.frag | 8 ++ >> src/libcamera/shaders/bayer_unpacked.frag | 8 ++ >> src/libcamera/software_isp/debayer.cpp | 29 +++++ >> src/libcamera/software_isp/debayer.h | 3 +- >> src/libcamera/software_isp/debayer_cpu.cpp | 3 +- >> src/libcamera/software_isp/debayer_cpu.h | 3 +- >> src/libcamera/software_isp/debayer_egl.cpp | 34 +++++- >> src/libcamera/software_isp/debayer_egl.h | 10 +- >> src/libcamera/software_isp/software_isp.cpp | 5 +- >> 19 files changed, 286 insertions(+), 18 deletions(-) >> create mode 100644 src/ipa/simple/algorithms/lsc.cpp >> create mode 100644 src/ipa/simple/algorithms/lsc.h >>
Hi Milan, On 20.07.26 10:34, Milan Zamazal wrote: > Robert Mader <robert.mader@collabora.com> writes: > >> Hi Milan, thanks for working on this! >> >> I just tried to apply the patches in order to play around with them - however it looks like they haven't >> yet rebased on top of 0.7.2 / doesn't apply to master. When you have time would you mind sending a rebased >> version? > Hi Robert, > > the patches are on top of Jacopo's libipa patches (v5 currently), so I > can rebase only there. ah, you mean when using his git branch instead of patchwork? Because applying the patch file (git am) of that series (https://patchwork.libcamera.org/series/6048/mbox/) against master works fine - suggestion a simle git rebase on master should also work. Either way, we can wait for a v6 and ask to rebase the branch. Thanks and best regards, Robert P.S.: would be pretty cool if b4 shazam would work with patchwork :P >> Best regards, >> >> Robert >> >> On 17.07.26 00:25, Milan Zamazal wrote: >>> Lens shading correction for software GPU ISP. Based on the initial work >>> by Hans’s students, taken over and significantly modified and eventually >>> reworked to use LSC from libipa (the ongoing work by Jacopo and others). >>> >>> The LSC is not implemented for CPU ISP within this series; it may be >>> added later if needed. >>> >>> It’s RFC because: >>> >>> - It’s not yet completely tested although it seems to be working in my >>> environment. >>> - It’s based on the libipa patches not yet merged. >>> - Further changes will be needed once GPU ISP multipass is merged. >>> >>> Example YAML for grid based LSC, no-op values, place it after Awb: >>> >>> - Lsc: >>> sets: >>> - ct: 6500 >>> r: [ >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 >>> ] >>> g: [ >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 >>> ] >>> b: [ >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 >>> ] >>> >>> Example YAML for polynomial based LSC, no-op values, place it after Awb: >>> >>> - Lsc: >>> type: "polynomial" >>> sets: >>> - ct: 6500 >>> r: >>> cx: 0.0 >>> cy: 0.0 >>> k0: 0.0 >>> k1: 0.0 >>> k2: 0.0 >>> k3: 0.0 >>> k4: 0.0 >>> g: >>> cx: 0.0 >>> cy: 0.0 >>> k0: 0.0 >>> k1: 0.0 >>> k2: 0.0 >>> k3: 0.0 >>> k4: 0.0 >>> b: >>> cx: 0.0 >>> cy: 0.0 >>> k0: 0.0 >>> k1: 0.0 >>> k2: 0.0 >>> k3: 0.0 >>> k4: 0.0 >>> >>> Changes in v8: >>> - LscValueType removed. >>> - A named constant introduced for minimum temperature change. >>> - A clarification comment added to the LUT value computation. >>> - lsc-enabled shader flag and the related variables removed. >>> - Wording corrections suggested by Bryan. >>> >>> Changes in v7: >>> - Updated for libipa patches v5 (temperature access). >>> >>> Changes in v6: >>> - Rebased on Jacopo’s libipa patches (v3). >>> - Not updating LSC tables on small or no temperature changes. >>> - Using libipa LSC algorithms; the implementation in ‘simple’ IPA >>> algorithm reduced to the minimum needed. >>> - Grid tables are defined using integers rather than floats, because >>> libipa LSC supports only quantised values and not floats. >>> - New boolean uniform to enable or disable LSC dynamically, rather than >>> only in shaders compile time; to be able to honour the LSC control. >>> - Specific handling of polynomial LSC removed. Polynomial LSC is >>> already handled by libipa, by making a grid-based LSC from it. While >>> a direct polynomial computation may be a bit faster with a minimum >>> number of the polynomial coefficients, the simplicity wins. If we >>> liked to have direct polynomial LSC computation, it should be >>> implemented with help of libipa. >>> >>> Changes in v5: >>> - ‘grids’ tuning file item renamed to ‘sets’ for consistency with rkisp1. >>> - Underscores appended to Lsc::lsc* names. >>> - Other minor stylistic changes. >>> - Proof-of-concept polynomial LSC implemented. >>> >>> Changes in v4: >>> - glFilterParam -> param >>> - Indentation changes in the shaders. >>> - A commit message part about temperature reworded. >>> - Updated for YamlObject -> ValueNode. >>> - New constant kLscValuesPerCell to distinguish between the constants >>> for the params array size (values) and for the stride (bytes). >>> - The lookup array switched to floats and the texture to half-floats. >>> >>> Changes in v3: >>> - LSC scripts patch dropped due to missing licences. >>> - DO_LSC -> APPLY_LSC >>> - textureUniformLsc_ is assigned unconditionally now. >>> - New constant DebayerParams::kLscBytesPerCell. >>> - LSC values in the tuning file are floats now and converted to bytes internally. >>> - Source code comments added to clarify the usage of the byte LUTs. >>> >>> Changes in v2: >>> - Remaining issues from the reviews (hopefully) addressed. >>> - Especially there is only a single texture now and LSC is fully >>> conditional. >>> - Major cleanup, hacks removed or replaced, typo fixes, cosmetic >>> changes, making linters happy, etc. >>> - See >>> https://lists.libcamera.org/pipermail/libcamera-devel/2026-January/056883.html >>> for an example how to add the grid data. >>> >>> Milan Zamazal (1): >>> libcamera: software_isp: Pass LSC availability to debayering >>> >>> Xander Pronk (5): >>> libcamera: software_isp: egl: Add filter parameter to >>> createTexture2D() >>> libcamera: software_isp: Add LSC data to DebayerParams >>> ipa: simple: Add LSC algorithm >>> libcamera: shaders: Add LSC support >>> libcamera: software_isp: debayer_egl: Add LSC support >>> >>> include/libcamera/internal/egl.h | 6 +- >>> .../internal/software_isp/debayer_params.h | 9 ++ >>> .../internal/software_isp/software_isp.h | 1 + >>> include/libcamera/ipa/soft.mojom | 4 +- >>> src/ipa/simple/algorithms/lsc.cpp | 100 ++++++++++++++++++ >>> src/ipa/simple/algorithms/lsc.h | 50 +++++++++ >>> src/ipa/simple/algorithms/meson.build | 1 + >>> src/ipa/simple/ipa_context.h | 6 ++ >>> src/ipa/simple/soft_simple.cpp | 7 +- >>> src/libcamera/egl.cpp | 17 ++- >>> src/libcamera/shaders/bayer_1x_packed.frag | 8 ++ >>> src/libcamera/shaders/bayer_unpacked.frag | 8 ++ >>> src/libcamera/software_isp/debayer.cpp | 29 +++++ >>> src/libcamera/software_isp/debayer.h | 3 +- >>> src/libcamera/software_isp/debayer_cpu.cpp | 3 +- >>> src/libcamera/software_isp/debayer_cpu.h | 3 +- >>> src/libcamera/software_isp/debayer_egl.cpp | 34 +++++- >>> src/libcamera/software_isp/debayer_egl.h | 10 +- >>> src/libcamera/software_isp/software_isp.cpp | 5 +- >>> 19 files changed, 286 insertions(+), 18 deletions(-) >>> create mode 100644 src/ipa/simple/algorithms/lsc.cpp >>> create mode 100644 src/ipa/simple/algorithms/lsc.h >>>
Robert Mader <robert.mader@collabora.com> writes: > Hi Milan, > > On 20.07.26 10:34, Milan Zamazal wrote: >> Robert Mader <robert.mader@collabora.com> writes: >> >>> Hi Milan, thanks for working on this! >>> >>> I just tried to apply the patches in order to play around with them - however it looks like they >>> haven't >>> yet rebased on top of 0.7.2 / doesn't apply to master. When you have time would you mind sending a >>> rebased >>> version? >> Hi Robert, >> >> the patches are on top of Jacopo's libipa patches (v5 currently), so I >> can rebase only there. > > ah, you mean when using his git branch instead of patchwork? Because applying the patch file (git am) of > that series (https://patchwork.libcamera.org/series/6048/mbox/) against master works fine - suggestion a > simle git rebase on master should also work. OK, they apply fine so I have no excuse not to update my part :-), done. > Either way, we can wait for a v6 and ask to rebase the branch. > > Thanks and best regards, > > Robert > > P.S.: would be pretty cool if b4 shazam would work with patchwork :P > >>> Best regards, >>> >>> Robert >>> >>> On 17.07.26 00:25, Milan Zamazal wrote: >>>> Lens shading correction for software GPU ISP. Based on the initial work >>>> by Hans’s students, taken over and significantly modified and eventually >>>> reworked to use LSC from libipa (the ongoing work by Jacopo and others). >>>> >>>> The LSC is not implemented for CPU ISP within this series; it may be >>>> added later if needed. >>>> >>>> It’s RFC because: >>>> >>>> - It’s not yet completely tested although it seems to be working in my >>>> environment. >>>> - It’s based on the libipa patches not yet merged. >>>> - Further changes will be needed once GPU ISP multipass is merged. >>>> >>>> Example YAML for grid based LSC, no-op values, place it after Awb: >>>> >>>> - Lsc: >>>> sets: >>>> - ct: 6500 >>>> r: [ >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 >>>> ] >>>> g: [ >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 >>>> ] >>>> b: [ >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, >>>> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 >>>> ] >>>> >>>> Example YAML for polynomial based LSC, no-op values, place it after Awb: >>>> >>>> - Lsc: >>>> type: "polynomial" >>>> sets: >>>> - ct: 6500 >>>> r: >>>> cx: 0.0 >>>> cy: 0.0 >>>> k0: 0.0 >>>> k1: 0.0 >>>> k2: 0.0 >>>> k3: 0.0 >>>> k4: 0.0 >>>> g: >>>> cx: 0.0 >>>> cy: 0.0 >>>> k0: 0.0 >>>> k1: 0.0 >>>> k2: 0.0 >>>> k3: 0.0 >>>> k4: 0.0 >>>> b: >>>> cx: 0.0 >>>> cy: 0.0 >>>> k0: 0.0 >>>> k1: 0.0 >>>> k2: 0.0 >>>> k3: 0.0 >>>> k4: 0.0 >>>> >>>> Changes in v8: >>>> - LscValueType removed. >>>> - A named constant introduced for minimum temperature change. >>>> - A clarification comment added to the LUT value computation. >>>> - lsc-enabled shader flag and the related variables removed. >>>> - Wording corrections suggested by Bryan. >>>> >>>> Changes in v7: >>>> - Updated for libipa patches v5 (temperature access). >>>> >>>> Changes in v6: >>>> - Rebased on Jacopo’s libipa patches (v3). >>>> - Not updating LSC tables on small or no temperature changes. >>>> - Using libipa LSC algorithms; the implementation in ‘simple’ IPA >>>> algorithm reduced to the minimum needed. >>>> - Grid tables are defined using integers rather than floats, because >>>> libipa LSC supports only quantised values and not floats. >>>> - New boolean uniform to enable or disable LSC dynamically, rather than >>>> only in shaders compile time; to be able to honour the LSC control. >>>> - Specific handling of polynomial LSC removed. Polynomial LSC is >>>> already handled by libipa, by making a grid-based LSC from it. While >>>> a direct polynomial computation may be a bit faster with a minimum >>>> number of the polynomial coefficients, the simplicity wins. If we >>>> liked to have direct polynomial LSC computation, it should be >>>> implemented with help of libipa. >>>> >>>> Changes in v5: >>>> - ‘grids’ tuning file item renamed to ‘sets’ for consistency with rkisp1. >>>> - Underscores appended to Lsc::lsc* names. >>>> - Other minor stylistic changes. >>>> - Proof-of-concept polynomial LSC implemented. >>>> >>>> Changes in v4: >>>> - glFilterParam -> param >>>> - Indentation changes in the shaders. >>>> - A commit message part about temperature reworded. >>>> - Updated for YamlObject -> ValueNode. >>>> - New constant kLscValuesPerCell to distinguish between the constants >>>> for the params array size (values) and for the stride (bytes). >>>> - The lookup array switched to floats and the texture to half-floats. >>>> >>>> Changes in v3: >>>> - LSC scripts patch dropped due to missing licences. >>>> - DO_LSC -> APPLY_LSC >>>> - textureUniformLsc_ is assigned unconditionally now. >>>> - New constant DebayerParams::kLscBytesPerCell. >>>> - LSC values in the tuning file are floats now and converted to bytes internally. >>>> - Source code comments added to clarify the usage of the byte LUTs. >>>> >>>> Changes in v2: >>>> - Remaining issues from the reviews (hopefully) addressed. >>>> - Especially there is only a single texture now and LSC is fully >>>> conditional. >>>> - Major cleanup, hacks removed or replaced, typo fixes, cosmetic >>>> changes, making linters happy, etc. >>>> - See >>>> https://lists.libcamera.org/pipermail/libcamera-devel/2026-January/056883.html >>>> for an example how to add the grid data. >>>> >>>> Milan Zamazal (1): >>>> libcamera: software_isp: Pass LSC availability to debayering >>>> >>>> Xander Pronk (5): >>>> libcamera: software_isp: egl: Add filter parameter to >>>> createTexture2D() >>>> libcamera: software_isp: Add LSC data to DebayerParams >>>> ipa: simple: Add LSC algorithm >>>> libcamera: shaders: Add LSC support >>>> libcamera: software_isp: debayer_egl: Add LSC support >>>> >>>> include/libcamera/internal/egl.h | 6 +- >>>> .../internal/software_isp/debayer_params.h | 9 ++ >>>> .../internal/software_isp/software_isp.h | 1 + >>>> include/libcamera/ipa/soft.mojom | 4 +- >>>> src/ipa/simple/algorithms/lsc.cpp | 100 ++++++++++++++++++ >>>> src/ipa/simple/algorithms/lsc.h | 50 +++++++++ >>>> src/ipa/simple/algorithms/meson.build | 1 + >>>> src/ipa/simple/ipa_context.h | 6 ++ >>>> src/ipa/simple/soft_simple.cpp | 7 +- >>>> src/libcamera/egl.cpp | 17 ++- >>>> src/libcamera/shaders/bayer_1x_packed.frag | 8 ++ >>>> src/libcamera/shaders/bayer_unpacked.frag | 8 ++ >>>> src/libcamera/software_isp/debayer.cpp | 29 +++++ >>>> src/libcamera/software_isp/debayer.h | 3 +- >>>> src/libcamera/software_isp/debayer_cpu.cpp | 3 +- >>>> src/libcamera/software_isp/debayer_cpu.h | 3 +- >>>> src/libcamera/software_isp/debayer_egl.cpp | 34 +++++- >>>> src/libcamera/software_isp/debayer_egl.h | 10 +- >>>> src/libcamera/software_isp/software_isp.cpp | 5 +- >>>> 19 files changed, 286 insertions(+), 18 deletions(-) >>>> create mode 100644 src/ipa/simple/algorithms/lsc.cpp >>>> create mode 100644 src/ipa/simple/algorithms/lsc.h >>>>
Lens shading correction for software GPU ISP. Based on the initial work by Hans’s students, taken over and significantly modified and eventually reworked to use LSC from libipa (the ongoing work by Jacopo and others). The LSC is not implemented for CPU ISP within this series; it may be added later if needed. It’s RFC because: - It’s not yet completely tested although it seems to be working in my environment. - It’s based on the libipa patches not yet merged. - Further changes will be needed once GPU ISP multipass is merged. Example YAML for grid based LSC, no-op values, place it after Awb: - Lsc: sets: - ct: 6500 r: [ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 ] g: [ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 ] b: [ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 ] Example YAML for polynomial based LSC, no-op values, place it after Awb: - Lsc: type: "polynomial" sets: - ct: 6500 r: cx: 0.0 cy: 0.0 k0: 0.0 k1: 0.0 k2: 0.0 k3: 0.0 k4: 0.0 g: cx: 0.0 cy: 0.0 k0: 0.0 k1: 0.0 k2: 0.0 k3: 0.0 k4: 0.0 b: cx: 0.0 cy: 0.0 k0: 0.0 k1: 0.0 k2: 0.0 k3: 0.0 k4: 0.0 Changes in v8: - LscValueType removed. - A named constant introduced for minimum temperature change. - A clarification comment added to the LUT value computation. - lsc-enabled shader flag and the related variables removed. - Wording corrections suggested by Bryan. Changes in v7: - Updated for libipa patches v5 (temperature access). Changes in v6: - Rebased on Jacopo’s libipa patches (v3). - Not updating LSC tables on small or no temperature changes. - Using libipa LSC algorithms; the implementation in ‘simple’ IPA algorithm reduced to the minimum needed. - Grid tables are defined using integers rather than floats, because libipa LSC supports only quantised values and not floats. - New boolean uniform to enable or disable LSC dynamically, rather than only in shaders compile time; to be able to honour the LSC control. - Specific handling of polynomial LSC removed. Polynomial LSC is already handled by libipa, by making a grid-based LSC from it. While a direct polynomial computation may be a bit faster with a minimum number of the polynomial coefficients, the simplicity wins. If we liked to have direct polynomial LSC computation, it should be implemented with help of libipa. Changes in v5: - ‘grids’ tuning file item renamed to ‘sets’ for consistency with rkisp1. - Underscores appended to Lsc::lsc* names. - Other minor stylistic changes. - Proof-of-concept polynomial LSC implemented. Changes in v4: - glFilterParam -> param - Indentation changes in the shaders. - A commit message part about temperature reworded. - Updated for YamlObject -> ValueNode. - New constant kLscValuesPerCell to distinguish between the constants for the params array size (values) and for the stride (bytes). - The lookup array switched to floats and the texture to half-floats. Changes in v3: - LSC scripts patch dropped due to missing licences. - DO_LSC -> APPLY_LSC - textureUniformLsc_ is assigned unconditionally now. - New constant DebayerParams::kLscBytesPerCell. - LSC values in the tuning file are floats now and converted to bytes internally. - Source code comments added to clarify the usage of the byte LUTs. Changes in v2: - Remaining issues from the reviews (hopefully) addressed. - Especially there is only a single texture now and LSC is fully conditional. - Major cleanup, hacks removed or replaced, typo fixes, cosmetic changes, making linters happy, etc. - See https://lists.libcamera.org/pipermail/libcamera-devel/2026-January/056883.html for an example how to add the grid data. Milan Zamazal (1): libcamera: software_isp: Pass LSC availability to debayering Xander Pronk (5): libcamera: software_isp: egl: Add filter parameter to createTexture2D() libcamera: software_isp: Add LSC data to DebayerParams ipa: simple: Add LSC algorithm libcamera: shaders: Add LSC support libcamera: software_isp: debayer_egl: Add LSC support include/libcamera/internal/egl.h | 6 +- .../internal/software_isp/debayer_params.h | 9 ++ .../internal/software_isp/software_isp.h | 1 + include/libcamera/ipa/soft.mojom | 4 +- src/ipa/simple/algorithms/lsc.cpp | 100 ++++++++++++++++++ src/ipa/simple/algorithms/lsc.h | 50 +++++++++ src/ipa/simple/algorithms/meson.build | 1 + src/ipa/simple/ipa_context.h | 6 ++ src/ipa/simple/soft_simple.cpp | 7 +- src/libcamera/egl.cpp | 17 ++- src/libcamera/shaders/bayer_1x_packed.frag | 8 ++ src/libcamera/shaders/bayer_unpacked.frag | 8 ++ src/libcamera/software_isp/debayer.cpp | 29 +++++ src/libcamera/software_isp/debayer.h | 3 +- src/libcamera/software_isp/debayer_cpu.cpp | 3 +- src/libcamera/software_isp/debayer_cpu.h | 3 +- src/libcamera/software_isp/debayer_egl.cpp | 34 +++++- src/libcamera/software_isp/debayer_egl.h | 10 +- src/libcamera/software_isp/software_isp.cpp | 5 +- 19 files changed, 286 insertions(+), 18 deletions(-) create mode 100644 src/ipa/simple/algorithms/lsc.cpp create mode 100644 src/ipa/simple/algorithms/lsc.h