diff options
author | Richard Sandiford <[email protected]> | 2014-07-22 10:51:17 +0100 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2014-09-17 13:17:47 +1000 |
commit | df14091c5857dc398521aaa9ff43bbbaee2d6116 (patch) | |
tree | f4e07d9d59dbb70a1d5e2e999092072d479ab6ab /src/mesa/main | |
parent | 234d194b49f392f9b5d55dc7f8a8b16eb8f07925 (diff) |
mesa: Add MESA_FORMAT_A8L8_{SNORM,SRGB}
The associated UNORM format already existed.
This means that each LnAn format has a reversed counterpart,
which is necessary for handling big-endian mesa<->gallium mappings.
[airlied: rebased onto current master]
Signed-off-by: Richard Sandiford <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
Signed-off-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/format_pack.c | 37 | ||||
-rw-r--r-- | src/mesa/main/format_unpack.c | 29 | ||||
-rw-r--r-- | src/mesa/main/formats.c | 10 | ||||
-rw-r--r-- | src/mesa/main/formats.csv | 2 | ||||
-rw-r--r-- | src/mesa/main/formats.h | 2 | ||||
-rw-r--r-- | src/mesa/main/texformat.c | 3 |
6 files changed, 83 insertions, 0 deletions
diff --git a/src/mesa/main/format_pack.c b/src/mesa/main/format_pack.c index 6bf174a81f7..8fc6043a6d5 100644 --- a/src/mesa/main/format_pack.c +++ b/src/mesa/main/format_pack.c @@ -1129,6 +1129,16 @@ pack_ubyte_L8A8_SRGB(const GLubyte src[4], void *dst) *d = PACK_COLOR_88(src[ACOMP], l); } +/* MESA_FORMAT_A8L8_SRGB */ + +static void +pack_ubyte_A8L8_SRGB(const GLubyte src[4], void *dst) +{ + GLushort *d = ((GLushort *) dst); + GLubyte l = util_format_linear_to_srgb_8unorm(src[RCOMP]); + *d = PACK_COLOR_88(l, src[ACOMP]); +} + static void pack_float_L8A8_SRGB(const GLfloat src[4], void *dst) { @@ -1138,6 +1148,15 @@ pack_float_L8A8_SRGB(const GLfloat src[4], void *dst) *d = PACK_COLOR_88(a, l); } +static void +pack_float_A8L8_SRGB(const GLfloat src[4], void *dst) +{ + GLushort *d = ((GLushort *) dst); + GLubyte a, l = util_format_linear_float_to_srgb_8unorm(src[RCOMP]); + CLAMPED_FLOAT_TO_UBYTE(a, src[ACOMP]); + *d = PACK_COLOR_88(l, a); +} + /* MESA_FORMAT_RGBA_FLOAT32 */ @@ -1563,6 +1582,20 @@ pack_float_L8A8_SNORM(const GLfloat src[4], void *dst) /* + * MESA_FORMAT_A8L8_SNORM + */ + +static void +pack_float_A8L8_SNORM(const GLfloat src[4], void *dst) +{ + GLushort *d = (GLushort *) dst; + GLbyte l = FLOAT_TO_BYTE(CLAMP(src[RCOMP], -1.0f, 1.0f)); + GLbyte a = FLOAT_TO_BYTE(CLAMP(src[ACOMP], -1.0f, 1.0f)); + *d = (l << 8) | a; +} + + +/* * MESA_FORMAT_A_SNORM16 */ @@ -1936,6 +1969,7 @@ _mesa_get_pack_ubyte_rgba_function(mesa_format format) table[MESA_FORMAT_R8G8B8A8_SRGB] = pack_ubyte_R8G8B8A8_SRGB; table[MESA_FORMAT_L_SRGB8] = pack_ubyte_L_SRGB8; table[MESA_FORMAT_L8A8_SRGB] = pack_ubyte_L8A8_SRGB; + table[MESA_FORMAT_A8L8_SRGB] = pack_ubyte_A8L8_SRGB; /* n/a */ table[MESA_FORMAT_SRGB_DXT1] = NULL; /* pack_ubyte_SRGB_DXT1; */ table[MESA_FORMAT_SRGBA_DXT1] = NULL; /* pack_ubyte_SRGBA_DXT1; */ @@ -1989,6 +2023,7 @@ _mesa_get_pack_ubyte_rgba_function(mesa_format format) table[MESA_FORMAT_A_SNORM8] = NULL; table[MESA_FORMAT_L_SNORM8] = NULL; table[MESA_FORMAT_L8A8_SNORM] = NULL; + table[MESA_FORMAT_A8L8_SNORM] = NULL; table[MESA_FORMAT_I_SNORM8] = NULL; table[MESA_FORMAT_A_SNORM16] = NULL; table[MESA_FORMAT_L_SNORM16] = NULL; @@ -2099,6 +2134,7 @@ _mesa_get_pack_float_rgba_function(mesa_format format) table[MESA_FORMAT_R8G8B8A8_SRGB] = pack_float_R8G8B8A8_SRGB; table[MESA_FORMAT_L_SRGB8] = pack_float_L_SRGB8; table[MESA_FORMAT_L8A8_SRGB] = pack_float_L8A8_SRGB; + table[MESA_FORMAT_A8L8_SRGB] = pack_float_A8L8_SRGB; /* n/a */ table[MESA_FORMAT_SRGB_DXT1] = NULL; @@ -2153,6 +2189,7 @@ _mesa_get_pack_float_rgba_function(mesa_format format) table[MESA_FORMAT_A_SNORM8] = pack_float_A_SNORM8; table[MESA_FORMAT_L_SNORM8] = pack_float_L_SNORM8; table[MESA_FORMAT_L8A8_SNORM] = pack_float_L8A8_SNORM; + table[MESA_FORMAT_A8L8_SNORM] = pack_float_A8L8_SNORM; table[MESA_FORMAT_I_SNORM8] = pack_float_L_SNORM8; /* reused */ table[MESA_FORMAT_A_SNORM16] = pack_float_A_SNORM16; table[MESA_FORMAT_L_SNORM16] = pack_float_L_SNORM16; diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c index 032efe2d7f3..cfa6a60becc 100644 --- a/src/mesa/main/format_unpack.c +++ b/src/mesa/main/format_unpack.c @@ -809,6 +809,19 @@ unpack_L8A8_SRGB(const void *src, GLfloat dst[][4], GLuint n) } static void +unpack_A8L8_SRGB(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] = + dst[i][GCOMP] = + dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float(s[i] >> 8); + dst[i][ACOMP] = UBYTE_TO_FLOAT(s[i] & 0xff); /* linear! */ + } +} + +static void unpack_SRGB_DXT1(const void *src, GLfloat dst[][4], GLuint n) { } @@ -1965,6 +1978,20 @@ unpack_L8A8_SNORM(const void *src, GLfloat dst[][4], GLuint n) } } + +static void +unpack_A8L8_SNORM(const void *src, GLfloat dst[][4], GLuint n) +{ + const GLshort *s = ((const GLshort *) src); + GLuint i; + for (i = 0; i < n; i++) { + dst[i][RCOMP] = + dst[i][GCOMP] = + dst[i][BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s[i] >> 8) ); + dst[i][ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s[i] & 0xff) ); + } +} + static void unpack_I_SNORM8(const void *src, GLfloat dst[][4], GLuint n) { @@ -2364,6 +2391,7 @@ get_unpack_rgba_function(mesa_format format) table[MESA_FORMAT_R8G8B8A8_SRGB] = unpack_R8G8B8A8_SRGB; table[MESA_FORMAT_L_SRGB8] = unpack_L_SRGB8; table[MESA_FORMAT_L8A8_SRGB] = unpack_L8A8_SRGB; + table[MESA_FORMAT_A8L8_SRGB] = unpack_A8L8_SRGB; table[MESA_FORMAT_SRGB_DXT1] = unpack_SRGB_DXT1; table[MESA_FORMAT_SRGBA_DXT1] = unpack_SRGBA_DXT1; table[MESA_FORMAT_SRGBA_DXT3] = unpack_SRGBA_DXT3; @@ -2483,6 +2511,7 @@ get_unpack_rgba_function(mesa_format format) table[MESA_FORMAT_A_SNORM8] = unpack_A_SNORM8; table[MESA_FORMAT_L_SNORM8] = unpack_L_SNORM8; table[MESA_FORMAT_L8A8_SNORM] = unpack_L8A8_SNORM; + table[MESA_FORMAT_A8L8_SNORM] = unpack_A8L8_SNORM; table[MESA_FORMAT_I_SNORM8] = unpack_I_SNORM8; table[MESA_FORMAT_A_SNORM16] = unpack_A_SNORM16; table[MESA_FORMAT_L_SNORM16] = unpack_L_SNORM16; diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index db22a45c46d..8fd36a08209 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -360,6 +360,7 @@ _mesa_get_format_color_encoding(mesa_format format) case MESA_FORMAT_R8G8B8A8_SRGB: case MESA_FORMAT_L_SRGB8: case MESA_FORMAT_L8A8_SRGB: + case MESA_FORMAT_A8L8_SRGB: case MESA_FORMAT_SRGB_DXT1: case MESA_FORMAT_SRGBA_DXT1: case MESA_FORMAT_SRGBA_DXT3: @@ -428,6 +429,9 @@ _mesa_get_srgb_format_linear(mesa_format format) case MESA_FORMAT_L8A8_SRGB: format = MESA_FORMAT_L8A8_UNORM; break; + case MESA_FORMAT_A8L8_SRGB: + format = MESA_FORMAT_A8L8_UNORM; + break; case MESA_FORMAT_SRGB_DXT1: format = MESA_FORMAT_RGB_DXT1; break; @@ -919,6 +923,7 @@ _mesa_format_to_type_and_comps(mesa_format format, return; case MESA_FORMAT_R8G8_SNORM: case MESA_FORMAT_L8A8_SNORM: + case MESA_FORMAT_A8L8_SNORM: *datatype = GL_BYTE; *comps = 2; return; @@ -970,6 +975,7 @@ _mesa_format_to_type_and_comps(mesa_format format, *comps = 1; return; case MESA_FORMAT_L8A8_SRGB: + case MESA_FORMAT_A8L8_SRGB: *datatype = GL_UNSIGNED_BYTE; *comps = 2; return; @@ -1475,6 +1481,7 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format, case MESA_FORMAT_L8A8_SRGB: return format == GL_LUMINANCE_ALPHA && type == GL_UNSIGNED_BYTE && littleEndian; case MESA_FORMAT_A8L8_UNORM: + case MESA_FORMAT_A8L8_SRGB: return GL_FALSE; case MESA_FORMAT_L16A16_UNORM: @@ -1797,6 +1804,9 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format, case MESA_FORMAT_L8A8_SNORM: return format == GL_LUMINANCE_ALPHA && type == GL_BYTE && littleEndian && !swapBytes; + case MESA_FORMAT_A8L8_SNORM: + return format == GL_LUMINANCE_ALPHA && type == GL_BYTE && + !littleEndian && !swapBytes; case MESA_FORMAT_I_SNORM8: return format == GL_RED && type == GL_BYTE; case MESA_FORMAT_A_SNORM16: diff --git a/src/mesa/main/formats.csv b/src/mesa/main/formats.csv index 4d542b7c6eb..b4d16deb9d2 100644 --- a/src/mesa/main/formats.csv +++ b/src/mesa/main/formats.csv @@ -119,6 +119,7 @@ MESA_FORMAT_G16R16_SNORM , packed, 1, 1, sn16, sn16, , MESA_FORMAT_R8G8_SNORM , packed, 1, 1, sn8 , sn8 , , , xy01, rgb MESA_FORMAT_G8R8_SNORM , packed, 1, 1, sn8 , sn8 , , , yx01, rgb MESA_FORMAT_L8A8_SNORM , packed, 1, 1, sn8 , sn8 , , , xxxy, rgb +MESA_FORMAT_A8L8_SNORM , packed, 1, 1, sn8 , sn8 , , , yyyx, rgb # Array signed/normalized formats MESA_FORMAT_A_SNORM8 , array , 1, 1, sn8 , , , , 000x, rgb @@ -141,6 +142,7 @@ MESA_FORMAT_B8G8R8X8_SRGB , packed, 1, 1, un8 , un8 , un8 , x8 MESA_FORMAT_R8G8B8A8_SRGB , packed, 1, 1, un8 , un8 , un8 , un8 , xyzw, srgb MESA_FORMAT_R8G8B8X8_SRGB , packed, 1, 1, un8 , un8 , un8 , x8 , xyz1, srgb MESA_FORMAT_L8A8_SRGB , packed, 1, 1, un8 , un8 , , , xxxy, srgb +MESA_FORMAT_A8L8_SRGB , packed, 1, 1, un8 , un8 , , , yyyx, srgb # Array sRGB formats MESA_FORMAT_L_SRGB8 , array , 1, 1, un8 , , , , xxx1, srgb diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h index d6253bf862f..86717380e90 100644 --- a/src/mesa/main/formats.h +++ b/src/mesa/main/formats.h @@ -265,6 +265,7 @@ typedef enum MESA_FORMAT_R8G8_SNORM, /* GGGG GGGG RRRR RRRR */ MESA_FORMAT_G8R8_SNORM, /* RRRR RRRR GGGG GGGG */ MESA_FORMAT_L8A8_SNORM, /* AAAA AAAA LLLL LLLL */ + MESA_FORMAT_A8L8_SNORM, /* LLLL LLLL AAAA AAAA */ /* Array signed/normalized formats */ MESA_FORMAT_A_SNORM8, /* byte[i] = A */ @@ -287,6 +288,7 @@ typedef enum MESA_FORMAT_R8G8B8A8_SRGB, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */ MESA_FORMAT_R8G8B8X8_SRGB, /* xxxx xxxx BBBB BBBB GGGG GGGG RRRR RRRR */ MESA_FORMAT_L8A8_SRGB, /* AAAA AAAA LLLL LLLL */ + MESA_FORMAT_A8L8_SRGB, /* LLLL LLLL AAAA AAAA */ /* Array sRGB formats */ MESA_FORMAT_L_SRGB8, /* ubyte[i] = L */ diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c index 6d3b8055661..09e307c08f0 100644 --- a/src/mesa/main/texformat.c +++ b/src/mesa/main/texformat.c @@ -485,6 +485,7 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target, case GL_LUMINANCE_ALPHA_SNORM: case GL_LUMINANCE8_ALPHA8_SNORM: RETURN_IF_SUPPORTED(MESA_FORMAT_L8A8_SNORM); + RETURN_IF_SUPPORTED(MESA_FORMAT_A8L8_SNORM); RETURN_IF_SUPPORTED(MESA_FORMAT_A8B8G8R8_SNORM); RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8A8_SNORM); break; @@ -555,6 +556,7 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target, case GL_SLUMINANCE_ALPHA_EXT: case GL_SLUMINANCE8_ALPHA8_EXT: RETURN_IF_SUPPORTED(MESA_FORMAT_L8A8_SRGB); + RETURN_IF_SUPPORTED(MESA_FORMAT_A8L8_SRGB); RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB); break; case GL_COMPRESSED_SLUMINANCE_EXT: @@ -563,6 +565,7 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target, break; case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT: RETURN_IF_SUPPORTED(MESA_FORMAT_L8A8_SRGB); + RETURN_IF_SUPPORTED(MESA_FORMAT_A8L8_SRGB); RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB); break; case GL_COMPRESSED_SRGB_EXT: |