summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorAntia Puentes <[email protected]>2015-12-19 16:02:05 +0100
committerEduardo Lima Mitev <[email protected]>2016-03-03 15:14:06 +0100
commit5f6e3a03704c67dd5a271a4e43645355c5199cc7 (patch)
treecdc624db3dae68de3d3a9935416f812df095fa83 /src/mesa/main
parent95392cfa9d815ec985ba14dfe347b30d232ed9e7 (diff)
mesa/formatquery: Added func to check if the 'resource' is supported
Checks that the 'resource', as defined by the ARB_internalformat_query2 specification, is supported by the implementation for those 'pnames' that require this check. Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/formatquery.c91
1 files changed, 90 insertions, 1 deletions
diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c
index 0b19bc7da04..03473ad460d 100644
--- a/src/mesa/main/formatquery.c
+++ b/src/mesa/main/formatquery.c
@@ -435,6 +435,94 @@ _is_target_supported(struct gl_context *ctx, GLenum target)
return true;
}
+static bool
+_is_resource_supported(struct gl_context *ctx, GLenum target,
+ GLenum internalformat, GLenum pname)
+{
+ /* From the ARB_internalformat_query2 spec:
+ *
+ * In the following descriptions, the term /resource/ is used to generically
+ * refer to an object of the appropriate type that has been created with
+ * <internalformat> and <target>. If the particular <target> and
+ * <internalformat> combination do not make sense, ... the "unsupported"
+ * answer should be given. This is not an error.
+ */
+
+ /* In the ARB_internalformat_query2 spec wording, some <pnames> do not care
+ * about the /resource/ being supported or not, we return 'true' for those.
+ */
+ switch (pname) {
+ case GL_INTERNALFORMAT_SUPPORTED:
+ case GL_INTERNALFORMAT_PREFERRED:
+ case GL_COLOR_COMPONENTS:
+ case GL_DEPTH_COMPONENTS:
+ case GL_STENCIL_COMPONENTS:
+ case GL_COLOR_RENDERABLE:
+ case GL_DEPTH_RENDERABLE:
+ case GL_STENCIL_RENDERABLE:
+ return true;
+ default:
+ break;
+ }
+
+ switch(target){
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_1D_ARRAY:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_2D_ARRAY:
+ case GL_TEXTURE_3D:
+ case GL_TEXTURE_CUBE_MAP:
+ case GL_TEXTURE_CUBE_MAP_ARRAY:
+ case GL_TEXTURE_RECTANGLE:
+ /* Based on what Mesa does for glTexImage1D/2D/3D and
+ * glCompressedTexImage1D/2D/3D functions.
+ */
+ if (_mesa_base_tex_format(ctx, internalformat) < 0)
+ return false;
+
+ /* additional checks for depth textures */
+ if (!_mesa_legal_texture_base_format_for_target(ctx, target, internalformat))
+ return false;
+
+ /* additional checks for compressed textures */
+ if (_mesa_is_compressed_format(ctx, internalformat) &&
+ (!_mesa_target_can_be_compressed(ctx, target, internalformat, NULL) ||
+ _mesa_format_no_online_compression(ctx, internalformat)))
+ return false;
+
+ break;
+ case GL_TEXTURE_2D_MULTISAMPLE:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ /* Based on what Mesa does for glTexImage2D/3DMultisample,
+ * glTexStorage2D/3DMultisample and
+ * glTextureStorage2D/3DMultisample functions.
+ */
+ if (!_mesa_is_renderable_texture_format(ctx, internalformat))
+ return false;
+
+ break;
+ case GL_TEXTURE_BUFFER:
+ /* Based on what Mesa does for the glTexBuffer function. */
+ if (_mesa_validate_texbuffer_format(ctx, internalformat) ==
+ MESA_FORMAT_NONE)
+ return false;
+
+ break;
+ case GL_RENDERBUFFER:
+ /* Based on what Mesa does for glRenderbufferStorage(Multisample) and
+ * glNamedRenderbufferStorage functions.
+ */
+ if (!_mesa_base_fbo_format(ctx, internalformat))
+ return false;
+
+ break;
+ default:
+ unreachable("bad target");
+ }
+
+ return true;
+}
+
/* default implementation of QueryInternalFormat driverfunc, for
* drivers not implementing ARB_internalformat_query2.
*/
@@ -487,7 +575,8 @@ _mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname,
*/
_set_default_response(pname, buffer);
- if (!_is_target_supported(ctx, target))
+ if (!_is_target_supported(ctx, target) ||
+ !_is_resource_supported(ctx, target, internalformat, pname))
goto end;
switch (pname) {