[3/3] libcamera: egl: Fix eGLImage() constructor stride calculation
diff mbox series

Message ID 20251122205507.37387-4-johannes.goede@oss.qualcomm.com
State New
Headers show
Series
  • GPUISP fixes
Related show

Commit Message

Hans de Goede Nov. 22, 2025, 8:55 p.m. UTC
The mimimum stride is width * bpp / 8 not width * bpp.

Correct this to fix setting the stride to a value which is
8 times too large.

Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
---
This can be squashed into "libcamera: software_isp: egl: Add a eGL base
helper class"
---
 include/libcamera/internal/egl.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Milan Zamazal Nov. 24, 2025, 2:37 p.m. UTC | #1
Hi Hans,

thank you for the fix.

Hans de Goede <johannes.goede@oss.qualcomm.com> writes:

> The mimimum stride is width * bpp / 8 not width * bpp.
>
> Correct this to fix setting the stride to a value which is
> 8 times too large.
>
> Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>

Reviewed-by: Milan Zamazal <mzamazal@redhat.com>

> ---
> This can be squashed into "libcamera: software_isp: egl: Add a eGL base
> helper class"
> ---
>  include/libcamera/internal/egl.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h
> index e61a394a..5b7cb248 100644
> --- a/include/libcamera/internal/egl.h
> +++ b/include/libcamera/internal/egl.h
> @@ -75,7 +75,7 @@ public:
>  	 */
>  	eGLImage(uint32_t width, uint32_t height, uint32_t bpp, GLenum texture_unit, uint32_t texture_unit_uniform_id)
>  	{
> -		uint32_t stride = libcamera::utils::alignUp(width * bpp, 256);
> +		uint32_t stride = libcamera::utils::alignUp(width * bpp / 8, 256);
>  
>  		init(width, height, bpp, stride, texture_unit, texture_unit_uniform_id);
>  	}
Nicolas Dufresne Nov. 24, 2025, 2:48 p.m. UTC | #2
Le lundi 24 novembre 2025 à 15:37 +0100, Milan Zamazal a écrit :
> Hi Hans,
> 
> thank you for the fix.
> 
> Hans de Goede <johannes.goede@oss.qualcomm.com> writes:
> 
> > The mimimum stride is width * bpp / 8 not width * bpp.
> > 
> > Correct this to fix setting the stride to a value which is
> > 8 times too large.
> > 
> > Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
> 
> Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
> 
> > ---
> > This can be squashed into "libcamera: software_isp: egl: Add a eGL base
> > helper class"
> > ---
> >  include/libcamera/internal/egl.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/include/libcamera/internal/egl.h
> > b/include/libcamera/internal/egl.h
> > index e61a394a..5b7cb248 100644
> > --- a/include/libcamera/internal/egl.h
> > +++ b/include/libcamera/internal/egl.h
> > @@ -75,7 +75,7 @@ public:
> >  	 */
> >  	eGLImage(uint32_t width, uint32_t height, uint32_t bpp, GLenum
> > texture_unit, uint32_t texture_unit_uniform_id)
> >  	{
> > -		uint32_t stride = libcamera::utils::alignUp(width * bpp,
> > 256);
> > +		uint32_t stride = libcamera::utils::alignUp(width * bpp /
> > 8, 256);

Perhaps add comment that this is only valid for bpp being multiple of 8 and for
packed format ?

Nicolas

> >  
> >  		init(width, height, bpp, stride, texture_unit,
> > texture_unit_uniform_id);
> >  	}

Patch
diff mbox series

diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h
index e61a394a..5b7cb248 100644
--- a/include/libcamera/internal/egl.h
+++ b/include/libcamera/internal/egl.h
@@ -75,7 +75,7 @@  public:
 	 */
 	eGLImage(uint32_t width, uint32_t height, uint32_t bpp, GLenum texture_unit, uint32_t texture_unit_uniform_id)
 	{
-		uint32_t stride = libcamera::utils::alignUp(width * bpp, 256);
+		uint32_t stride = libcamera::utils::alignUp(width * bpp / 8, 256);
 
 		init(width, height, bpp, stride, texture_unit, texture_unit_uniform_id);
 	}