}
-/*
- * MESA_FORMAT_R5G6B5_UNORM
- * Warning: these functions do not match the current Mesa definition
- * of MESA_FORMAT_R5G6B5_UNORM.
- */
-
static void
pack_ubyte_R5G6B5_UNORM(const GLubyte src[4], void *dst)
{
GLushort *d = ((GLushort *) dst);
- *d = PACK_COLOR_565_REV(src[RCOMP], src[GCOMP], src[BCOMP]);
+ *d = PACK_COLOR_565(src[BCOMP], src[GCOMP], src[RCOMP]);
}
static void
UNCLAMPED_FLOAT_TO_UBYTE(r, src[RCOMP]);
UNCLAMPED_FLOAT_TO_UBYTE(g, src[GCOMP]);
UNCLAMPED_FLOAT_TO_UBYTE(b, src[BCOMP]);
- *d = PACK_COLOR_565_REV(r, g, b);
+ *d = PACK_COLOR_565(b, g, r);
}
static void
static void
unpack_ubyte_R5G6B5_UNORM(const void *src, GLubyte dst[][4], GLuint n)
{
- /* Warning: this function does not match the current Mesa definition
- * of MESA_FORMAT_R5G6B5_UNORM.
- */
const GLushort *s = ((const GLushort *) src);
GLuint i;
for (i = 0; i < n; i++) {
GLuint t = (s[i] >> 8) | (s[i] << 8); /* byte swap */
- dst[i][RCOMP] = EXPAND_5_8((t >> 11) & 0x1f);
+ dst[i][RCOMP] = EXPAND_5_8( t & 0x1f);
dst[i][GCOMP] = EXPAND_6_8((t >> 5 ) & 0x3f);
- dst[i][BCOMP] = EXPAND_5_8( t & 0x1f);
+ dst[i][BCOMP] = EXPAND_5_8((t >> 11) & 0x1f);
dst[i][ACOMP] = 0xff;
}
}
return format == GL_RGB && type == GL_UNSIGNED_BYTE && littleEndian;
case MESA_FORMAT_B5G6R5_UNORM:
- return format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 && !swapBytes;
+ return ((format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) ||
+ (format == GL_BGR && type == GL_UNSIGNED_SHORT_5_6_5_REV)) &&
+ !swapBytes;
case MESA_FORMAT_R5G6B5_UNORM:
- /* Some of the 16-bit MESA_FORMATs that would seem to correspond to
- * GL_UNSIGNED_SHORT_* are byte-swapped instead of channel-reversed,
- * according to formats.h, so they can't be matched.
- */
- return GL_FALSE;
+ return ((format == GL_BGR && type == GL_UNSIGNED_SHORT_5_6_5) ||
+ (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5_REV)) &&
+ !swapBytes;
case MESA_FORMAT_B4G4R4A4_UNORM:
return format == GL_BGRA && type == GL_UNSIGNED_SHORT_4_4_4_4_REV &&
* ** when type applies to all components
*
* examples: msb <------ TEXEL BITS -----------> lsb
- * MESA_FORMAT_A8B8G8R8_UNORM, AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR
- * MESA_FORMAT_R5G6B5_UNORM RRRR RGGG GGGB BBBB
- * MESA_FORMAT_B4G4R4X4_UNORM BBBB GGGG RRRR XXXX
+ * MESA_FORMAT_A8B8G8R8_UNORM, RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA
+ * MESA_FORMAT_R5G6B5_UNORM BBBB BGGG GGGR RRRR
+ * MESA_FORMAT_B4G4R4X4_UNORM XXXX RRRR GGGG BBBB
* MESA_FORMAT_Z32_FLOAT_S8X24_UINT
* MESA_FORMAT_R10G10B10A2_UINT
* MESA_FORMAT_R9G9B9E5_FLOAT
}
else {
for (col = 0; col < srcWidth; col++) {
- dstUS[col] = PACK_COLOR_565_REV( srcUB[0], srcUB[1], srcUB[2] );
+ dstUS[col] = PACK_COLOR_565( srcUB[2], srcUB[1], srcUB[0] );
srcUB += 3;
}
}
GLint i, GLint j, GLint k, GLfloat *texel)
{
const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- const GLushort s = (*src >> 8) | (*src << 8); /* byte swap */
- texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 8) & 0xf8) | ((s >> 13) & 0x7) );
- texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 3) & 0xfc) | ((s >> 9) & 0x3) );
- texel[BCOMP] = UBYTE_TO_FLOAT( ((s << 3) & 0xf8) | ((s >> 2) & 0x7) );
+ const GLushort s = *src;
+ texel[RCOMP] = ((s ) & 0x1f) * (1.0F / 31.0F);
+ texel[GCOMP] = ((s >> 5 ) & 0x3f) * (1.0F / 63.0F);
+ texel[BCOMP] = ((s >> 11) & 0x1f) * (1.0F / 31.0F);
texel[ACOMP] = 1.0F;
}