mesa: add _mesa_is_api_gles2() helper

The glsl compiler has been reworked to avoid passing gl_context around
so that we can avoid expensive recompiles across the code base for
minor changes. This helper will help us avoid passing gl_context around
where its otherwise unrequired.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22305>
This commit is contained in:
Timothy Arceri
2023-04-05 11:50:18 +10:00
committed by Marge Bot
parent 86ad0356b6
commit bf8f11a2de
2 changed files with 15 additions and 5 deletions
+1 -5
View File
@@ -303,11 +303,7 @@ _mesa_is_gles1(const struct gl_context *ctx)
static inline bool
_mesa_is_gles2(const struct gl_context *ctx)
{
#if HAVE_OPENGL_ES_2
return ctx->API == API_OPENGLES2;
#else
return false;
#endif
return _mesa_is_api_gles2(ctx->API);
}
/**
+14
View File
@@ -32,6 +32,7 @@
#ifndef MENUMS_H
#define MENUMS_H
#include <stdbool.h>
#include "util/macros.h"
/**
@@ -49,6 +50,19 @@ typedef enum
API_OPENGL_LAST = API_OPENGL_CORE
} gl_api;
/**
* Checks if the api is for GLES 2.0 or later
*/
static inline bool
_mesa_is_api_gles2(gl_api api)
{
#if HAVE_OPENGL_ES_2
return api == API_OPENGLES2;
#else
return false;
#endif
}
/**
* An index for each type of texture object. These correspond to the GL
* texture target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc.