[Mesa-dev] [RFC 14/63] mesa/formatquery: Added a func to check if the <target> is supported

Eduardo Lima Mitev elima at igalia.com
Tue Jan 19 08:41:54 PST 2016


From: Antia Puentes <apuentes at igalia.com>

>From the ARB_internalformat_query2 spec:

  "If the particular <target> and <internalformat> combination do not make
   sense, or if a particular type of <target> is not supported by the
   implementation the "unsupported" answer should be given. This is not an
   error."

This function checks if the <target> is supported by the implementation.
---
 src/mesa/main/formatquery.c | 71 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)

diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c
index a0dc350..961af6d 100644
--- a/src/mesa/main/formatquery.c
+++ b/src/mesa/main/formatquery.c
@@ -28,6 +28,7 @@
 #include "enums.h"
 #include "fbobject.h"
 #include "formatquery.h"
+#include "teximage.h"
 
 /* Handles the cases where either ARB_internalformat_query or
  * ARB_internalformat_query2 have to return an error.
@@ -363,6 +364,76 @@ _set_default_response(GLenum pname, GLint buffer[16])
    }
 }
 
+static bool
+_is_target_supported(struct gl_context *ctx, GLenum target)
+{
+   /* The ARB_internalformat_query2 spec says:
+    *
+    *     "if a particular type of <target> is not supported by the
+    *     implementation the "unsupported" answer should be given.
+    *     This is not an error."
+    */
+   switch(target){
+   case GL_TEXTURE_2D:
+   case GL_TEXTURE_3D:
+      break;
+
+   case GL_TEXTURE_1D:
+      if (!_mesa_is_desktop_gl(ctx))
+         return false;
+      break;
+
+   case GL_TEXTURE_1D_ARRAY:
+      if (!(_mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_array))
+         return false;
+      break;
+
+   case GL_TEXTURE_2D_ARRAY:
+      if (!((_mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_array)
+            || _mesa_is_gles3(ctx)))
+         return false;
+      break;
+
+   case GL_TEXTURE_CUBE_MAP:
+      if (!ctx->Extensions.ARB_texture_cube_map)
+         return false;
+      break;
+
+   case GL_TEXTURE_CUBE_MAP_ARRAY:
+      if (!ctx->Extensions.ARB_texture_cube_map_array)
+         return false;
+      break;
+
+   case GL_TEXTURE_RECTANGLE:
+      if (!(_mesa_is_desktop_gl(ctx) && ctx->Extensions.NV_texture_rectangle))
+          return false;
+      break;
+
+   case GL_TEXTURE_BUFFER:
+      if (!(ctx->API == API_OPENGL_CORE &&
+            ctx->Extensions.ARB_texture_buffer_object))
+         return false;
+      break;
+
+   case GL_RENDERBUFFER:
+      if (!ctx->Extensions.ARB_framebuffer_object)
+         return false;
+      break;
+
+   case GL_TEXTURE_2D_MULTISAMPLE:
+   case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+      if (!(ctx->Extensions.ARB_texture_multisample && _mesa_is_desktop_gl(ctx))
+          && !_mesa_is_gles31(ctx))
+         return false;
+      break;
+
+   default:
+      unreachable("invalid target");
+   }
+
+   return true;
+}
+
 /* default implementation of QueryInternalFormat driverfunc, for
  * drivers not implementing ARB_internalformat_query2.
  */
-- 
2.5.3



More information about the mesa-dev mailing list