From c765eb86debdc06fe304511bc2edbb6f3e3d7813 Mon Sep 17 00:00:00 2001 From: Justin Weiss Date: Sun, 13 Sep 2020 20:06:57 -0700 Subject: Add a threaded renderer This change adds a gpulib implementation that accepts GPU commands and runs them through a real gpulib implementation on a thread. Depending on a setting, it can either force a sync every frame, or continue to work until the next frame arrives. --- frontend/libretro.c | 17 ++++++++++++++++- frontend/libretro_core_options.h | 14 ++++++++++++++ frontend/main.c | 2 ++ frontend/menu.c | 1 + frontend/plugin_lib.h | 5 +++++ 5 files changed, 38 insertions(+), 1 deletion(-) (limited to 'frontend') diff --git a/frontend/libretro.c b/frontend/libretro.c index 93bfc28..323932a 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -1818,6 +1818,21 @@ static void update_variables(bool in_flight) Config.SpuIrq = 1; } +#ifdef THREAD_RENDERING + var.key = "pcsx_rearmed_gpu_thread_rendering"; + var.value = NULL; + + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (strcmp(var.value, "disabled") == 0) + pl_rearmed_cbs.thread_rendering = THREAD_RENDERING_OFF; + else if (strcmp(var.value, "sync") == 0) + pl_rearmed_cbs.thread_rendering = THREAD_RENDERING_SYNC; + else if (strcmp(var.value, "async") == 0) + pl_rearmed_cbs.thread_rendering = THREAD_RENDERING_ASYNC; + } +#endif + #ifdef GPU_PEOPS var.value = NULL; var.key = "pcsx_rearmed_gpu_peops_odd_even_bit"; @@ -2031,7 +2046,7 @@ static void update_variables(bool in_flight) "pcsx_rearmed_gpu_unai_fast_lighting", "pcsx_rearmed_gpu_unai_ilace_force", "pcsx_rearmed_gpu_unai_pixel_skip", - "pcsx_rearmed_gpu_unai_scale_hires" + "pcsx_rearmed_gpu_unai_scale_hires", }; option_display.visible = show_advanced_gpu_unai_settings; diff --git a/frontend/libretro_core_options.h b/frontend/libretro_core_options.h index 941bd81..1075e8f 100644 --- a/frontend/libretro_core_options.h +++ b/frontend/libretro_core_options.h @@ -972,6 +972,20 @@ struct retro_core_option_definition option_defs_us[] = { }, "disabled", }, +#ifdef THREAD_RENDERING + { + "pcsx_rearmed_gpu_thread_rendering", + "Threaded Rendering", + "When enabled, runs GPU commands in a thread. Sync waits for drawing to finish before vsync. Async will not wait unless there's another frame behind it.", + { + { "disabled", NULL }, + { "sync", NULL }, + { "async", NULL }, + { NULL, NULL}, + }, + "disabled", + }, +#endif #endif /* GPU UNAI Advanced Settings */ { diff --git a/frontend/main.c b/frontend/main.c index 51cb7bf..d3c7d40 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -125,6 +125,8 @@ void emu_set_default_config(void) Config.SpuIrq = Config.RCntFix = Config.VSyncWA = 0; Config.PsxAuto = 1; + pl_rearmed_cbs.thread_rendering = 0; + pl_rearmed_cbs.gpu_neon.allow_interlace = 2; // auto pl_rearmed_cbs.gpu_neon.enhancement_enable = pl_rearmed_cbs.gpu_neon.enhancement_no_main = 0; diff --git a/frontend/menu.c b/frontend/menu.c index e5c2738..bd56cf4 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -420,6 +420,7 @@ static const struct { CE_INTVAL_N("adev0_is_nublike", in_adev_is_nublike[0]), CE_INTVAL_N("adev1_is_nublike", in_adev_is_nublike[1]), CE_INTVAL_V(frameskip, 3), + CE_INTVAL_P(thread_rendering), CE_INTVAL_P(gpu_peops.iUseDither), CE_INTVAL_P(gpu_peops.dwActFixes), CE_INTVAL_P(gpu_unai.ilace_force), diff --git a/frontend/plugin_lib.h b/frontend/plugin_lib.h index 114aaad..71dfcb5 100644 --- a/frontend/plugin_lib.h +++ b/frontend/plugin_lib.h @@ -1,6 +1,10 @@ #ifndef __PLUGIN_LIB_H__ #define __PLUGIN_LIB_H__ +#define THREAD_RENDERING_OFF 0 +#define THREAD_RENDERING_SYNC 1 +#define THREAD_RENDERING_ASYNC 2 + enum { DKEY_SELECT = 0, DKEY_L3, @@ -70,6 +74,7 @@ struct rearmed_cbs { unsigned int *gpu_hcnt; unsigned int flip_cnt; // increment manually if not using pl_vout_flip unsigned int only_16bpp; // platform is 16bpp-only + unsigned int thread_rendering; struct { int allow_interlace; // 0 off, 1 on, 2 guess int enhancement_enable; -- cgit v1.2.3