From 43047988e507799d7d5bbcd926c5d0b5b94fcdc1 Mon Sep 17 00:00:00 2001 From: Justin Weiss Date: Sun, 2 Aug 2020 22:04:52 -0700 Subject: Add an option to downscale hi-res views Some older devices that use gpu_unai don't have a high enough resolution to display all of the pixels in high-res mode. There's a setting in unai to skip rendering of these pixels, but it's not connected to the libretro frontend, and does not appear to be used in the gpulib implementation at all. This commit adds a gpu_unai setting, Enable Hi-Res Downscaling, that will enable pixel skipping and blit only the pixels actually rendered into a buffer no larger than 384x240. This buffer is then treated as the actual framebuffer by gpulib and the libretro frontend. --- frontend/libretro.c | 18 +++++++++++++++--- frontend/libretro_core_options.h | 11 +++++++++++ frontend/main.c | 1 + frontend/menu.c | 1 + frontend/plugin_lib.h | 1 + 5 files changed, 29 insertions(+), 3 deletions(-) (limited to 'frontend') diff --git a/frontend/libretro.c b/frontend/libretro.c index 50392a9..8dc6bc3 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -1999,6 +1999,17 @@ static void update_variables(bool in_flight) pl_rearmed_cbs.gpu_unai.blending = 1; } + var.key = "pcsx_rearmed_gpu_unai_scale_hires"; + var.value = NULL; + + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (strcmp(var.value, "disabled") == 0) + pl_rearmed_cbs.gpu_unai.scale_hires = 0; + else if (strcmp(var.value, "enabled") == 0) + pl_rearmed_cbs.gpu_unai.scale_hires = 1; + } + var.key = "pcsx_rearmed_show_gpu_unai_settings"; var.value = NULL; @@ -2014,17 +2025,18 @@ static void update_variables(bool in_flight) { unsigned i; struct retro_core_option_display option_display; - char gpu_unai_option[5][40] = { + char gpu_unai_option[6][40] = { "pcsx_rearmed_gpu_unai_blending", "pcsx_rearmed_gpu_unai_lighting", "pcsx_rearmed_gpu_unai_fast_lighting", "pcsx_rearmed_gpu_unai_ilace_force", - "pcsx_rearmed_gpu_unai_pixel_skip" + "pcsx_rearmed_gpu_unai_pixel_skip", + "pcsx_rearmed_gpu_unai_scale_hires" }; option_display.visible = show_advanced_gpu_unai_settings; - for (i = 0; i < 5; i++) + for (i = 0; i < 6; i++) { option_display.key = gpu_unai_option[i]; environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display); diff --git a/frontend/libretro_core_options.h b/frontend/libretro_core_options.h index 95544f0..283abc6 100644 --- a/frontend/libretro_core_options.h +++ b/frontend/libretro_core_options.h @@ -961,6 +961,17 @@ struct retro_core_option_definition option_defs_us[] = { }, "disabled", }, + { + "pcsx_rearmed_gpu_unai_scale_hires", + "(GPU) Enable Hi-Res Downscaling", + "When enabled, will scale hi-res modes to 320x240, skipping unrendered pixels.", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL}, + }, + "disabled", + }, #endif /* GPU UNAI Advanced Settings */ { diff --git a/frontend/main.c b/frontend/main.c index b1ee4c7..51cb7bf 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -140,6 +140,7 @@ void emu_set_default_config(void) pl_rearmed_cbs.gpu_unai.abe_hack = pl_rearmed_cbs.gpu_unai.no_light = pl_rearmed_cbs.gpu_unai.no_blend = 0; + pl_rearmed_cbs.gpu_unai.scale_hires = 0; memset(&pl_rearmed_cbs.gpu_peopsgl, 0, sizeof(pl_rearmed_cbs.gpu_peopsgl)); pl_rearmed_cbs.gpu_peopsgl.iVRamSize = 64; pl_rearmed_cbs.gpu_peopsgl.iTexGarbageCollection = 1; diff --git a/frontend/menu.c b/frontend/menu.c index f4a45ba..e5c2738 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -432,6 +432,7 @@ static const struct { CE_INTVAL_P(gpu_unai.abe_hack), CE_INTVAL_P(gpu_unai.no_light), CE_INTVAL_P(gpu_unai.no_blend), + CE_INTVAL_P(gpu_unai.scale_hires), CE_INTVAL_P(gpu_neon.allow_interlace), CE_INTVAL_P(gpu_neon.enhancement_enable), CE_INTVAL_P(gpu_neon.enhancement_no_main), diff --git a/frontend/plugin_lib.h b/frontend/plugin_lib.h index 09cc4c5..ee03169 100644 --- a/frontend/plugin_lib.h +++ b/frontend/plugin_lib.h @@ -91,6 +91,7 @@ struct rearmed_cbs { int abe_hack; int no_light, no_blend; int lineskip; + int scale_hires; } gpu_unai; struct { int dwActFixes; -- cgit v1.2.3