[Mesa-dev] [RFC 06/21] mesa/extensions: Create _mesa_extension_supported()

Nanley Chery nanleychery at gmail.com
Mon Oct 19 15:36:24 PDT 2015


From: Nanley Chery <nanley.g.chery at intel.com>

Create a function which determines if an extension is supported in the
current context.

Signed-off-by: Nanley Chery <nanley.g.chery at intel.com>
---
 src/mesa/main/extensions.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 390e026..7137bc9 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -423,6 +423,23 @@ typedef unsigned short extension_index;
 
 
 /**
+ * Given an extension enum, return whether or not the extension is supported
+ * dependent on the following factors:
+ * There's driver support and the OpenGL/ES version is at least that
+ * specified in the extension_table.
+ */
+static inline bool
+_mesa_extension_supported(const struct gl_context *ctx, extension_index ei)
+{
+   const bool *base = (bool *) &ctx->Extensions;
+   const struct extension *i = extension_table + ei;
+   const uint8_t api_set = 1 << ctx->API;
+   return (i->api_set & api_set) &&
+          (ctx->Version >= i->version[ctx->API]) &&
+          base[i->offset];
+}
+
+/**
  * Compare two entries of the extensions table.  Sorts first by year,
  * then by name.
  *
-- 
2.6.1



More information about the mesa-dev mailing list