[Mesa-dev] [RFC 47/63] mesa/formatquery: Added queries related to image textures

Eduardo Lima Mitev elima at igalia.com
Tue Jan 19 08:42:27 PST 2016


From: Antia Puentes <apuentes at igalia.com>

>From the ARB_internalformat_query2 specification:

   "- IMAGE_TEXEL_SIZE: The size of a texel when the resource when used as
      an image texture is returned in <params>.  This is the value from the
      /Size/ column in Table 3.22. If the resource is not supported for image
      textures, or if image textures are not supported, zero is returned.

    - IMAGE_COMPATIBILITY_CLASS: The compatibility class of the resource when
      used as an image texture is returned in <params>.  This corresponds to
      the value from the /Class/ column in Table 3.22. The possible values
      returned are IMAGE_CLASS_4_X_32, IMAGE_CLASS_2_X_32, IMAGE_CLASS_1_X_32,
      IMAGE_CLASS_4_X_16, IMAGE_CLASS_2_X_16, IMAGE_CLASS_1_X_16,
      IMAGE_CLASS_4_X_8, IMAGE_CLASS_2_X_8, IMAGE_CLASS_1_X_8,
      IMAGE_CLASS_11_11_10, and IMAGE_CLASS_10_10_10_2, which correspond to
      the 4x32, 2x32, 1x32, 4x16, 2x16, 1x16, 4x8, 2x8, 1x8, the class
      (a) 11/11/10 packed floating-point format, and the class (b)
      10/10/10/2 packed formats, respectively.
      If the resource is not supported for image textures, or if image
      textures are not supported, NONE is returned.

    - IMAGE_PIXEL_FORMAT: The pixel format of the resource when used as an
      image texture is returned in <params>.  This is the value
      from the /Pixel format/ column in Table 3.22. If the resource is not
      supported for image textures, or if image textures are not supported,
      NONE is returned.

    - IMAGE_PIXEL_TYPE: The pixel type of the resource when used as an
      image texture is returned in <params>.  This is the value from
      the /Pixel type/ column in Table 3.22. If the resource is not supported
      for image textures, or if image textures are not supported, NONE is
      returned."
---
 src/mesa/main/formatquery.c | 63 ++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 56 insertions(+), 7 deletions(-)

diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c
index 6ed3cc8..04cae06 100644
--- a/src/mesa/main/formatquery.c
+++ b/src/mesa/main/formatquery.c
@@ -1193,21 +1193,70 @@ _mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname,
                                       buffer);
       break;
 
-   case GL_IMAGE_TEXEL_SIZE:
-      /* @TODO */
+   case GL_IMAGE_TEXEL_SIZE: {
+      mesa_format image_format;
+
+      if (!ctx->Extensions.ARB_shader_image_load_store ||
+          target == GL_RENDERBUFFER)
+         goto end;
+
+      image_format = _mesa_get_shader_image_format(internalformat);
+      if (image_format == MESA_FORMAT_NONE)
+         goto end;
+
+      /* We return bits */
+      buffer[0] = (_mesa_get_format_bytes(image_format) * 8);
       break;
+   }
 
    case GL_IMAGE_COMPATIBILITY_CLASS:
-      /* @TODO */
+      if (!ctx->Extensions.ARB_shader_image_load_store ||
+          target == GL_RENDERBUFFER)
+         goto end;
+
+      buffer[0] = _mesa_get_image_format_class(internalformat);
       break;
 
-   case GL_IMAGE_PIXEL_FORMAT:
-      /* @TODO */
+   case GL_IMAGE_PIXEL_FORMAT: {
+      GLint base_format;
+
+      if (!ctx->Extensions.ARB_shader_image_load_store ||
+          target == GL_RENDERBUFFER ||
+          !_mesa_is_shader_image_format_supported(ctx, internalformat))
+         goto end;
+
+      base_format = _mesa_base_tex_format(ctx, internalformat);
+      if (base_format == -1)
+         goto end;
+
+      if (_mesa_is_enum_format_integer(internalformat))
+         buffer[0] = _mesa_base_format_to_integer_format(base_format);
+      else
+         buffer[0] = base_format;
       break;
+   }
 
-   case GL_IMAGE_PIXEL_TYPE:
-      /* @TODO */
+   case GL_IMAGE_PIXEL_TYPE: {
+      mesa_format image_format;
+      GLenum datatype;
+      GLuint comps;
+
+      if (!ctx->Extensions.ARB_shader_image_load_store ||
+          target == GL_RENDERBUFFER)
+         goto end;
+
+      image_format = _mesa_get_shader_image_format(internalformat);
+      if (image_format == MESA_FORMAT_NONE)
+         goto end;
+
+      _mesa_uncompressed_format_to_type_and_comps(image_format, &datatype,
+                                                  &comps);
+      if (!datatype)
+         goto end;
+
+      buffer[0] = datatype;
       break;
+   }
 
    case GL_IMAGE_FORMAT_COMPATIBILITY_TYPE: {
       if (!ctx->Extensions.ARB_shader_image_load_store)
-- 
2.5.3



More information about the mesa-dev mailing list