Ian Romanick <i...@freedesktop.org> writes:

> From: Ian Romanick <ian.d.roman...@intel.com>
>
> Use this method in _mesa_GetInternalformativ for both GL_SAMPLES and
> GL_NUM_SAMPLE_COUNTS.

> diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
> index 70c5324..3daf3da 100644
> --- a/src/mesa/main/dd.h
> +++ b/src/mesa/main/dd.h
> @@ -201,6 +201,25 @@ struct dd_function_table {
>                                       GLenum srcFormat, GLenum srcType );
>  
>     /**
> +    * Determine sample counts support for a particular format
> +    *
> +    * \param ctx            GL context
> +    * \param internalFormat GL format enum.  Must be color renderable

color, depth, or stencil renderable, right?

> diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c
> index 5a815c2..989d90b 100644
> --- a/src/mesa/main/formatquery.c
> +++ b/src/mesa/main/formatquery.c
> @@ -86,11 +86,25 @@ _mesa_GetInternalformativ(GLenum target, GLenum 
> internalformat, GLenum pname,
>  
>     switch (pname) {
>     case GL_SAMPLES:
> -      buffer[0] = ctx->Const.MaxSamples;
> -      count = 1;
> +      if (ctx->Driver.QuerySamplesForFormat)
> +         count = ctx->Driver.QuerySamplesForFormat(ctx, internalformat,
> +                                                   buffer);
> +      else
> +         count = 0;
>        break;
>     case GL_NUM_SAMPLE_COUNTS:
> -      buffer[0] = 1;
> +      if (ctx->Driver.QuerySamplesForFormat) {
> +         const size_t num_samples =
> +            ctx->Driver.QuerySamplesForFormat(ctx, internalformat, buffer);
> +
> +         /* QuerySamplesForFormat writes some stuff to buffer, so we have to
> +          * separately over-write it with the requested value.
> +          */
> +         buffer[0] = (GLint) num_samples;
> +      } else {
> +         buffer[0] = 0;
> +      }

Given that buffer[0] = 0 is invalid, aren't we asserting that drivers
that let you hit this function have QuerySamplesForFormat()?

Attachment: pgpTV6uKEmnSa.pgp
Description: PGP signature

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

Reply via email to