(UWP) Push temporary fixes for issue that happens when resizing on UWP

with latest Xbox Series dashboard; DXGIResizeBuffers passing 0, 0 as
width/height is apparently problematic as it changes 0, 0 to 8,8
instead,
breaking the program
This commit is contained in:
twinaphex 2021-08-20 23:16:01 +02:00
parent 77a17b213d
commit eb50d7dbb4
7 changed files with 93 additions and 108 deletions

View File

@ -280,9 +280,6 @@
#define DEFAULT_FULLSCREEN_Y 0
#endif
/* Force 4k resolution */
#define DEFAULT_FORCE_RESOLUTION false
/* Number of threads to use for video recording */
#define DEFAULT_VIDEO_RECORD_THREADS 2

View File

@ -1572,9 +1572,6 @@ static struct config_bool_setting *populate_settings_bool(
SETTING_BOOL("auto_screenshot_filename", &settings->bools.auto_screenshot_filename, true, DEFAULT_AUTO_SCREENSHOT_FILENAME, false);
SETTING_BOOL("video_force_srgb_disable", &settings->bools.video_force_srgb_disable, true, false, false);
SETTING_BOOL("video_fullscreen", &settings->bools.video_fullscreen, true, DEFAULT_FULLSCREEN, false);
#ifdef __WINRT__
SETTING_BOOL("video_force_resolution", &settings->bools.video_force_resolution, true, DEFAULT_FORCE_RESOLUTION, false);
#endif
SETTING_BOOL("bundle_assets_extract_enable", &settings->bools.bundle_assets_extract_enable, true, DEFAULT_BUNDLE_ASSETS_EXTRACT_ENABLE, false);
SETTING_BOOL("video_vsync", &settings->bools.video_vsync, true, DEFAULT_VSYNC, false);
SETTING_BOOL("video_adaptive_vsync", &settings->bools.video_adaptive_vsync, true, DEFAULT_ADAPTIVE_VSYNC, false);

View File

@ -524,7 +524,6 @@ typedef struct settings
#ifdef HAVE_VIDEO_LAYOUT
bool video_layout_enable;
#endif
bool video_force_resolution;
/* Accessibility */
bool accessibility_enable;

View File

@ -97,6 +97,8 @@ void win32_show_cursor(void *data, bool state);
HWND win32_get_window(void);
bool is_running_on_xbox(void);
bool win32_has_focus(void *data);
void win32_clip_window(bool grab);

View File

@ -11017,23 +11017,6 @@ static bool setting_append_list(
general_read_handler);
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint_special;
menu_settings_list_current_add_range(list, list_info, 0, 4320, 8, true, true);
CONFIG_BOOL(
list, list_info,
&settings->bools.video_force_resolution,
MENU_ENUM_LABEL_VIDEO_FORCE_RESOLUTION,
MENU_ENUM_LABEL_VALUE_VIDEO_FORCE_RESOLUTION,
DEFAULT_FORCE_RESOLUTION,
MENU_ENUM_LABEL_VALUE_OFF,
MENU_ENUM_LABEL_VALUE_ON,
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler,
SD_FLAG_CMD_APPLY_AUTO);
MENU_SETTINGS_LIST_CURRENT_ADD_CMD(list, list_info, CMD_EVENT_REINIT_FROM_TOGGLE);
SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_LAKKA_ADVANCED);
}
#if defined(DINGUX) && defined(DINGUX_BETA)

View File

