[Mesa-dev] [PATCH] meta: remove _meta_in_progress(), fix multisample enable/disable

Brian Paul brianp at vmware.com
Thu Aug 30 07:45:13 PDT 2012


This partially reverts d638da23d2ec2e9c52655b1ea138249e7f8bcccb.

With gallium the meta code is not always built so the call to
_meta_in_progress() was unresolved.  Simply special-case the
GL_MULTISAMPLE case in the meta code.  There might be other special
cases in the future given all the differences between legacy GL,
core GL, GLES, etc.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=54234
and https://bugs.freedesktop.org/show_bug.cgi?id=54239
---
 src/mesa/drivers/common/meta.c |   43 ++++++++++++++++++++++++++++-----------
 src/mesa/drivers/common/meta.h |    3 --
 src/mesa/main/enable.c         |    7 +-----
 3 files changed, 32 insertions(+), 21 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index abb7d4e..9a6b72b 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -438,6 +438,35 @@ _mesa_meta_free(struct gl_context *ctx)
 
 
 /**
+ * This is an alternative to _mesa_set_enable() to handle some special cases.
+ * See comments inside.
+ */
+static void
+meta_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
+{
+   switch (cap) {
+   case GL_MULTISAMPLE:
+      /* We need to enable/disable multisample when using GLES but this enum
+       * is not supported there.
+       */
+      if (ctx->Multisample.Enabled == state)
+         return;
+      FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+      ctx->Multisample.Enabled = state;
+      break;
+   default:
+      _mesa_problem(ctx, "Unexpected cap in _meta_set_enable()");
+      return;
+   }
+
+   if (ctx->Driver.Enable) {
+      ctx->Driver.Enable(ctx, cap, state);
+   }
+}
+
+
+
+/**
  * Enter meta state.  This is like a light-weight version of glPushAttrib
  * but it also resets most GL state back to default values.
  *
@@ -755,7 +784,7 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
    if (state & MESA_META_MULTISAMPLE) {
       save->MultisampleEnabled = ctx->Multisample.Enabled;
       if (ctx->Multisample.Enabled)
-         _mesa_set_enable(ctx, GL_MULTISAMPLE, GL_FALSE);
+         meta_set_enable(ctx, GL_MULTISAMPLE, GL_FALSE);
    }
 
    /* misc */
@@ -1057,7 +1086,7 @@ _mesa_meta_end(struct gl_context *ctx)
 
    if (state & MESA_META_MULTISAMPLE) {
       if (ctx->Multisample.Enabled != save->MultisampleEnabled)
-         _mesa_set_enable(ctx, GL_MULTISAMPLE, save->MultisampleEnabled);
+         meta_set_enable(ctx, GL_MULTISAMPLE, save->MultisampleEnabled);
    }
 
    /* misc */
@@ -1077,16 +1106,6 @@ _mesa_meta_end(struct gl_context *ctx)
 
 
 /**
- * Determine whether Mesa is currently in a meta state.
- */
-GLboolean
-_mesa_meta_in_progress(struct gl_context *ctx)
-{
-   return ctx->Meta->SaveStackDepth != 0;
-}
-
-
-/**
  * Convert Z from a normalized value in the range [0, 1] to an object-space
  * Z coordinate in [-1, +1] so that drawing at the new Z position with the
  * default/identity ortho projection results in the original Z value.
diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
index d8dfb56..b5783ef 100644
--- a/src/mesa/drivers/common/meta.h
+++ b/src/mesa/drivers/common/meta.h
@@ -70,9 +70,6 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state);
 extern void
 _mesa_meta_end(struct gl_context *ctx);
 
-extern GLboolean
-_mesa_meta_in_progress(struct gl_context *ctx);
-
 extern void
 _mesa_meta_BlitFramebuffer(struct gl_context *ctx,
                            GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index b713f5f..14eea53 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -765,13 +765,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
 
       /* GL_ARB_multisample */
       case GL_MULTISAMPLE_ARB:
-         /* Technically speaking, this should not be allowed for OpenGL ES 2.0
-          * or 3.0.  However, meta really needs it.
-          */
-         if (!_mesa_meta_in_progress(ctx) && !_mesa_is_desktop_gl(ctx)
-             && ctx->API != API_OPENGLES)
+         if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES)
             goto invalid_enum_error;
-
          if (ctx->Multisample.Enabled == state)
             return;
          FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
-- 
1.7.3.4



More information about the mesa-dev mailing list