package/mesa3d: fix glxinfo crash when gles1 is disabled

mesa3d 23.1 introduced a regression crashing glxinfo (and some piglit tests)
when gles1 is disabled.
See: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9038

Fixes:
https://gitlab.com/buildroot.org/buildroot/-/jobs/4287983490

Signed-off-by: Romain Naour <romain.naour@gmail.com>
Cc: Bernd Kuhls <bernd.kuhls@t-online.de>
[yann.morin.1998@free.fr: fix Upstream tag as noticed by Baruch]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
This commit is contained in:
Romain Naour 2023-05-18 23:30:53 +02:00 committed by Yann E. MORIN
parent 4944ff2878
commit 62b64c56b8

View File

@ -0,0 +1,50 @@
From 2a6908ff4c94284b39c3cd4c97e1069876720eb7 Mon Sep 17 00:00:00 2001
From: Jordan Justen <jordan.l.justen@intel.com>
Date: Tue, 16 May 2023 18:46:50 -0700
Subject: [PATCH] mesa/main: Exit early when trying to create an unsupported
context API
Fixes: adbe8b6c17a ("mesa: optimize out _mesa_is_desktop_gl*() and _mesa_is_gles*() calls when not built")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9038
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23068>
Upstream: https://gitlab.freedesktop.org/mesa/mesa/-/commit/8bb1ecaa02177720758255bdd7ec34a5d15feca4
[Romain: backport to 23.1]
Signed-off-by: Romain Naour <romain.naour@gmail.com>
---
src/mesa/main/context.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index d8eea2ea867..2b810b0d863 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -996,6 +996,24 @@ _mesa_initialize_context(struct gl_context *ctx,
struct gl_shared_state *shared;
int i;
+ switch (api) {
+ case API_OPENGL_COMPAT:
+ case API_OPENGL_CORE:
+ if (!HAVE_OPENGL)
+ return GL_FALSE;
+ break;
+ case API_OPENGLES2:
+ if (!HAVE_OPENGL_ES_2)
+ return GL_FALSE;
+ break;
+ case API_OPENGLES:
+ if (!HAVE_OPENGL_ES_1)
+ return GL_FALSE;
+ break;
+ default:
+ return GL_FALSE;
+ }
+
ctx->API = api;
ctx->DrawBuffer = NULL;
ctx->ReadBuffer = NULL;
--
2.40.1