[PATCH weston v2 1/2] gl-renderer: Take a list of acceptable formats in create functions
Pekka Paalanen
ppaalanen at gmail.com
Mon May 18 01:59:29 PDT 2015
On Fri, 15 May 2015 12:12:39 -0500
Derek Foreman <derekf at osg.samsung.com> wrote:
> Currently we pass either a single format or no formats to the gl renderer
> create and output_create functions. We extend this to any number of
> formats so we can allow fallback formats if we don't get our first pick.
>
> Reviewed-By: Bryce Harrington <bryce at osg.samsung.com>
> Reviewed-By: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
> Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
> ---
> src/compositor-drm.c | 5 ++--
> src/compositor-fbdev.c | 4 +--
> src/compositor-wayland.c | 12 ++++----
> src/compositor-x11.c | 5 ++--
> src/gl-renderer.c | 71 ++++++++++++++++++++++++++++++++----------------
> src/gl-renderer.h | 6 ++--
> 6 files changed, 66 insertions(+), 37 deletions(-)
>
> diff --git a/src/gl-renderer.c b/src/gl-renderer.c
> index ae3122f..248c8aa 100644
> --- a/src/gl-renderer.c
> +++ b/src/gl-renderer.c
> @@ -1898,14 +1898,38 @@ log_egl_config_info(EGLDisplay egldpy, EGLConfig eglconfig)
> }
>
> static int
> +match_config_to_visual(EGLDisplay egl_display,
> + EGLint visual_id,
> + EGLConfig *configs,
> + int count)
> +{
> + int i;
> +
> + for (i = 0; i < count; ++i) {
> + EGLint id;
> +
> + if (!eglGetConfigAttrib(egl_display,
> + configs[i], EGL_NATIVE_VISUAL_ID,
> + &id))
> + continue;
> +
> + if (id == visual_id)
> + return i;
> + }
> +
> + weston_log("Unable to find an appropriate EGL config.\n");
You are calling this function in a loop until it does not return -1 or
all formats are through, so the error message doesn't really fit.
Something like "Visual 0xblahblah not matched with an EGLConfig" might
be better.
> + return -1;
> +}
> +
> +static int
> egl_choose_config(struct gl_renderer *gr, const EGLint *attribs,
> - const EGLint *visual_id,
> + const EGLint *visual_id, const int n_ids,
> EGLConfig *config_out)
> {
> EGLint count = 0;
> EGLint matched = 0;
> EGLConfig *configs;
> - int i;
> + int i, config_index = -1;
>
> if (!eglGetConfigs(gr->egl_display, NULL, 0, &count) || count < 1)
> return -1;
> @@ -1915,31 +1939,27 @@ egl_choose_config(struct gl_renderer *gr, const EGLint *attribs,
> return -1;
>
> if (!eglChooseConfig(gr->egl_display, attribs, configs,
> - count, &matched))
> + count, &matched) || !matched)
> goto out;
>
> - for (i = 0; i < matched; ++i) {
> - EGLint id;
> + if (!visual_id)
> + config_index = 0;
>
> - if (visual_id) {
> - if (!eglGetConfigAttrib(gr->egl_display,
> - configs[i], EGL_NATIVE_VISUAL_ID,
> - &id))
> - continue;
> + for (i = 0; config_index == -1 && i < n_ids; i++)
> + config_index = match_config_to_visual(gr->egl_display,
> + visual_id[i],
> + configs,
> + matched);
>
> - if (id != 0 && id != *visual_id)
> - continue;
> - }
> -
> - *config_out = configs[i];
> -
> - free(configs);
> - return 0;
> - }
> + if (config_index != -1)
> + *config_out = configs[config_index];
>
> out:
> free(configs);
> - return -1;
> + if (config_index == -1)
The error message you wrote would be more at home here, but it seems
all the callers already report it.
> + return -1;
> +
> + return 0;
> }
You can fix the error message in a follow-up, so that I can push these
now. I think these two patches are proper for post RC1 as
reasonable bug fixes.
Pushed.
b33877a..c4cfe85 master -> master
Might also want to fix the error message that says
[08:53:48.703] failed to choose EGL config
[08:53:48.703] EGL error state: EGL_SUCCESS (0x3000)
[08:53:48.705] failed to initialize egl
to be less confusing. ;-)
Thanks,
pq
More information about the wayland-devel
mailing list