mesa/formatquery: Added texture view related queries
authorAntia Puentes <apuentes@igalia.com>
Sat, 19 Dec 2015 19:29:31 +0000 (20:29 +0100)
committerEduardo Lima Mitev <elima@igalia.com>
Thu, 3 Mar 2016 14:14:07 +0000 (15:14 +0100)
From the ARB_internalformat_query2 specification:

   "- TEXTURE_VIEW: The support for using the resource with the TextureView
      command is returned in <params>.
      Possible values returned are FULL_SUPPORT, CAVEAT_SUPPORT, or NONE.
      If the resource or operation is not supported, NONE is returned.

    - VIEW_COMPATIBILITY_CLASS: The compatibility class of the resource when
      used as a texture view is returned in <params>. The compatibility
      class is one of the values from the /Class/ column of Table 3.X.2. If
      the resource has no other formats that are compatible, the resource
      does not support views, or if texture views are not supported, NONE is
      returned."

Reviewed-by: Dave Airlie <airlied@redhat.com>
src/mesa/main/formatquery.c

index 9fe9072..ac29bc8 100644 (file)
@@ -35,6 +35,7 @@
 #include "genmipmap.h"
 #include "shaderimage.h"
 #include "texcompress.h"
+#include "textureview.h"
 
 static bool
 _is_renderable(struct gl_context *ctx, GLenum internalformat)
@@ -617,6 +618,7 @@ _mesa_query_internal_format_default(struct gl_context *ctx, GLenum target,
    case GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE:
    case GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE:
    case GL_CLEAR_BUFFER:
+   case GL_TEXTURE_VIEW:
       params[0] = GL_FULL_SUPPORT;
       break;
 
@@ -1376,11 +1378,23 @@ _mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname,
       break;
 
    case GL_TEXTURE_VIEW:
-      /* @TODO */
-      break;
-
    case GL_VIEW_COMPATIBILITY_CLASS:
-      /* @TODO */
+      if (!_mesa_has_ARB_texture_view(ctx) ||
+          target == GL_TEXTURE_BUFFER ||
+          target == GL_RENDERBUFFER)
+         goto end;
+
+      if (pname == GL_TEXTURE_VIEW) {
+         ctx->Driver.QueryInternalFormat(ctx, target, internalformat, pname,
+                                         buffer);
+      } else {
+         GLenum view_class = _mesa_texture_view_lookup_view_class(ctx,
+                                                                  internalformat);
+         if (view_class == GL_FALSE)
+            goto end;
+
+         buffer[0] = view_class;
+      }
       break;
 
    default: