[v9,16/26] libcamera: software_isp: GPU support for unpacked 10/12-bit formats
diff mbox series

Message ID 20251217100138.82525-17-bryan.odonoghue@linaro.org
State New
Headers show
Series
  • Add GLES 2.0 GPUISP to libcamera
Related show

Commit Message

Bryan O'Donoghue Dec. 17, 2025, 10:01 a.m. UTC
From: Milan Zamazal <mzamazal@redhat.com>

The GPU processing supports 8-bit sensor formats and 10/12-bit packed
formats.  Support for 10/12-bit unpacked formats is missing, let's add
it.

10/12-bit unpacked formats use two adjacent bytes to store the value.
This means the 8-bit shaders can be used if we can modify them for
additional support of 16-bit addressing.  This requires the following
modifications:

- Using GL_RG (two bytes per pixel) instead of GL_LUMINANCE (one byte
  per pixel) as the texture format for the given input formats.

- Setting the texture width to the number of pixels rather than the
  number of bytes.

- Making the definition of `fetch' macro variable, according to the
  pixel format.

- Using only `fetch' for accessing the texture.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 src/libcamera/shaders/bayer_unpacked.frag | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Hans de Goede Dec. 17, 2025, 10:55 a.m. UTC | #1
Hi,

On 17-Dec-25 11:01, Bryan O'Donoghue wrote:
> From: Milan Zamazal <mzamazal@redhat.com>
> 
> The GPU processing supports 8-bit sensor formats and 10/12-bit packed
> formats.  Support for 10/12-bit unpacked formats is missing, let's add
> it.
> 
> 10/12-bit unpacked formats use two adjacent bytes to store the value.
> This means the 8-bit shaders can be used if we can modify them for
> additional support of 16-bit addressing.  This requires the following
> modifications:
> 
> - Using GL_RG (two bytes per pixel) instead of GL_LUMINANCE (one byte
>   per pixel) as the texture format for the given input formats.
> 
> - Setting the texture width to the number of pixels rather than the
>   number of bytes.
> 
> - Making the definition of `fetch' macro variable, according to the
>   pixel format.
> 
> - Using only `fetch' for accessing the texture.
> 
> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>

Regards,

Hans



> ---
>  src/libcamera/shaders/bayer_unpacked.frag | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/shaders/bayer_unpacked.frag b/src/libcamera/shaders/bayer_unpacked.frag
> index 114e32058..477e8bbf6 100644
> --- a/src/libcamera/shaders/bayer_unpacked.frag
> +++ b/src/libcamera/shaders/bayer_unpacked.frag
> @@ -41,9 +41,17 @@ float apply_contrast(float value, float contrastExp)
>  void main(void) {
>      vec3 rgb;
>  
> +    #if defined(RAW10P)
> +    #define pixel(p) p.r / 4.0 + p.g * 64.0
> +    #define fetch(x, y) pixel(texture2D(tex_y, vec2(x, y)))
> +    #elif defined(RAW12P)
> +    #define pixel(p) p.r / 16.0 + p.g * 16.0
> +    #define fetch(x, y) pixel(texture2D(tex_y, vec2(x, y)))
> +    #else
>      #define fetch(x, y) texture2D(tex_y, vec2(x, y)).r
> +    #endif
>  
> -    float C = texture2D(tex_y, center.xy).r; // ( 0, 0)
> +    float C = fetch(center.x, center.y); // ( 0, 0)
>      const vec4 kC = vec4( 4.0,  6.0,  5.0,  5.0) / 8.0;
>  
>      // Determine which of four types of pixels we are on.

Patch
diff mbox series

diff --git a/src/libcamera/shaders/bayer_unpacked.frag b/src/libcamera/shaders/bayer_unpacked.frag
index 114e32058..477e8bbf6 100644
--- a/src/libcamera/shaders/bayer_unpacked.frag
+++ b/src/libcamera/shaders/bayer_unpacked.frag
@@ -41,9 +41,17 @@  float apply_contrast(float value, float contrastExp)
 void main(void) {
     vec3 rgb;
 
+    #if defined(RAW10P)
+    #define pixel(p) p.r / 4.0 + p.g * 64.0
+    #define fetch(x, y) pixel(texture2D(tex_y, vec2(x, y)))
+    #elif defined(RAW12P)
+    #define pixel(p) p.r / 16.0 + p.g * 16.0
+    #define fetch(x, y) pixel(texture2D(tex_y, vec2(x, y)))
+    #else
     #define fetch(x, y) texture2D(tex_y, vec2(x, y)).r
+    #endif
 
-    float C = texture2D(tex_y, center.xy).r; // ( 0, 0)
+    float C = fetch(center.x, center.y); // ( 0, 0)
     const vec4 kC = vec4( 4.0,  6.0,  5.0,  5.0) / 8.0;
 
     // Determine which of four types of pixels we are on.