mesa/formatquery: Added {COLOR,DEPTH,STENCIL}_RENDERABLE <pname> queries
authorAntia Puentes <apuentes@igalia.com>
Sat, 19 Dec 2015 17:35:57 +0000 (18:35 +0100)
committerEduardo Lima Mitev <elima@igalia.com>
Thu, 3 Mar 2016 14:14:06 +0000 (15:14 +0100)
Reviewed-by: Dave Airlie <airlied@redhat.com>
src/mesa/main/formatquery.c

index 5d7df15fd0de4b69b5d99eea5e33bfdb59f0152b..339bee0d454c30ba0c64262a8751dd884edbc109 100644 (file)
@@ -1001,15 +1001,23 @@ _mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname,
       break;
 
    case GL_COLOR_RENDERABLE:
-      /* @TODO */
-      break;
-
    case GL_DEPTH_RENDERABLE:
-      /* @TODO */
-      break;
-
    case GL_STENCIL_RENDERABLE:
-      /* @TODO */
+      if (!_is_renderable(ctx, internalformat))
+         goto end;
+
+      if (pname == GL_COLOR_RENDERABLE) {
+         if (!_mesa_is_color_format(internalformat))
+            goto end;
+      } else {
+         GLenum baseFormat = _mesa_base_fbo_format(ctx, internalformat);
+         if (baseFormat != GL_DEPTH_STENCIL &&
+             ((pname == GL_DEPTH_RENDERABLE && baseFormat != GL_DEPTH_COMPONENT) ||
+              (pname == GL_STENCIL_RENDERABLE && baseFormat != GL_STENCIL_INDEX)))
+            goto end;
+      }
+
+      buffer[0] = GL_TRUE;
       break;
 
    case GL_FRAMEBUFFER_RENDERABLE: