diff options
-rw-r--r-- | src/mesa/main/format_pack.c | 28 | ||||
-rw-r--r-- | src/mesa/main/format_unpack.c | 29 | ||||
-rw-r--r-- | src/mesa/main/formats.c | 35 | ||||
-rw-r--r-- | src/mesa/main/formats.h | 3 | ||||
-rw-r--r-- | src/mesa/main/texstore.c | 61 | ||||
-rw-r--r-- | src/mesa/swrast/s_texfetch.c | 12 |
6 files changed, 153 insertions, 15 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; } diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c index fa559300d03..28a50f31ee4 100644 --- a/src/mesa/main/format_unpack.c +++ b/src/mesa/main/format_unpack.c @@ -2281,6 +2281,32 @@ unpack_ABGR2101010(const void *src, GLfloat dst[][4], GLuint n) } } +static void +unpack_SIGNED_RG88(const void *src, GLfloat dst[][4], GLuint n) +{ + const GLushort *s = ((const GLushort *) src); + GLuint i; + for (i = 0; i < n; i++) { + dst[i][RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s[i] >> 8) ); + dst[i][GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s[i] & 0xff) ); + dst[i][BCOMP] = 0.0F; + dst[i][ACOMP] = 1.0F; + } +} + +static void +unpack_SIGNED_RG1616(const void *src, GLfloat dst[][4], GLuint n) +{ + const GLuint *s = ((const GLuint *) src); + GLuint i; + for (i = 0; i < n; i++) { + dst[i][RCOMP] = SHORT_TO_FLOAT_TEX( (GLshort) (s[i] >> 16) ); + dst[i][GCOMP] = SHORT_TO_FLOAT_TEX( (GLshort) (s[i] & 0xffff) ); + dst[i][BCOMP] = 0.0F; + dst[i][ACOMP] = 1.0F; + } +} + /** * Return the unpacker function for the given format. */ @@ -2495,6 +2521,9 @@ get_unpack_rgba_function(gl_format format) table[MESA_FORMAT_ABGR2101010] = unpack_ABGR2101010; + table[MESA_FORMAT_SIGNED_RG88] = unpack_SIGNED_RG88; + table[MESA_FORMAT_SIGNED_RG1616] = unpack_SIGNED_RG1616; + initialized = GL_TRUE; } diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index 0da0dfa8ce9..1246c4d9265 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -1772,6 +1772,24 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] = 0, 0, 0, 0, 0, 1, 1, 4 }, + { + MESA_FORMAT_SIGNED_RG88, + "MESA_FORMAT_SIGNED_RG88", + GL_RG, + GL_SIGNED_NORMALIZED, + 8, 8, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_SIGNED_RG1616, + "MESA_FORMAT_SIGNED_RG1616", + GL_RG, + GL_SIGNED_NORMALIZED, + 16, 16, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, }; @@ -2855,6 +2873,16 @@ _mesa_format_to_type_and_comps(gl_format format, *comps = 4; return; + case MESA_FORMAT_SIGNED_RG88: + *datatype = GL_BYTE; + *comps = 2; + return; + + case MESA_FORMAT_SIGNED_RG1616: + *datatype = GL_SHORT; + *comps = 2; + return; + case MESA_FORMAT_COUNT: assert(0); return; @@ -3401,6 +3429,13 @@ _mesa_format_matches_format_and_type(gl_format gl_format, return format == GL_RGBA && type == GL_UNSIGNED_INT_2_10_10_10_REV && !swapBytes; + case MESA_FORMAT_SIGNED_RG88: + return format == GL_RG && type == GL_BYTE && !littleEndian && + !swapBytes; + + case MESA_FORMAT_SIGNED_RG1616: + return format == GL_RG && type == GL_SHORT && !littleEndian && + !swapBytes; } return GL_FALSE; diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h index f96c18aa4f3..a1f0d226a59 100644 --- a/src/mesa/main/formats.h +++ b/src/mesa/main/formats.h @@ -306,6 +306,9 @@ typedef enum MESA_FORMAT_ABGR2101010, + MESA_FORMAT_SIGNED_RG88, + MESA_FORMAT_SIGNED_RG1616, + MESA_FORMAT_COUNT } gl_format; 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; } diff --git a/src/mesa/swrast/s_texfetch.c b/src/mesa/swrast/s_texfetch.c index 67b3cf7c457..b886e6586a0 100644 --- a/src/mesa/swrast/s_texfetch.c +++ b/src/mesa/swrast/s_texfetch.c @@ -1292,6 +1292,18 @@ texfetch_funcs[] = NULL, NULL }, + { + MESA_FORMAT_SIGNED_RG88, + NULL, + NULL, + NULL + }, + { + MESA_FORMAT_SIGNED_RG1616, + NULL, + NULL, + NULL + }, }; |