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/texstore.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/texstore.c')
-rw-r--r-- | src/mesa/main/texstore.c | 61 |
1 files changed, 46 insertions, 15 deletions
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 1534583af82..8eaf43a6a90 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -2191,6 +2191,7 @@ _mesa_texstore_snorm88(TEXSTORE_PARAMS) const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_SIGNED_AL88 || + dstFormat == MESA_FORMAT_SIGNED_RG88 || dstFormat == MESA_FORMAT_SIGNED_RG88_REV); ASSERT(_mesa_get_format_bytes(dstFormat) == 2); @@ -2210,13 +2211,27 @@ _mesa_texstore_snorm88(TEXSTORE_PARAMS) for (img = 0; img < srcDepth; img++) { GLbyte *dstRow = (GLbyte *) dstSlices[img]; for (row = 0; row < srcHeight; row++) { - GLbyte *dst = dstRow; - for (col = 0; col < srcWidth; col++) { - dst[0] = FLOAT_TO_BYTE_TEX(src[0]); - dst[1] = FLOAT_TO_BYTE_TEX(src[1]); - src += 2; - dst += 2; + GLushort *dst = (GLushort *) dstRow; + + if (dstFormat == MESA_FORMAT_SIGNED_AL88 || + dstFormat == MESA_FORMAT_SIGNED_RG88_REV) { + for (col = 0; col < srcWidth; col++) { + GLubyte l = FLOAT_TO_BYTE_TEX(src[0]); + GLubyte a = FLOAT_TO_BYTE_TEX(src[1]); + + dst[col] = PACK_COLOR_88_REV(l, a); + src += 2; + } + } else { + for (col = 0; col < srcWidth; col++) { + GLubyte l = FLOAT_TO_BYTE_TEX(src[0]); + GLubyte a = FLOAT_TO_BYTE_TEX(src[1]); + + dst[col] = PACK_COLOR_88(l, a); + src += 2; + } } + dstRow += dstRowStride; } } @@ -2278,6 +2293,7 @@ _mesa_texstore_snorm1616(TEXSTORE_PARAMS) const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_SIGNED_AL1616 || + dstFormat == MESA_FORMAT_SIGNED_RG1616 || dstFormat == MESA_FORMAT_SIGNED_GR1616); ASSERT(_mesa_get_format_bytes(dstFormat) == 4); @@ -2297,17 +2313,29 @@ _mesa_texstore_snorm1616(TEXSTORE_PARAMS) for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { - GLshort *dst = (GLshort *) dstRow; - for (col = 0; col < srcWidth; col++) { - GLushort l, a; + GLuint *dst = (GLuint *) dstRow; - UNCLAMPED_FLOAT_TO_SHORT(l, src[0]); - UNCLAMPED_FLOAT_TO_SHORT(a, src[1]); - dst[0] = l; - dst[1] = a; - src += 2; - dst += 2; + if (dstFormat == MESA_FORMAT_SIGNED_AL1616 || + dstFormat == MESA_FORMAT_SIGNED_GR1616) { + for (col = 0; col < srcWidth; col++) { + GLushort l, a; + + UNCLAMPED_FLOAT_TO_SHORT(l, src[0]); + UNCLAMPED_FLOAT_TO_SHORT(a, src[1]); + dst[col] = PACK_COLOR_1616_REV(l, a); + src += 2; + } + } else { + for (col = 0; col < srcWidth; col++) { + GLushort l, a; + + UNCLAMPED_FLOAT_TO_SHORT(l, src[0]); + UNCLAMPED_FLOAT_TO_SHORT(a, src[1]); + dst[col] = PACK_COLOR_1616_REV(l, a); + src += 2; + } } + dstRow += dstRowStride; } } @@ -3828,6 +3856,9 @@ _mesa_get_texstore_func(gl_format format) table[MESA_FORMAT_ABGR2101010] = _mesa_texstore_abgr2101010; + table[MESA_FORMAT_SIGNED_RG88] = _mesa_texstore_snorm88; + table[MESA_FORMAT_SIGNED_RG1616] = _mesa_texstore_snorm1616; + initialized = GL_TRUE; } |