From: Ian Romanick <ian.d.roman...@intel.com> Use this method in _mesa_GetInternalformativ for both GL_SAMPLES and GL_NUM_SAMPLE_COUNTS.
Signed-off-by: Ian Romanick <ian.d.roman...@intel.com> --- src/mesa/drivers/common/driverfuncs.c | 1 + src/mesa/main/dd.h | 19 +++++++++++++++++++ src/mesa/main/formatquery.c | 20 +++++++++++++++++--- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c index 93fa3c7..3de5199 100644 --- a/src/mesa/drivers/common/driverfuncs.c +++ b/src/mesa/drivers/common/driverfuncs.c @@ -91,6 +91,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver) /* Texture functions */ driver->ChooseTextureFormat = _mesa_choose_tex_format; + driver->QuerySamplesForFormat = NULL; driver->TexImage = _mesa_store_teximage; driver->TexSubImage = _mesa_store_texsubimage; driver->GetTexImage = _mesa_meta_GetTexImage; 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 + * \param samples Buffer to hold the returned sample counts. + * Drivers \b must \b not return more than 16 counts. + * + * \note + * Callers of this method must not pass an invalid value for \c + * internalFormat. + * + * \returns + * The number of sample counts actually written to \c samples. + */ + size_t (*QuerySamplesForFormat)(struct gl_context *ctx, + GLenum internalFormat, + int samples[16]); + + /** * Called by glTexImage[123]D() and glCopyTexImage[12]D() * Allocate texture memory and copy the user's image to the buffer. * The gl_texture_image fields, etc. will be fully initialized. 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; + } + count = 1; break; default: -- 1.7.11.7 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev