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 <rsandifo@linux.vnet.ibm.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
[MESA_FORMAT_R8G8B8A8_SRGB] = BRW_SURFACEFORMAT_R8G8B8A8_UNORM_SRGB,
[MESA_FORMAT_L_SRGB8] = BRW_SURFACEFORMAT_L8_UNORM_SRGB,
[MESA_FORMAT_L8A8_SRGB] = BRW_SURFACEFORMAT_L8A8_UNORM_SRGB,
+ [MESA_FORMAT_A8L8_SRGB] = 0,
[MESA_FORMAT_SRGB_DXT1] = BRW_SURFACEFORMAT_DXT1_RGB_SRGB,
[MESA_FORMAT_SRGBA_DXT1] = BRW_SURFACEFORMAT_BC1_UNORM_SRGB,
[MESA_FORMAT_SRGBA_DXT3] = BRW_SURFACEFORMAT_BC2_UNORM_SRGB,
[MESA_FORMAT_A_SNORM8] = 0,
[MESA_FORMAT_L_SNORM8] = 0,
[MESA_FORMAT_L8A8_SNORM] = 0,
+ [MESA_FORMAT_A8L8_SNORM] = 0,
[MESA_FORMAT_I_SNORM8] = 0,
[MESA_FORMAT_A_SNORM16] = 0,
[MESA_FORMAT_L_SNORM16] = 0,
*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)
{
*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 */
}
+/*
+ * 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
*/
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; */
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;
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;
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;
}
}
+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)
{
}
}
+
+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)
{
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;
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;
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:
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;
return;
case MESA_FORMAT_R8G8_SNORM:
case MESA_FORMAT_L8A8_SNORM:
+ case MESA_FORMAT_A8L8_SNORM:
*datatype = GL_BYTE;
*comps = 2;
return;
*comps = 1;
return;
case MESA_FORMAT_L8A8_SRGB:
+ case MESA_FORMAT_A8L8_SRGB:
*datatype = GL_UNSIGNED_BYTE;
*comps = 2;
return;
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:
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:
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
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
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 */
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 */
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;
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:
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:
FETCH_FUNCS(R8G8_SNORM),
FETCH_NULL(G8R8_SNORM),
FETCH_FUNCS(L8A8_SNORM),
+ FETCH_FUNCS(A8L8_SNORM),
/* Array signed/normalized formats */
FETCH_FUNCS(A_SNORM8),
FETCH_FUNCS(R8G8B8A8_SRGB),
FETCH_FUNCS(R8G8B8X8_SRGB),
FETCH_FUNCS(L8A8_SRGB),
+ FETCH_FUNCS(A8L8_SRGB),
/* Array sRGB formats */
FETCH_FUNCS(L_SRGB8),
}
+static void
+FETCH(A8L8_SRGB)(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 2);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(s >> 8);
+ texel[ACOMP] = UBYTE_TO_FLOAT(s & 0xff); /* linear */
+}
+
+
static void
FETCH(RGBA_SINT8)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
}
+static void
+FETCH(A8L8_SNORM)(const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ const GLushort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
+ texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s & 0xff) );
+}
+
+
static void
FETCH(X8B8G8R8_SNORM)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)