3DS - Fix corrupted graphics on real hardware
This commit is contained in:
parent
a82189b0c9
commit
e45ee3c189
1 changed files with 16 additions and 13 deletions
|
@ -251,30 +251,33 @@ void RenderBackend_UploadSurface(RenderBackend_Surface *surface, const unsigned
|
||||||
frame_started = false;
|
frame_started = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char *abgr_buffer = (unsigned char*)linearAlloc(width * height * 4);
|
unsigned char *abgr_buffer = (unsigned char*)linearAlloc(surface->texture.width * surface->texture.height * 4);
|
||||||
|
|
||||||
if (abgr_buffer != NULL)
|
if (abgr_buffer != NULL)
|
||||||
{
|
{
|
||||||
const unsigned char *src = pixels;
|
const unsigned char *src = pixels;
|
||||||
unsigned char *dst = abgr_buffer;
|
|
||||||
|
|
||||||
// Convert from colour-keyed RGB to ABGR
|
// Convert from colour-keyed RGB to ABGR
|
||||||
for (size_t i = 0; i < width * height; ++i)
|
for (size_t h = 0; h < height; ++h)
|
||||||
{
|
{
|
||||||
unsigned char r = *src++;
|
unsigned char *dst = &abgr_buffer[h * surface->texture.width * 4];
|
||||||
unsigned char g = *src++;
|
|
||||||
unsigned char b = *src++;
|
|
||||||
|
|
||||||
*dst++ = r == 0 && g == 0 && b == 0 ? 0 : 0xFF;
|
for (size_t w = 0; w < width; ++w)
|
||||||
*dst++ = b;
|
{
|
||||||
*dst++ = g;
|
unsigned char r = *src++;
|
||||||
*dst++ = r;
|
unsigned char g = *src++;
|
||||||
|
unsigned char b = *src++;
|
||||||
|
|
||||||
|
*dst++ = r == 0 && g == 0 && b == 0 ? 0 : 0xFF;
|
||||||
|
*dst++ = b;
|
||||||
|
*dst++ = g;
|
||||||
|
*dst++ = r;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure data is in physical ram
|
GSPGPU_FlushDataCache(abgr_buffer, surface->texture.width * surface->texture.height * 4);
|
||||||
GSPGPU_FlushDataCache(abgr_buffer, width * height * 4);
|
|
||||||
|
|
||||||
C3D_SyncDisplayTransfer((u32*)abgr_buffer, GX_BUFFER_DIM(width, height), (u32*)surface->texture.data, GX_BUFFER_DIM(surface->texture.width, surface->texture.height), TEXTURE_TRANSFER_FLAGS);
|
C3D_SyncDisplayTransfer((u32*)abgr_buffer, GX_BUFFER_DIM(surface->texture.width, surface->texture.height), (u32*)surface->texture.data, GX_BUFFER_DIM(surface->texture.width, surface->texture.height), TEXTURE_TRANSFER_FLAGS);
|
||||||
|
|
||||||
linearFree(abgr_buffer);
|
linearFree(abgr_buffer);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue