From 0f3f206b3c365b6afcb7e133e669371bddab02d1 Mon Sep 17 00:00:00 2001 From: bmaupin Date: Fri, 22 Nov 2019 13:08:21 -0500 Subject: [PATCH 1/2] Add option to change renderer --- platform/libretro/libretro.c | 9 +++++++++ platform/libretro/libretro_core_options.h | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index b836185b..7d2e89bd 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -1431,6 +1431,15 @@ static void update_variables(void) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { PicoIn.sndFilterRange = (atoi(var.value) * 65536) / 100; } + + var.value = NULL; + var.key = "picodrive_renderer"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { + if (strcmp(var.value, "fast") == 0) + PicoIn.opt |= POPT_ALT_RENDERER; + else + PicoIn.opt &= ~POPT_ALT_RENDERER; + } } void retro_run(void) diff --git a/platform/libretro/libretro_core_options.h b/platform/libretro/libretro_core_options.h index a9ac83cb..4748b1e1 100644 --- a/platform/libretro/libretro_core_options.h +++ b/platform/libretro/libretro_core_options.h @@ -200,6 +200,17 @@ struct retro_core_option_definition option_defs_us[] = { }, "60" }, + { + "picodrive_renderer", + "Renderer", + "Fast renderer can't render any mid-frame image changes so it is useful only for some games.", + { + { "accurate", NULL }, + { "fast", NULL }, + { NULL, NULL }, + }, + "accurate" + }, { NULL, NULL, NULL, {{0}}, NULL }, }; From 6877c461f60fb53d88d0368505202d57de053900 Mon Sep 17 00:00:00 2001 From: bmaupin Date: Tue, 25 Feb 2020 13:34:02 -0500 Subject: [PATCH 2/2] Copy tile-based fast renderer buffer Also omit renderer option when RENDER_GSKIT_PS2 is used since it seems to have its own logic --- platform/libretro/libretro.c | 19 +++++++++++++++++++ platform/libretro/libretro_core_options.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 7d2e89bd..0216d2b5 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -1545,6 +1545,25 @@ void retro_run(void) ps2->padding = padding; #else + if (PicoIn.opt & POPT_ALT_RENDERER) { + /* In retro_init, PicoDrawSetOutBuf is called to make sure the output gets written to vout_buf, but this only + * applies to the line renderer (pico/draw.c). The faster tile-based renderer (pico/draw2.c) enabled by + * POPT_ALT_RENDERER writes to Pico.est.Draw2FB, so we need to manually copy that to vout_buf. + */ + /* This section is mostly copied from pemu_finalize_frame in platform/linux/emu.c */ + unsigned short *pd = (unsigned short *)vout_buf; + /* Skip the leftmost 8 columns (it seems to be used as some sort of caching or overscan area) */ + unsigned char *ps = Pico.est.Draw2FB + 8; + unsigned short *pal = Pico.est.HighPal; + int x; + if (Pico.m.dirtyPal) + PicoDrawUpdateHighPal(); + /* Copy up to the max height to include the overscan area, and skip the leftmost 8 columns again */ + for (i = 0; i < VOUT_MAX_HEIGHT; i++, ps += 8) + for (x = 0; x < vout_width; x++) + *pd++ = pal[*ps++]; + } + buff = (char*)vout_buf + vout_offset; #endif diff --git a/platform/libretro/libretro_core_options.h b/platform/libretro/libretro_core_options.h index 4748b1e1..bb69909a 100644 --- a/platform/libretro/libretro_core_options.h +++ b/platform/libretro/libretro_core_options.h @@ -200,6 +200,7 @@ struct retro_core_option_definition option_defs_us[] = { }, "60" }, +#if !defined(RENDER_GSKIT_PS2) { "picodrive_renderer", "Renderer", @@ -211,6 +212,7 @@ struct retro_core_option_definition option_defs_us[] = { }, "accurate" }, +#endif { NULL, NULL, NULL, {{0}}, NULL }, };