summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris Forbes <[email protected]>2012-11-30 21:22:14 +1300
committerChris Forbes <[email protected]>2013-03-02 11:35:16 +1300
commit1822496f3a7baf1c1726fda008cb89fbbade5c8d (patch)
tree03eec65012883b8a943b24fdc8837bd3fa0b0f14 /src
parent7c1017e292b2d27af6d7e15db874f50223d73e15 (diff)
mesa: implement sample mask
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 <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/enable.c18
-rw-r--r--src/mesa/main/get.c9
-rw-r--r--src/mesa/main/get_hash_params.py2
-rw-r--r--src/mesa/main/mtypes.h6
-rw-r--r--src/mesa/main/multisample.c20
5 files changed, 53 insertions, 2 deletions
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 7e85fdfb3f4..b688f050b1f 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 056bacb196b..2399f9c9dd3 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 0f900a3a8c1..5022ddc4052 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 446f91dd9f8..a80944c817f 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 2d3a35ef389..2484946158f 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;
}