[UI] Image post-processing and full presentation/window rework

[GPU] Add FXAA post-processing
[UI] Add FidelityFX FSR and CAS post-processing
[UI] Add blue noise dithering from 10bpc to 8bpc
[GPU] Apply the DC PWL gamma ramp closer to the spec, supporting fully white color
[UI] Allow the GPU CP thread to present on the host directly, bypassing the UI thread OS paint event
[UI] Allow variable refresh rate (or tearing)
[UI] Present the newest frame (restart) on DXGI
[UI] Replace GraphicsContext with a far more advanced Presenter with more coherent surface connection and UI overlay state management
[UI] Connect presentation to windows via the Surface class, not native window handles
[Vulkan] Switch to simpler Vulkan setup with no instance/device separation due to interdependencies and to pass fewer objects around
[Vulkan] Lower the minimum required Vulkan version to 1.0
[UI/GPU] Various cleanup, mainly ComPtr usage
[UI] Support per-monitor DPI awareness v2 on Windows
[UI] DPI-scale Dear ImGui
[UI] Replace the remaining non-detachable window delegates with unified window event and input listeners
[UI] Allow listeners to safely destroy or close the window, and to register/unregister listeners without use-after-free and the ABA problem
[UI] Explicit Z ordering of input listeners and UI overlays, top-down for input, bottom-up for drawing
[UI] Add explicit window lifecycle phases
[UI] Replace Window virtual functions with explicit desired state, its application, actual state, its feedback
[UI] GTK: Apply the initial size to the drawing area
[UI] Limit internal UI frame rate to that of the monitor
[UI] Hide the cursor using a timer instead of polling due to no repeated UI thread paints with GPU CP thread presentation, and only within the window
This commit is contained in:
Triang3l
2022-01-29 13:22:03 +03:00
parent 372bdd3ec9
commit fe3f0f26e4
428 changed files with 75942 additions and 18360 deletions

View File

@@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2021 Ben Vanik. All rights reserved. *
* Copyright 2022 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
@@ -19,37 +19,64 @@
// Autogenerated by `xb premake`.
#include "build/version.h"
// For RequestHighPerformance.
// For RequestWin32MMCSS.
#include <dwmapi.h>
// For RequestWin32HighResolutionTimer.
#include <winternl.h>
DEFINE_bool(win32_high_freq, true,
"Requests high performance from the NT kernel", "Kernel");
DEFINE_bool(win32_high_resolution_timer, true,
"Requests high-resolution timer from the NT kernel", "Win32");
DEFINE_bool(
win32_mmcss, true,
"Opt in the Multimedia Class Scheduler Service (MMCSS) scheduling for "
"prioritized access to CPU resources",
"Win32");
namespace xe {
static void RequestHighPerformance() {
#if XE_PLATFORM_WIN32
NTSTATUS(*NtQueryTimerResolution)
(OUT PULONG MinimumResolution, OUT PULONG MaximumResolution,
OUT PULONG CurrentResolution);
static void RequestWin32HighResolutionTimer() {
HMODULE ntdll_module = GetModuleHandleW(L"ntdll.dll");
if (!ntdll_module) {
return;
}
NTSTATUS(*NtSetTimerResolution)
(IN ULONG DesiredResolution, IN BOOLEAN SetResolution,
OUT PULONG CurrentResolution);
NtQueryTimerResolution = (decltype(NtQueryTimerResolution))GetProcAddress(
GetModuleHandleW(L"ntdll.dll"), "NtQueryTimerResolution");
NtSetTimerResolution = (decltype(NtSetTimerResolution))GetProcAddress(
GetModuleHandleW(L"ntdll.dll"), "NtSetTimerResolution");
if (!NtQueryTimerResolution || !NtSetTimerResolution) {
// clang-format off
NTSTATUS (NTAPI* nt_query_timer_resolution)(OUT PULONG MinimumResolution,
OUT PULONG MaximumResolution,
OUT PULONG CurrentResolution);
NTSTATUS (NTAPI* nt_set_timer_resolution)(IN ULONG DesiredResolution,
IN BOOLEAN SetResolution,
OUT PULONG CurrentResolution);
// clang-format on
nt_query_timer_resolution =
reinterpret_cast<decltype(nt_query_timer_resolution)>(
GetProcAddress(ntdll_module, "NtQueryTimerResolution"));
nt_set_timer_resolution = reinterpret_cast<decltype(nt_set_timer_resolution)>(
GetProcAddress(ntdll_module, "NtSetTimerResolution"));
if (!nt_query_timer_resolution || !nt_set_timer_resolution) {
return;
}
ULONG minimum_resolution, maximum_resolution, current_resolution;
NtQueryTimerResolution(&minimum_resolution, &maximum_resolution,
&current_resolution);
NtSetTimerResolution(maximum_resolution, TRUE, &current_resolution);
#endif
nt_query_timer_resolution(&minimum_resolution, &maximum_resolution,
&current_resolution);
nt_set_timer_resolution(maximum_resolution, TRUE, &current_resolution);
}
static void RequestWin32MMCSS() {
HMODULE dwmapi_module = LoadLibraryW(L"dwmapi.dll");
if (!dwmapi_module) {
return;
}
// clang-format off
HRESULT (STDAPICALLTYPE* dwm_enable_mmcss)(BOOL fEnableMMCSS);
// clang-format on
dwm_enable_mmcss = reinterpret_cast<decltype(dwm_enable_mmcss)>(
GetProcAddress(dwmapi_module, "DwmEnableMMCSS"));
if (dwm_enable_mmcss) {
dwm_enable_mmcss(TRUE);
}
FreeLibrary(dwmapi_module);
}
bool ParseWin32LaunchArguments(
@@ -103,9 +130,12 @@ int InitializeWin32App(const std::string_view app_name) {
#endif
XE_BUILD_BRANCH "@" XE_BUILD_COMMIT_SHORT " on " XE_BUILD_DATE);
// Request high performance timing.
if (cvars::win32_high_freq) {
RequestHighPerformance();
// Request high-performance timing and scheduling.
if (cvars::win32_high_resolution_timer) {
RequestWin32HighResolutionTimer();
}
if (cvars::win32_mmcss) {
RequestWin32MMCSS();
}
return 0;