V2: - fix multiline comment style
    - stop using ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH since that
      doesn't exist anymore.

V3: - check for the extension being enabled
    - tidier flagging of _NEW_MULTISAMPLE
    - fix weird indentation in get.c

V4: - move flush later in SampleMaski()

Signed-off-by: Chris Forbes <chr...@ijw.co.nz>
Reviewed-by: Eric Anholt <e...@anholt.net>
---
 src/mesa/main/enable.c           | 18 ++++++++++++++++++
 src/mesa/main/get.c              |  9 +++++++++
 src/mesa/main/get_hash_params.py |  2 ++
 src/mesa/main/mtypes.h           |  6 ++++++
 src/mesa/main/multisample.c      | 20 ++++++++++++++++++--
 5 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 7e85fdf..b688f05 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -1013,6 +1013,17 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, 
GLboolean state)
          }
          break;
 
+      /* ARB_texture_multisample */
+      case GL_SAMPLE_MASK:
+         if (!_mesa_is_desktop_gl(ctx))
+            goto invalid_enum_error;
+         CHECK_EXTENSION(ARB_texture_multisample, cap);
+         if (ctx->Multisample.SampleMask == state)
+            return;
+         FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+         ctx->Multisample.SampleMask = state;
+         break;
+
       default:
          goto invalid_enum_error;
    }
@@ -1583,6 +1594,13 @@ _mesa_IsEnabled( GLenum cap )
         CHECK_EXTENSION(OES_EGL_image_external);
          return is_texture_enabled(ctx, TEXTURE_EXTERNAL_BIT);
 
+      /* ARB_texture_multisample */
+      case GL_SAMPLE_MASK:
+         if (!_mesa_is_desktop_gl(ctx))
+            goto invalid_enum_error;
+         CHECK_EXTENSION(ARB_texture_multisample);
+         return ctx->Multisample.SampleMask;
+
       default:
          goto invalid_enum_error;
    }
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 056bacb..2399f9c 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1635,6 +1635,15 @@ find_value_indexed(const char *func, GLenum pname, 
GLuint index, union value *v)
         goto invalid_enum;
       v->value_int = ctx->UniformBufferBindings[index].Size;
       return TYPE_INT;
+
+   /* ARB_texture_multisample / GL3.2 */
+   case GL_SAMPLE_MASK_VALUE:
+      if (index != 0)
+         goto invalid_value;
+      if (!ctx->Extensions.ARB_texture_multisample)
+         goto invalid_enum;
+      v->value_int = ctx->Multisample.SampleMaskValue;
+      return TYPE_INT;
    }
 
  invalid_enum:
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index 0f900a3..5022ddc 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -664,6 +664,8 @@ descriptor=[
   [ "MAX_COLOR_TEXTURE_SAMPLES", "CONTEXT_INT(Const.MaxColorTextureSamples), 
extra_ARB_texture_multisample" ],
   [ "MAX_DEPTH_TEXTURE_SAMPLES", "CONTEXT_INT(Const.MaxDepthTextureSamples), 
extra_ARB_texture_multisample" ],
   [ "MAX_INTEGER_SAMPLES", "CONTEXT_INT(Const.MaxIntegerSamples), 
extra_ARB_texture_multisample" ],
+  [ "SAMPLE_MASK", "CONTEXT_BOOL(Multisample.SampleMask), 
extra_ARB_texture_multisample" ],
+  [ "MAX_SAMPLE_MASK_WORDS", "CONST(1), extra_ARB_texture_multisample" ],
 
 
 # GL_ARB_sampler_objects / GL 3.3
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 446f91d..a80944c 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -993,6 +993,12 @@ struct gl_multisample_attrib
    GLboolean SampleCoverage;
    GLfloat SampleCoverageValue;
    GLboolean SampleCoverageInvert;
+
+   /* ARB_texture_multisample / GL3.2 additions */
+   GLboolean SampleMask;
+   GLbitfield SampleMaskValue; /* GL spec defines this as an array but >32x 
MSAA is
+                                * madness
+                                */
 };
 
 
diff --git a/src/mesa/main/multisample.c b/src/mesa/main/multisample.c
index 2d3a35e..2484946 100644
--- a/src/mesa/main/multisample.c
+++ b/src/mesa/main/multisample.c
@@ -60,6 +60,10 @@ _mesa_init_multisample(struct gl_context *ctx)
    ctx->Multisample.SampleCoverage = GL_FALSE;
    ctx->Multisample.SampleCoverageValue = 1.0;
    ctx->Multisample.SampleCoverageInvert = GL_FALSE;
+
+   /* ARB_texture_multisample / GL3.2 additions */
+   ctx->Multisample.SampleMask = GL_FALSE;
+   ctx->Multisample.SampleMaskValue = ~(GLbitfield)0;
 }
 
 
@@ -93,6 +97,18 @@ _mesa_GetMultisamplefv(GLenum pname, GLuint index, GLfloat * 
val)
 void GLAPIENTRY
 _mesa_SampleMaski(GLuint index, GLbitfield mask)
 {
-   assert(!"Not implemented");
-   // TODO: make this work
+   GET_CURRENT_CONTEXT(ctx);
+
+   if (!ctx->Extensions.ARB_texture_multisample) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glSampleMaski");
+      return;
+   }
+
+   if (index != 0) {
+      _mesa_error(ctx, GL_INVALID_VALUE, "glSampleMaski(index)");
+      return;
+   }
+
+   FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+   ctx->Multisample.SampleMaskValue = mask;
 }
-- 
1.8.1.4

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

Reply via email to