Merge pull request #8262 from alphanu1/master

Implementation screen centring and dynamic super resolution
This commit is contained in:
Twinaphex 2019-02-12 14:20:49 +01:00 committed by GitHub
commit c9db325bd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 48 additions and 7 deletions

View File

@ -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;

View File

@ -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,24 @@ void crt_video_restore(void)
first_run = true;
}
int crt_compute_dynamic_width(int width)
{
double p_clock = 18000000;
int min_height = 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;
return width;
break;
}
return 0;
}
#if defined(HAVE_VIDEOCORE)
static void crt_rpi_switch(int width, int height, float hz)
{

View File

@ -27,12 +27,14 @@
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);
void crt_video_restore(void);
int crt_compute_dynamic_width(int width);
RETRO_END_DECLS
#endif

View File

@ -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,12 @@ 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 == 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);
}
else if (!video_info.crt_switch_resolution)
video_driver_crt_switching_active = false;

View File

@ -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);
/* 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);
}
static int setting_action_left_analog_dpad_mode(rarch_setting_t *setting, bool wraparound)
@ -1300,8 +1305,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 +1572,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;

View File

@ -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,