[Mesa-dev] [PATCH 8/9] mesa: Add driver method to determine the possible sample counts
Eric Anholt
eric at anholt.net
Thu Dec 20 17:17:53 PST 2012
Ian Romanick <idr at freedesktop.org> writes:
> From: Ian Romanick <ian.d.romanick at 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()?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20121220/0fdf7403/attachment-0001.pgp>
More information about the mesa-dev
mailing list