diff options
author | Antia Puentes <[email protected]> | 2015-12-19 19:50:25 +0100 |
---|---|---|
committer | Eduardo Lima Mitev <[email protected]> | 2016-03-03 15:14:07 +0100 |
commit | bd45fb3de4d067c014084affef76095ba74091d9 (patch) | |
tree | 4a3c744ae53859b4a77e49c549b8c8cfa62d6452 /src | |
parent | 990a7200e091f1d0f79979f9c02fc50a07d6acad (diff) |
mesa/formatquery: Added queries related to image textures
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."
Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/formatquery.c | 63 |
1 files changed, 56 insertions, 7 deletions
diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c index f487f32e7f5..289f133114d 100644 --- a/src/mesa/main/formatquery.c +++ b/src/mesa/main/formatquery.c @@ -1220,21 +1220,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)) |