diff options
author | Antia Puentes <[email protected]> | 2015-11-17 21:29:04 +0100 |
---|---|---|
committer | Eduardo Lima Mitev <[email protected]> | 2016-03-03 15:14:07 +0100 |
commit | 990a7200e091f1d0f79979f9c02fc50a07d6acad (patch) | |
tree | fa6f768da51366a045df6d8a54fa460394ad850c /src | |
parent | 52c3692324675535105f2d5bbdf2c4cd26e76580 (diff) |
mesa/shaderimage: Added func to get the GL_IMAGE_CLASS from the format
It will be used by the ARB_internalformat_query2 implementation to
implement the IMAGE_COMPATIBILITY_CLASS <pname> query.
Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/shaderimage.c | 45 | ||||
-rw-r--r-- | src/mesa/main/shaderimage.h | 6 |
2 files changed, 51 insertions, 0 deletions
diff --git a/src/mesa/main/shaderimage.c b/src/mesa/main/shaderimage.c index a71686d0ec4..fa967a2408a 100644 --- a/src/mesa/main/shaderimage.c +++ b/src/mesa/main/shaderimage.c @@ -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) diff --git a/src/mesa/main/shaderimage.h b/src/mesa/main/shaderimage.h index 794c926d040..85193e104f6 100644 --- a/src/mesa/main/shaderimage.h +++ b/src/mesa/main/shaderimage.h @@ -43,6 +43,12 @@ 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. */ |