summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/formatquery.c
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2012-12-01 11:05:00 -0800
committerIan Romanick <[email protected]>2013-01-15 21:34:45 -0800
commitf5e7f12e4a1d2ee98ced36c232842d60181fc01e (patch)
tree90eeea0255dfd8eca7baf91251ed71b75d7b7fed /src/mesa/main/formatquery.c
parentbda540d2357f69a63dcf16550e178f803682d6ce (diff)
mesa: Add driver method to determine the possible sample counts
Use this method in _mesa_GetInternalformativ for both GL_SAMPLES and GL_NUM_SAMPLE_COUNTS. v2: internalFormat may not be color renderable by the driver, so zero can be returned as a sample count. Require that drivers supporting the extension provide a QuerySamplesForFormat function. The later was suggested by Eric Anholt. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
Diffstat (limited to 'src/mesa/main/formatquery.c')
-rw-r--r--src/mesa/main/formatquery.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c
index 64f10cdf494..f08ab66f040 100644
--- a/src/mesa/main/formatquery.c
+++ b/src/mesa/main/formatquery.c
@@ -42,6 +42,8 @@ _mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname,
return;
}
+ assert(ctx->Driver.QuerySamplesForFormat != NULL);
+
/* The ARB_internalformat_query spec says:
*
* "If the <target> parameter to GetInternalformativ is not one of
@@ -91,13 +93,34 @@ _mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname,
switch (pname) {
case GL_SAMPLES:
- buffer[0] = ctx->Const.MaxSamples;
- count = 1;
+ count = ctx->Driver.QuerySamplesForFormat(ctx, internalformat, buffer);
break;
- case GL_NUM_SAMPLE_COUNTS:
- buffer[0] = 1;
+ case GL_NUM_SAMPLE_COUNTS: {
+ /* The driver can return 0, and we should pass that along to the
+ * application. The ARB decided that ARB_internalformat_query should
+ * behave as ARB_internalformat_query2 in this situation.
+ *
+ * The ARB_internalformat_query2 spec says:
+ *
+ * "- NUM_SAMPLE_COUNTS: The number of sample counts that would be
+ * returned by querying SAMPLES is returned in <params>.
+ * * If <internalformat> is not color-renderable,
+ * depth-renderable, or stencil-renderable (as defined in
+ * section 4.4.4), or if <target> does not support multiple
+ * samples (ie other than TEXTURE_2D_MULTISAMPLE,
+ * TEXTURE_2D_MULTISAMPLE_ARRAY, or RENDERBUFFER), 0 is
+ * returned."
+ */
+ 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;
count = 1;
break;
+ }
default:
_mesa_error(ctx, GL_INVALID_ENUM,
"glGetInternalformativ(pname=%s)",