[libcamera-devel,v2,2/2] qcam: assets: shader: bayer_8.vert: Add precision
diff mbox series

Message ID 20220628191355.78408-1-kunalagarwal1072002@gmail.com
State New
Headers show
Series
  • [libcamera-devel,v2,1/2] qcam: assets: shader: bayer_8.frag: Add precision
Related show

Commit Message

Kunal Agarwal June 28, 2022, 7:13 p.m. UTC
Currently there is no defined precision for data types
which results in compilation errors for shader.

Adding precision mediump for sufficient and required
range and accuracy. Also suitable for textures.
Precision highp also works but is not supported by some
older hardware devices and consumes more memory.

Signed-off-by: Kunal Agarwal <kunalagarwal1072002@gmail.com>
---
 src/qcam/assets/shader/bayer_8.vert | 3 +++
 1 file changed, 3 insertions(+)

Comments

Laurent Pinchart July 21, 2022, 8:15 p.m. UTC | #1
Hi Kunal,

Thank you for the patch.

On Wed, Jun 29, 2022 at 12:43:55AM +0530, Kunal Agarwal via libcamera-devel wrote:
> Currently there is no defined precision for data types
> which results in compilation errors for shader.
> 
> Adding precision mediump for sufficient and required
> range and accuracy. Also suitable for textures.
> Precision highp also works but is not supported by some
> older hardware devices and consumes more memory.

The OpenGL ES Shading Language specification states, in section "4.5.3
Default Precision Qualifiers",

  The vertex language has the following predeclared globally scoped
  default precision statements:

  precision highp float;
  precision highp int;
  precision lowp sampler2D;
  precision lowp samplerCube;

Do you get any shader compilation error without this patch ? If so, on
which platform ? If not, do you need to reduce the precision for floats
to mediump, or is the default highp fine ?

> Signed-off-by: Kunal Agarwal <kunalagarwal1072002@gmail.com>
> ---
>  src/qcam/assets/shader/bayer_8.vert | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/src/qcam/assets/shader/bayer_8.vert b/src/qcam/assets/shader/bayer_8.vert
> index 3695a5e9..a250bb81 100644
> --- a/src/qcam/assets/shader/bayer_8.vert
> +++ b/src/qcam/assets/shader/bayer_8.vert
> @@ -15,6 +15,9 @@ Copyright (C) 2021, Linaro
>  */
>  
>  //Vertex Shader
> +#ifdef GL_ES
> +precision mediump float;
> +#endif
>  
>  attribute vec4 vertexIn;
>  attribute vec2 textureIn;
Kunal Agarwal July 22, 2022, 7:30 a.m. UTC | #2
Hi Laurent,

Thank you for the pointers.

> The OpenGL ES Shading Language specification states, in section "4.5.3
> Default Precision Qualifiers",
>
>   The vertex language has the following predeclared globally scoped
>   default precision statements:
>
>   precision highp float;
>   precision highp int;
>   precision lowp sampler2D;
>   precision lowp samplerCube;
>
> Do you get any shader compilation error without this patch ? If so, on
> which platform ? If not, do you need to reduce the precision for floats
> to mediump, or is the default highp fine ?

Tested the working of vertex shader without explicitly specifying precision.
It works. Other than the limitations of highp for some devices, I don't see
any particular reason to reduce the precision of floats to mediump.
So default highp should be fine and this patch need not be applied.

Regards,

Kunal Agarwal


On Fri, Jul 22, 2022 at 1:45 AM Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> Hi Kunal,
>
> Thank you for the patch.
>
> On Wed, Jun 29, 2022 at 12:43:55AM +0530, Kunal Agarwal via libcamera-devel wrote:
> > Currently there is no defined precision for data types
> > which results in compilation errors for shader.
> >
> > Adding precision mediump for sufficient and required
> > range and accuracy. Also suitable for textures.
> > Precision highp also works but is not supported by some
> > older hardware devices and consumes more memory.
>
> The OpenGL ES Shading Language specification states, in section "4.5.3
> Default Precision Qualifiers",
>
>   The vertex language has the following predeclared globally scoped
>   default precision statements:
>
>   precision highp float;
>   precision highp int;
>   precision lowp sampler2D;
>   precision lowp samplerCube;
>
> Do you get any shader compilation error without this patch ? If so, on
> which platform ? If not, do you need to reduce the precision for floats
> to mediump, or is the default highp fine ?
>
> > Signed-off-by: Kunal Agarwal <kunalagarwal1072002@gmail.com>
> > ---
> >  src/qcam/assets/shader/bayer_8.vert | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/src/qcam/assets/shader/bayer_8.vert b/src/qcam/assets/shader/bayer_8.vert
> > index 3695a5e9..a250bb81 100644
> > --- a/src/qcam/assets/shader/bayer_8.vert
> > +++ b/src/qcam/assets/shader/bayer_8.vert
> > @@ -15,6 +15,9 @@ Copyright (C) 2021, Linaro
> >  */
> >
> >  //Vertex Shader
> > +#ifdef GL_ES
> > +precision mediump float;
> > +#endif
> >
> >  attribute vec4 vertexIn;
> >  attribute vec2 textureIn;
>
> --
> Regards,
>
> Laurent Pinchart

Patch
diff mbox series

diff --git a/src/qcam/assets/shader/bayer_8.vert b/src/qcam/assets/shader/bayer_8.vert
index 3695a5e9..a250bb81 100644
--- a/src/qcam/assets/shader/bayer_8.vert
+++ b/src/qcam/assets/shader/bayer_8.vert
@@ -15,6 +15,9 @@  Copyright (C) 2021, Linaro
 */
 
 //Vertex Shader
+#ifdef GL_ES
+precision mediump float;
+#endif
 
 attribute vec4 vertexIn;
 attribute vec2 textureIn;