mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
Fix Direct3D9 framebuffer upload conversion funcs.
All of the 16 bit formats were, afaict, wrong in different ways.
This commit is contained in:
parent
539a7b1772
commit
4110a24d8f
@ -433,37 +433,40 @@ void ConvertRGBA4444ToRGBA8888(u32 *dst32, const u16 *src, const u32 numPixels)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: This seems to be ABGR4444 -> RGBA888?
|
||||
void ConvertBGRA4444ToRGBA8888(u32 *dst32, const u16 *src, const u32 numPixels) {
|
||||
void ConvertRGBA4444ToBGRA8888(u32 *dst32, const u16 *src, const u32 numPixels) {
|
||||
u8 *dst = (u8 *)dst32;
|
||||
for (u32 x = 0; x < numPixels; x++) {
|
||||
u16 col = src[x];
|
||||
dst[x * 4 + 0] = (col >> 12) << 4;
|
||||
dst[x * 4 + 1] = ((col >> 8) & 0xf) << 4;
|
||||
dst[x * 4 + 2] = ((col >> 4) & 0xf) << 4;
|
||||
dst[x * 4 + 3] = (col & 0xf) << 4;
|
||||
u16 c = src[x];
|
||||
u32 r = c & 0x000f;
|
||||
u32 g = (c >> 4) & 0x000f;
|
||||
u32 b = (c >> 8) & 0x000f;
|
||||
u32 a = (c >> 12) & 0x000f;
|
||||
|
||||
dst[x] = (r << (16 + 4)) | (g << (8 + 4)) | (b << 4) | (a << (24 + 4));
|
||||
}
|
||||
}
|
||||
|
||||
inline void ARGB8From565(u16 c, u32 * dst) {
|
||||
*dst = ((c & 0x001f) << 19) | (((c >> 5) & 0x003f) << 11) | ((((c >> 10) & 0x001f) << 3)) | 0xFF000000;
|
||||
}
|
||||
|
||||
inline void ARGB8From5551(u16 c, u32 * dst) {
|
||||
*dst = ((c & 0x001f) << 19) | (((c >> 5) & 0x001f) << 11) | ((((c >> 10) & 0x001f) << 3)) | 0xFF000000;
|
||||
}
|
||||
|
||||
void ConvertBGRA5551ToRGBA8888(u32 *dst, const u16 *src, const u32 numPixels) {
|
||||
void ConvertRGBA5551ToBGRA8888(u32 *dst, const u16 *src, const u32 numPixels) {
|
||||
for (u32 x = 0; x < numPixels; x++) {
|
||||
u16 col0 = src[x];
|
||||
ARGB8From5551(col0, &dst[x]);
|
||||
u16 c = src[x];
|
||||
u32 r = c & 0x001f;
|
||||
u32 g = (c >> 5) & 0x001f;
|
||||
u32 b = (c >> 10) & 0x001f;
|
||||
// We force an arithmetic shift to get the sign bits/
|
||||
u32 a = ((s32)(s16)c) & 0xff000000;
|
||||
|
||||
dst[x] = (r << (16 + 3)) | (g << (8 + 3)) | (b << 3) | a;
|
||||
}
|
||||
}
|
||||
|
||||
void ConvertBGR565ToRGBA8888(u32 *dst, const u16 *src, const u32 numPixels) {
|
||||
void ConvertRGB565ToBGRA8888(u32 *dst, const u16 *src, const u32 numPixels) {
|
||||
for (u32 x = 0; x < numPixels; x++) {
|
||||
u16 col0 = src[x];
|
||||
ARGB8From565(col0, &dst[x]);
|
||||
u16 c = src[x];
|
||||
u32 r = c & 0x001f;
|
||||
u32 g = (c >> 5) & 0x003f;
|
||||
u32 b = (c >> 11) & 0x001f;
|
||||
|
||||
dst[x] = (r << (16 + 3)) | (g << (8 + 2)) | (b << 3) | 0xFF000000;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,9 +126,9 @@ void ConvertRGBA565ToRGBA8888(u32 *dst, const u16 *src, const u32 numPixels);
|
||||
void ConvertRGBA5551ToRGBA8888(u32 *dst, const u16 *src, const u32 numPixels);
|
||||
void ConvertRGBA4444ToRGBA8888(u32 *dst, const u16 *src, const u32 numPixels);
|
||||
|
||||
void ConvertBGRA4444ToRGBA8888(u32 *dst, const u16 *src, const u32 numPixels);
|
||||
void ConvertBGRA5551ToRGBA8888(u32 *dst, const u16 *src, const u32 numPixels);
|
||||
void ConvertBGR565ToRGBA8888(u32 *dst, const u16 *src, const u32 numPixels);
|
||||
void ConvertRGBA4444ToBGRA8888(u32 *dst, const u16 *src, const u32 numPixels);
|
||||
void ConvertRGBA5551ToBGRA8888(u32 *dst, const u16 *src, const u32 numPixels);
|
||||
void ConvertRGB565ToBGRA8888(u32 *dst, const u16 *src, const u32 numPixels);
|
||||
|
||||
void ConvertRGBA4444ToABGR4444Basic(u16 *dst, const u16 *src, const u32 numPixels);
|
||||
void ConvertRGBA5551ToABGR1555Basic(u16 *dst, const u16 *src, const u32 numPixels);
|
||||
|
@ -140,7 +140,7 @@ namespace DX9 {
|
||||
{
|
||||
const u16_le *src = (const u16_le *)srcPixels + srcStride * y;
|
||||
u32 *dst = (u32 *)(convBuf + rect.Pitch * y);
|
||||
ConvertBGR565ToRGBA8888(dst, src, width);
|
||||
ConvertRGB565ToBGRA8888(dst, src, width);
|
||||
}
|
||||
break;
|
||||
// faster
|
||||
@ -148,14 +148,14 @@ namespace DX9 {
|
||||
{
|
||||
const u16_le *src = (const u16_le *)srcPixels + srcStride * y;
|
||||
u32 *dst = (u32 *)(convBuf + rect.Pitch * y);
|
||||
ConvertBGRA5551ToRGBA8888(dst, src, width);
|
||||
ConvertRGBA5551ToBGRA8888(dst, src, width);
|
||||
}
|
||||
break;
|
||||
case GE_FORMAT_4444:
|
||||
{
|
||||
const u16_le *src = (const u16_le *)srcPixels + srcStride * y;
|
||||
u8 *dst = (u8 *)(convBuf + rect.Pitch * y);
|
||||
ConvertBGRA4444ToRGBA8888((u32 *)dst, src, width);
|
||||
ConvertRGBA4444ToBGRA8888((u32 *)dst, src, width);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -163,7 +163,7 @@ namespace DX9 {
|
||||
{
|
||||
const u32_le *src = (const u32_le *)srcPixels + srcStride * y;
|
||||
u32 *dst = (u32 *)(convBuf + rect.Pitch * y);
|
||||
ConvertBGRA8888ToRGBA8888(dst, src, width);
|
||||
ConvertRGBA8888ToBGRA8888(dst, src, width);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -172,7 +172,7 @@ namespace DX9 {
|
||||
for (int y = 0; y < height; y++) {
|
||||
const u32_le *src = (const u32_le *)srcPixels + srcStride * y;
|
||||
u32 *dst = (u32 *)(convBuf + rect.Pitch * y);
|
||||
ConvertBGRA8888ToRGBA8888(dst, src, width);
|
||||
ConvertRGBA8888ToBGRA8888(dst, src, width);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user