mesa/main: Exit early when trying to create an unsupported context API

Fixes: adbe8b6c17 ("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>
This commit is contained in:
Jordan Justen 2023-05-16 18:46:50 -07:00 committed by Marge Bot
parent f9688f6378
commit 8bb1ecaa02

View file

@ -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;