meta: Save and restore a bunch of MSAA state.
authorEric Anholt <eric@anholt.net>
Tue, 11 Feb 2014 00:23:50 +0000 (16:23 -0800)
committerEric Anholt <eric@anholt.net>
Fri, 21 Feb 2014 18:43:38 +0000 (10:43 -0800)
We're disabling GL_MULTISAMPLE, so we didn't need to worry about a lot of
that state.  But to do MSAA to MSAA blits, we need to start handling more
state.

v2: Fix pasteo caught by Kenneth.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/common/meta.c
src/mesa/drivers/common/meta.h

index a0613f26a7673a9ba2c24dbe6c71e7fece4fefb7..2dec2c34edacdb81b49f044eb2696ad645238ed8 100644 (file)
@@ -51,6 +51,7 @@
 #include "main/macros.h"
 #include "main/matrix.h"
 #include "main/mipmap.h"
+#include "main/multisample.h"
 #include "main/pixel.h"
 #include "main/pbo.h"
 #include "main/polygon.h"
@@ -719,9 +720,20 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
    }
 
    if (state & MESA_META_MULTISAMPLE) {
-      save->MultisampleEnabled = ctx->Multisample.Enabled;
+      save->Multisample = ctx->Multisample; /* struct copy */
+
       if (ctx->Multisample.Enabled)
          _mesa_set_multisample(ctx, GL_FALSE);
+      if (ctx->Multisample.SampleCoverage)
+         _mesa_set_enable(ctx, GL_SAMPLE_COVERAGE, GL_FALSE);
+      if (ctx->Multisample.SampleAlphaToCoverage)
+         _mesa_set_enable(ctx, GL_SAMPLE_ALPHA_TO_COVERAGE, GL_FALSE);
+      if (ctx->Multisample.SampleAlphaToOne)
+         _mesa_set_enable(ctx, GL_SAMPLE_ALPHA_TO_ONE, GL_FALSE);
+      if (ctx->Multisample.SampleShading)
+         _mesa_set_enable(ctx, GL_SAMPLE_SHADING, GL_FALSE);
+      if (ctx->Multisample.SampleMask)
+         _mesa_set_enable(ctx, GL_SAMPLE_MASK, GL_FALSE);
    }
 
    if (state & MESA_META_FRAMEBUFFER_SRGB) {
@@ -1059,8 +1071,30 @@ _mesa_meta_end(struct gl_context *ctx)
    }
 
    if (state & MESA_META_MULTISAMPLE) {
-      if (ctx->Multisample.Enabled != save->MultisampleEnabled)
-         _mesa_set_multisample(ctx, save->MultisampleEnabled);
+      struct gl_multisample_attrib *ctx_ms = &ctx->Multisample;
+      struct gl_multisample_attrib *save_ms = &save->Multisample;
+
+      if (ctx_ms->Enabled != save_ms->Enabled)
+         _mesa_set_multisample(ctx, save_ms->Enabled);
+      if (ctx_ms->SampleCoverage != save_ms->SampleCoverage)
+         _mesa_set_enable(ctx, GL_SAMPLE_COVERAGE, save_ms->SampleCoverage);
+      if (ctx_ms->SampleAlphaToCoverage != save_ms->SampleAlphaToCoverage)
+         _mesa_set_enable(ctx, GL_SAMPLE_ALPHA_TO_COVERAGE, save_ms->SampleAlphaToCoverage);
+      if (ctx_ms->SampleAlphaToOne != save_ms->SampleAlphaToOne)
+         _mesa_set_enable(ctx, GL_SAMPLE_ALPHA_TO_ONE, save_ms->SampleAlphaToOne);
+      if (ctx_ms->SampleCoverageValue != save_ms->SampleCoverageValue ||
+          ctx_ms->SampleCoverageInvert != save_ms->SampleCoverageInvert) {
+         _mesa_SampleCoverage(save_ms->SampleCoverageValue,
+                              save_ms->SampleCoverageInvert);
+      }
+      if (ctx_ms->SampleShading != save_ms->SampleShading)
+         _mesa_set_enable(ctx, GL_SAMPLE_SHADING, save_ms->SampleShading);
+      if (ctx_ms->SampleMask != save_ms->SampleMask)
+         _mesa_set_enable(ctx, GL_SAMPLE_MASK, save_ms->SampleMask);
+      if (ctx_ms->SampleMaskValue != save_ms->SampleMaskValue)
+         _mesa_SampleMaski(0, save_ms->SampleMaskValue);
+      if (ctx_ms->MinSampleShadingValue != save_ms->MinSampleShadingValue)
+         _mesa_MinSampleShading(save_ms->MinSampleShadingValue);
    }
 
    if (state & MESA_META_FRAMEBUFFER_SRGB) {
index 5d79253139f14bdadb436bf001624134c84cfdc2..7d4474eca4f5d12566c7209605aecfd8167c3084 100644 (file)
@@ -168,7 +168,7 @@ struct save_state
    struct gl_feedback Feedback;
 
    /** MESA_META_MULTISAMPLE */
-   GLboolean MultisampleEnabled;
+   struct gl_multisample_attrib Multisample;
 
    /** MESA_META_FRAMEBUFFER_SRGB */
    GLboolean sRGBEnabled;