[v2,0/4] software-isp: Align GPU cropping and statistics
mbox series

Message ID 20261015223604.311616-1-halfline@gmail.com
Headers show
Series
  • software-isp: Align GPU cropping and statistics
Related show

Message

Ray Strode Oct. 15, 2026, 10:36 p.m. UTC
Hi all,

This series fixes crop positioning and statistics alignment in the EGL
software ISP when producing frames at different output sizes and aspect
ratios.

The GPU projection currently positions the cropped image off-center in
the output, shifting the visible scene. CPU statistics operate on the
full sensor buffer using a window derived from the output dimensions,
so metering can cover a different region from the one displayed.

Patches 1 and 2 center the GPU crop and test the projection by mapping
expected sensor crop corners and the sensor center to output coordinates.
Patches 3 and 4 align statistics with the visible sensor region and test
the selected crop rectangles across output sizes and aspect ratios,
including integer rounding before Bayer alignment.

Changes in v2:
- Replace the rendering and statistics integration tests with direct
  geometry unit tests, following Laurent's feedback. The tests require
  neither a graphics context nor sensor buffers.
- Use the standard three lines of diff context.

Thanks,
Ray

Ray Strode (4):
  software-isp: Center the GPU image crop
  tests: Validate debayer projection geometry
  software-isp: Meter the visible sensor crop
  tests: Validate the visible sensor crop

 .../internal/software_isp/debayer_geometry.h  |  49 +++++++
 .../internal/software_isp/meson.build         |   1 +
 src/libcamera/software_isp/debayer_egl.cpp    |  34 ++---
 src/libcamera/software_isp/debayer_egl.h      |   1 -
 test/debayer-geometry.cpp                     | 129 ++++++++++++++++++
 test/meson.build                              |   1 +
 6 files changed, 188 insertions(+), 27 deletions(-)
 create mode 100644 include/libcamera/internal/software_isp/debayer_geometry.h
 create mode 100644 test/debayer-geometry.cpp

Comments

Kieran Bingham Oct. 16, 2026, 10:36 a.m. UTC | #1
Quoting Ray Strode (2026-10-15 23:36:00)
> Hi all,
> 
> This series fixes crop positioning and statistics alignment in the EGL
> software ISP when producing frames at different output sizes and aspect
> ratios.
> 
> The GPU projection currently positions the cropped image off-center in
> the output, shifting the visible scene. CPU statistics operate on the
> full sensor buffer using a window derived from the output dimensions,
> so metering can cover a different region from the one displayed.
> 
> Patches 1 and 2 center the GPU crop and test the projection by mapping
> expected sensor crop corners and the sensor center to output coordinates.
> Patches 3 and 4 align statistics with the visible sensor region and test
> the selected crop rectangles across output sizes and aspect ratios,
> including integer rounding before Bayer alignment.
> 
> Changes in v2:
> - Replace the rendering and statistics integration tests with direct
>   geometry unit tests, following Laurent's feedback. The tests require
>   neither a graphics context nor sensor buffers.
> - Use the standard three lines of diff context.

I'm not sure if it's a yak or not in here, but I see modifications to
the ROI for the stats, and also that this is impacting which pixels are
actually being given to the application.

Could you try to incorporate and report the actual ScalerCrop metadata
please?

 - https://patchwork.libcamera.org/project/libcamera/list/?series=5919

might be a starting point here.

That could optionally lead to implementing the control so that we can
parse ScalerCrop to set different parameters into the shader here, but
we should definitely be reporting what is actually set regardless.

--
Kieran


> 
> Thanks,
> Ray
> 
> Ray Strode (4):
>   software-isp: Center the GPU image crop
>   tests: Validate debayer projection geometry
>   software-isp: Meter the visible sensor crop
>   tests: Validate the visible sensor crop
> 
>  .../internal/software_isp/debayer_geometry.h  |  49 +++++++
>  .../internal/software_isp/meson.build         |   1 +
>  src/libcamera/software_isp/debayer_egl.cpp    |  34 ++---
>  src/libcamera/software_isp/debayer_egl.h      |   1 -
>  test/debayer-geometry.cpp                     | 129 ++++++++++++++++++
>  test/meson.build                              |   1 +
>  6 files changed, 188 insertions(+), 27 deletions(-)
>  create mode 100644 include/libcamera/internal/software_isp/debayer_geometry.h
>  create mode 100644 test/debayer-geometry.cpp
> 
> -- 
> 2.56.0
>
Ray Strode Oct. 16, 2026, 8:30 p.m. UTC | #2
Hi Kieran,

v3 now reports the configured CPU/EGL image region through
ScalerCropMaximum and completed-request ScalerCrop, building on your
patches:

https://patchwork.libcamera.org/project/libcamera/list/?series=6258

Reporting is limited to capture paths that preserve the sensor output;
intermediate cropping or scaling needs an additional mapping.

Thanks,
Ray