[v2,2/6] libcamera: egl: Ensure required extensions are supported
diff mbox series

Message ID 20261204031914.117401-3-me@coolgi.dev
State New
Headers show
Series
  • dd GPU benchmarking to SoftISP eGL
Related show

Commit Message

Remy Alipoursafari Dec. 4, 2026, 3:18 a.m. UTC
From: Remy Alipoursafari <remy.alipoursafari@collabora.com>

Ensures that the EGL context supports EGL_EXT_image_dma_buf_import, and
the OpenGL ES context supports GL_OES_EGL_image.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Signed-off-by: Remy Alipoursafari <remy.alipoursafari@collabora.com>
Reviewed-by: Robert Mader <robert.mader@collabora.com>
---
 src/libcamera/egl.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Bryan O'Donoghue Dec. 5, 2026, 12:54 a.m. UTC | #1
On 04/12/2026 03:18, Remy Alipoursafari wrote:
> From: Remy Alipoursafari <remy.alipoursafari@collabora.com>
> 
> Ensures that the EGL context supports EGL_EXT_image_dma_buf_import, and
> the OpenGL ES context supports GL_OES_EGL_image.
> 
> Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
> Signed-off-by: Remy Alipoursafari <remy.alipoursafari@collabora.com>
> Reviewed-by: Robert Mader <robert.mader@collabora.com>
> ---
>   src/libcamera/egl.cpp | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
> 
> diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp
> index 70f293b7..1a0b6c37 100644
> --- a/src/libcamera/egl.cpp
> +++ b/src/libcamera/egl.cpp
> @@ -467,6 +467,18 @@ int eGL::initEGLContext()
>   		return -ENODEV;
>   	}
> 
> +#define CHECK_EXTENSION(name, func) ({                       \
> +	if (!func(name)) {                                   \
> +		LOG(eGL, Error) << name << " not supported"; \
> +		return -ENODEV;                              \
> +	}                                                    \
> +})
> +#define CHECK_EGL_EXTENSION(name) CHECK_EXTENSION(name, hasEGLExtension);
> +#define CHECK_GLES_EXTENSION(name) CHECK_EXTENSION(name, hasGLESExtension);
> +
> +	CHECK_EGL_EXTENSION("EGL_EXT_image_dma_buf_import");
> +	CHECK_GLES_EXTENSION("GL_OES_EGL_image");
> +
>   	contextGuard.release();
> 
>   	return 0;
> --
> 2.56.1
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

Patch
diff mbox series

diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp
index 70f293b7..1a0b6c37 100644
--- a/src/libcamera/egl.cpp
+++ b/src/libcamera/egl.cpp
@@ -467,6 +467,18 @@  int eGL::initEGLContext()
 		return -ENODEV;
 	}
 
+#define CHECK_EXTENSION(name, func) ({                       \
+	if (!func(name)) {                                   \
+		LOG(eGL, Error) << name << " not supported"; \
+		return -ENODEV;                              \
+	}                                                    \
+})
+#define CHECK_EGL_EXTENSION(name) CHECK_EXTENSION(name, hasEGLExtension);
+#define CHECK_GLES_EXTENSION(name) CHECK_EXTENSION(name, hasGLESExtension);
+
+	CHECK_EGL_EXTENSION("EGL_EXT_image_dma_buf_import");
+	CHECK_GLES_EXTENSION("GL_OES_EGL_image");
+
 	contextGuard.release();
 
 	return 0;