From 8bb1ecaa02177720758255bdd7ec34a5d15feca4 Mon Sep 17 00:00:00 2001 From: Jordan Justen Date: Tue, 16 May 2023 18:46:50 -0700 Subject: 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 Reviewed-by: Eric Engestrom Part-of: --- 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; -- cgit v1.2.1