mirror of
https://github.com/stenzek/duckstation.git
synced 2026-02-04 05:04:33 +00:00
Qt: Only override with real/fractional scale on Metal renderer
Vulkan/MoltenVK can't handle it.
This commit is contained in:
@@ -56,11 +56,13 @@ const std::optional<WindowInfo>& DisplayWidget::getWindowInfo(RenderAPI render_a
|
||||
if (!m_window_info.has_value())
|
||||
m_window_info = QtUtils::GetWindowInfoForWidget(this, render_api, error);
|
||||
|
||||
m_render_api = m_window_info.has_value() ? render_api : RenderAPI::None;
|
||||
return m_window_info;
|
||||
}
|
||||
|
||||
void DisplayWidget::clearWindowInfo()
|
||||
{
|
||||
m_render_api = RenderAPI::None;
|
||||
m_window_info.reset();
|
||||
}
|
||||
|
||||
@@ -73,7 +75,7 @@ void DisplayWidget::checkForSizeChange()
|
||||
const u16 prev_width = m_window_info->surface_width;
|
||||
const u16 prev_height = m_window_info->surface_height;
|
||||
const float prev_scale = m_window_info->surface_scale;
|
||||
QtUtils::UpdateSurfaceSize(this, &m_window_info.value());
|
||||
QtUtils::UpdateSurfaceSize(this, m_render_api, &m_window_info.value());
|
||||
if (prev_width != m_window_info->surface_width || prev_height != m_window_info->surface_height ||
|
||||
prev_scale != m_window_info->surface_scale)
|
||||
{
|
||||
@@ -517,6 +519,7 @@ const std::optional<WindowInfo>& AuxiliaryDisplayWidget::getWindowInfo(RenderAPI
|
||||
if (!m_window_info.has_value())
|
||||
m_window_info = QtUtils::GetWindowInfoForWidget(this, render_api, error);
|
||||
|
||||
m_render_api = m_window_info.has_value() ? render_api : RenderAPI::None;
|
||||
return m_window_info;
|
||||
}
|
||||
|
||||
@@ -529,7 +532,7 @@ void AuxiliaryDisplayWidget::checkForSizeChange()
|
||||
const u16 prev_width = m_window_info->surface_width;
|
||||
const u16 prev_height = m_window_info->surface_height;
|
||||
const float prev_scale = m_window_info->surface_scale;
|
||||
QtUtils::UpdateSurfaceSize(this, &m_window_info.value());
|
||||
QtUtils::UpdateSurfaceSize(this, m_render_api, &m_window_info.value());
|
||||
if (prev_width != m_window_info->surface_width || prev_height != m_window_info->surface_height ||
|
||||
prev_scale != m_window_info->surface_scale)
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "util/window_info.h"
|
||||
#include "util/gpu_types.h"
|
||||
|
||||
#include "common/types.h"
|
||||
|
||||
@@ -55,6 +56,8 @@ private:
|
||||
bool isActuallyFullscreen() const;
|
||||
void updateCenterPos();
|
||||
|
||||
std::vector<int> m_keys_pressed_with_modifiers;
|
||||
|
||||
QPoint m_relative_mouse_start_pos{};
|
||||
QPoint m_relative_mouse_center_pos{};
|
||||
bool m_relative_mouse_enabled = false;
|
||||
@@ -64,8 +67,7 @@ private:
|
||||
bool m_cursor_hidden = false;
|
||||
bool m_destroying = false;
|
||||
|
||||
std::vector<int> m_keys_pressed_with_modifiers;
|
||||
|
||||
RenderAPI m_render_api = RenderAPI::None;
|
||||
std::optional<WindowInfo> m_window_info;
|
||||
|
||||
const char* m_window_position_key = nullptr;
|
||||
@@ -109,5 +111,6 @@ private:
|
||||
|
||||
void* m_userdata = nullptr;
|
||||
std::optional<WindowInfo> m_window_info;
|
||||
RenderAPI m_render_api = RenderAPI::None;
|
||||
bool m_destroying = false;
|
||||
};
|
||||
|
||||
@@ -132,7 +132,7 @@ std::optional<WindowInfo> QtUtils::GetWindowInfoForWidget(QWidget* widget, Rende
|
||||
}
|
||||
#endif
|
||||
|
||||
UpdateSurfaceSize(widget, &wi);
|
||||
UpdateSurfaceSize(widget, render_api, &wi);
|
||||
|
||||
// Query refresh rate, we need it for sync.
|
||||
Error refresh_rate_error;
|
||||
@@ -156,7 +156,7 @@ std::optional<WindowInfo> QtUtils::GetWindowInfoForWidget(QWidget* widget, Rende
|
||||
return wi;
|
||||
}
|
||||
|
||||
void QtUtils::UpdateSurfaceSize(QWidget* widget, WindowInfo* wi)
|
||||
void QtUtils::UpdateSurfaceSize(QWidget* widget, RenderAPI render_api, WindowInfo* wi)
|
||||
{
|
||||
// Why this nonsense? Qt's device independent sizes are integer, and fractional scaling is lossy.
|
||||
// We can't get back the "real" size of the window. So we have to platform natively query the actual client size.
|
||||
@@ -176,7 +176,10 @@ void QtUtils::UpdateSurfaceSize(QWidget* widget, WindowInfo* wi)
|
||||
wi->surface_width = static_cast<u16>(size->first);
|
||||
wi->surface_height = static_cast<u16>(size->second);
|
||||
wi->surface_scale = static_cast<float>(widget->devicePixelRatio());
|
||||
if (Core::GetBaseBoolSettingValue("Main", "UseFractionalWindowScale", true))
|
||||
|
||||
// Only use "real" fractional window scale for Metal renderer.
|
||||
// Vulkan returns suboptimal constantly, triggering swap chain recreations.
|
||||
if (render_api == RenderAPI::Metal && Core::GetBaseBoolSettingValue("Main", "UseFractionalWindowScale", true))
|
||||
{
|
||||
if (const std::optional<double> real_device_pixel_ratio = CocoaTools::GetViewRealScalingFactor(wi->window_handle))
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@ std::optional<WindowInfo> GetWindowInfoForWidget(QWidget* widget, RenderAPI rend
|
||||
|
||||
/// Calculates the pixel size (real geometry) for a widget.
|
||||
/// Also sets the "real" DPR scale for the widget, ignoring any operating-system level downsampling.
|
||||
void UpdateSurfaceSize(QWidget* widget, WindowInfo* wi);
|
||||
void UpdateSurfaceSize(QWidget* widget, RenderAPI render_api, WindowInfo* wi);
|
||||
|
||||
/// Changes the screensaver inhibit state.
|
||||
bool SetScreensaverInhibit(bool inhibit, Error* error);
|
||||
|
||||
Reference in New Issue
Block a user