To match PIPE_FORMAT_R8G8B8A8_SRGB.
v2: fix component name copy&paste bugs
Reviewed-by: José Fonseca <jfonseca@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
}
+/* 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
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 */
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;
}
}
+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)
{
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;
0, 0, 0, 0, 0,
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",
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:
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;
return;
case MESA_FORMAT_A8B8G8R8_SRGB:
case MESA_FORMAT_B8G8R8A8_SRGB:
+ case MESA_FORMAT_R8G8B8A8_SRGB:
*datatype = GL_UNSIGNED_BYTE;
*comps = 4;
return;
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;
/* 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 */
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;
fetch_texel_2d_sargb8,
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 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 )