[Mesa-dev] [PATCH 1/5] egl: Provide meaningfull error when built w/o requested platform
Eric Engestrom
eric.engestrom at imgtec.com
Mon Nov 13 18:04:05 UTC 2017
On Monday, 2017-11-13 14:06:10 +0000, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov at collabora.com>
>
> The current "No EGL platform enabled." is misleading and wrong.
> We reach said code when $platform is missing.
>
> To make this more obvious and clear provide wrappers in the header
> file, making the code a bit easier to follow.
>
> Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
Thanks for the cleanup :)
Series is:
Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>
> ---
> src/egl/drivers/dri2/egl_dri2.c | 12 +-----------
> src/egl/drivers/dri2/egl_dri2.h | 40 ++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 41 insertions(+), 11 deletions(-)
>
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
> index 8861742c17f..af821425355 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -915,33 +915,23 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp)
> return EGL_FALSE;
>
> switch (disp->Platform) {
> -#ifdef HAVE_SURFACELESS_PLATFORM
> case _EGL_PLATFORM_SURFACELESS:
> ret = dri2_initialize_surfaceless(drv, disp);
> break;
> -#endif
> -#ifdef HAVE_X11_PLATFORM
> case _EGL_PLATFORM_X11:
> ret = dri2_initialize_x11(drv, disp);
> break;
> -#endif
> -#ifdef HAVE_DRM_PLATFORM
> case _EGL_PLATFORM_DRM:
> ret = dri2_initialize_drm(drv, disp);
> break;
> -#endif
> -#ifdef HAVE_WAYLAND_PLATFORM
> case _EGL_PLATFORM_WAYLAND:
> ret = dri2_initialize_wayland(drv, disp);
> break;
> -#endif
> -#ifdef HAVE_ANDROID_PLATFORM
> case _EGL_PLATFORM_ANDROID:
> ret = dri2_initialize_android(drv, disp);
> break;
> -#endif
> default:
> - _eglLog(_EGL_WARNING, "No EGL platform enabled.");
> + unreachable("Callers ensure we cannot get here.");
> return EGL_FALSE;
> }
>
> diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
> index 0ec8f44dce2..9cccf05253a 100644
> --- a/src/egl/drivers/dri2/egl_dri2.h
> +++ b/src/egl/drivers/dri2/egl_dri2.h
> @@ -400,20 +400,60 @@ _EGLImage *
> dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx,
> EGLClientBuffer buffer, const EGLint *attr_list);
>
> +#ifdef HAVE_X11_PLATFORM
> EGLBoolean
> dri2_initialize_x11(_EGLDriver *drv, _EGLDisplay *disp);
> +#else
> +static inline EGLBoolean
> +dri2_initialize_x11(_EGLDriver *drv, _EGLDisplay *disp)
> +{
> + return _eglError(EGL_NOT_INITIALIZED, "X11 platform not built");
> +}
> +#endif
>
> +#ifdef HAVE_DRM_PLATFORM
> EGLBoolean
> dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp);
> +#else
> +static inline EGLBoolean
> +dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
> +{
> + return _eglError(EGL_NOT_INITIALIZED, "GBM/DRM platform not built");
> +}
> +#endif
>
> +#ifdef HAVE_WAYLAND_PLATFORM
> EGLBoolean
> dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp);
> +#else
> +static inline EGLBoolean
> +dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp)
> +{
> + return _eglError(EGL_NOT_INITIALIZED, "Wayland platform not built");
> +}
> +#endif
>
> +#ifdef HAVE_ANDROID_PLATFORM
> EGLBoolean
> dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp);
> +#else
> +static inline EGLBoolean
> +dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp)
> +{
> + return _eglError(EGL_NOT_INITIALIZED, "Android platform not built");
> +}
> +#endif
>
> +#ifdef HAVE_SURFACELESS_PLATFORM
> EGLBoolean
> dri2_initialize_surfaceless(_EGLDriver *drv, _EGLDisplay *disp);
> +#else
> +static inline EGLBoolean
> +dri2_initialize_surfaceless(_EGLDriver *drv, _EGLDisplay *disp)
> +{
> + return _eglError(EGL_NOT_INITIALIZED, "Surfaceless platform not built");
> +}
> +#endif
>
> void
> dri2_flush_drawable_for_swapbuffers(_EGLDisplay *disp, _EGLSurface *draw);
> --
> 2.15.0
>
More information about the mesa-dev
mailing list