diff options
author | Francisco Jerez <[email protected]> | 2013-11-22 19:49:58 -0800 |
---|---|---|
committer | Francisco Jerez <[email protected]> | 2014-01-15 16:42:07 +0100 |
commit | 7510c10209d95458ededf01234b644bf2020d768 (patch) | |
tree | 817d5a1b7d5cde0579746a2a081a0d10b2f8820f /src/mesa/main/format_pack.c | |
parent | 87942749a327725014b0d160b3e48d6d83723ac2 (diff) |
mesa: Add MESA_FORMAT_SIGNED_RG88 and _RG1616.
Including pack/unpack and texstore code. ARB_shader_image_load_store
requires support for the GL_RG8_SNORM and GL_RG16_SNORM formats, which
map to MESA_FORMAT_SIGNED_GR88 and MESA_FORMAT_SIGNED_GR1616 on
little-endian hosts, and MESA_FORMAT_SIGNED_RG88 and
MESA_FORMAT_SIGNED_RG1616 respectively on big-endian hosts -- only the
former were already present, add support for the latter.
Acked-by: Chris Forbes <[email protected]>
Reviewed-by: Paul Berry <[email protected]>
Diffstat (limited to 'src/mesa/main/format_pack.c')
-rw-r--r-- | src/mesa/main/format_pack.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/mesa/main/format_pack.c b/src/mesa/main/format_pack.c index 9b6929d4486..41f5f99c180 100644 --- a/src/mesa/main/format_pack.c +++ b/src/mesa/main/format_pack.c @@ -1849,6 +1849,31 @@ pack_float_ABGR2101010(const GLfloat src[4], void *dst) *d = PACK_COLOR_2101010_US(a, b, g, r); } +/* + * MESA_FORMAT_SIGNED_RG88 + */ + +static void +pack_float_SIGNED_RG88(const GLfloat src[4], void *dst) +{ + GLushort *d = (GLushort *) dst; + GLbyte r = FLOAT_TO_BYTE(CLAMP(src[RCOMP], -1.0f, 1.0f)); + GLbyte g = FLOAT_TO_BYTE(CLAMP(src[GCOMP], -1.0f, 1.0f)); + *d = (r << 8) | (g & 0xff); +} + +/* + * MESA_FORMAT_SIGNED_RG1616 + */ + +static void +pack_float_SIGNED_RG1616(const GLfloat src[4], void *dst) +{ + GLuint *d = (GLuint *) dst; + GLshort r = FLOAT_TO_SHORT(CLAMP(src[RCOMP], -1.0f, 1.0f)); + GLshort g = FLOAT_TO_SHORT(CLAMP(src[GCOMP], -1.0f, 1.0f)); + *d = (r << 16) | (g & 0xffff); +} /** * Return a function that can pack a GLubyte rgba[4] color. @@ -2165,6 +2190,9 @@ _mesa_get_pack_float_rgba_function(gl_format format) table[MESA_FORMAT_ABGR2101010] = pack_float_ABGR2101010; + table[MESA_FORMAT_SIGNED_RG88] = pack_float_SIGNED_RG88; + table[MESA_FORMAT_SIGNED_RG1616] = pack_float_SIGNED_RG1616; + initialized = GL_TRUE; } |