diff options
-rw-r--r-- | src/mesa/main/format_pack.c | 18 | ||||
-rw-r--r-- | src/mesa/main/format_unpack.c | 15 | ||||
-rw-r--r-- | src/mesa/main/formats.c | 21 | ||||
-rw-r--r-- | src/mesa/main/formats.h | 3 | ||||
-rw-r--r-- | src/mesa/main/texstore.c | 17 | ||||
-rw-r--r-- | src/mesa/swrast/s_texfetch.c | 6 |
6 files changed, 76 insertions, 4 deletions
diff --git a/src/mesa/main/format_pack.c b/src/mesa/main/format_pack.c index ee505ec80e3..b870001d909 100644 --- a/src/mesa/main/format_pack.c +++ b/src/mesa/main/format_pack.c @@ -1880,6 +1880,20 @@ pack_float_SIGNED_RG1616(const GLfloat src[4], void *dst) *d = (r << 16) | (g & 0xffff); } +/* + * MESA_FORMAT_B8G8R8X8_SRGB + */ + +static void +pack_float_XRGB8888_SRGB(const GLfloat src[4], void *dst) +{ + GLuint *d = (GLuint *) dst; + GLubyte r = linear_float_to_srgb_ubyte(src[RCOMP]); + GLubyte g = linear_float_to_srgb_ubyte(src[GCOMP]); + GLubyte b = linear_float_to_srgb_ubyte(src[BCOMP]); + *d = PACK_COLOR_8888(127, r, g, b); +} + /** * Return a function that can pack a GLubyte rgba[4] color. */ @@ -2034,6 +2048,8 @@ _mesa_get_pack_ubyte_rgba_function(mesa_format format) table[MESA_FORMAT_R10G10B10A2_UNORM] = pack_ubyte_ABGR2101010; + table[MESA_FORMAT_B8G8R8X8_SRGB] = NULL; + initialized = GL_TRUE; } @@ -2197,6 +2213,8 @@ _mesa_get_pack_float_rgba_function(mesa_format format) table[MESA_FORMAT_G8R8_SNORM] = pack_float_SIGNED_RG88; table[MESA_FORMAT_G16R16_SNORM] = pack_float_SIGNED_RG1616; + table[MESA_FORMAT_B8G8R8X8_SRGB] = pack_float_XRGB8888_SRGB; + initialized = GL_TRUE; } diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c index f9c42e768d6..1a0e7271c8d 100644 --- a/src/mesa/main/format_unpack.c +++ b/src/mesa/main/format_unpack.c @@ -2313,6 +2313,19 @@ unpack_SIGNED_RG1616(const void *src, GLfloat dst[][4], GLuint n) } } +static void +unpack_XRGB8888_SRGB(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] = _mesa_nonlinear_to_linear( (s[i] >> 16) & 0xff ); + dst[i][GCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 8) & 0xff ); + dst[i][BCOMP] = _mesa_nonlinear_to_linear( (s[i] ) & 0xff ); + dst[i][ACOMP] = 1.0F; + } +} + /** * Return the unpacker function for the given format. */ @@ -2530,6 +2543,8 @@ get_unpack_rgba_function(mesa_format format) table[MESA_FORMAT_G8R8_SNORM] = unpack_SIGNED_RG88; table[MESA_FORMAT_G16R16_SNORM] = unpack_SIGNED_RG1616; + table[MESA_FORMAT_B8G8R8X8_SRGB] = unpack_XRGB8888_SRGB; + initialized = GL_TRUE; } diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index f6c399ede58..e0b774e3a44 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -1790,6 +1790,15 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] = 0, 0, 0, 0, 0, 1, 1, 4 }, + { + MESA_FORMAT_B8G8R8X8_SRGB, + "MESA_FORMAT_B8G8R8X8_SRGB", + GL_RGB, + GL_UNSIGNED_NORMALIZED, + 8, 8, 8, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, }; @@ -2035,6 +2044,7 @@ _mesa_get_format_color_encoding(mesa_format format) case MESA_FORMAT_ETC2_SRGB8: case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC: case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1: + case MESA_FORMAT_B8G8R8X8_SRGB: return GL_SRGB; default: return GL_LINEAR; @@ -2089,6 +2099,9 @@ _mesa_get_srgb_format_linear(mesa_format format) case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1: format = MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1; break; + case MESA_FORMAT_B8G8R8X8_SRGB: + format = MESA_FORMAT_B8G8R8X8_UNORM; + break; default: break; } @@ -2895,6 +2908,11 @@ _mesa_format_to_type_and_comps(mesa_format format, *comps = 2; return; + case MESA_FORMAT_B8G8R8X8_SRGB: + *datatype = GL_UNSIGNED_BYTE; + *comps = 4; + return; + case MESA_FORMAT_COUNT: assert(0); return; @@ -3448,6 +3466,9 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format, case MESA_FORMAT_G16R16_SNORM: return format == GL_RG && type == GL_SHORT && !littleEndian && !swapBytes; + + case MESA_FORMAT_B8G8R8X8_SRGB: + return GL_FALSE; } return GL_FALSE; diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h index 3102584b6a0..07b84d6fa42 100644 --- a/src/mesa/main/formats.h +++ b/src/mesa/main/formats.h @@ -333,6 +333,7 @@ typedef enum * R10G10B10A2_UNORM * G8R8_SINT * G16R16_SINT + * B8G8R8X8_SRGB * */ /*@{*/ @@ -647,6 +648,8 @@ typedef enum MESA_FORMAT_G8R8_SNORM, /* RRRR RRRR GGGG GGGG */ MESA_FORMAT_G16R16_SNORM, /* RRRR RRRR RRRR RRRR GGGG GGGG GGGG GGGG */ + MESA_FORMAT_B8G8R8X8_SRGB, /* xxxx xxxx RRRR RRRR GGGG GGGG BBBB BBBB */ + MESA_FORMAT_COUNT } mesa_format; diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 3e22a0b46f7..edf7e816727 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -3290,10 +3290,17 @@ _mesa_texstore_sargb8(TEXSTORE_PARAMS) mesa_format newDstFormat; GLboolean k; - ASSERT(dstFormat == MESA_FORMAT_B8G8R8A8_SRGB); - - /* reuse normal rgba texstore code */ - newDstFormat = MESA_FORMAT_B8G8R8A8_UNORM; + switch (dstFormat) { + case MESA_FORMAT_B8G8R8A8_SRGB: + newDstFormat = MESA_FORMAT_B8G8R8A8_UNORM; + break; + case MESA_FORMAT_B8G8R8X8_SRGB: + newDstFormat = MESA_FORMAT_B8G8R8X8_UNORM; + break; + default: + ASSERT(0); + return GL_FALSE; + } k = _mesa_texstore_argb8888(ctx, dims, baseInternalFormat, newDstFormat, @@ -3859,6 +3866,8 @@ _mesa_get_texstore_func(mesa_format format) table[MESA_FORMAT_G8R8_SNORM] = _mesa_texstore_snorm88; table[MESA_FORMAT_G16R16_SNORM] = _mesa_texstore_snorm1616; + table[MESA_FORMAT_B8G8R8X8_SRGB] = _mesa_texstore_sargb8; + initialized = GL_TRUE; } diff --git a/src/mesa/swrast/s_texfetch.c b/src/mesa/swrast/s_texfetch.c index b620748c936..9c173a8b3dd 100644 --- a/src/mesa/swrast/s_texfetch.c +++ b/src/mesa/swrast/s_texfetch.c @@ -1304,6 +1304,12 @@ texfetch_funcs[] = NULL, NULL }, + { + MESA_FORMAT_B8G8R8X8_SRGB, + NULL, + NULL, + NULL + }, }; |