[Mesa-dev] [PATCH v2 6/7] mesa: Add MESA_FORMAT_{A8R8G8B8, X8R8G8B8, X8B8G8R8}_SRGB
Richard Sandiford
rsandifo at linux.vnet.ibm.com
Tue Jul 22 03:02:10 PDT 2014
This means that each 8888 SRGB format has a reversed counterpart,
which is necessary for handling big-endian mesa<->gallium mappings.
Signed-off-by: Richard Sandiford <rsandifo at linux.vnet.ibm.com>
---
src/mesa/drivers/dri/i965/brw_surface_formats.c | 1 +
src/mesa/main/format_pack.c | 60 +++++++++++++++++++++++++
src/mesa/main/format_unpack.c | 42 +++++++++++++++++
src/mesa/main/formats.c | 45 +++++++++++++++++++
src/mesa/main/formats.h | 3 ++
src/mesa/main/texformat.c | 10 +++++
src/mesa/main/texstore.c | 8 +++-
src/mesa/swrast/s_texfetch.c | 3 ++
src/mesa/swrast/s_texfetch_tmp.h | 24 ++++++++++
9 files changed, 195 insertions(+), 1 deletion(-)
diff --git a/src/mesa/drivers/dri/i965/brw_surface_formats.c b/src/mesa/drivers/dri/i965/brw_surface_formats.c
index 596609e..3522fdd 100644
--- a/src/mesa/drivers/dri/i965/brw_surface_formats.c
+++ b/src/mesa/drivers/dri/i965/brw_surface_formats.c
@@ -512,6 +512,7 @@ brw_format_for_mesa_format(mesa_format mesa_format)
[MESA_FORMAT_B5G5R5X1_UNORM] = BRW_SURFACEFORMAT_B5G5R5X1_UNORM,
[MESA_FORMAT_R8G8B8X8_SNORM] = 0,
[MESA_FORMAT_R8G8B8X8_SRGB] = 0,
+ [MESA_FORMAT_X8B8G8R8_SRGB] = 0,
[MESA_FORMAT_RGBX_UINT8] = 0,
[MESA_FORMAT_RGBX_SINT8] = 0,
[MESA_FORMAT_B10G10R10X2_UNORM] = BRW_SURFACEFORMAT_B10G10R10X2_UNORM,
diff --git a/src/mesa/main/format_pack.c b/src/mesa/main/format_pack.c
index 41253e7..6f89a72 100644
--- a/src/mesa/main/format_pack.c
+++ b/src/mesa/main/format_pack.c
@@ -1108,6 +1108,31 @@ pack_float_B8G8R8A8_SRGB(const GLfloat src[4], void *dst)
}
+/* MESA_FORMAT_A8R8G8B8_SRGB */
+
+static void
+pack_ubyte_A8R8G8B8_SRGB(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(b, g, r, src[ACOMP]);
+}
+
+static void
+pack_float_A8R8G8B8_SRGB(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(b, g, r, a);
+}
+
+
/* MESA_FORMAT_R8G8B8A8_SRGB */
static void
@@ -1782,6 +1807,21 @@ pack_float_R8G8B8X8_SRGB(const GLfloat src[4], void *dst)
}
+/*
+ * MESA_FORMAT_X8B8G8R8_SRGB
+ */
+
+static void
+pack_float_X8B8G8R8_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(r, g, b, 127);
+}
+
+
/* MESA_FORMAT_B10G10R10X2_UNORM */
static void
@@ -1931,6 +1971,20 @@ pack_float_B8G8R8X8_SRGB(const GLfloat src[4], void *dst)
*d = PACK_COLOR_8888(127, r, g, b);
}
+/*
+ * MESA_FORMAT_X8R8G8B8_SRGB
+ */
+
+static void
+pack_float_X8R8G8B8_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(b, g, r, 127);
+}
+
/**
* Return a function that can pack a GLubyte rgba[4] color.
*/
@@ -1998,6 +2052,7 @@ _mesa_get_pack_ubyte_rgba_function(mesa_format format)
table[MESA_FORMAT_BGR_SRGB8] = pack_ubyte_BGR_SRGB8;
table[MESA_FORMAT_A8B8G8R8_SRGB] = pack_ubyte_A8B8G8R8_SRGB;
table[MESA_FORMAT_B8G8R8A8_SRGB] = pack_ubyte_B8G8R8A8_SRGB;
+ table[MESA_FORMAT_A8R8G8B8_SRGB] = pack_ubyte_A8R8G8B8_SRGB;
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;
@@ -2072,6 +2127,7 @@ _mesa_get_pack_ubyte_rgba_function(mesa_format format)
table[MESA_FORMAT_B5G5R5X1_UNORM] = pack_ubyte_XRGB1555_UNORM;
table[MESA_FORMAT_R8G8B8X8_SNORM] = NULL;
table[MESA_FORMAT_R8G8B8X8_SRGB] = NULL;
+ table[MESA_FORMAT_X8B8G8R8_SRGB] = NULL;
table[MESA_FORMAT_RGBX_UINT8] = NULL;
table[MESA_FORMAT_RGBX_SINT8] = NULL;
table[MESA_FORMAT_B10G10R10X2_UNORM] = pack_ubyte_B10G10R10X2_UNORM;
@@ -2087,6 +2143,7 @@ _mesa_get_pack_ubyte_rgba_function(mesa_format format)
table[MESA_FORMAT_R10G10B10A2_UNORM] = pack_ubyte_R10G10B10A2_UNORM;
table[MESA_FORMAT_B8G8R8X8_SRGB] = NULL;
+ table[MESA_FORMAT_X8R8G8B8_SRGB] = NULL;
initialized = GL_TRUE;
}
@@ -2163,6 +2220,7 @@ _mesa_get_pack_float_rgba_function(mesa_format format)
table[MESA_FORMAT_BGR_SRGB8] = pack_float_BGR_SRGB8;
table[MESA_FORMAT_A8B8G8R8_SRGB] = pack_float_A8B8G8R8_SRGB;
table[MESA_FORMAT_B8G8R8A8_SRGB] = pack_float_B8G8R8A8_SRGB;
+ table[MESA_FORMAT_A8R8G8B8_SRGB] = pack_float_A8R8G8B8_SRGB;
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;
@@ -2235,6 +2293,7 @@ _mesa_get_pack_float_rgba_function(mesa_format format)
table[MESA_FORMAT_B5G5R5X1_UNORM] = pack_float_XRGB1555_UNORM;
table[MESA_FORMAT_R8G8B8X8_SNORM] = pack_float_XBGR8888_SNORM;
table[MESA_FORMAT_R8G8B8X8_SRGB] = pack_float_R8G8B8X8_SRGB;
+ table[MESA_FORMAT_X8B8G8R8_SRGB] = pack_float_X8B8G8R8_SRGB;
table[MESA_FORMAT_RGBX_UINT8] = NULL;
table[MESA_FORMAT_RGBX_SINT8] = NULL;
table[MESA_FORMAT_B10G10R10X2_UNORM] = pack_float_B10G10R10X2_UNORM;
@@ -2253,6 +2312,7 @@ _mesa_get_pack_float_rgba_function(mesa_format format)
table[MESA_FORMAT_G16R16_SNORM] = pack_float_G16R16_SNORM;
table[MESA_FORMAT_B8G8R8X8_SRGB] = pack_float_B8G8R8X8_SRGB;
+ table[MESA_FORMAT_X8R8G8B8_SRGB] = pack_float_X8R8G8B8_SRGB;
initialized = GL_TRUE;
}
diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index fddb067..3a58489 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -797,6 +797,19 @@ unpack_B8G8R8A8_SRGB(const void *src, GLfloat dst[][4], GLuint n)
}
static void
+unpack_A8R8G8B8_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] >> 8) & 0xff );
+ dst[i][GCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 16) & 0xff );
+ dst[i][BCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 24) );
+ dst[i][ACOMP] = UBYTE_TO_FLOAT( s[i] & 0xff ); /* linear! */
+ }
+}
+
+static void
unpack_R8G8B8A8_SRGB(const void *src, GLfloat dst[][4], GLuint n)
{
const GLuint *s = ((const GLuint *) src);
@@ -2159,6 +2172,19 @@ unpack_R8G8B8X8_SRGB(const void *src, GLfloat dst[][4], GLuint n)
}
static void
+unpack_X8B8G8R8_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] >> 24) );
+ dst[i][GCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 16) & 0xff );
+ dst[i][BCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 8) & 0xff );
+ dst[i][ACOMP] = 1.0f;
+ }
+}
+
+static void
unpack_XBGR8888_UINT(const void *src, GLfloat dst[][4], GLuint n)
{
const GLbyte *s = (const GLbyte *) src;
@@ -2353,6 +2379,19 @@ unpack_B8G8R8X8_SRGB(const void *src, GLfloat dst[][4], GLuint n)
}
}
+static void
+unpack_X8R8G8B8_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] >> 8) & 0xff );
+ dst[i][GCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 16) & 0xff );
+ dst[i][BCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 24) );
+ dst[i][ACOMP] = 1.0F;
+ }
+}
+
/**
* Return the unpacker function for the given format.
*/
@@ -2415,6 +2454,7 @@ get_unpack_rgba_function(mesa_format format)
table[MESA_FORMAT_BGR_SRGB8] = unpack_BGR_SRGB8;
table[MESA_FORMAT_A8B8G8R8_SRGB] = unpack_A8B8G8R8_SRGB;
table[MESA_FORMAT_B8G8R8A8_SRGB] = unpack_B8G8R8A8_SRGB;
+ table[MESA_FORMAT_A8R8G8B8_SRGB] = unpack_A8R8G8B8_SRGB;
table[MESA_FORMAT_R8G8B8A8_SRGB] = unpack_R8G8B8A8_SRGB;
table[MESA_FORMAT_L_SRGB8] = unpack_L_SRGB8;
table[MESA_FORMAT_L8A8_SRGB] = unpack_L8A8_SRGB;
@@ -2555,6 +2595,7 @@ get_unpack_rgba_function(mesa_format format)
table[MESA_FORMAT_B5G5R5X1_UNORM] = unpack_XRGB1555_UNORM;
table[MESA_FORMAT_R8G8B8X8_SNORM] = unpack_R8G8B8X8_SNORM;
table[MESA_FORMAT_R8G8B8X8_SRGB] = unpack_R8G8B8X8_SRGB;
+ table[MESA_FORMAT_X8B8G8R8_SRGB] = unpack_X8B8G8R8_SRGB;
table[MESA_FORMAT_RGBX_UINT8] = unpack_XBGR8888_UINT;
table[MESA_FORMAT_RGBX_SINT8] = unpack_XBGR8888_SINT;
table[MESA_FORMAT_B10G10R10X2_UNORM] = unpack_B10G10R10X2_UNORM;
@@ -2573,6 +2614,7 @@ get_unpack_rgba_function(mesa_format format)
table[MESA_FORMAT_G16R16_SNORM] = unpack_G16R16_SNORM;
table[MESA_FORMAT_B8G8R8X8_SRGB] = unpack_B8G8R8X8_SRGB;
+ table[MESA_FORMAT_X8R8G8B8_SRGB] = unpack_X8R8G8B8_SRGB;
initialized = GL_TRUE;
}
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index e33b1b7..13345ce 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -772,6 +772,15 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
1, 1, 4
},
{
+ MESA_FORMAT_A8R8G8B8_SRGB,
+ "MESA_FORMAT_A8R8G8B8_SRGB",
+ GL_RGBA,
+ GL_UNSIGNED_NORMALIZED,
+ 8, 8, 8, 8,
+ 0, 0, 0, 0, 0,
+ 1, 1, 4
+ },
+ {
MESA_FORMAT_B8G8R8X8_SRGB,
"MESA_FORMAT_B8G8R8X8_SRGB",
GL_RGB,
@@ -781,6 +790,15 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
1, 1, 4
},
{
+ MESA_FORMAT_X8R8G8B8_SRGB,
+ "MESA_FORMAT_X8R8G8B8_SRGB",
+ GL_RGB,
+ GL_UNSIGNED_NORMALIZED,
+ 8, 8, 8, 0,
+ 0, 0, 0, 0, 0,
+ 1, 1, 4
+ },
+ {
MESA_FORMAT_R8G8B8A8_SRGB,
"MESA_FORMAT_R8G8B8A8_SRGB",
GL_RGBA,
@@ -799,6 +817,15 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
1, 1, 4
},
{
+ MESA_FORMAT_X8B8G8R8_SRGB,
+ "MESA_FORMAT_X8B8G8R8_SRGB",
+ GL_RGB,
+ GL_UNSIGNED_NORMALIZED,
+ 8, 8, 8, 0,
+ 0, 0, 0, 0, 0,
+ 1, 1, 4
+ },
+ {
MESA_FORMAT_L8A8_SRGB,
"MESA_FORMAT_L8A8_SRGB",
GL_LUMINANCE_ALPHA,
@@ -2066,6 +2093,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_A8R8G8B8_SRGB:
case MESA_FORMAT_R8G8B8A8_SRGB:
case MESA_FORMAT_L_SRGB8:
case MESA_FORMAT_L8A8_SRGB:
@@ -2075,10 +2103,12 @@ _mesa_get_format_color_encoding(mesa_format format)
case MESA_FORMAT_SRGBA_DXT3:
case MESA_FORMAT_SRGBA_DXT5:
case MESA_FORMAT_R8G8B8X8_SRGB:
+ case MESA_FORMAT_X8B8G8R8_SRGB:
case MESA_FORMAT_ETC2_SRGB8:
case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC:
case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1:
case MESA_FORMAT_B8G8R8X8_SRGB:
+ case MESA_FORMAT_X8R8G8B8_SRGB:
return GL_SRGB;
default:
return GL_LINEAR;
@@ -2103,6 +2133,9 @@ _mesa_get_srgb_format_linear(mesa_format format)
case MESA_FORMAT_B8G8R8A8_SRGB:
format = MESA_FORMAT_B8G8R8A8_UNORM;
break;
+ case MESA_FORMAT_A8R8G8B8_SRGB:
+ format = MESA_FORMAT_A8R8G8B8_UNORM;
+ break;
case MESA_FORMAT_R8G8B8A8_SRGB:
format = MESA_FORMAT_R8G8B8A8_UNORM;
break;
@@ -2130,6 +2163,9 @@ _mesa_get_srgb_format_linear(mesa_format format)
case MESA_FORMAT_R8G8B8X8_SRGB:
format = MESA_FORMAT_R8G8B8X8_UNORM;
break;
+ case MESA_FORMAT_X8B8G8R8_SRGB:
+ format = MESA_FORMAT_X8B8G8R8_UNORM;
+ break;
case MESA_FORMAT_ETC2_SRGB8:
format = MESA_FORMAT_ETC2_RGB8;
break;
@@ -2142,6 +2178,9 @@ _mesa_get_srgb_format_linear(mesa_format format)
case MESA_FORMAT_B8G8R8X8_SRGB:
format = MESA_FORMAT_B8G8R8X8_UNORM;
break;
+ case MESA_FORMAT_X8R8G8B8_SRGB:
+ format = MESA_FORMAT_X8R8G8B8_UNORM;
+ break;
default:
break;
}
@@ -2641,6 +2680,7 @@ _mesa_format_to_type_and_comps(mesa_format format,
return;
case MESA_FORMAT_A8B8G8R8_SRGB:
case MESA_FORMAT_B8G8R8A8_SRGB:
+ case MESA_FORMAT_A8R8G8B8_SRGB:
case MESA_FORMAT_R8G8B8A8_SRGB:
*datatype = GL_UNSIGNED_BYTE;
*comps = 4;
@@ -2912,6 +2952,7 @@ _mesa_format_to_type_and_comps(mesa_format format,
return;
case MESA_FORMAT_R8G8B8X8_SRGB:
+ case MESA_FORMAT_X8B8G8R8_SRGB:
case MESA_FORMAT_RGBX_UINT8:
*datatype = GL_UNSIGNED_BYTE;
*comps = 4;
@@ -2976,6 +3017,7 @@ _mesa_format_to_type_and_comps(mesa_format format,
return;
case MESA_FORMAT_B8G8R8X8_SRGB:
+ case MESA_FORMAT_X8R8G8B8_SRGB:
*datatype = GL_UNSIGNED_BYTE;
*comps = 4;
return;
@@ -3091,6 +3133,7 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format,
return GL_FALSE;
case MESA_FORMAT_A8R8G8B8_UNORM:
+ case MESA_FORMAT_A8R8G8B8_SRGB:
if (format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8 && !swapBytes)
return GL_TRUE;
@@ -3514,6 +3557,7 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format,
case MESA_FORMAT_B5G5R5X1_UNORM:
case MESA_FORMAT_R8G8B8X8_SNORM:
case MESA_FORMAT_R8G8B8X8_SRGB:
+ case MESA_FORMAT_X8B8G8R8_SRGB:
case MESA_FORMAT_RGBX_UINT8:
case MESA_FORMAT_RGBX_SINT8:
case MESA_FORMAT_B10G10R10X2_UNORM:
@@ -3540,6 +3584,7 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format,
!swapBytes;
case MESA_FORMAT_B8G8R8X8_SRGB:
+ case MESA_FORMAT_X8R8G8B8_SRGB:
return GL_FALSE;
}
diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
index 17cbe86..2e3d6d4 100644
--- a/src/mesa/main/formats.h
+++ b/src/mesa/main/formats.h
@@ -260,9 +260,12 @@ typedef enum
/* Packed sRGB 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_A8R8G8B8_SRGB, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */
MESA_FORMAT_B8G8R8X8_SRGB, /* xxxx xxxx RRRR RRRR GGGG GGGG BBBB BBBB */
+ MESA_FORMAT_X8R8G8B8_SRGB, /* BBBB BBBB GGGG GGGG RRRR RRRR xxxx xxxx */
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_X8B8G8R8_SRGB, /* RRRR RRRR GGGG GGGG BBBB BBBB xxxx xxxx */
MESA_FORMAT_L8A8_SRGB, /* AAAA AAAA LLLL LLLL */
MESA_FORMAT_A8L8_SRGB, /* LLLL LLLL AAAA AAAA */
diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index 99a1ff3..2f01def 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -532,6 +532,9 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
RETURN_IF_SUPPORTED(MESA_FORMAT_BGR_SRGB8);
RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB);
+
+ RETURN_IF_SUPPORTED(MESA_FORMAT_X8B8G8R8_SRGB);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB);
break;
case GL_SRGB_ALPHA_EXT:
case GL_SRGB8_ALPHA8_EXT:
@@ -539,38 +542,45 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
RETURN_IF_SUPPORTED(MESA_FORMAT_A8B8G8R8_SRGB);
RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB);
break;
case GL_SLUMINANCE_EXT:
case GL_SLUMINANCE8_EXT:
RETURN_IF_SUPPORTED(MESA_FORMAT_L_SRGB8);
RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB);
break;
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);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB);
break;
case GL_COMPRESSED_SLUMINANCE_EXT:
RETURN_IF_SUPPORTED(MESA_FORMAT_L_SRGB8);
RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB);
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);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB);
break;
case GL_COMPRESSED_SRGB_EXT:
if (ctx->Mesa_DXTn)
RETURN_IF_SUPPORTED(MESA_FORMAT_SRGB_DXT1);
RETURN_IF_SUPPORTED(MESA_FORMAT_BGR_SRGB8);
RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB);
break;
case GL_COMPRESSED_SRGB_ALPHA_EXT:
if (ctx->Mesa_DXTn)
RETURN_IF_SUPPORTED(MESA_FORMAT_SRGBA_DXT3); /* Not srgba_dxt1, see spec */
RETURN_IF_SUPPORTED(MESA_FORMAT_A8B8G8R8_SRGB);
RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB);
break;
case GL_ALPHA8UI_EXT:
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 22fc1e2..ce38765 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -3185,6 +3185,7 @@ _mesa_texstore_srgba8(TEXSTORE_PARAMS)
ASSERT(dstFormat == MESA_FORMAT_A8B8G8R8_SRGB ||
dstFormat == MESA_FORMAT_R8G8B8X8_SRGB ||
+ dstFormat == MESA_FORMAT_X8B8G8R8_SRGB ||
dstFormat == MESA_FORMAT_R8G8B8A8_SRGB);
newDstFormat = _mesa_get_srgb_format_linear(dstFormat);
@@ -3206,7 +3207,9 @@ _mesa_texstore_sargb8(TEXSTORE_PARAMS)
GLboolean k;
assert(dstFormat == MESA_FORMAT_B8G8R8A8_SRGB ||
- dstFormat == MESA_FORMAT_B8G8R8X8_SRGB);
+ dstFormat == MESA_FORMAT_A8R8G8B8_SRGB ||
+ dstFormat == MESA_FORMAT_B8G8R8X8_SRGB ||
+ dstFormat == MESA_FORMAT_X8R8G8B8_SRGB);
newDstFormat = _mesa_get_srgb_format_linear(dstFormat);
@@ -3624,6 +3627,7 @@ _mesa_get_texstore_func(mesa_format format)
table[MESA_FORMAT_BGR_SRGB8] = _mesa_texstore_srgb8;
table[MESA_FORMAT_A8B8G8R8_SRGB] = _mesa_texstore_srgba8;
table[MESA_FORMAT_B8G8R8A8_SRGB] = _mesa_texstore_sargb8;
+ table[MESA_FORMAT_A8R8G8B8_SRGB] = _mesa_texstore_sargb8;
table[MESA_FORMAT_L_SRGB8] = _mesa_texstore_sl8;
table[MESA_FORMAT_L8A8_SRGB] = _mesa_texstore_sla8;
table[MESA_FORMAT_A8L8_SRGB] = _mesa_texstore_sla8;
@@ -3759,6 +3763,7 @@ _mesa_get_texstore_func(mesa_format format)
table[MESA_FORMAT_B5G5R5X1_UNORM] = store_ubyte_texture;
table[MESA_FORMAT_R8G8B8X8_SNORM] = _mesa_texstore_signed_rgbx8888;
table[MESA_FORMAT_R8G8B8X8_SRGB] = _mesa_texstore_srgba8;
+ table[MESA_FORMAT_X8B8G8R8_SRGB] = _mesa_texstore_srgba8;
table[MESA_FORMAT_R8G8B8A8_SRGB] = _mesa_texstore_srgba8;
table[MESA_FORMAT_RGBX_UINT8] = _mesa_texstore_rgba_uint8;
table[MESA_FORMAT_RGBX_SINT8] = _mesa_texstore_rgba_int8;
@@ -3778,6 +3783,7 @@ _mesa_get_texstore_func(mesa_format format)
table[MESA_FORMAT_G16R16_SNORM] = _mesa_texstore_snorm1616;
table[MESA_FORMAT_B8G8R8X8_SRGB] = _mesa_texstore_sargb8;
+ table[MESA_FORMAT_X8R8G8B8_SRGB] = _mesa_texstore_sargb8;
initialized = GL_TRUE;
}
diff --git a/src/mesa/swrast/s_texfetch.c b/src/mesa/swrast/s_texfetch.c
index 72930bb..d885507 100644
--- a/src/mesa/swrast/s_texfetch.c
+++ b/src/mesa/swrast/s_texfetch.c
@@ -257,9 +257,12 @@ texfetch_funcs[] =
/* Packed sRGB formats */
FETCH_FUNCS(A8B8G8R8_SRGB),
FETCH_FUNCS(B8G8R8A8_SRGB),
+ FETCH_FUNCS(A8R8G8B8_SRGB),
FETCH_NULL(B8G8R8X8_SRGB),
+ FETCH_NULL(X8R8G8B8_SRGB),
FETCH_FUNCS(R8G8B8A8_SRGB),
FETCH_FUNCS(R8G8B8X8_SRGB),
+ FETCH_FUNCS(X8B8G8R8_SRGB),
FETCH_FUNCS(L8A8_SRGB),
FETCH_FUNCS(A8L8_SRGB),
diff --git a/src/mesa/swrast/s_texfetch_tmp.h b/src/mesa/swrast/s_texfetch_tmp.h
index 9effe5f..a0bfa2b 100644
--- a/src/mesa/swrast/s_texfetch_tmp.h
+++ b/src/mesa/swrast/s_texfetch_tmp.h
@@ -769,6 +769,18 @@ FETCH(B8G8R8A8_SRGB)(const struct swrast_texture_image *texImage,
static void
+FETCH(A8R8G8B8_SRGB)(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 >> 8) & 0xff );
+ texel[GCOMP] = nonlinear_to_linear( (s >> 16) & 0xff );
+ texel[BCOMP] = nonlinear_to_linear( (s >> 24) );
+ texel[ACOMP] = UBYTE_TO_FLOAT( s & 0xff ); /* linear! */
+}
+
+
+static void
FETCH(R8G8B8A8_SRGB)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
@@ -793,6 +805,18 @@ FETCH(R8G8B8X8_SRGB)(const struct swrast_texture_image *texImage,
static void
+FETCH(X8B8G8R8_SRGB)(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 >> 24) );
+ texel[GCOMP] = nonlinear_to_linear( (s >> 16) & 0xff );
+ texel[BCOMP] = nonlinear_to_linear( (s >> 8) & 0xff );
+ texel[ACOMP] = 1.0f;
+}
+
+
+static void
FETCH(L_SRGB8)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
--
1.8.3.1
More information about the mesa-dev
mailing list