From 4981320657d53a631ce37f3bd0aa1229d9f8ef4d Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Mon, 4 Oct 2021 03:26:31 +0200 Subject: [PATCH] early-access version 2104 --- CMakeLists.txt | 10 +- CMakeModules/CopyYuzuQt5Deps.cmake | 1 + README.md | 2 +- src/audio_core/command_generator.cpp | 3 + src/audio_core/mix_context.cpp | 2 + src/audio_core/voice_context.cpp | 2 + src/common/CMakeLists.txt | 1 + src/common/logging/backend.cpp | 3 + src/common/logging/log.h | 6 +- src/common/logging/log_entry.h | 28 ++ src/common/logging/text_formatter.cpp | 1 + src/common/logging/types.h | 17 - src/common/param_package.cpp | 1 + .../hle/kernel/k_auto_object_container.cpp | 2 + .../service/am/applets/applet_web_browser.cpp | 10 + src/core/hle/service/lbl/lbl.cpp | 1 + .../system_clock_context_update_callback.h | 1 + src/core/hle/service/time/system_clock_core.h | 2 + src/core/network/network.cpp | 2 - src/video_core/gpu.h | 1 + .../renderer_opengl/gl_texture_cache.cpp | 1 + .../renderer_opengl/gl_texture_cache.h | 1 + .../renderer_vulkan/vk_texture_cache.cpp | 1 + .../renderer_vulkan/vk_texture_cache.h | 2 +- .../texture_cache/image_view_info.cpp | 1 + src/video_core/texture_cache/texture_cache.h | 5 + .../texture_cache/texture_cache_base.h | 6 - src/yuzu/configuration/configure_tas.cpp | 1 + src/yuzu/configuration/configure_tas.ui | 333 ++++++++++-------- src/yuzu/main.cpp | 48 ++- 30 files changed, 314 insertions(+), 181 deletions(-) create mode 100755 src/common/logging/log_entry.h diff --git a/CMakeLists.txt b/CMakeLists.txt index bd0f6b978..123a3082a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -237,7 +237,7 @@ yuzu_find_packages() # Qt5 requires that we find components, so it doesn't fit our pretty little find package function if(ENABLE_QT) - set(QT_VERSION 5.12) + set(QT_VERSION 5.15) # We want to load the generated conan qt config so that we get the QT_ROOT var so that we can use the official # Qt5Config inside the root folder instead of the conan generated one. if(EXISTS ${CMAKE_BINARY_DIR}/qtConfig.cmake) @@ -339,8 +339,8 @@ if(ENABLE_QT) set(QT_PREFIX_HINT) if(YUZU_USE_BUNDLED_QT) - if ((MSVC_VERSION GREATER_EQUAL 1910 AND MSVC_VERSION LESS 1930) AND ARCHITECTURE_x86_64) - set(QT_BUILD qt-5.12.8-msvc2017_64) + if ((MSVC_VERSION GREATER_EQUAL 1920 AND MSVC_VERSION LESS 1940) AND ARCHITECTURE_x86_64) + set(QT_BUILD qt-5.15.2-msvc2019_64) elseif ((${CMAKE_SYSTEM_NAME} STREQUAL "Linux") AND NOT MINGW AND ARCHITECTURE_x86_64) set(QT_BUILD qt5_5_15_2) else() @@ -369,7 +369,7 @@ endif() if (ENABLE_SDL2) if (YUZU_USE_BUNDLED_SDL2) # Detect toolchain and platform - if ((MSVC_VERSION GREATER_EQUAL 1910 AND MSVC_VERSION LESS 1930) AND ARCHITECTURE_x86_64) + if ((MSVC_VERSION GREATER_EQUAL 1920 AND MSVC_VERSION LESS 1940) AND ARCHITECTURE_x86_64) set(SDL2_VER "SDL2-2.0.16") else() message(FATAL_ERROR "No bundled SDL2 binaries for your toolchain. Disable YUZU_USE_BUNDLED_SDL2 and provide your own.") @@ -462,7 +462,7 @@ if (CONAN_REQUIRED_LIBS) if(ENABLE_QT) list(APPEND CMAKE_MODULE_PATH "${CONAN_QT_ROOT_RELEASE}") list(APPEND CMAKE_PREFIX_PATH "${CONAN_QT_ROOT_RELEASE}") - find_package(Qt5 5.12 REQUIRED COMPONENTS Widgets) + find_package(Qt5 5.15 REQUIRED COMPONENTS Widgets) if (YUZU_USE_QT_WEB_ENGINE) find_package(Qt5 REQUIRED COMPONENTS WebEngineCore WebEngineWidgets) endif() diff --git a/CMakeModules/CopyYuzuQt5Deps.cmake b/CMakeModules/CopyYuzuQt5Deps.cmake index 4a6aeebbb..dd97f5b2b 100755 --- a/CMakeModules/CopyYuzuQt5Deps.cmake +++ b/CMakeModules/CopyYuzuQt5Deps.cmake @@ -33,6 +33,7 @@ function(copy_yuzu_Qt5_deps target_dir) Qt5Positioning$<$:d>.* Qt5PrintSupport$<$:d>.* Qt5Qml$<$:d>.* + Qt5QmlModels$<$:d>.* Qt5Quick$<$:d>.* Qt5QuickWidgets$<$:d>.* Qt5WebChannel$<$:d>.* diff --git a/README.md b/README.md index c3121ff1a..b73995abe 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 2101. +This is the source code for early-access 2104. ## Legal Notice diff --git a/src/audio_core/command_generator.cpp b/src/audio_core/command_generator.cpp index 45b2eef52..830af46ad 100755 --- a/src/audio_core/command_generator.cpp +++ b/src/audio_core/command_generator.cpp @@ -2,13 +2,16 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include #include #include + #include "audio_core/algorithm/interpolate.h" #include "audio_core/command_generator.h" #include "audio_core/effect_context.h" #include "audio_core/mix_context.h" #include "audio_core/voice_context.h" +#include "common/common_types.h" #include "core/memory.h" namespace AudioCore { diff --git a/src/audio_core/mix_context.cpp b/src/audio_core/mix_context.cpp index 4bca72eb0..057aab5ad 100755 --- a/src/audio_core/mix_context.cpp +++ b/src/audio_core/mix_context.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include + #include "audio_core/behavior_info.h" #include "audio_core/common.h" #include "audio_core/effect_context.h" diff --git a/src/audio_core/voice_context.cpp b/src/audio_core/voice_context.cpp index d8c954b60..75012a887 100755 --- a/src/audio_core/voice_context.cpp +++ b/src/audio_core/voice_context.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include + #include "audio_core/behavior_info.h" #include "audio_core/voice_context.h" #include "core/memory.h" diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index b18a2a2f5..cb5c0f326 100755 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -79,6 +79,7 @@ add_library(common STATIC logging/filter.cpp logging/filter.h logging/log.h + logging/log_entry.h logging/text_formatter.cpp logging/text_formatter.h logging/types.h diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index e40d117d6..0e85a9c1d 100755 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -9,6 +9,8 @@ #include #include +#include + #ifdef _WIN32 #include // For OutputDebugStringW #endif @@ -22,6 +24,7 @@ #include "common/logging/backend.h" #include "common/logging/log.h" +#include "common/logging/log_entry.h" #include "common/logging/text_formatter.h" #include "common/settings.h" #ifdef _WIN32 diff --git a/src/common/logging/log.h b/src/common/logging/log.h index 8d43eddc7..c186d55ef 100755 --- a/src/common/logging/log.h +++ b/src/common/logging/log.h @@ -4,7 +4,11 @@ #pragma once -#include +#include +#include + +#include + #include "common/logging/types.h" namespace Common::Log { diff --git a/src/common/logging/log_entry.h b/src/common/logging/log_entry.h new file mode 100755 index 000000000..dd6f44841 --- /dev/null +++ b/src/common/logging/log_entry.h @@ -0,0 +1,28 @@ +// Copyright 2021 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include + +#include "common/logging/types.h" + +namespace Common::Log { + +/** + * A log entry. Log entries are store in a structured format to permit more varied output + * formatting on different frontends, as well as facilitating filtering and aggregation. + */ +struct Entry { + std::chrono::microseconds timestamp; + Class log_class{}; + Level log_level{}; + const char* filename = nullptr; + unsigned int line_num = 0; + std::string function; + std::string message; + bool final_entry = false; +}; + +} // namespace Common::Log diff --git a/src/common/logging/text_formatter.cpp b/src/common/logging/text_formatter.cpp index cfc0d5846..10b2281db 100755 --- a/src/common/logging/text_formatter.cpp +++ b/src/common/logging/text_formatter.cpp @@ -13,6 +13,7 @@ #include "common/common_funcs.h" #include "common/logging/filter.h" #include "common/logging/log.h" +#include "common/logging/log_entry.h" #include "common/logging/text_formatter.h" #include "common/string_util.h" diff --git a/src/common/logging/types.h b/src/common/logging/types.h index ddf9d27ca..2d21fc483 100755 --- a/src/common/logging/types.h +++ b/src/common/logging/types.h @@ -4,8 +4,6 @@ #pragma once -#include - #include "common/common_types.h" namespace Common::Log { @@ -131,19 +129,4 @@ enum class Class : u8 { Count ///< Total number of logging classes }; -/** - * A log entry. Log entries are store in a structured format to permit more varied output - * formatting on different frontends, as well as facilitating filtering and aggregation. - */ -struct Entry { - std::chrono::microseconds timestamp; - Class log_class{}; - Level log_level{}; - const char* filename = nullptr; - unsigned int line_num = 0; - std::string function; - std::string message; - bool final_entry = false; -}; - } // namespace Common::Log diff --git a/src/common/param_package.cpp b/src/common/param_package.cpp index b916b4866..bbf20f5eb 100755 --- a/src/common/param_package.cpp +++ b/src/common/param_package.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include #include #include diff --git a/src/core/hle/kernel/k_auto_object_container.cpp b/src/core/hle/kernel/k_auto_object_container.cpp index 010006bb7..d5f80d5b2 100755 --- a/src/core/hle/kernel/k_auto_object_container.cpp +++ b/src/core/hle/kernel/k_auto_object_container.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include + #include "core/hle/kernel/k_auto_object_container.h" namespace Kernel { diff --git a/src/core/hle/service/am/applets/applet_web_browser.cpp b/src/core/hle/service/am/applets/applet_web_browser.cpp index 35f194961..927eeefff 100755 --- a/src/core/hle/service/am/applets/applet_web_browser.cpp +++ b/src/core/hle/service/am/applets/applet_web_browser.cpp @@ -24,6 +24,7 @@ #include "core/hle/service/am/applets/applet_web_browser.h" #include "core/hle/service/filesystem/filesystem.h" #include "core/hle/service/ns/pl_u.h" +#include "core/loader/loader.h" namespace Service::AM::Applets { @@ -122,6 +123,15 @@ FileSys::VirtualFile GetOfflineRomFS(Core::System& system, u64 title_id, const auto nca = system.GetContentProvider().GetEntry(title_id, nca_type); if (nca == nullptr) { + if (nca_type == FileSys::ContentRecordType::HtmlDocument) { + LOG_WARNING(Service_AM, "Falling back to AppLoader to get the RomFS."); + FileSys::VirtualFile romfs; + system.GetAppLoader().ReadManualRomFS(romfs); + if (romfs != nullptr) { + return romfs; + } + } + LOG_ERROR(Service_AM, "NCA of type={} with title_id={:016X} is not found in the ContentProvider!", nca_type, title_id); diff --git a/src/core/hle/service/lbl/lbl.cpp b/src/core/hle/service/lbl/lbl.cpp index 24890c830..37ff37277 100755 --- a/src/core/hle/service/lbl/lbl.cpp +++ b/src/core/hle/service/lbl/lbl.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include #include #include "common/logging/log.h" diff --git a/src/core/hle/service/time/system_clock_context_update_callback.h b/src/core/hle/service/time/system_clock_context_update_callback.h index 797954958..6936397a5 100755 --- a/src/core/hle/service/time/system_clock_context_update_callback.h +++ b/src/core/hle/service/time/system_clock_context_update_callback.h @@ -4,6 +4,7 @@ #pragma once +#include #include #include "core/hle/service/time/clock_types.h" diff --git a/src/core/hle/service/time/system_clock_core.h b/src/core/hle/service/time/system_clock_core.h index 83d0e5d62..b9237ad28 100755 --- a/src/core/hle/service/time/system_clock_core.h +++ b/src/core/hle/service/time/system_clock_core.h @@ -4,6 +4,8 @@ #pragma once +#include + #include "common/common_types.h" #include "core/hle/service/time/clock_types.h" diff --git a/src/core/network/network.cpp b/src/core/network/network.cpp index 72eea52f0..a3e0664b9 100755 --- a/src/core/network/network.cpp +++ b/src/core/network/network.cpp @@ -366,8 +366,6 @@ std::optional GetHostIPv4Address() { if (res != network_interfaces.end()) { char ip_addr[16] = {}; ASSERT(inet_ntop(AF_INET, &res->ip_address, ip_addr, sizeof(ip_addr)) != nullptr); - LOG_INFO(Network, "IP address: {}", ip_addr); - return TranslateIPv4(res->ip_address); } else { LOG_ERROR(Network, "Couldn't find selected interface \"{}\"", selected_network_interface); diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index a2bbfd99e..05e5c94f3 100755 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #pragma once + #include #include "common/bit_field.h" diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp index 54dae2c41..8c3ca3d82 100755 --- a/src/video_core/renderer_opengl/gl_texture_cache.cpp +++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp @@ -20,6 +20,7 @@ #include "video_core/surface.h" #include "video_core/texture_cache/formatter.h" #include "video_core/texture_cache/samples_helper.h" +#include "video_core/texture_cache/util.h" namespace OpenGL { namespace { diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.h index c498a8a8f..1ca2c90be 100755 --- a/src/video_core/renderer_opengl/gl_texture_cache.h +++ b/src/video_core/renderer_opengl/gl_texture_cache.h @@ -12,6 +12,7 @@ #include "shader_recompiler/shader_info.h" #include "video_core/renderer_opengl/gl_resource_manager.h" #include "video_core/renderer_opengl/util_shaders.h" +#include "video_core/texture_cache/image_view_base.h" #include "video_core/texture_cache/texture_cache_base.h" namespace OpenGL { diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 3b87640b5..06c5fb867 100755 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp @@ -21,6 +21,7 @@ #include "video_core/renderer_vulkan/vk_texture_cache.h" #include "video_core/texture_cache/formatter.h" #include "video_core/texture_cache/samples_helper.h" +#include "video_core/texture_cache/util.h" #include "video_core/vulkan_common/vulkan_device.h" #include "video_core/vulkan_common/vulkan_memory_allocator.h" #include "video_core/vulkan_common/vulkan_wrapper.h" diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.h b/src/video_core/renderer_vulkan/vk_texture_cache.h index 6d5a68bfe..b09c468e4 100755 --- a/src/video_core/renderer_vulkan/vk_texture_cache.h +++ b/src/video_core/renderer_vulkan/vk_texture_cache.h @@ -4,11 +4,11 @@ #pragma once -#include #include #include "shader_recompiler/shader_info.h" #include "video_core/renderer_vulkan/vk_staging_buffer_pool.h" +#include "video_core/texture_cache/image_view_base.h" #include "video_core/texture_cache/texture_cache_base.h" #include "video_core/vulkan_common/vulkan_memory_allocator.h" #include "video_core/vulkan_common/vulkan_wrapper.h" diff --git a/src/video_core/texture_cache/image_view_info.cpp b/src/video_core/texture_cache/image_view_info.cpp index 6527e14c8..e751f26c7 100755 --- a/src/video_core/texture_cache/image_view_info.cpp +++ b/src/video_core/texture_cache/image_view_info.cpp @@ -8,6 +8,7 @@ #include "video_core/texture_cache/image_view_info.h" #include "video_core/texture_cache/texture_cache_base.h" #include "video_core/texture_cache/types.h" +#include "video_core/texture_cache/util.h" #include "video_core/textures/texture.h" namespace VideoCommon { diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index c6e50bb5f..f70c1f764 100755 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h @@ -4,10 +4,15 @@ #pragma once +#include + #include "common/alignment.h" #include "video_core/dirty_flags.h" +#include "video_core/engines/kepler_compute.h" +#include "video_core/texture_cache/image_view_base.h" #include "video_core/texture_cache/samples_helper.h" #include "video_core/texture_cache/texture_cache_base.h" +#include "video_core/texture_cache/util.h" namespace VideoCommon { diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h index 423402128..2d1893c1c 100755 --- a/src/video_core/texture_cache/texture_cache_base.h +++ b/src/video_core/texture_cache/texture_cache_base.h @@ -8,7 +8,6 @@ #include #include #include -#include #include #include @@ -18,10 +17,6 @@ #include "video_core/compatible_formats.h" #include "video_core/delayed_destruction_ring.h" #include "video_core/engines/fermi_2d.h" -#include "video_core/engines/kepler_compute.h" -#include "video_core/engines/maxwell_3d.h" -#include "video_core/memory_manager.h" -#include "video_core/rasterizer_interface.h" #include "video_core/surface.h" #include "video_core/texture_cache/descriptor_table.h" #include "video_core/texture_cache/image_base.h" @@ -30,7 +25,6 @@ #include "video_core/texture_cache/render_targets.h" #include "video_core/texture_cache/slot_vector.h" #include "video_core/texture_cache/types.h" -#include "video_core/texture_cache/util.h" #include "video_core/textures/texture.h" namespace VideoCommon { diff --git a/src/yuzu/configuration/configure_tas.cpp b/src/yuzu/configuration/configure_tas.cpp index b666b175a..8e5a4c72d 100755 --- a/src/yuzu/configuration/configure_tas.cpp +++ b/src/yuzu/configuration/configure_tas.cpp @@ -18,6 +18,7 @@ ConfigureTasDialog::ConfigureTasDialog(QWidget* parent) setFocusPolicy(Qt::ClickFocus); setWindowTitle(tr("TAS Configuration")); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); connect(ui->tas_path_button, &QToolButton::pressed, this, [this] { SetDirectory(DirectoryTarget::TAS, ui->tas_path_edit); }); diff --git a/src/yuzu/configuration/configure_tas.ui b/src/yuzu/configuration/configure_tas.ui index 95575ed9d..3972f9083 100755 --- a/src/yuzu/configuration/configure_tas.ui +++ b/src/yuzu/configuration/configure_tas.ui @@ -1,153 +1,194 @@ - ConfigureTas - - - - - - - - TAS - - - - - - Reads controller input from scripts in the same format as TAS-nx scripts.<br/>For a more detailed explanation please consult the FAQ on the yuzu website. - - - - - - - To check which hotkeys control the playback/recording, please refer to the Hotkey settings (General -> Hotkeys). - - - true - - - - - - - WARNING: This is an experimental feature.<br/>It will not play back scripts frame perfectly with the current, imperfect syncing method. - - - true - - - - - - - - - - - - - - Settings - - - - - - Enable TAS features - - - - - - - Automatic controller profile swapping - - - - - - - Loop script - - - - - - - false - - - Pause execution during loads - - - - - - - - - - - - - - Script Directory - - - - - - Path - - - - - - - ... - - - - - - - - - - - - - - - - 0 - 0 - + ConfigureTas + + + + 0 + 0 + 337 + 316 + + + + + + + + + TAS + + + + + + Reads controller input from scripts in the same format as TAS-nx scripts.<br/>For a more detailed explanation please consult the FAQ on the yuzu website. - - Qt::Horizontal + + + + + + To check which hotkeys control the playback/recording, please refer to the Hotkey settings (General -> Hotkeys). - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + true - - + + + + + + WARNING: This is an experimental feature.<br/>It will not play back scripts frame perfectly with the current, imperfect syncing method. + + + true + + + + + + - - - - - buttonBox - accepted() - ConfigureTas - accept() - - - buttonBox - rejected() - ConfigureTas - reject() - - + + + + + + + Settings + + + + + + Enable TAS features + + + + + + + Automatic controller profile swapping + + + + + + + Loop script + + + + + + + false + + + Pause execution during loads + + + + + + + + + + + + + + Script Directory + + + + + + Path + + + + + + + ... + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 0 + 0 + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + ConfigureTas + accept() + + + 20 + 20 + + + 20 + 20 + + + + + buttonBox + rejected() + ConfigureTas + reject() + + + 20 + 20 + + + 20 + 20 + + + + diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 0bd0c5b04..389851f37 100755 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -59,6 +59,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual #include #include #include +#include #include #include #include @@ -2920,8 +2921,13 @@ void GMainWindow::UpdateWindowTitle(std::string_view title_name, std::string_vie if (title_name.empty()) { setWindowTitle(QString::fromStdString(window_title)); } else { - const auto run_title = - fmt::format("{} | {} | {} | {}", window_title, title_name, title_version, gpu_vendor); + const auto run_title = [window_title, title_name, title_version, gpu_vendor]() { + if (title_version.empty()) { + return fmt::format("{} | {} | {}", window_title, title_name, gpu_vendor); + } + return fmt::format("{} | {} | {} | {}", window_title, title_name, title_version, + gpu_vendor); + }(); setWindowTitle(QString::fromStdString(run_title)); } } @@ -3452,6 +3458,41 @@ void GMainWindow::SetDiscordEnabled([[maybe_unused]] bool state) { #undef main #endif +static void SetHighDPIAttributes(int argc, char* argv[]) { + // Create a temporary QApplication as a workaround to get the current screen geometry. + QApplication* temp_app = new QApplication(argc, argv); + + const QScreen* primary_screen = temp_app->primaryScreen(); + const QRect screen_rect = primary_screen->geometry(); + const int real_width = screen_rect.width(); + const int real_height = screen_rect.height(); + const float real_ratio = primary_screen->logicalDotsPerInch() / 96.0f; + + delete temp_app; + + // Recommended minimum width and height for proper window fit. + // Any screen with a lower resolution than this will still have a scale of 1. + constexpr float minimum_width = 1350.0f; + constexpr float minimum_height = 900.0f; + + const float width_ratio = std::max(1.0f, real_width / minimum_width); + const float height_ratio = std::max(1.0f, real_height / minimum_height); + + // Get the lower of the 2 ratios and truncate, this is the maximum integer scale. + const float max_ratio = std::trunc(std::min(width_ratio, height_ratio)); + + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); + + if (max_ratio > real_ratio) { + QApplication::setHighDpiScaleFactorRoundingPolicy( + Qt::HighDpiScaleFactorRoundingPolicy::Round); + } else { + QApplication::setHighDpiScaleFactorRoundingPolicy( + Qt::HighDpiScaleFactorRoundingPolicy::Floor); + } +} + int main(int argc, char* argv[]) { Common::DetachedTasks detached_tasks; MicroProfileOnThreadCreate("Frontend"); @@ -3484,8 +3525,11 @@ int main(int argc, char* argv[]) { } #endif + SetHighDPIAttributes(argc, argv); + // Enables the core to make the qt created contexts current on std::threads QCoreApplication::setAttribute(Qt::AA_DontCheckOpenGLContextThreadAffinity); + QApplication app(argc, argv); // Qt changes the locale and causes issues in float conversion using std::to_string() when