Module: Mesa
Branch: master
Commit: f6a818e76d09633c37057703ba1796ecd5678317
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f6a818e76d09633c37057703ba1796ecd5678317

Author: Nanley Chery <[email protected]>
Date:   Wed Sep  2 11:53:16 2015 -0700

mesa/extensions: Create _mesa_extension_supported()

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

v2: Use common variable names (Emil)
    Insert new line between variables and return statement (Chad)
    Rename api_set variable to api_bit (Chad)

Signed-off-by: Nanley Chery <[email protected]>
Reviewed-by: Chad Versace <[email protected]>

---

 src/mesa/main/extensions.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 4fd7487..83c4921 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -426,6 +426,24 @@ 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 i)
+{
+   const bool *base = (bool *) &ctx->Extensions;
+   const struct extension *ext = extension_table + i;
+   const uint8_t api_bit = 1 << ctx->API;
+
+   return (ext->api_set & api_bit) &&
+          (ctx->Version >= ext->version[ctx->API]) &&
+          base[ext->offset];
+}
+
+/**
  * Compare two entries of the extensions table.  Sorts first by year,
  * then by name.
  *

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to