From 14b80cc3e1e31af56605591ef489d67851dd5d78 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Tue, 12 Feb 2019 09:44:06 +0000 Subject: [PATCH 01/11] incorporation of dynamic super res Closer to native look super resolution. Used to prevent artefacts --- gfx/video_crt_switch.c | 25 +++++++++++++++++++++++-- gfx/video_crt_switch.h | 2 +- gfx/video_driver.c | 7 ++++++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/gfx/video_crt_switch.c b/gfx/video_crt_switch.c index c4135a6df1..6bdd1c6fed 100644 --- a/gfx/video_crt_switch.c +++ b/gfx/video_crt_switch.c @@ -177,7 +177,7 @@ static void crt_screen_setup_aspect(unsigned width, unsigned height) void crt_switch_res_core(unsigned width, unsigned height, float hz, unsigned crt_mode, - int crt_switch_center_adjust, int monitor_index) + int crt_switch_center_adjust, int monitor_index, bool dynamic) { /* ra_core_hz float passed from within * void video_driver_monitor_adjust_system_rates(void) */ @@ -185,6 +185,10 @@ void crt_switch_res_core(unsigned width, unsigned height, ra_core_width = width; ra_core_height = height; ra_core_hz = hz; + + if (dynamic == true) + ra_core_width = crt_compute_dynamic_width(width); + crt_center_adjust = crt_switch_center_adjust; crt_index = monitor_index; @@ -209,7 +213,7 @@ void crt_switch_res_core(unsigned width, unsigned height, ra_tmp_height = ra_core_height; ra_tmp_width = ra_core_width; - /* Check if aspect is correct, if notchange */ + /* Check if aspect is correct, if not change */ if (video_driver_get_aspect_ratio() != fly_aspect) { video_driver_set_aspect_ratio_value((float)fly_aspect); @@ -225,6 +229,23 @@ void crt_video_restore(void) first_run = true; } +static int crt_compute_dynamic_width(int width) +{ + double p_clock = 18000000; + int min_heught = 261; + #if defined(HAVE_VIDEOCORE) + double p_clock = 32000000; + #endif + + for (int i =1; i < 10; i++) + { + if (((width*0.5*i) * min_height * ra_core_hz) > p_clock) + width = width*i; + break; + } + +} + #if defined(HAVE_VIDEOCORE) static void crt_rpi_switch(int width, int height, float hz) { diff --git a/gfx/video_crt_switch.h b/gfx/video_crt_switch.h index 8bf588bae7..d73e79a2a7 100644 --- a/gfx/video_crt_switch.h +++ b/gfx/video_crt_switch.h @@ -27,7 +27,7 @@ RETRO_BEGIN_DECLS -void crt_switch_res_core(unsigned width, unsigned height, float hz, unsigned crt_mode, int crt_switch_center_adjust, int monitor_index); +void crt_switch_res_core(unsigned width, unsigned height, float hz, unsigned crt_mode, int crt_switch_center_adjust, int monitor_index, bool dynamic); void crt_aspect_ratio_switch(unsigned width, unsigned height); diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 4b441b4ba5..dfe571e690 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -142,6 +142,7 @@ static unsigned video_driver_state_scale = 0; static unsigned video_driver_state_out_bpp = 0; static bool video_driver_state_out_rgb32 = false; static bool video_driver_crt_switching_active = false; +static bool video_driver_crt_dynamic_super_width = false; static struct retro_system_av_info video_driver_av_info; @@ -2647,7 +2648,10 @@ void video_driver_frame(const void *data, unsigned width, width = 3840; if (video_info.crt_switch_resolution_super == 1920) width = 1920; - crt_switch_res_core(width, height, video_driver_core_hz, video_info.crt_switch_resolution, video_info.crt_switch_center_adjust, video_info.monitor_index); + if (video_info.crt_switch_resolution_super == 1920) + video_driver_crt_dynamic_super_width = true; + + crt_switch_res_core(width, height, video_driver_core_hz, video_info.crt_switch_resolution, video_info.crt_switch_center_adjust, video_info.monitor_index, video_driver_crt_dynamic_super_width); } else if (!video_info.crt_switch_resolution) video_driver_crt_switching_active = false; @@ -2734,6 +2738,7 @@ void video_driver_build_info(video_frame_info_t *video_info) video_info->crt_switch_resolution = settings->uints.crt_switch_resolution; video_info->crt_switch_resolution_super = settings->uints.crt_switch_resolution_super; video_info->crt_switch_center_adjust = settings->ints.crt_switch_center_adjust; + video_info->crt_switch_custom_refresh_enable =settings->bools.crt_switch_custom_refresh_enable; video_info->black_frame_insertion = settings->bools.video_black_frame_insertion; video_info->hard_sync = settings->bools.video_hard_sync; video_info->hard_sync_frames = settings->uints.video_hard_sync_frames; From 4dc6cf2fb44ecb9f412c9eb3cec2f274a8875c19 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Tue, 12 Feb 2019 09:46:22 +0000 Subject: [PATCH 02/11] incorporated center adjust for Linux --- gfx/display_servers/dispserv_x11.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gfx/display_servers/dispserv_x11.c b/gfx/display_servers/dispserv_x11.c index 6e75e87714..715cb9752d 100644 --- a/gfx/display_servers/dispserv_x11.c +++ b/gfx/display_servers/dispserv_x11.c @@ -144,6 +144,7 @@ static bool x11_display_server_set_resolution(void *data, int vmax = 0; int pdefault = 8; int pwidth = 0; + int x_offset = center; float roundw = 0.0f; float roundh = 0.0f; float pixel_clock = 0; @@ -160,7 +161,7 @@ static bool x11_display_server_set_resolution(void *data, video_monitor_set_refresh_rate(hz); /* following code is the mode line generator */ - hsp = width * 1.140; + hsp = (width * 1.140) + x_offset; hfp = width * 1.055; pwidth = width; From 1282a02212092719e0e51a170cb57bdbdee759cf Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Tue, 12 Feb 2019 09:48:35 +0000 Subject: [PATCH 03/11] Added dynamic option in menu --- menu/menu_setting.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 319e5084af..f995d01537 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1300,8 +1300,10 @@ static int setting_uint_action_left_crt_switch_resolution_super( case 0: *setting->value.target.unsigned_integer = 3840; break; - case 1920: + case 1: /* for dynamic super resolution switching - best fit */ *setting->value.target.unsigned_integer = 0; + case 1920: + *setting->value.target.unsigned_integer = 1; break; case 2560: *setting->value.target.unsigned_integer = 1920; @@ -1565,8 +1567,10 @@ static int setting_uint_action_right_crt_switch_resolution_super( switch (*setting->value.target.unsigned_integer) { case 0: - *setting->value.target.unsigned_integer = 1920; + *setting->value.target.unsigned_integer = 1; break; + case 1: /* for dynamic super resolution switching - best fit */ + *setting->value.target.unsigned_integer = 1920; case 1920: *setting->value.target.unsigned_integer = 2560; break; From f7d2fbd212bca2b0efdc5bebbf268d19c4491538 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Tue, 12 Feb 2019 10:04:41 +0000 Subject: [PATCH 04/11] fix for dynamic super resolutions --- gfx/video_driver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index dfe571e690..ea68acd237 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -2648,9 +2648,9 @@ void video_driver_frame(const void *data, unsigned width, width = 3840; if (video_info.crt_switch_resolution_super == 1920) width = 1920; - if (video_info.crt_switch_resolution_super == 1920) + if (video_info.crt_switch_resolution_super == 1) video_driver_crt_dynamic_super_width = true; - + crt_switch_res_core(width, height, video_driver_core_hz, video_info.crt_switch_resolution, video_info.crt_switch_center_adjust, video_info.monitor_index, video_driver_crt_dynamic_super_width); } else if (!video_info.crt_switch_resolution) From a76c1f4c512be4bb1e380fb682611f1885d718e4 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Tue, 12 Feb 2019 10:10:35 +0000 Subject: [PATCH 05/11] Removed CRT setting video driver build info --- gfx/video_driver.c | 1 - 1 file changed, 1 deletion(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index ea68acd237..50ca1e5843 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -2738,7 +2738,6 @@ void video_driver_build_info(video_frame_info_t *video_info) video_info->crt_switch_resolution = settings->uints.crt_switch_resolution; video_info->crt_switch_resolution_super = settings->uints.crt_switch_resolution_super; video_info->crt_switch_center_adjust = settings->ints.crt_switch_center_adjust; - video_info->crt_switch_custom_refresh_enable =settings->bools.crt_switch_custom_refresh_enable; video_info->black_frame_insertion = settings->bools.video_black_frame_insertion; video_info->hard_sync = settings->bools.video_hard_sync; video_info->hard_sync_frames = settings->uints.video_hard_sync_frames; From 7aabf7f5e1a279e87a9e512867d14e9c13ad1f6b Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Tue, 12 Feb 2019 10:16:04 +0000 Subject: [PATCH 06/11] added static function and Clean up --- gfx/video_crt_switch.c | 7 ++++--- gfx/video_crt_switch.h | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/gfx/video_crt_switch.c b/gfx/video_crt_switch.c index 6bdd1c6fed..22f0cc3191 100644 --- a/gfx/video_crt_switch.c +++ b/gfx/video_crt_switch.c @@ -232,7 +232,7 @@ void crt_video_restore(void) static int crt_compute_dynamic_width(int width) { double p_clock = 18000000; - int min_heught = 261; + int min_height = 261; #if defined(HAVE_VIDEOCORE) double p_clock = 32000000; #endif @@ -241,9 +241,10 @@ static int crt_compute_dynamic_width(int width) { if (((width*0.5*i) * min_height * ra_core_hz) > p_clock) width = width*i; - break; + return width; + break; } - + return 0; } #if defined(HAVE_VIDEOCORE) diff --git a/gfx/video_crt_switch.h b/gfx/video_crt_switch.h index d73e79a2a7..20634f7ed6 100644 --- a/gfx/video_crt_switch.h +++ b/gfx/video_crt_switch.h @@ -33,6 +33,8 @@ void crt_aspect_ratio_switch(unsigned width, unsigned height); void crt_video_restore(void); +static int crt_compute_dynamic_width(int width); + RETRO_END_DECLS #endif From 924fcc28348cd0bcd24e5c2251b8eaf0144a9846 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Tue, 12 Feb 2019 10:26:17 +0000 Subject: [PATCH 07/11] Fix build warnings and cleanup --- gfx/video_crt_switch.c | 2 +- gfx/video_crt_switch.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gfx/video_crt_switch.c b/gfx/video_crt_switch.c index 22f0cc3191..35586ab9dd 100644 --- a/gfx/video_crt_switch.c +++ b/gfx/video_crt_switch.c @@ -229,7 +229,7 @@ void crt_video_restore(void) first_run = true; } -static int crt_compute_dynamic_width(int width) +int crt_compute_dynamic_width(int width) { double p_clock = 18000000; int min_height = 261; diff --git a/gfx/video_crt_switch.h b/gfx/video_crt_switch.h index 20634f7ed6..7e3c9541e9 100644 --- a/gfx/video_crt_switch.h +++ b/gfx/video_crt_switch.h @@ -33,7 +33,7 @@ void crt_aspect_ratio_switch(unsigned width, unsigned height); void crt_video_restore(void); -static int crt_compute_dynamic_width(int width); +int crt_compute_dynamic_width(int width); RETRO_END_DECLS From acbb014b2d5569b77a9d1a622b04062d5e49ad5c Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Tue, 12 Feb 2019 10:51:06 +0000 Subject: [PATCH 08/11] Added MSG_DYNAMIC --- msg_hash.h | 1 + 1 file changed, 1 insertion(+) diff --git a/msg_hash.h b/msg_hash.h index 441d3fe1bd..f86a7737b3 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -208,6 +208,7 @@ enum msg_hash_enums MSG_NO_ARGUMENTS_SUPPLIED_AND_NO_MENU_BUILTIN, MSG_COMPILER, MSG_NATIVE, + MSG_DYNAMIC, MSG_UNKNOWN_COMPILER, MSG_FAILED, MSG_SUCCEEDED, From b1c5d9a59492b4f255bd3c2ccabbb9ece6babb74 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Tue, 12 Feb 2019 10:53:36 +0000 Subject: [PATCH 09/11] Added text to replace 0 for CRT superres MSG_DYNAMIC --- menu/menu_setting.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index f995d01537..342f75245f 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1198,6 +1198,11 @@ static void setting_get_string_representation_crt_switch_resolution_super( strlcpy(s, msg_hash_to_str(MSG_NATIVE), len); else snprintf(s, len, "%d", *setting->value.target.unsigned_integer); + + if (*setting->value.target.unsigned_integer == 1) + strlcpy(s, msg_hash_to_str(MSG_DYNAMIC), len); + else + snprintf(s, len, "%d", *setting->value.target.unsigned_integer); } static int setting_action_left_analog_dpad_mode(rarch_setting_t *setting, bool wraparound) From c9c3c626e85a37e5fe6bc6fbd42a62a47c638948 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Tue, 12 Feb 2019 11:23:53 +0000 Subject: [PATCH 10/11] turn dynamic super res off on the fly --- gfx/video_driver.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 50ca1e5843..28ee36f792 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -2650,6 +2650,8 @@ void video_driver_frame(const void *data, unsigned width, width = 1920; if (video_info.crt_switch_resolution_super == 1) video_driver_crt_dynamic_super_width = true; + else + video_driver_crt_dynamic_super_width = false; crt_switch_res_core(width, height, video_driver_core_hz, video_info.crt_switch_resolution, video_info.crt_switch_center_adjust, video_info.monitor_index, video_driver_crt_dynamic_super_width); } From 2172dbe8ba552dcdf40e7c5c10858beba9064231 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Tue, 12 Feb 2019 12:45:45 +0000 Subject: [PATCH 11/11] change super resolution 1 to read DYNAMIC --- menu/menu_setting.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 342f75245f..50782557a4 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1198,11 +1198,11 @@ static void setting_get_string_representation_crt_switch_resolution_super( strlcpy(s, msg_hash_to_str(MSG_NATIVE), len); else snprintf(s, len, "%d", *setting->value.target.unsigned_integer); - +/* TO DO make 1 read as DYNAMIC */ if (*setting->value.target.unsigned_integer == 1) strlcpy(s, msg_hash_to_str(MSG_DYNAMIC), len); else - snprintf(s, len, "%d", *setting->value.target.unsigned_integer); + snprintf(s, len, "%d", *setting->value.target.unsigned_integer); } static int setting_action_left_analog_dpad_mode(rarch_setting_t *setting, bool wraparound)