mesa: add _mesa_is_api_gles2() helper
authorTimothy Arceri <tarceri@itsqueeze.com>
Wed, 5 Apr 2023 01:50:18 +0000 (11:50 +1000)
committerMarge Bot <emma+marge@anholt.net>
Thu, 6 Apr 2023 08:07:35 +0000 (08:07 +0000)
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>

src/mesa/main/context.h
src/mesa/main/menums.h

index 1b25627..eabb0ff 100644 (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);
 }
 
 /**
index b78fb26..360809e 100644 (file)
@@ -32,6 +32,7 @@
 #ifndef MENUMS_H
 #define MENUMS_H
 
+#include <stdbool.h>
 #include "util/macros.h"
 
 /**
@@ -50,6 +51,19 @@ typedef enum
 } 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.
  * Note: the order is from highest priority to lowest priority.