diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/format_pack.c | 27 | ||||
-rw-r--r-- | src/mesa/main/format_unpack.c | 14 | ||||
-rw-r--r-- | src/mesa/main/formats.c | 15 | ||||
-rw-r--r-- | src/mesa/main/formats.h | 1 | ||||
-rw-r--r-- | src/mesa/main/texstore.c | 3 | ||||
-rw-r--r-- | src/mesa/swrast/s_texfetch.c | 6 | ||||
-rw-r--r-- | src/mesa/swrast/s_texfetch_tmp.h | 13 |
7 files changed, 79 insertions, 0 deletions
diff --git a/src/mesa/main/format_pack.c b/src/mesa/main/format_pack.c index 89958f79ff5..acab6cb8d00 100644 --- a/src/mesa/main/format_pack.c +++ b/src/mesa/main/format_pack.c @@ -1108,6 +1108,31 @@ pack_float_SARGB8(const GLfloat src[4], void *dst) } +/* MESA_FORMAT_R8G8B8A8_SRGB */ + +static void +pack_ubyte_SABGR8(const GLubyte src[4], void *dst) +{ + GLuint *d = ((GLuint *) dst); + GLubyte r = linear_ubyte_to_srgb_ubyte(src[RCOMP]); + GLubyte g = linear_ubyte_to_srgb_ubyte(src[GCOMP]); + GLubyte b = linear_ubyte_to_srgb_ubyte(src[BCOMP]); + *d = PACK_COLOR_8888(src[ACOMP], b, g, r); +} + +static void +pack_float_SABGR8(const GLfloat src[4], void *dst) +{ + GLuint *d = ((GLuint *) dst); + GLubyte r, g, b, a; + r = linear_float_to_srgb_ubyte(src[RCOMP]); + g = linear_float_to_srgb_ubyte(src[GCOMP]); + b = linear_float_to_srgb_ubyte(src[BCOMP]); + UNCLAMPED_FLOAT_TO_UBYTE(a, src[ACOMP]); + *d = PACK_COLOR_8888(a, b, g, r); +} + + /* MESA_FORMAT_L_SRGB8 */ static void @@ -1961,6 +1986,7 @@ _mesa_get_pack_ubyte_rgba_function(mesa_format format) table[MESA_FORMAT_BGR_SRGB8] = pack_ubyte_SRGB8; table[MESA_FORMAT_A8B8G8R8_SRGB] = pack_ubyte_SRGBA8; table[MESA_FORMAT_B8G8R8A8_SRGB] = pack_ubyte_SARGB8; + table[MESA_FORMAT_R8G8B8A8_SRGB] = pack_ubyte_SABGR8; table[MESA_FORMAT_L_SRGB8] = pack_ubyte_SL8; table[MESA_FORMAT_L8A8_SRGB] = pack_ubyte_SLA8; /* n/a */ @@ -2125,6 +2151,7 @@ _mesa_get_pack_float_rgba_function(mesa_format format) table[MESA_FORMAT_BGR_SRGB8] = pack_float_SRGB8; table[MESA_FORMAT_A8B8G8R8_SRGB] = pack_float_SRGBA8; table[MESA_FORMAT_B8G8R8A8_SRGB] = pack_float_SARGB8; + table[MESA_FORMAT_R8G8B8A8_SRGB] = pack_float_SABGR8; table[MESA_FORMAT_L_SRGB8] = pack_float_SL8; table[MESA_FORMAT_L8A8_SRGB] = pack_float_SLA8; diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c index 1a0e7271c8d..2348ef60583 100644 --- a/src/mesa/main/format_unpack.c +++ b/src/mesa/main/format_unpack.c @@ -797,6 +797,19 @@ unpack_SARGB8(const void *src, GLfloat dst[][4], GLuint n) } static void +unpack_SABGR8(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] ) & 0xff ); + dst[i][GCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 8) & 0xff ); + dst[i][BCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 16) & 0xff ); + dst[i][ACOMP] = UBYTE_TO_FLOAT( s[i] >> 24 ); /* linear! */ + } +} + +static void unpack_SL8(const void *src, GLfloat dst[][4], GLuint n) { const GLubyte *s = ((const GLubyte *) src); @@ -2388,6 +2401,7 @@ get_unpack_rgba_function(mesa_format format) table[MESA_FORMAT_BGR_SRGB8] = unpack_SRGB8; table[MESA_FORMAT_A8B8G8R8_SRGB] = unpack_SRGBA8; table[MESA_FORMAT_B8G8R8A8_SRGB] = unpack_SARGB8; + table[MESA_FORMAT_R8G8B8A8_SRGB] = unpack_SABGR8; table[MESA_FORMAT_L_SRGB8] = unpack_SL8; table[MESA_FORMAT_L8A8_SRGB] = unpack_SLA8; table[MESA_FORMAT_SRGB_DXT1] = unpack_SRGB_DXT1; diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index e0b774e3a44..0cf97fa316b 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -520,6 +520,15 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] = 1, 1, 4 }, { + MESA_FORMAT_R8G8B8A8_SRGB, + "MESA_FORMAT_R8G8B8A8_SRGB", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { MESA_FORMAT_L_SRGB8, "MESA_FORMAT_L_SRGB8", GL_LUMINANCE, @@ -2034,6 +2043,7 @@ _mesa_get_format_color_encoding(mesa_format format) case MESA_FORMAT_BGR_SRGB8: case MESA_FORMAT_A8B8G8R8_SRGB: case MESA_FORMAT_B8G8R8A8_SRGB: + case MESA_FORMAT_R8G8B8A8_SRGB: case MESA_FORMAT_L_SRGB8: case MESA_FORMAT_L8A8_SRGB: case MESA_FORMAT_SRGB_DXT1: @@ -2069,6 +2079,9 @@ _mesa_get_srgb_format_linear(mesa_format format) case MESA_FORMAT_B8G8R8A8_SRGB: format = MESA_FORMAT_B8G8R8A8_UNORM; break; + case MESA_FORMAT_R8G8B8A8_SRGB: + format = MESA_FORMAT_R8G8B8A8_UNORM; + break; case MESA_FORMAT_L_SRGB8: format = MESA_FORMAT_L_UNORM8; break; @@ -2576,6 +2589,7 @@ _mesa_format_to_type_and_comps(mesa_format format, return; case MESA_FORMAT_A8B8G8R8_SRGB: case MESA_FORMAT_B8G8R8A8_SRGB: + case MESA_FORMAT_R8G8B8A8_SRGB: *datatype = GL_UNSIGNED_BYTE; *comps = 4; return; @@ -2985,6 +2999,7 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format, return GL_FALSE; case MESA_FORMAT_R8G8B8A8_UNORM: + case MESA_FORMAT_R8G8B8A8_SRGB: if (format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8_REV && !swapBytes) return GL_TRUE; diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h index 07b84d6fa42..a12fe4f087a 100644 --- a/src/mesa/main/formats.h +++ b/src/mesa/main/formats.h @@ -419,6 +419,7 @@ typedef enum /* Type P formats */ MESA_FORMAT_A8B8G8R8_SRGB, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */ MESA_FORMAT_B8G8R8A8_SRGB, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */ + MESA_FORMAT_R8G8B8A8_SRGB, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */ /* Type A format(s) */ MESA_FORMAT_L_SRGB8, /* uchar[i] = L */ diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index edf7e816727..557703d015d 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -3294,6 +3294,9 @@ _mesa_texstore_sargb8(TEXSTORE_PARAMS) case MESA_FORMAT_B8G8R8A8_SRGB: newDstFormat = MESA_FORMAT_B8G8R8A8_UNORM; break; + case MESA_FORMAT_R8G8B8A8_SRGB: + newDstFormat = MESA_FORMAT_R8G8B8A8_UNORM; + break; case MESA_FORMAT_B8G8R8X8_SRGB: newDstFormat = MESA_FORMAT_B8G8R8X8_UNORM; break; diff --git a/src/mesa/swrast/s_texfetch.c b/src/mesa/swrast/s_texfetch.c index 9c173a8b3dd..8ba75348ff7 100644 --- a/src/mesa/swrast/s_texfetch.c +++ b/src/mesa/swrast/s_texfetch.c @@ -437,6 +437,12 @@ texfetch_funcs[] = fetch_texel_3d_sargb8 }, { + MESA_FORMAT_R8G8B8A8_SRGB, + fetch_texel_1d_sabgr8, + fetch_texel_2d_sabgr8, + fetch_texel_3d_sabgr8 + }, + { MESA_FORMAT_L_SRGB8, fetch_texel_1d_sl8, fetch_texel_2d_sl8, diff --git a/src/mesa/swrast/s_texfetch_tmp.h b/src/mesa/swrast/s_texfetch_tmp.h index 1db3adc7114..8821125a0e1 100644 --- a/src/mesa/swrast/s_texfetch_tmp.h +++ b/src/mesa/swrast/s_texfetch_tmp.h @@ -1015,6 +1015,19 @@ static void FETCH(sargb8)(const struct swrast_texture_image *texImage, +/* Fetch texel from 1D, 2D or 3D sabgr8 texture, return 4 GLfloats */ +static void FETCH(sabgr8)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + texel[RCOMP] = nonlinear_to_linear( (s ) & 0xff ); + texel[GCOMP] = nonlinear_to_linear( (s >> 8) & 0xff ); + texel[BCOMP] = nonlinear_to_linear( (s >> 16) & 0xff ); + texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); /* linear! */ +} + + + /* Fetch texel from 1D, 2D or 3D sl8 texture, return 4 GLfloats */ static void FETCH(sl8)(const struct swrast_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ) |