Re: [Mesa-dev] [PATCH V2 10/22] mesa: implement sample mask
Chris Forbes writes: > diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c > index 056bacb..3a618fc 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; > } Something went horribly wrong with indentation here. > @@ -92,7 +96,15 @@ _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); > + FLUSH_VERTICES(ctx, 0); > + > + if (index != 0) { > + _mesa_error(ctx, GL_INVALID_VALUE, "glSampleMaski(index)"); > + return; > + } > + > + ctx->Multisample.SampleMaskValue = mask; > + ctx->NewState |= _NEW_MULTISAMPLE; You can optionally fold the _NEW_MULTISAMPLE NewState into the second arg of FLUSH_VERTICES since you aren't doing any special NewState flagging reduction. pgpZOKVOpO11T.pgp Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH V2 10/22] mesa: implement sample mask
On 4 February 2013 21:48, Chris Forbes wrote: > V2: - fix multiline comment style > - stop using ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH since that > doesn't exist anymore. > > Signed-off-by: Chris Forbes > --- > src/mesa/main/enable.c | 15 +++ > 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 | 16 ++-- > 5 files changed, 46 insertions(+), 2 deletions(-) > > diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c > index 7e85fdf..a02c63a 100644 > --- a/src/mesa/main/enable.c > +++ b/src/mesa/main/enable.c > @@ -1013,6 +1013,14 @@ _mesa_set_enable(struct gl_context *ctx, GLenum > cap, GLboolean state) > } > break; > > + /* ARB_texture_multisample */ > + case GL_SAMPLE_MASK: > + if (ctx->Multisample.SampleMask == state) > +return; > + FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); > + ctx->Multisample.SampleMask = state; > + break; > + > You need to add: if (!_mesa_is_desktop_gl(ctx)) goto invalid_enum_error; CHECK_EXTENSION(ARB_texture_multisample); (as you do in _mesa_IsEnabled() below). >default: > goto invalid_enum_error; > } > @@ -1583,6 +1591,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..3a618fc 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 c5e1b3a..7bd681f 100644 > --- a/src/mesa/main/get_hash_params.py > +++ b/src/mesa/main/get_hash_params.py > @@ -666,6 +666,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 0ac90bc..70d3c22 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; > } > > void GLAPIENTRY > @@ -92,7 +96,15 @@ _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); > + FLUSH_VERTICES(ctx, 0); > + > + if (index != 0) { > + _mesa_error(ctx, GL_INVALID_VALUE, "glSampleMaski(index)"); > + return; > + } > + > + ctx->Multisample.SampleMaskValue = mask; > + ctx->NewState |= _NEW_MULTISAMPLE; > This function need
[Mesa-dev] [PATCH V2 10/22] mesa: implement sample mask
V2: - fix multiline comment style - stop using ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH since that doesn't exist anymore. Signed-off-by: Chris Forbes --- src/mesa/main/enable.c | 15 +++ 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 | 16 ++-- 5 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 7e85fdf..a02c63a 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -1013,6 +1013,14 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) } break; + /* ARB_texture_multisample */ + case GL_SAMPLE_MASK: + if (ctx->Multisample.SampleMask == state) +return; + FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); + ctx->Multisample.SampleMask = state; + break; + default: goto invalid_enum_error; } @@ -1583,6 +1591,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..3a618fc 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 c5e1b3a..7bd681f 100644 --- a/src/mesa/main/get_hash_params.py +++ b/src/mesa/main/get_hash_params.py @@ -666,6 +666,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 0ac90bc..70d3c22 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; } void GLAPIENTRY @@ -92,7 +96,15 @@ _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); + FLUSH_VERTICES(ctx, 0); + + if (index != 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glSampleMaski(index)"); + return; + } + + ctx->Multisample.SampleMaskValue = mask; + ctx->NewState |= _NEW_MULTISAMPLE; } -- 1.8.1.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev