[Mesa-dev] [RFC PATCH 13/26] mesa: implement sample mask

Brian Paul brianp at vmware.com
Wed Jan 2 10:11:16 PST 2013


On 12/29/2012 05:35 AM, Chris Forbes wrote:
> Signed-off-by: Chris Forbes<chrisf at ijw.co.nz>
> ---
>   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, 45 insertions(+), 3 deletions(-)
>
> diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
> index b48794f..aeeab15 100644
> --- a/src/mesa/main/enable.c
> +++ b/src/mesa/main/enable.c
> @@ -988,6 +988,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;
>      }
> @@ -1556,6 +1564,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 4c227a8..e15cbf8 100644
> --- a/src/mesa/main/get.c
> +++ b/src/mesa/main/get.c
> @@ -1618,6 +1618,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;

Funny indentation.  Just use spaces instead of tabs.


>      }
>
>    invalid_enum:
> diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
> index 689a7e0..8e053a4 100644
> --- a/src/mesa/main/get_hash_params.py
> +++ b/src/mesa/main/get_hash_params.py
> @@ -644,6 +644,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 6f6cdaa..dda6a3e 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -980,7 +980,6 @@ struct gl_list_attrib
>      GLuint ListBase;
>   };
>
> -
>   /**
>    * Multisample attribute group (GL_MULTISAMPLE_BIT).
>    */
> @@ -993,6 +992,11 @@ 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 */

The doxygen-style comment here would be /**< GL spec defines ... */


>   };
>
>
> diff --git a/src/mesa/main/multisample.c b/src/mesa/main/multisample.c
> index ee9e263..d277ff8 100644
> --- a/src/mesa/main/multisample.c
> +++ b/src/mesa/main/multisample.c
> @@ -59,6 +59,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
> @@ -88,7 +92,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);
> +   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx );
> +
> +   if (index != 0) {
> +      _mesa_error(ctx, GL_INVALID_VALUE, "glSampleMaski(index)");
> +      return;
> +   }
> +
> +   ctx->Multisample.SampleMaskValue = mask;
> +   ctx->NewState |= _NEW_MULTISAMPLE;
>   }
>



More information about the mesa-dev mailing list