[25/35] libcamera: shaders: Use highp not mediump for float precision
diff mbox series

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

Commit Message

Bryan O'Donoghue June 11, 2025, 1:32 a.m. UTC
We get better sample resolution with highp instead of mediump.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 include/libcamera/internal/shaders/RGB.frag             | 2 +-
 include/libcamera/internal/shaders/YUV_2_planes.frag    | 2 +-
 include/libcamera/internal/shaders/YUV_3_planes.frag    | 2 +-
 include/libcamera/internal/shaders/YUV_packed.frag      | 2 +-
 include/libcamera/internal/shaders/bayer_1x_packed.frag | 2 +-
 include/libcamera/internal/shaders/bayer_8.frag         | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

Comments

Bryan O'Donoghue June 16, 2025, 7:19 p.m. UTC | #1
On 11/06/2025 02:32, Bryan O'Donoghue wrote:
> We get better sample resolution with highp instead of mediump.
> 
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> ---

With the fixes we have implemented, I wonder if this patch is really 
necessary also how to really verify its effect.

Keep for now but definitely at least note in the TODO. With the shaders 
broken it was obvious higher precision floats produced better output.

With the shaders now not broken, no artifacts etc, its very difficult to 
tell the difference with the eye between mediump and highp.

At this stage I don't think this patch does any harm, may improve output 
but if I saw two images side-by-side I would not be able to discern the 
difference.

---
bod
Milan Zamazal June 18, 2025, 8:27 a.m. UTC | #2
Bryan O'Donoghue <bryan.odonoghue@linaro.org> writes:

> On 11/06/2025 02:32, Bryan O'Donoghue wrote:
>> We get better sample resolution with highp instead of mediump.
>> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
>> ---
>
> With the fixes we have implemented, I wonder if this patch is really necessary also how to really verify its
> effect.
>
> Keep for now but definitely at least note in the TODO. With the shaders broken it was obvious higher precision
> floats produced better output.
>
> With the shaders now not broken, no artifacts etc, its very difficult to tell the difference with the eye between
> mediump and highp.

I can't see any artefacts here with unpacked or with 8-bit when using
mediump.

Is there any impact on performance expected?  I may observe some
performance penalty (~3%) when using 8-bit with highp but I'm not sure.

> At this stage I don't think this patch does any harm, may improve output but if I saw two images side-by-side I
> would not be able to discern the difference.
>
> ---
> bod
Bryan O'Donoghue June 18, 2025, 8:30 a.m. UTC | #3
On 18/06/2025 09:27, Milan Zamazal wrote:
>> With the shaders now not broken, no artifacts etc, its very difficult to tell the difference with the eye between
>> mediump and highp.
> I can't see any artefacts here with unpacked or with 8-bit when using
> mediump.
> 
> Is there any impact on performance expected?  I may observe some
> performance penalty (~3%) when using 8-bit with highp but I'm not sure.

I thought the highp/mediump thing was more mediated by some hardware not 
supporting highp.

TBH I think this can be dropped.

---
bod

Patch
diff mbox series

diff --git a/include/libcamera/internal/shaders/RGB.frag b/include/libcamera/internal/shaders/RGB.frag
index 4c374ac9..72439589 100644
--- a/include/libcamera/internal/shaders/RGB.frag
+++ b/include/libcamera/internal/shaders/RGB.frag
@@ -6,7 +6,7 @@ 
  */
 
 #ifdef GL_ES
-precision mediump float;
+precision highp float;
 #endif
 
 varying vec2 textureOut;
diff --git a/include/libcamera/internal/shaders/YUV_2_planes.frag b/include/libcamera/internal/shaders/YUV_2_planes.frag
index 1d5d1206..d286f117 100644
--- a/include/libcamera/internal/shaders/YUV_2_planes.frag
+++ b/include/libcamera/internal/shaders/YUV_2_planes.frag
@@ -6,7 +6,7 @@ 
  */
 
 #ifdef GL_ES
-precision mediump float;
+precision highp float;
 #endif
 
 varying vec2 textureOut;
diff --git a/include/libcamera/internal/shaders/YUV_3_planes.frag b/include/libcamera/internal/shaders/YUV_3_planes.frag
index 8f788e90..8e3e0b4a 100644
--- a/include/libcamera/internal/shaders/YUV_3_planes.frag
+++ b/include/libcamera/internal/shaders/YUV_3_planes.frag
@@ -6,7 +6,7 @@ 
  */
 
 #ifdef GL_ES
-precision mediump float;
+precision highp float;
 #endif
 
 varying vec2 textureOut;
diff --git a/include/libcamera/internal/shaders/YUV_packed.frag b/include/libcamera/internal/shaders/YUV_packed.frag
index b9ef9d41..3c9e3e39 100644
--- a/include/libcamera/internal/shaders/YUV_packed.frag
+++ b/include/libcamera/internal/shaders/YUV_packed.frag
@@ -6,7 +6,7 @@ 
  */
 
 #ifdef GL_ES
-precision mediump float;
+precision highp float;
 #endif
 
 varying vec2 textureOut;
diff --git a/include/libcamera/internal/shaders/bayer_1x_packed.frag b/include/libcamera/internal/shaders/bayer_1x_packed.frag
index f53f5575..19b13ad0 100644
--- a/include/libcamera/internal/shaders/bayer_1x_packed.frag
+++ b/include/libcamera/internal/shaders/bayer_1x_packed.frag
@@ -20,7 +20,7 @@ 
  */
 
 #ifdef GL_ES
-precision mediump float;
+precision highp float;
 #endif
 
 /*
diff --git a/include/libcamera/internal/shaders/bayer_8.frag b/include/libcamera/internal/shaders/bayer_8.frag
index 7e35ca88..aa7a1b00 100644
--- a/include/libcamera/internal/shaders/bayer_8.frag
+++ b/include/libcamera/internal/shaders/bayer_8.frag
@@ -16,7 +16,7 @@  Copyright (C) 2021, Linaro
 
 //Pixel Shader
 #ifdef GL_ES
-precision mediump float;
+precision highp float;
 #endif
 
 /** Monochrome RGBA or GL_LUMINANCE Bayer encoded texture.*/