mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-16 21:58:21 +02:00
Add format B5G5R5X1
This commit is contained in:
parent
521c61ff01
commit
94abc4b51e
6 changed files with 84 additions and 0 deletions
|
|
@ -63,6 +63,7 @@ PIPE_FORMAT_A8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, r
|
|||
PIPE_FORMAT_X8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzw1, rgb
|
||||
PIPE_FORMAT_A8B8G8R8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, rgb
|
||||
PIPE_FORMAT_X8B8G8R8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzy1, rgb
|
||||
PIPE_FORMAT_B5G5R5X1_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyx1, rgb
|
||||
PIPE_FORMAT_B5G5R5A1_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb
|
||||
PIPE_FORMAT_B4G4R4A4_UNORM , plain, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb
|
||||
PIPE_FORMAT_B5G6R5_UNORM , plain, 1, 1, un5 , un6 , un5 , , zyx1, rgb
|
||||
|
|
|
|||
|
Can't render this file because it contains an unexpected character in line 8 and column 3.
|
|
|
@ -120,6 +120,13 @@ util_format_test_cases[] =
|
|||
* 16-bit rendertarget formats
|
||||
*/
|
||||
|
||||
{PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x0000), {0.0, 0.0, 0.0, 0.0}},
|
||||
{PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x001f), {0.0, 0.0, 1.0, 0.0}},
|
||||
{PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x03e0), {0.0, 1.0, 0.0, 0.0}},
|
||||
{PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x7c00), {1.0, 0.0, 0.0, 0.0}},
|
||||
{PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x8000), {0.0, 0.0, 0.0, 1.0}},
|
||||
{PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0xffff), {1.0, 1.0, 1.0, 1.0}},
|
||||
|
||||
{PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), {0.0, 0.0, 0.0, 0.0}},
|
||||
{PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x001f), {0.0, 0.0, 1.0, 0.0}},
|
||||
{PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x03e0), {0.0, 1.0, 0.0, 0.0}},
|
||||
|
|
|
|||
|
|
@ -938,6 +938,7 @@ format_to_type_comps(enum pipe_format pformat,
|
|||
*datatype = DTYPE_UBYTE;
|
||||
*comps = 4;
|
||||
return;
|
||||
case PIPE_FORMAT_B5G5R5X1_UNORM:
|
||||
case PIPE_FORMAT_B5G5R5A1_UNORM:
|
||||
*datatype = DTYPE_USHORT_1_5_5_5_REV;
|
||||
*comps = 4;
|
||||
|
|
|
|||
|
|
@ -92,6 +92,11 @@ util_pack_color_ub(ubyte r, ubyte g, ubyte b, ubyte a,
|
|||
uc->us = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
|
||||
}
|
||||
return;
|
||||
case PIPE_FORMAT_B5G5R5X1_UNORM:
|
||||
{
|
||||
uc->us = ((0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
|
||||
}
|
||||
return;
|
||||
case PIPE_FORMAT_B5G5R5A1_UNORM:
|
||||
{
|
||||
uc->us = ((a & 0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
|
||||
|
|
@ -216,6 +221,15 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc,
|
|||
*a = (ubyte) 0xff;
|
||||
}
|
||||
return;
|
||||
case PIPE_FORMAT_B5G5R5X1_UNORM:
|
||||
{
|
||||
ushort p = uc->us;
|
||||
*r = (ubyte) (((p >> 7) & 0xf8) | ((p >> 12) & 0x7));
|
||||
*g = (ubyte) (((p >> 2) & 0xf8) | ((p >> 7) & 0x7));
|
||||
*b = (ubyte) (((p << 3) & 0xf8) | ((p >> 2) & 0x7));
|
||||
*a = (ubyte) 0xff;
|
||||
}
|
||||
return;
|
||||
case PIPE_FORMAT_B5G5R5A1_UNORM:
|
||||
{
|
||||
ushort p = uc->us;
|
||||
|
|
@ -361,6 +375,11 @@ util_pack_color(const float rgba[4], enum pipe_format format, union util_color *
|
|||
uc->us = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
|
||||
}
|
||||
return;
|
||||
case PIPE_FORMAT_B5G5R5X1_UNORM:
|
||||
{
|
||||
uc->us = ((0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
|
||||
}
|
||||
return;
|
||||
case PIPE_FORMAT_B5G5R5A1_UNORM:
|
||||
{
|
||||
uc->us = ((a & 0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
|
||||
|
|
|
|||
|
|
@ -295,6 +295,55 @@ r8g8b8a8_put_tile_rgba(unsigned *dst,
|
|||
}
|
||||
|
||||
|
||||
/*** PIPE_FORMAT_B5G5R5X1_UNORM ***/
|
||||
|
||||
static void
|
||||
x1r5g5b5_get_tile_rgba(const ushort *src,
|
||||
unsigned w, unsigned h,
|
||||
float *p,
|
||||
unsigned dst_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
const ushort pixel = *src++;
|
||||
pRow[0] = ((pixel >> 10) & 0x1f) * (1.0f / 31.0f);
|
||||
pRow[1] = ((pixel >> 5) & 0x1f) * (1.0f / 31.0f);
|
||||
pRow[2] = ((pixel ) & 0x1f) * (1.0f / 31.0f);
|
||||
pRow[3] = 1.0f;
|
||||
}
|
||||
p += dst_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
x1r5g5b5_put_tile_rgba(ushort *dst,
|
||||
unsigned w, unsigned h,
|
||||
const float *p,
|
||||
unsigned src_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
const float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
unsigned r, g, b;
|
||||
r = float_to_ubyte(pRow[0]);
|
||||
g = float_to_ubyte(pRow[1]);
|
||||
b = float_to_ubyte(pRow[2]);
|
||||
r = r >> 3; /* 5 bits */
|
||||
g = g >> 3; /* 5 bits */
|
||||
b = b >> 3; /* 5 bits */
|
||||
*dst++ = (1 << 15) | (r << 10) | (g << 5) | b;
|
||||
}
|
||||
p += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*** PIPE_FORMAT_B5G5R5A1_UNORM ***/
|
||||
|
||||
static void
|
||||
|
|
@ -1174,6 +1223,9 @@ pipe_tile_raw_to_rgba(enum pipe_format format,
|
|||
case PIPE_FORMAT_A8B8G8R8_UNORM:
|
||||
r8g8b8a8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_B5G5R5X1_UNORM:
|
||||
x1r5g5b5_get_tile_rgba((ushort *) src, w, h, dst, dst_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_B5G5R5A1_UNORM:
|
||||
a1r5g5b5_get_tile_rgba((ushort *) src, w, h, dst, dst_stride);
|
||||
break;
|
||||
|
|
@ -1368,6 +1420,9 @@ pipe_put_tile_rgba(struct pipe_context *pipe,
|
|||
case PIPE_FORMAT_A8B8G8R8_UNORM:
|
||||
r8g8b8a8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_B5G5R5X1_UNORM:
|
||||
x1r5g5b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_B5G5R5A1_UNORM:
|
||||
a1r5g5b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -157,6 +157,7 @@ enum pipe_format {
|
|||
PIPE_FORMAT_DXT5_SRGBA = 109,
|
||||
|
||||
PIPE_FORMAT_A8B8G8R8_UNORM = 110,
|
||||
PIPE_FORMAT_B5G5R5X1_UNORM = 111,
|
||||
|
||||
PIPE_FORMAT_COUNT
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue