summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorAntia Puentes <[email protected]>2015-12-22 15:07:57 +0100
committerEduardo Lima Mitev <[email protected]>2016-03-03 15:14:06 +0100
commit4722abc6300249e5afeff54e1286d2261c26bd28 (patch)
tree10d39091f329e822a2694ee2beacdfd14c8866a3 /src/mesa
parent5f6e3a03704c67dd5a271a4e43645355c5199cc7 (diff)
mesa/formatquery: Added a func to check <internalformat> supported
From the ARB_internalformat_query2 specification: "The INTERNALFORMAT_SUPPORTED <pname> can be used to determine if the internal format is supported, and the other <pnames> are defined in terms of whether or not the format is supported." v2: Consider also FBO base formats when checking if the internalformat is supported. Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/formatquery.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c
index 03473ad460d..60d8b71b0d2 100644
--- a/src/mesa/main/formatquery.c
+++ b/src/mesa/main/formatquery.c
@@ -523,6 +523,43 @@ _is_resource_supported(struct gl_context *ctx, GLenum target,
return true;
}
+static bool
+_is_internalformat_supported(struct gl_context *ctx, GLenum target,
+ GLenum internalformat)
+{
+ /* From the ARB_internalformat_query2 specification:
+ *
+ * "- INTERNALFORMAT_SUPPORTED: If <internalformat> is an internal format
+ * that is supported by the implementation in at least some subset of
+ * possible operations, TRUE is written to <params>. If <internalformat>
+ * if not a valid token for any internal format usage, FALSE is returned.
+ *
+ * <internalformats> that must be supported (in GL 4.2 or later) include
+ * the following:
+ * - "sized internal formats" from Table 3.12, 3.13, and 3.15,
+ * - any specific "compressed internal format" from Table 3.14,
+ * - any "image unit format" from Table 3.21.
+ * - any generic "compressed internal format" from Table 3.14, if the
+ * implementation accepts it for any texture specification commands, and
+ * - unsized or base internal format, if the implementation accepts
+ * it for texture or image specification.
+ */
+ GLint buffer[1];
+
+ /* At this point a internalformat is valid if it is valid as a texture or
+ * as a renderbuffer format. The checks are different because those methods
+ * return different values when passing non supported internalformats */
+ if (_mesa_base_tex_format(ctx, internalformat) < 0 &&
+ _mesa_base_fbo_format(ctx, internalformat) == 0)
+ return false;
+
+ /* Let the driver have the final word */
+ ctx->Driver.QueryInternalFormat(ctx, target, internalformat,
+ GL_INTERNALFORMAT_SUPPORTED, buffer);
+
+ return (buffer[0] == GL_TRUE);
+}
+
/* default implementation of QueryInternalFormat driverfunc, for
* drivers not implementing ARB_internalformat_query2.
*/
@@ -576,6 +613,7 @@ _mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname,
_set_default_response(pname, buffer);
if (!_is_target_supported(ctx, target) ||
+ !_is_internalformat_supported(ctx, target, internalformat) ||
!_is_resource_supported(ctx, target, internalformat, pname))
goto end;