[Mesa-dev] [PATCH 48/65] mesa/formatquery: Added queries related to image textures
Eduardo Lima Mitev
elima at igalia.com
Wed Feb 3 15:45:33 UTC 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 57f23f4..f25bcec 100644
--- a/src/mesa/main/formatquery.c
+++ b/src/mesa/main/formatquery.c
@@ -1199,21 +1199,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 (!_mesa_has_ARB_shader_image_load_store(ctx) ||
+ 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 (!_mesa_has_ARB_shader_image_load_store(ctx) ||
+ 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 (!_mesa_has_ARB_shader_image_load_store(ctx) ||
+ 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 (!_mesa_has_ARB_shader_image_load_store(ctx) ||
+ 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 (!_mesa_has_ARB_shader_image_load_store(ctx))
--
2.5.3
More information about the mesa-dev
mailing list