From: notaz Date: Sun, 29 Apr 2012 16:18:49 +0000 (+0300) Subject: gpu plugins: always support 16bpp blit X-Git-Tag: r15~48 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ea7de6a1495abfbc49c54fd2a90e902fdfa13d9;p=pcsx_rearmed.git gpu plugins: always support 16bpp blit use this for generic sdl and maemo --- diff --git a/frontend/plat_sdl.c b/frontend/plat_sdl.c index 19d7ac07..b9a27c37 100644 --- a/frontend/plat_sdl.c +++ b/frontend/plat_sdl.c @@ -80,6 +80,7 @@ void plat_init(void) in_sdl_init(in_sdl_defbinds); in_probe(); + pl_rearmed_cbs.only_16bpp = 1; return; fail: diff --git a/frontend/plugin_lib.h b/frontend/plugin_lib.h index 8645385d..bcf74acc 100644 --- a/frontend/plugin_lib.h +++ b/frontend/plugin_lib.h @@ -57,6 +57,7 @@ struct rearmed_cbs { unsigned int *gpu_hcnt; unsigned int flip_cnt; // increment manually if not using pl_vout_flip unsigned int screen_w, screen_h; // gles plugin wants this + unsigned int only_16bpp; // platform is 16bpp-only struct { int allow_interlace; // 0 off, 1 on, 2 guess } gpu_neon; diff --git a/maemo/hildon.c b/maemo/hildon.c index 8948c3bb..8e7635a6 100644 --- a/maemo/hildon.c +++ b/maemo/hildon.c @@ -182,6 +182,8 @@ void maemo_init(int *argc, char ***argv) g_layer_x = (X_RES - D_WIDTH) / 2; g_layer_y = (Y_RES - D_HEIGHT) / 2; g_layer_w = D_WIDTH, g_layer_h = D_HEIGHT; + + pl_rearmed_cbs.only_16bpp = 1; } void menu_loop(void) diff --git a/plugins/dfxvideo/draw_pl.c b/plugins/dfxvideo/draw_pl.c index 22351a44..dffd52b4 100644 --- a/plugins/dfxvideo/draw_pl.c +++ b/plugins/dfxvideo/draw_pl.c @@ -32,13 +32,7 @@ static void blit(void *vout_buf) if (w <= 0) return; -#ifndef MAEMO - pitch *= PSXDisplay.RGB24 ? 3 : 2; -#else - // n900 doesn't do rgb24 for some reason - pitch *= 2; - #define bgr888_to_rgb888 bgr888_to_rgb565 -#endif + pitch *= (PSXDisplay.RGB24 && !rcbs->only_16bpp) ? 3 : 2; // account for centering h -= PreviousPSXDisplay.Range.y0; @@ -47,9 +41,19 @@ static void blit(void *vout_buf) if (PSXDisplay.RGB24) { - for (; h-- > 0; dest += pitch, srcs += 1024) + if (!rcbs->only_16bpp) + { + for (; h-- > 0; dest += pitch, srcs += 1024) + { + bgr888_to_rgb888(dest, srcs, w * 3); + } + } + else { - bgr888_to_rgb888(dest, srcs, w * 3); + for (; h-- > 0; dest += pitch, srcs += 1024) + { + bgr888_to_rgb565(dest, srcs, w * 3); + } } } else diff --git a/plugins/gpu_unai/gpu.cpp b/plugins/gpu_unai/gpu.cpp index 5a0ad2c3..3c30ffaf 100644 --- a/plugins/gpu_unai/gpu.cpp +++ b/plugins/gpu_unai/gpu.cpp @@ -861,19 +861,22 @@ static void blit(void) if (isRGB24) { -#ifndef MAEMO - for (; h1-- > 0; dest += w0 * 3, fb_offs += 1024) + if (!cbs->only_16bpp) { - fb_offs &= 1024*512-1; - bgr888_to_rgb888(dest, base + fb_offs, w0 * 3); + for (; h1-- > 0; dest += w0 * 3, fb_offs += 1024) + { + fb_offs &= 1024*512-1; + bgr888_to_rgb888(dest, base + fb_offs, w0 * 3); + } } -#else - for (; h1-- > 0; dest += w0 * 2, fb_offs += 1024) + else { - fb_offs &= 1024*512-1; - bgr888_to_rgb565(dest, base + fb_offs, w0 * 3); + for (; h1-- > 0; dest += w0 * 2, fb_offs += 1024) + { + fb_offs &= 1024*512-1; + bgr888_to_rgb565(dest, base + fb_offs, w0 * 3); + } } -#endif } else { diff --git a/plugins/gpulib/cspace.c b/plugins/gpulib/cspace.c index eee56ced..408211ff 100644 --- a/plugins/gpulib/cspace.c +++ b/plugins/gpulib/cspace.c @@ -1,9 +1,14 @@ #include "cspace.h" +/* + * note: these are intended for testing and should be avoided + * in favor of NEON version or platform-specific conversion + */ + void bgr555_to_rgb565(void *dst_, const void *src_, int bytes) { - unsigned int *src = (unsigned int *)src_; - unsigned int *dst = (unsigned int *)dst_; + const unsigned int *src = src_; + unsigned int *dst = dst_; unsigned int p; int x; @@ -15,7 +20,24 @@ void bgr555_to_rgb565(void *dst_, const void *src_, int bytes) } } +void bgr888_to_rgb565(void *dst_, const void *src_, int bytes) +{ + const unsigned char *src = src_; + unsigned int *dst = dst_; + unsigned int r1, g1, b1, r2, g2, b2; + + for (; bytes >= 6; bytes -= 6, src += 6, dst++) { + r1 = src[0] & 0xf8; + g1 = src[1] & 0xfc; + b1 = src[2] & 0xf8; + r2 = src[3] & 0xf8; + g2 = src[4] & 0xfc; + b2 = src[5] & 0xf8; + *dst = (r2 << 24) | (g2 << 19) | (b2 << 13) | + (r1 << 8) | (g1 << 3) | (b1 >> 3); + } +} + // TODO? void bgr888_to_rgb888(void *dst, const void *src, int bytes) {} -void bgr888_to_rgb565(void *dst, const void *src, int bytes) {} diff --git a/plugins/gpulib/vout_pl.c b/plugins/gpulib/vout_pl.c index 91de0571..79b6c3e6 100644 --- a/plugins/gpulib/vout_pl.c +++ b/plugins/gpulib/vout_pl.c @@ -36,8 +36,8 @@ static void check_mode_change(void) { old_status = gpu.status.reg; old_h = gpu.screen.h; - screen_buf = cbs->pl_vout_set_mode(gpu.screen.hres, - gpu.screen.h, gpu.status.rgb24 ? 24 : 16); + screen_buf = cbs->pl_vout_set_mode(gpu.screen.hres, gpu.screen.h, + (gpu.status.rgb24 && !cbs->only_16bpp) ? 24 : 16); } } @@ -60,21 +60,22 @@ static void blit(void) if (gpu.status.rgb24) { -#ifndef MAEMO - dest += (doffs / 8) * 24; - for (; h-- > 0; dest += stride * 3, fb_offs += 1024) - { - fb_offs &= 1024*512-1; - bgr888_to_rgb888(dest, vram + fb_offs, w * 3); + if (cbs->only_16bpp) { + dest += doffs * 2; + for (; h-- > 0; dest += stride * 2, fb_offs += 1024) + { + fb_offs &= 1024*512-1; + bgr888_to_rgb565(dest, vram + fb_offs, w * 3); + } } -#else - dest += doffs * 2; - for (; h-- > 0; dest += stride * 2, fb_offs += 1024) - { - fb_offs &= 1024*512-1; - bgr888_to_rgb565(dest, vram + fb_offs, w * 3); + else { + dest += (doffs / 8) * 24; + for (; h-- > 0; dest += stride * 3, fb_offs += 1024) + { + fb_offs &= 1024*512-1; + bgr888_to_rgb888(dest, vram + fb_offs, w * 3); + } } -#endif } else {