[Mesa-dev] [PATCH] meta: Refactor handling of GL_MULTISAMPLE.
Paul Berry
stereotype441 at gmail.com
Thu Sep 13 10:50:36 PDT 2012
In commit 055093e (meta: remove call to _meta_in_progress(), fix
multisample enable/disable), we created a meta_set_enable() function
that could be used by meta ops to enable and disable GL_MULTISAMPLE
even when the GLES API was in use (the GLES API doesn't support
GL_MULTISAMPLE; it behaves as if it is always enabled). This created
some unfortunate code duplication between meta_set_enable() and the
existing _mesa_set_enable() function.
This patch eliminates the duplication by creating a
_mesa_set_multisample() function, which is used by both meta ops and
_mesa_set_enable() to enable/disable GL_MULTISAMPLE.
---
src/mesa/drivers/common/meta.c | 33 ++-------------------------------
src/mesa/main/enable.c | 24 +++++++++++++++++++-----
src/mesa/main/enable.h | 4 ++++
3 files changed, 25 insertions(+), 36 deletions(-)
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 7e81e5e..4771976 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -438,35 +438,6 @@ _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.
*
@@ -786,7 +757,7 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
if (state & MESA_META_MULTISAMPLE) {
save->MultisampleEnabled = ctx->Multisample.Enabled;
if (ctx->Multisample.Enabled)
- meta_set_enable(ctx, GL_MULTISAMPLE, GL_FALSE);
+ _mesa_set_multisample(ctx, GL_FALSE);
}
/* misc */
@@ -1090,7 +1061,7 @@ _mesa_meta_end(struct gl_context *ctx)
if (state & MESA_META_MULTISAMPLE) {
if (ctx->Multisample.Enabled != save->MultisampleEnabled)
- meta_set_enable(ctx, GL_MULTISAMPLE, save->MultisampleEnabled);
+ _mesa_set_multisample(ctx, save->MultisampleEnabled);
}
/* misc */
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 14eea53..5dd8833 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -251,6 +251,23 @@ enable_texture(struct gl_context *ctx, GLboolean state, GLbitfield texBit)
/**
+ * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for
+ * whether the API supports it (GLES doesn't).
+ */
+void
+_mesa_set_multisample(struct gl_context *ctx, GLboolean state)
+{
+ if (ctx->Multisample.Enabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+ ctx->Multisample.Enabled = state;
+
+ if (ctx->Driver.Enable) {
+ ctx->Driver.Enable(ctx, GL_MULTISAMPLE, state);
+ }
+}
+
+/**
* Helper function to enable or disable state.
*
* \param ctx GL context.
@@ -767,11 +784,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
case GL_MULTISAMPLE_ARB:
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);
- ctx->Multisample.Enabled = state;
- break;
+ _mesa_set_multisample(ctx, state);
+ return;
case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
if (ctx->Multisample.SampleAlphaToCoverage == state)
return;
diff --git a/src/mesa/main/enable.h b/src/mesa/main/enable.h
index 6d90c17..c49b494 100644
--- a/src/mesa/main/enable.h
+++ b/src/mesa/main/enable.h
@@ -67,5 +67,9 @@ _mesa_EnableClientState( GLenum cap );
extern void GLAPIENTRY
_mesa_DisableClientState( GLenum cap );
+extern void
+_mesa_set_multisample(struct gl_context *ctx, GLboolean state);
+
+
#endif
--
1.7.12
More information about the mesa-dev
mailing list