On 07/27/2012 10:11 AM, Ian Romanick wrote:
On 07/27/2012 09:19 AM, nobled wrote:
And a more trivial _mesa_feature_deprecated().

I don't think this patch is going to be useful.  There are only three
pieces of functionality that are deprecated but not removed.

1. Line widths > 1.0.

2. The queries for MAX_VARYING_COMPONENTS and MAX_VARYING_FLOATS
(deprecated in 3.2).

3. The queries for NUM_COMPRESSED_TEXTURE_FORMATS and
COMPRESSED_TEXTURE_FORMATS (deprecated in 4.2).

In all other cases simply knowing that ctx->API == API_OPENGL_CORE is
enough information.  I have a bunch of patches (patch carpet bombing)
that make ES 1.x and ES 2.0 filtering use similar mechanism.

Since there are so few special cases, I think it's okay to open-code the
checks.

---
  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)

Also... there are a *ton* of places where this check is necessary. I'd much rather have a simple pointer deference and compare than have a function call to all of this.

+{
+   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 */
  /*@{*/




_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to