mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 07:59:42 +00:00
Make resolution switching automatic and fix angle output issues [UWP/XBOX] (#13406)
* force angle to render at 1080p regardless of screensize as the output is 1080p regardless of screensize. This fixes an issue where at 4k any angle output would be zoomed into a corner * set resolution based on display resolution (auto 4k) * set driver to d3d11 if booting with opengl * reset width and height of output on boot to match display Co-authored-by: Tunip3 <tunip3@users.noreply.github.com>
This commit is contained in:
parent
e1d144e2b8
commit
a28e226ef4
@ -2127,8 +2127,13 @@ static struct config_uint_setting *populate_settings_uint(
|
||||
SETTING_UINT("keyboard_gamepad_mapping_type",&settings->uints.input_keyboard_gamepad_mapping_type, true, 1, false);
|
||||
SETTING_UINT("input_poll_type_behavior", &settings->uints.input_poll_type_behavior, true, 2, false);
|
||||
SETTING_UINT("video_monitor_index", &settings->uints.video_monitor_index, true, DEFAULT_MONITOR_INDEX, false);
|
||||
SETTING_UINT("video_fullscreen_x", &settings->uints.video_fullscreen_x, true, DEFAULT_FULLSCREEN_X, false);
|
||||
SETTING_UINT("video_fullscreen_y", &settings->uints.video_fullscreen_y, true, DEFAULT_FULLSCREEN_Y, false);
|
||||
#ifdef __WINRT__
|
||||
SETTING_UINT("video_fullscreen_x", &settings->uints.video_fullscreen_x, true, uwp_get_width(), false);
|
||||
SETTING_UINT("video_fullscreen_y", &settings->uints.video_fullscreen_y, true, uwp_get_height(), false);
|
||||
#else
|
||||
SETTING_UINT("video_fullscreen_x", &settings->uints.video_fullscreen_x, true, DEFAULT_FULLSCREEN_X, false);
|
||||
SETTING_UINT("video_fullscreen_y", &settings->uints.video_fullscreen_y, true, DEFAULT_FULLSCREEN_Y, false);
|
||||
#endif
|
||||
SETTING_UINT("video_window_opacity", &settings->uints.video_window_opacity, true, DEFAULT_WINDOW_OPACITY, false);
|
||||
#ifdef HAVE_VIDEO_LAYOUT
|
||||
SETTING_UINT("video_layout_selected_view", &settings->uints.video_layout_selected_view, true, 0, false);
|
||||
|
@ -4000,6 +4000,14 @@ static bool gl2_alive(void *data)
|
||||
gl->ctx_driver->check_window(gl->ctx_data,
|
||||
&quit, &resize, &temp_width, &temp_height);
|
||||
|
||||
#ifdef __WINRT__
|
||||
if (is_running_on_xbox())
|
||||
{
|
||||
//we can set it to 1920x1080 as xbox uwp windowsize is guaranteed to be 1920x1080 and currently there is now way to set angle to use a variable resolution swapchain so regardless of the size the window is always 1080p
|
||||
temp_width = 1920;
|
||||
temp_height = 1080;
|
||||
}
|
||||
#endif
|
||||
if (quit)
|
||||
gl->quitting = true;
|
||||
else if (resize)
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include "../gfx_widgets.h"
|
||||
#endif
|
||||
|
||||
|
||||
static const struct video_ortho gl3_default_ortho = {0, 1, 0, 1, -1, 1};
|
||||
|
||||
void gl3_build_default_matrix(float *data)
|
||||
@ -1565,6 +1566,15 @@ static bool gl3_alive(void *data)
|
||||
gl->ctx_driver->check_window(gl->ctx_data,
|
||||
&quit, &resize, &temp_width, &temp_height);
|
||||
|
||||
#ifdef __WINRT__
|
||||
if (is_running_on_xbox())
|
||||
{
|
||||
//we can set it to 1920x1080 as xbox uwp windowsize is guaranteed to be 1920x1080 and currently there is now way to set angle to use a variable resolution swapchain so regardless of the size the window is always 1080p
|
||||
temp_width = 1920;
|
||||
temp_height = 1080;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (quit)
|
||||
gl->quitting = true;
|
||||
else if (resize)
|
||||
|
@ -146,6 +146,12 @@ static void gfx_ctx_uwp_get_video_size(void *data,
|
||||
bool quit;
|
||||
bool resize;
|
||||
win32_check_window(NULL, &quit, &resize, width, height);
|
||||
if (is_running_on_xbox())
|
||||
{
|
||||
//we can set it to 1920x1080 as xbox uwp windowsize is guaranteed to be 1920x1080 and currently there is now way to set angle to use a variable resolution swapchain so regardless of the size the window is always 1080p
|
||||
width = 1920;
|
||||
height = 1080;
|
||||
}
|
||||
}
|
||||
|
||||
static void *gfx_ctx_uwp_init(void *video_driver)
|
||||
|
@ -3305,8 +3305,8 @@ bool video_driver_init_internal(bool *video_is_threaded, bool verbosity_enabled)
|
||||
#ifdef __WINRT__
|
||||
if (is_running_on_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;
|
||||
width = uwp_get_width();
|
||||
height = uwp_get_height();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
@ -30,6 +30,11 @@ void uwp_open_broadfilesystemaccess_settings(void);
|
||||
|
||||
void* uwp_get_corewindow(void);
|
||||
|
||||
bool is_running_on_xbox(void);
|
||||
|
||||
int uwp_get_height(void);
|
||||
int uwp_get_width(void);
|
||||
|
||||
void uwp_input_next_frame(void *data);
|
||||
bool uwp_keyboard_pressed(unsigned key);
|
||||
int16_t uwp_mouse_state(unsigned port, unsigned id, bool screen);
|
||||
|
@ -218,7 +218,6 @@ int main(Platform::Array<Platform::String^>^)
|
||||
Platform::String^ data_dir = Windows::Storage::ApplicationData::Current->LocalFolder->Path + L"\\";
|
||||
wcstombs(uwp_dir_data, data_dir->Data(), sizeof(uwp_dir_data));
|
||||
|
||||
|
||||
// delete vfs cache dir, we do this because this allows a far far more consise implementation than manually implementing a function to do this
|
||||
// this may be a little slower but shouldn't really matter as the cache dir should never have more than a few items
|
||||
Platform::String^ vfs_dir = Windows::Storage::ApplicationData::Current->LocalFolder->Path + L"\\VFSCACHE";
|
||||
@ -337,6 +336,43 @@ void App::Load(Platform::String^ entryPoint)
|
||||
}
|
||||
m_initialized = true;
|
||||
|
||||
if (is_running_on_xbox())
|
||||
{
|
||||
bool reset = false;
|
||||
int width = uwp_get_width();
|
||||
int height = uwp_get_height();
|
||||
//reset driver to d3d11 if set to opengl on boot as cores can just set to gl when needed and there is no good reason to use gl for the menus
|
||||
settings_t* settings = config_get_ptr();
|
||||
char* currentdriver = settings->arrays.video_driver;
|
||||
if (strcmpi(currentdriver, "gl")==0)
|
||||
{
|
||||
//set driver to default
|
||||
configuration_set_string(settings,
|
||||
settings->arrays.video_driver,
|
||||
config_get_default_video());
|
||||
//reset needed
|
||||
reset = true;
|
||||
}
|
||||
if ((settings->uints.video_fullscreen_x != width) || (settings->uints.video_fullscreen_y != height))
|
||||
{
|
||||
//get width and height from display again
|
||||
configuration_set_int(settings,
|
||||
settings->uints.video_fullscreen_x,
|
||||
width);
|
||||
configuration_set_int(settings,
|
||||
settings->uints.video_fullscreen_y,
|
||||
height);
|
||||
//reset needed
|
||||
reset = true;
|
||||
}
|
||||
if (reset)
|
||||
{
|
||||
//restart driver
|
||||
command_event(CMD_EVENT_REINIT, NULL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
auto catalog = Windows::ApplicationModel::PackageCatalog::OpenForCurrentPackage();
|
||||
|
||||
catalog->PackageInstalling +=
|
||||
@ -667,10 +703,10 @@ extern "C" {
|
||||
switch (type)
|
||||
{
|
||||
case DISPLAY_METRIC_PIXEL_WIDTH:
|
||||
*value = DisplayInformation::GetForCurrentView()->ScreenWidthInRawPixels;
|
||||
*value = uwp_get_width();
|
||||
return true;
|
||||
case DISPLAY_METRIC_PIXEL_HEIGHT:
|
||||
*value = DisplayInformation::GetForCurrentView()->ScreenHeightInRawPixels;
|
||||
*value = uwp_get_height();
|
||||
return true;
|
||||
case DISPLAY_METRIC_MM_WIDTH:
|
||||
/* 25.4 mm in an inch. */
|
||||
@ -709,8 +745,8 @@ extern "C" {
|
||||
if (is_xbox)
|
||||
{
|
||||
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;
|
||||
*width = settings->uints.video_fullscreen_x != 0 ? settings->uints.video_fullscreen_x : uwp_get_width();
|
||||
*height = settings->uints.video_fullscreen_y != 0 ? settings->uints.video_fullscreen_y : uwp_get_height();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -728,6 +764,32 @@ extern "C" {
|
||||
return (void*)CoreWindow::GetForCurrentThread();
|
||||
}
|
||||
|
||||
int uwp_get_height(void)
|
||||
{
|
||||
if (is_running_on_xbox())
|
||||
{
|
||||
const Windows::Graphics::Display::Core::HdmiDisplayInformation^ hdi = Windows::Graphics::Display::Core::HdmiDisplayInformation::GetForCurrentView();
|
||||
if (hdi)
|
||||
return Windows::Graphics::Display::Core::HdmiDisplayInformation::GetForCurrentView()->GetCurrentDisplayMode()->ResolutionHeightInRawPixels;
|
||||
}
|
||||
const LONG32 resolution_scale = static_cast<LONG32>(Windows::Graphics::Display::DisplayInformation::GetForCurrentView()->ResolutionScale);
|
||||
auto surface_scale = static_cast<float>(resolution_scale) / 100.0f;
|
||||
return static_cast<LONG32>(CoreWindow::GetForCurrentThread()->Bounds.Height * surface_scale);
|
||||
}
|
||||
|
||||
int uwp_get_width(void)
|
||||
{
|
||||
if (is_running_on_xbox())
|
||||
{
|
||||
const Windows::Graphics::Display::Core::HdmiDisplayInformation^ hdi = Windows::Graphics::Display::Core::HdmiDisplayInformation::GetForCurrentView();
|
||||
if (hdi)
|
||||
return Windows::Graphics::Display::Core::HdmiDisplayInformation::GetForCurrentView()->GetCurrentDisplayMode()->ResolutionWidthInRawPixels;
|
||||
}
|
||||
const LONG32 resolution_scale = static_cast<LONG32>(Windows::Graphics::Display::DisplayInformation::GetForCurrentView()->ResolutionScale);
|
||||
auto surface_scale = static_cast<float>(resolution_scale) / 100.0f;
|
||||
return static_cast<LONG32>(CoreWindow::GetForCurrentThread()->Bounds.Width * surface_scale);
|
||||
}
|
||||
|
||||
void uwp_fill_installed_core_packages(struct string_list *list)
|
||||
{
|
||||
for (auto package : Windows::ApplicationModel::Package::Current->Dependencies)
|
||||
|
Loading…
Reference in New Issue
Block a user