mesa/shaderimage: Added func to get the GL_IMAGE_CLASS from the format
authorAntia Puentes <apuentes@igalia.com>
Tue, 17 Nov 2015 20:29:04 +0000 (21:29 +0100)
committerEduardo Lima Mitev <elima@igalia.com>
Thu, 3 Mar 2016 14:14:07 +0000 (15:14 +0100)
It will be used by the ARB_internalformat_query2 implementation to
implement the IMAGE_COMPATIBILITY_CLASS <pname> query.

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

index a71686d0ec466280c740e42317f2d4a1dabbad3b..fa967a2408ab9554b72f51c3df4feb8b591fe9e6 100644 (file)
@@ -331,6 +331,51 @@ get_image_format_class(mesa_format format)
    }
 }
 
+static GLenum
+_image_format_class_to_glenum(enum image_format_class class)
+{
+   switch (class) {
+   case IMAGE_FORMAT_CLASS_NONE:
+      return GL_NONE;
+   case IMAGE_FORMAT_CLASS_1X8:
+      return GL_IMAGE_CLASS_1_X_8;
+   case IMAGE_FORMAT_CLASS_1X16:
+      return GL_IMAGE_CLASS_1_X_16;
+   case IMAGE_FORMAT_CLASS_1X32:
+      return GL_IMAGE_CLASS_1_X_32;
+   case IMAGE_FORMAT_CLASS_2X8:
+      return GL_IMAGE_CLASS_2_X_8;
+   case IMAGE_FORMAT_CLASS_2X16:
+      return GL_IMAGE_CLASS_2_X_16;
+   case IMAGE_FORMAT_CLASS_2X32:
+      return GL_IMAGE_CLASS_2_X_32;
+   case IMAGE_FORMAT_CLASS_10_11_11:
+      return GL_IMAGE_CLASS_11_11_10;
+   case IMAGE_FORMAT_CLASS_4X8:
+      return GL_IMAGE_CLASS_4_X_8;
+   case IMAGE_FORMAT_CLASS_4X16:
+      return GL_IMAGE_CLASS_4_X_16;
+   case IMAGE_FORMAT_CLASS_4X32:
+      return GL_IMAGE_CLASS_4_X_32;
+   case IMAGE_FORMAT_CLASS_2_10_10_10:
+      return GL_IMAGE_CLASS_10_10_10_2;
+   default:
+      assert("Invalid image_format_class");
+      return GL_NONE;
+   }
+}
+
+GLenum
+_mesa_get_image_format_class(GLenum format)
+{
+   mesa_format tex_format = _mesa_get_shader_image_format(format);
+   if (tex_format == MESA_FORMAT_NONE)
+      return GL_NONE;
+
+   enum image_format_class class = get_image_format_class(tex_format);
+   return _image_format_class_to_glenum(class);
+}
+
 bool
 _mesa_is_shader_image_format_supported(const struct gl_context *ctx,
                                        GLenum format)
index 794c926d0406cb2f422224dd90a3775e1427188a..85193e104f65166d24a19d5e35bc8d519e69f845 100644 (file)
@@ -42,6 +42,12 @@ struct gl_context;
 mesa_format
 _mesa_get_shader_image_format(GLenum format);
 
+/**
+ * Get the GL image format class for a shader image format GL enum
+ */
+GLenum
+_mesa_get_image_format_class(GLenum format);
+
 /**
  * Return whether an image format should be supported based on the current API
  * version of the context.