From 4a9da08a991bcce19a54e73204631b08a610e48c Mon Sep 17 00:00:00 2001 From: stefan11111 Date: Thu, 29 Jan 2026 03:28:37 +0200 Subject: [PATCH] kdrive/fbdev: simplify `fbdev_glamor_egl_chose_configs` Now that we're first trying no-config contexts, there is no need to inject an `EGL_NO_CONFIG_KHR` as the first config in the returned list Signed-off-by: stefan11111 --- hw/kdrive/fbdev/fb_glamor.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/hw/kdrive/fbdev/fb_glamor.c b/hw/kdrive/fbdev/fb_glamor.c index d1daad3d05..259daa536c 100644 --- a/hw/kdrive/fbdev/fb_glamor.c +++ b/hw/kdrive/fbdev/fb_glamor.c @@ -435,26 +435,21 @@ fbdev_glamor_egl_chose_configs(EGLDisplay display, const EGLint *attrib_list, *configs = NULL; *num_configs = 0; - if (!eglChooseConfig(display, attrib_list, NULL, 0, &max_configs)) { + if (!eglChooseConfig(display, attrib_list, NULL, 0, &max_configs) || max_configs == 0) { return; } - *configs = calloc(max_configs + 1, sizeof(EGLConfig)); + *configs = calloc(max_configs, sizeof(EGLConfig)); if (*configs == NULL) { return; } - (*configs)[0] = EGL_NO_CONFIG_KHR; - - if (!eglChooseConfig(display, attrib_list, &(*configs)[1], max_configs, num_configs) || *num_configs == 0) { + if (!eglChooseConfig(display, attrib_list, *configs, max_configs, num_configs) || *num_configs == 0) { free(*configs); *configs = NULL; *num_configs = 0; } - (*num_configs)++; - max_configs++; - if (*num_configs < max_configs) { /* Shouldn't happen */ void *tmp = realloc(*configs, *num_configs * sizeof(EGLConfig)); @@ -499,7 +494,7 @@ fbdev_glamor_egl_try_big_gl_api(FbdevScrPriv *scrpriv) /* Try creating a no-config context, maybe we can skip all the config stuff */ scrpriv->ctx = fbdev_glamor_egl_create_context(scrpriv->display, - NULL, 1, + NULL, 0, ctx_attrib_lists, ARR_SIZE(ctx_attrib_lists)); if (scrpriv->ctx == EGL_NO_CONTEXT) { @@ -564,7 +559,7 @@ fbdev_glamor_egl_try_gles_api(FbdevScrPriv *scrpriv) /* Try creating a no-config context, maybe we can skip all the config stuff */ scrpriv->ctx = fbdev_glamor_egl_create_context(scrpriv->display, - NULL, 1, + NULL, 0, ctx_attrib_lists, ARR_SIZE(ctx_attrib_lists));