[Mesa-dev] [PATCH 2/2] mesa: add _mesa_feature_removed() helper

nobled nobled at dreamwidth.org
Fri Jul 27 09:19:33 PDT 2012


And a more trivial _mesa_feature_deprecated().

---
 src/mesa/main/context.c |   29 +++++++++++++++++++++++++++++
 src/mesa/main/context.h |   14 ++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 18a9ac8..1a025e8 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1897,5 +1897,34 @@ _mesa_valid_to_render(struct gl_context *ctx,
const char *where)
    return GL_TRUE;
 }

+GLboolean
+_mesa_feature_removed(struct gl_context *ctx, int deprecated, int removed)
+{
+   int version = ctx->VersionMajor * 10 + ctx->VersionMinor;
+
+   /* Has not been deprecated or removed in this version. */
+   if (version < deprecated)
+      return GL_FALSE;
+   /* Has been deprecated, and removed since this is a forward-compatible
+      context. */
+   if (ctx->Const.ContextFlags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)
+      return GL_TRUE;
+   /* Has not been removed from any core GL version yet. */
+   if (removed == 0)
+      return GL_FALSE;
+   /* Has been deprecated, but not removed in this version, and this is
+      not a forward-compatible context, so it's still present. */
+   if (version < removed)
+      return GL_FALSE;
+   /* Has been removed in this version, but this is a compatibility
+      context, which restores removed features. */
+   if (ctx->Const.ProfileMask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
+      return GL_FALSE;
+
+   /* Has been removed in this version, and this is a core context. */
+   assert(ctx->Const.ProfileMask & GL_CONTEXT_CORE_PROFILE_BIT);
+   return GL_TRUE;
+}
+

 /*@}*/
diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index a66dd50..169dde0 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -165,6 +165,20 @@ extern GLboolean
 _mesa_valid_to_render(struct gl_context *ctx, const char *where);


+static inline GLboolean
+_mesa_feature_deprecated(struct gl_context *ctx, int deprecated)
+{
+   int version = ctx->VersionMajor * 10 + ctx->VersionMinor;
+
+   /* Has been deprecated or removed in this version. */
+   if (version >= deprecated)
+      return GL_TRUE;
+   return GL_FALSE;
+}
+
+extern GLboolean
+_mesa_feature_removed(struct gl_context *ctx, int deprecated, int removed);
+

 /** \name Miscellaneous */
 /*@{*/
-- 
1.7.9.5


More information about the mesa-dev mailing list