@ -30105,103 +30105,101 @@ static bool video_driver_init_internal(
}
else
{
#if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__)
bool window_custom_size_enable = settings->bools.video_window_save_positions;
#else
bool window_custom_size_enable = settings->bools.video_window_custom_size_enable;
#endif
/* TODO: remove when the new window resizing core is hooked */
if (window_custom_size_enable &&
settings->uints.window_position_width &&
settings->uints.window_position_height)
#ifdef __WINRT__
if (is_running_on_xbox())
{
width = settings->uints.window_position_width;
height = settings->uints.window_position_height;
width = settings->uints.video_fullscreen_x != 0 ? settings->uints.video_fullscreen_x : 3840;
height = settings->uints.video_fullscreen_y != 0 ? settings->uints.video_fullscreen_y : 2160;
}
else
#endif
{
float video_scale = settings->floats.video_scale;
unsigned max_win_width;
unsigned max_win_height;
/* Determine maximum allowed window dimensions
* NOTE: We cannot read the actual display
* metrics here, because the context driver
* has not yet been initialised... */
/* > Try explicitly configured values */
max_win_width = settings->uints.window_auto_width_max;
max_win_height = settings->uints.window_auto_height_max;
/* > Handle invalid settings */
if ((max_win_width == 0) || (max_win_height == 0))
#if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__)
bool window_custom_size_enable = settings->bools.video_window_save_positions;
#else
bool window_custom_size_enable = settings->bools.video_window_custom_size_enable;
#endif
/* TODO: remove when the new window resizing core is hooked */
if (window_custom_size_enable &&
settings->uints.window_position_width &&
settings->uints.window_position_height)
{
/* > Try configured fullscreen width/height */
max_win_width = settings->uints.video_fullscreen_x;
max_win_height = settings->uints.video_fullscreen_y;
if ((max_win_width == 0) || (max_win_height == 0))
{
/* Maximum window width/size *must* be non-zero;
* if all else fails, used defined default
* maximum window size */
max_win_width = DEFAULT_WINDOW_AUTO_WIDTH_MAX;
max_win_height = DEFAULT_WINDOW_AUTO_HEIGHT_MAX;
}
}
/* Determine nominal window size based on
* core geometry */
if (settings->bools.video_force_aspect)
{
/* Do rounding here to simplify integer
* scale correctness. */
unsigned base_width = roundf(geom->base_height *
p_rarch->video_driver_aspect_ratio);
width = roundf(base_width * video_scale);
width = settings->uints.window_position_width;
height = settings->uints.window_position_height;
}
else
width = roundf(geom->base_width * video_scale);
height = roundf(geom->base_height * video_scale);
/* Cap window size to maximum allowed values */
if ((width > max_win_width) || (height > max_win_height))
{
unsigned geom_width = (width > 0) ? width : 1;
unsigned geom_height = (height > 0) ? height : 1;
float geom_aspect = (float)geom_width / (float)geom_height;
float max_win_aspect = (float)max_win_width / (float)max_win_height;
float video_scale = settings->floats.video_scale;
/* Determine maximum allowed window dimensions
* NOTE: We cannot read the actual display
* metrics here, because the context driver
* has not yet been initialised... */
if (geom_aspect > max_win_aspect)
/* > Try explicitly configured values */
unsigned max_win_width = settings->uints.window_auto_width_max;
unsigned max_win_height = settings->uints.window_auto_height_max;
/* > Handle invalid settings */
if ((max_win_width == 0) || (max_win_height == 0))
{
width = max_win_width;
height = geom_height * max_win_width / geom_width;
/* Account for any possible rounding errors... */
height = (height < 1) ? 1 : height;
height = (height > max_win_height) ? max_win_height : height;
/* > Try configured fullscreen width/height */
max_win_width = settings->uints.video_fullscreen_x;
max_win_height = settings->uints.video_fullscreen_y;
if ((max_win_width == 0) || (max_win_height == 0))
{
/* Maximum window width/size *must* be non-zero;
* if all else fails, used defined default
* maximum window size */
max_win_width = DEFAULT_WINDOW_AUTO_WIDTH_MAX;
max_win_height = DEFAULT_WINDOW_AUTO_HEIGHT_MAX;
}
}
/* Determine nominal window size based on
* core geometry */
if (settings->bools.video_force_aspect)
{
/* Do rounding here to simplify integer
* scale correctness. */
unsigned base_width = roundf(geom->base_height *
p_rarch->video_driver_aspect_ratio);
width = roundf(base_width * video_scale);
}
else
width = roundf(geom->base_width * video_scale);
height = roundf(geom->base_height * video_scale);
/* Cap window size to maximum allowed values */
if ((width > max_win_width) || (height > max_win_height))
{
height = max_win_height;
width = geom_width * max_win_height / geom_height;
/* Account for any possible rounding errors... */
width = (width < 1) ? 1 : width;
width = (width > max_win_width) ? max_win_width : width;
unsigned geom_width = (width > 0) ? width : 1;
unsigned geom_height = (height > 0) ? height : 1;
float geom_aspect = (float)geom_width / (float)geom_height;
float max_win_aspect = (float)max_win_width / (float)max_win_height;
if (geom_aspect > max_win_aspect)
{
width = max_win_width;
height = geom_height * max_win_width / geom_width;
/* Account for any possible rounding errors... */
height = (height < 1) ? 1 : height;
height = (height > max_win_height) ? max_win_height : height;
}
else
{
height = max_win_height;
width = geom_width * max_win_height / geom_height;
/* Account for any possible rounding errors... */
width = (width < 1) ? 1 : width;
width = (width > max_win_width) ? max_win_width : width;
}
}
}
}
}
#ifdef __WINRT__
if (settings->bools.video_force_resolution)
{
width = settings->uints.video_fullscreen_x != 0 ? settings->uints.video_fullscreen_x : 3840;
height = settings->uints.video_fullscreen_y != 0 ? settings->uints.video_fullscreen_y : 2160;
}
#endif
if (width && height)
RARCH_LOG("[Video]: Video @ %ux%u\n", width, height);
else

View File

@ -558,6 +558,8 @@ void App::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
/* DisplayInformation event handlers. */
void App::OnDpiChanged(DisplayInformation^ sender, Object^ args)
{
m_windowResized = true;
@ -587,6 +589,12 @@ void App::OnPackageInstalling(PackageCatalog^ sender, PackageInstallingEventArgs
/* Implement UWP equivalents of various win32_* functions */
extern "C" {
bool is_running_on_xbox(void)
{
Platform::String^ device_family = Windows::System::Profile::AnalyticsInfo::VersionInfo->DeviceFamily;
return (device_family == L"Windows.Xbox");
}
bool win32_has_focus(void *data)
{
return App::GetInstance()->IsWindowFocused();
@ -668,12 +676,13 @@ extern "C" {
void win32_check_window(void *data,
bool *quit, bool *resize, unsigned *width, unsigned *height)
{
*quit = App::GetInstance()->IsWindowClosed();
settings_t* settings = config_get_ptr();
if (settings->bools.video_force_resolution)
static bool is_xbox = is_running_on_xbox();
*quit = App::GetInstance()->IsWindowClosed();
if (is_xbox)
{
*width = settings->uints.video_fullscreen_x != 0 ? settings->uints.video_fullscreen_x : 3840;
*height = settings->uints.video_fullscreen_y != 0 ? settings->uints.video_fullscreen_y : 2160;
settings_t* settings = config_get_ptr();
*width = settings->uints.video_fullscreen_x != 0 ? settings->uints.video_fullscreen_x : 3840;
*height = settings->uints.video_fullscreen_y != 0 ? settings->uints.video_fullscreen_y : 2160;
return;
}