mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-07-03 01:17:56 -05:00
Merge pull request #10125 from lat9nq/vsync-select
configuration: Expose separate swap present modes
This commit is contained in:
@ -189,6 +189,8 @@ add_executable(yuzu
|
||||
multiplayer/state.h
|
||||
multiplayer/validation.h
|
||||
precompiled_headers.h
|
||||
qt_common.cpp
|
||||
qt_common.h
|
||||
startup_checks.cpp
|
||||
startup_checks.h
|
||||
uisettings.cpp
|
||||
|
@ -1,36 +1,48 @@
|
||||
// SPDX-FileCopyrightText: 2014 Citra Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <glad/glad.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QtCore/qglobal.h>
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA
|
||||
#include <QCamera>
|
||||
#include <QCameraImageCapture>
|
||||
#include <QCameraInfo>
|
||||
#endif
|
||||
#include <QCursor>
|
||||
#include <QEvent>
|
||||
#include <QGuiApplication>
|
||||
#include <QHBoxLayout>
|
||||
#include <QKeyEvent>
|
||||
#include <QLayout>
|
||||
#include <QList>
|
||||
#include <QMessageBox>
|
||||
#include <QPainter>
|
||||
#include <QScreen>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QSize>
|
||||
#include <QStringLiteral>
|
||||
#include <QSurfaceFormat>
|
||||
#include <QTimer>
|
||||
#include <QWindow>
|
||||
#include <QtCore/qobjectdefs.h>
|
||||
|
||||
#ifdef HAS_OPENGL
|
||||
#include <QOffscreenSurface>
|
||||
#include <QOpenGLContext>
|
||||
#endif
|
||||
|
||||
#if !defined(WIN32)
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
#endif
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/microprofile.h"
|
||||
#include "common/polyfill_thread.h"
|
||||
#include "common/scm_rev.h"
|
||||
#include "common/settings.h"
|
||||
#include "common/settings_input.h"
|
||||
#include "common/thread.h"
|
||||
#include "core/core.h"
|
||||
#include "core/cpu_manager.h"
|
||||
#include "core/frontend/framebuffer_layout.h"
|
||||
@ -40,11 +52,16 @@
|
||||
#include "input_common/drivers/tas_input.h"
|
||||
#include "input_common/drivers/touch_screen.h"
|
||||
#include "input_common/main.h"
|
||||
#include "video_core/gpu.h"
|
||||
#include "video_core/rasterizer_interface.h"
|
||||
#include "video_core/renderer_base.h"
|
||||
#include "yuzu/bootmanager.h"
|
||||
#include "yuzu/main.h"
|
||||
#include "yuzu/qt_common.h"
|
||||
|
||||
static Core::Frontend::WindowSystemType GetWindowSystemType();
|
||||
class QObject;
|
||||
class QPaintEngine;
|
||||
class QSurface;
|
||||
|
||||
EmuThread::EmuThread(Core::System& system) : m_system{system} {}
|
||||
|
||||
@ -154,7 +171,10 @@ public:
|
||||
|
||||
// disable vsync for any shared contexts
|
||||
auto format = share_context->format();
|
||||
format.setSwapInterval(main_surface ? Settings::values.use_vsync.GetValue() : 0);
|
||||
const int swap_interval =
|
||||
Settings::values.vsync_mode.GetValue() == Settings::VSyncMode::Immediate ? 0 : 1;
|
||||
|
||||
format.setSwapInterval(main_surface ? swap_interval : 0);
|
||||
|
||||
context = std::make_unique<QOpenGLContext>();
|
||||
context->setShareContext(share_context);
|
||||
@ -221,7 +241,7 @@ public:
|
||||
explicit RenderWidget(GRenderWindow* parent) : QWidget(parent), render_window(parent) {
|
||||
setAttribute(Qt::WA_NativeWindow);
|
||||
setAttribute(Qt::WA_PaintOnScreen);
|
||||
if (GetWindowSystemType() == Core::Frontend::WindowSystemType::Wayland) {
|
||||
if (QtCommon::GetWindowSystemType() == Core::Frontend::WindowSystemType::Wayland) {
|
||||
setAttribute(Qt::WA_DontCreateNativeAncestors);
|
||||
}
|
||||
}
|
||||
@ -259,46 +279,6 @@ struct NullRenderWidget : public RenderWidget {
|
||||
explicit NullRenderWidget(GRenderWindow* parent) : RenderWidget(parent) {}
|
||||
};
|
||||
|
||||
static Core::Frontend::WindowSystemType GetWindowSystemType() {
|
||||
// Determine WSI type based on Qt platform.
|
||||
QString platform_name = QGuiApplication::platformName();
|
||||
if (platform_name == QStringLiteral("windows"))
|
||||
return Core::Frontend::WindowSystemType::Windows;
|
||||
else if (platform_name == QStringLiteral("xcb"))
|
||||
return Core::Frontend::WindowSystemType::X11;
|
||||
else if (platform_name == QStringLiteral("wayland"))
|
||||
return Core::Frontend::WindowSystemType::Wayland;
|
||||
else if (platform_name == QStringLiteral("wayland-egl"))
|
||||
return Core::Frontend::WindowSystemType::Wayland;
|
||||
else if (platform_name == QStringLiteral("cocoa"))
|
||||
return Core::Frontend::WindowSystemType::Cocoa;
|
||||
else if (platform_name == QStringLiteral("android"))
|
||||
return Core::Frontend::WindowSystemType::Android;
|
||||
|
||||
LOG_CRITICAL(Frontend, "Unknown Qt platform {}!", platform_name.toStdString());
|
||||
return Core::Frontend::WindowSystemType::Windows;
|
||||
}
|
||||
|
||||
static Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window) {
|
||||
Core::Frontend::EmuWindow::WindowSystemInfo wsi;
|
||||
wsi.type = GetWindowSystemType();
|
||||
|
||||
// Our Win32 Qt external doesn't have the private API.
|
||||
#if defined(WIN32) || defined(__APPLE__)
|
||||
wsi.render_surface = window ? reinterpret_cast<void*>(window->winId()) : nullptr;
|
||||
#else
|
||||
QPlatformNativeInterface* pni = QGuiApplication::platformNativeInterface();
|
||||
wsi.display_connection = pni->nativeResourceForWindow("display", window);
|
||||
if (wsi.type == Core::Frontend::WindowSystemType::Wayland)
|
||||
wsi.render_surface = window ? pni->nativeResourceForWindow("surface", window) : nullptr;
|
||||
else
|
||||
wsi.render_surface = window ? reinterpret_cast<void*>(window->winId()) : nullptr;
|
||||
#endif
|
||||
wsi.render_surface_scale = window ? static_cast<float>(window->devicePixelRatio()) : 1.0f;
|
||||
|
||||
return wsi;
|
||||
}
|
||||
|
||||
GRenderWindow::GRenderWindow(GMainWindow* parent, EmuThread* emu_thread_,
|
||||
std::shared_ptr<InputCommon::InputSubsystem> input_subsystem_,
|
||||
Core::System& system_)
|
||||
@ -904,7 +884,7 @@ bool GRenderWindow::InitRenderTarget() {
|
||||
}
|
||||
|
||||
// Update the Window System information with the new render target
|
||||
window_info = GetWindowSystemInfo(child_widget->windowHandle());
|
||||
window_info = QtCommon::GetWindowSystemInfo(child_widget->windowHandle());
|
||||
|
||||
child_widget->resize(Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height);
|
||||
layout()->addWidget(child_widget);
|
||||
|
@ -5,27 +5,46 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <stop_token>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QImage>
|
||||
#include <QObject>
|
||||
#include <QPoint>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QThread>
|
||||
#include <QTouchEvent>
|
||||
#include <QWidget>
|
||||
#include <qglobal.h>
|
||||
#include <qnamespace.h>
|
||||
#include <qobjectdefs.h>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/polyfill_thread.h"
|
||||
#include "common/thread.h"
|
||||
#include "core/frontend/emu_window.h"
|
||||
|
||||
class GRenderWindow;
|
||||
class GMainWindow;
|
||||
class QCamera;
|
||||
class QCameraImageCapture;
|
||||
class QCloseEvent;
|
||||
class QFocusEvent;
|
||||
class QKeyEvent;
|
||||
class QMouseEvent;
|
||||
class QObject;
|
||||
class QResizeEvent;
|
||||
class QShowEvent;
|
||||
class QTimer;
|
||||
class QTouchEvent;
|
||||
class QWheelEvent;
|
||||
|
||||
namespace Core {
|
||||
enum class SystemResultStatus : u32;
|
||||
class System;
|
||||
} // namespace Core
|
||||
|
||||
@ -40,7 +59,6 @@ enum class TasState;
|
||||
|
||||
namespace VideoCore {
|
||||
enum class LoadCallbackStage;
|
||||
class RendererBase;
|
||||
} // namespace VideoCore
|
||||
|
||||
class EmuThread final : public QThread {
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <QSettings>
|
||||
#include "common/fs/fs.h"
|
||||
#include "common/fs/path_util.h"
|
||||
#include "common/settings.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/service/acc/profile_manager.h"
|
||||
#include "core/hle/service/hid/controllers/npad.h"
|
||||
@ -709,7 +710,6 @@ void Config::ReadRendererValues() {
|
||||
ReadGlobalSetting(Settings::values.nvdec_emulation);
|
||||
ReadGlobalSetting(Settings::values.accelerate_astc);
|
||||
ReadGlobalSetting(Settings::values.async_astc);
|
||||
ReadGlobalSetting(Settings::values.use_vsync);
|
||||
ReadGlobalSetting(Settings::values.shader_backend);
|
||||
ReadGlobalSetting(Settings::values.use_asynchronous_shaders);
|
||||
ReadGlobalSetting(Settings::values.use_fast_gpu_time);
|
||||
@ -719,6 +719,10 @@ void Config::ReadRendererValues() {
|
||||
ReadGlobalSetting(Settings::values.bg_blue);
|
||||
|
||||
if (global) {
|
||||
Settings::values.vsync_mode.SetValue(static_cast<Settings::VSyncMode>(
|
||||
ReadSetting(QString::fromStdString(Settings::values.vsync_mode.GetLabel()),
|
||||
static_cast<u32>(Settings::values.vsync_mode.GetDefault()))
|
||||
.value<u32>()));
|
||||
ReadBasicSetting(Settings::values.renderer_debug);
|
||||
ReadBasicSetting(Settings::values.renderer_shader_feedback);
|
||||
ReadBasicSetting(Settings::values.enable_nsight_aftermath);
|
||||
@ -1351,7 +1355,6 @@ void Config::SaveRendererValues() {
|
||||
Settings::values.nvdec_emulation.UsingGlobal());
|
||||
WriteGlobalSetting(Settings::values.accelerate_astc);
|
||||
WriteGlobalSetting(Settings::values.async_astc);
|
||||
WriteGlobalSetting(Settings::values.use_vsync);
|
||||
WriteSetting(QString::fromStdString(Settings::values.shader_backend.GetLabel()),
|
||||
static_cast<u32>(Settings::values.shader_backend.GetValue(global)),
|
||||
static_cast<u32>(Settings::values.shader_backend.GetDefault()),
|
||||
@ -1364,6 +1367,9 @@ void Config::SaveRendererValues() {
|
||||
WriteGlobalSetting(Settings::values.bg_blue);
|
||||
|
||||
if (global) {
|
||||
WriteSetting(QString::fromStdString(Settings::values.vsync_mode.GetLabel()),
|
||||
static_cast<u32>(Settings::values.vsync_mode.GetValue()),
|
||||
static_cast<u32>(Settings::values.vsync_mode.GetDefault()));
|
||||
WriteBasicSetting(Settings::values.renderer_debug);
|
||||
WriteBasicSetting(Settings::values.renderer_shader_feedback);
|
||||
WriteBasicSetting(Settings::values.enable_nsight_aftermath);
|
||||
|
@ -4,20 +4,76 @@
|
||||
// Include this early to include Vulkan headers how we want to
|
||||
#include "video_core/vulkan_common/vulkan_wrapper.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iosfwd>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <QBoxLayout>
|
||||
#include <QCheckBox>
|
||||
#include <QColorDialog>
|
||||
#include <QVulkanInstance>
|
||||
#include <QComboBox>
|
||||
#include <QIcon>
|
||||
#include <QLabel>
|
||||
#include <QPixmap>
|
||||
#include <QPushButton>
|
||||
#include <QSlider>
|
||||
#include <QStringLiteral>
|
||||
#include <QtCore/qobjectdefs.h>
|
||||
#include <qcoreevent.h>
|
||||
#include <qglobal.h>
|
||||
#include <vulkan/vulkan_core.h>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "common/dynamic_library.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/settings.h"
|
||||
#include "core/core.h"
|
||||
#include "ui_configure_graphics.h"
|
||||
#include "video_core/vulkan_common/vulkan_instance.h"
|
||||
#include "video_core/vulkan_common/vulkan_library.h"
|
||||
#include "video_core/vulkan_common/vulkan_surface.h"
|
||||
#include "yuzu/configuration/configuration_shared.h"
|
||||
#include "yuzu/configuration/configure_graphics.h"
|
||||
#include "yuzu/qt_common.h"
|
||||
#include "yuzu/uisettings.h"
|
||||
|
||||
static const std::vector<VkPresentModeKHR> default_present_modes{VK_PRESENT_MODE_IMMEDIATE_KHR,
|
||||
VK_PRESENT_MODE_FIFO_KHR};
|
||||
|
||||
// Converts a setting to a present mode (or vice versa)
|
||||
static constexpr VkPresentModeKHR VSyncSettingToMode(Settings::VSyncMode mode) {
|
||||
switch (mode) {
|
||||
case Settings::VSyncMode::Immediate:
|
||||
return VK_PRESENT_MODE_IMMEDIATE_KHR;
|
||||
case Settings::VSyncMode::Mailbox:
|
||||
return VK_PRESENT_MODE_MAILBOX_KHR;
|
||||
case Settings::VSyncMode::FIFO:
|
||||
return VK_PRESENT_MODE_FIFO_KHR;
|
||||
case Settings::VSyncMode::FIFORelaxed:
|
||||
return VK_PRESENT_MODE_FIFO_RELAXED_KHR;
|
||||
default:
|
||||
return VK_PRESENT_MODE_FIFO_KHR;
|
||||
}
|
||||
}
|
||||
|
||||
static constexpr Settings::VSyncMode PresentModeToSetting(VkPresentModeKHR mode) {
|
||||
switch (mode) {
|
||||
case VK_PRESENT_MODE_IMMEDIATE_KHR:
|
||||
return Settings::VSyncMode::Immediate;
|
||||
case VK_PRESENT_MODE_MAILBOX_KHR:
|
||||
return Settings::VSyncMode::Mailbox;
|
||||
case VK_PRESENT_MODE_FIFO_KHR:
|
||||
return Settings::VSyncMode::FIFO;
|
||||
case VK_PRESENT_MODE_FIFO_RELAXED_KHR:
|
||||
return Settings::VSyncMode::FIFORelaxed;
|
||||
default:
|
||||
return Settings::VSyncMode::FIFO;
|
||||
}
|
||||
}
|
||||
|
||||
ConfigureGraphics::ConfigureGraphics(const Core::System& system_, QWidget* parent)
|
||||
: QWidget(parent), ui{std::make_unique<Ui::ConfigureGraphics>()}, system{system_} {
|
||||
vulkan_device = Settings::values.vulkan_device.GetValue();
|
||||
@ -39,13 +95,16 @@ ConfigureGraphics::ConfigureGraphics(const Core::System& system_, QWidget* paren
|
||||
|
||||
connect(ui->api, qOverload<int>(&QComboBox::currentIndexChanged), this, [this] {
|
||||
UpdateAPILayout();
|
||||
PopulateVSyncModeSelection();
|
||||
if (!Settings::IsConfiguringGlobal()) {
|
||||
ConfigurationShared::SetHighlight(
|
||||
ui->api_widget, ui->api->currentIndex() != ConfigurationShared::USE_GLOBAL_INDEX);
|
||||
}
|
||||
});
|
||||
connect(ui->device, qOverload<int>(&QComboBox::activated), this,
|
||||
[this](int device) { UpdateDeviceSelection(device); });
|
||||
connect(ui->device, qOverload<int>(&QComboBox::activated), this, [this](int device) {
|
||||
UpdateDeviceSelection(device);
|
||||
PopulateVSyncModeSelection();
|
||||
});
|
||||
connect(ui->backend, qOverload<int>(&QComboBox::activated), this,
|
||||
[this](int backend) { UpdateShaderBackendSelection(backend); });
|
||||
|
||||
@ -70,6 +129,43 @@ ConfigureGraphics::ConfigureGraphics(const Core::System& system_, QWidget* paren
|
||||
ui->fsr_sharpening_label->setVisible(Settings::IsConfiguringGlobal());
|
||||
}
|
||||
|
||||
void ConfigureGraphics::PopulateVSyncModeSelection() {
|
||||
const Settings::RendererBackend backend{GetCurrentGraphicsBackend()};
|
||||
if (backend == Settings::RendererBackend::Null) {
|
||||
ui->vsync_mode_combobox->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
ui->vsync_mode_combobox->setEnabled(true);
|
||||
|
||||
const int current_index = //< current selected vsync mode from combobox
|
||||
ui->vsync_mode_combobox->currentIndex();
|
||||
const auto current_mode = //< current selected vsync mode as a VkPresentModeKHR
|
||||
current_index == -1 ? VSyncSettingToMode(Settings::values.vsync_mode.GetValue())
|
||||
: vsync_mode_combobox_enum_map[current_index];
|
||||
int index{};
|
||||
const int device{ui->device->currentIndex()}; //< current selected Vulkan device
|
||||
const auto& present_modes = //< relevant vector of present modes for the selected device or API
|
||||
backend == Settings::RendererBackend::Vulkan ? device_present_modes[device]
|
||||
: default_present_modes;
|
||||
|
||||
ui->vsync_mode_combobox->clear();
|
||||
vsync_mode_combobox_enum_map.clear();
|
||||
vsync_mode_combobox_enum_map.reserve(present_modes.size());
|
||||
for (const auto present_mode : present_modes) {
|
||||
const auto mode_name = TranslateVSyncMode(present_mode, backend);
|
||||
if (mode_name.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ui->vsync_mode_combobox->insertItem(index, mode_name);
|
||||
vsync_mode_combobox_enum_map.push_back(present_mode);
|
||||
if (present_mode == current_mode) {
|
||||
ui->vsync_mode_combobox->setCurrentIndex(index);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigureGraphics::UpdateDeviceSelection(int device) {
|
||||
if (device == -1) {
|
||||
return;
|
||||
@ -99,6 +195,9 @@ void ConfigureGraphics::SetConfiguration() {
|
||||
ui->nvdec_emulation_widget->setEnabled(runtime_lock);
|
||||
ui->resolution_combobox->setEnabled(runtime_lock);
|
||||
ui->accelerate_astc->setEnabled(runtime_lock);
|
||||
ui->vsync_mode_layout->setEnabled(runtime_lock ||
|
||||
Settings::values.renderer_backend.GetValue() ==
|
||||
Settings::RendererBackend::Vulkan);
|
||||
ui->use_disk_shader_cache->setChecked(Settings::values.use_disk_shader_cache.GetValue());
|
||||
ui->use_asynchronous_gpu_emulation->setChecked(
|
||||
Settings::values.use_asynchronous_gpu_emulation.GetValue());
|
||||
@ -170,7 +269,24 @@ void ConfigureGraphics::SetConfiguration() {
|
||||
Settings::values.bg_green.GetValue(),
|
||||
Settings::values.bg_blue.GetValue()));
|
||||
UpdateAPILayout();
|
||||
PopulateVSyncModeSelection(); //< must happen after UpdateAPILayout
|
||||
SetFSRIndicatorText(ui->fsr_sharpening_slider->sliderPosition());
|
||||
|
||||
// VSync setting needs to be determined after populating the VSync combobox
|
||||
if (Settings::IsConfiguringGlobal()) {
|
||||
const auto vsync_mode_setting = Settings::values.vsync_mode.GetValue();
|
||||
const auto vsync_mode = VSyncSettingToMode(vsync_mode_setting);
|
||||
int index{};
|
||||
for (const auto mode : vsync_mode_combobox_enum_map) {
|
||||
if (mode == vsync_mode) {
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if (static_cast<unsigned long>(index) < vsync_mode_combobox_enum_map.size()) {
|
||||
ui->vsync_mode_combobox->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigureGraphics::SetFSRIndicatorText(int percentage) {
|
||||
@ -178,6 +294,27 @@ void ConfigureGraphics::SetFSRIndicatorText(int percentage) {
|
||||
tr("%1%", "FSR sharpening percentage (e.g. 50%)").arg(100 - (percentage / 2)));
|
||||
}
|
||||
|
||||
const QString ConfigureGraphics::TranslateVSyncMode(VkPresentModeKHR mode,
|
||||
Settings::RendererBackend backend) const {
|
||||
switch (mode) {
|
||||
case VK_PRESENT_MODE_IMMEDIATE_KHR:
|
||||
return backend == Settings::RendererBackend::OpenGL
|
||||
? tr("Off")
|
||||
: QStringLiteral("Immediate (%1)").arg(tr("VSync Off"));
|
||||
case VK_PRESENT_MODE_MAILBOX_KHR:
|
||||
return QStringLiteral("Mailbox (%1)").arg(tr("Recommended"));
|
||||
case VK_PRESENT_MODE_FIFO_KHR:
|
||||
return backend == Settings::RendererBackend::OpenGL
|
||||
? tr("On")
|
||||
: QStringLiteral("FIFO (%1)").arg(tr("VSync On"));
|
||||
case VK_PRESENT_MODE_FIFO_RELAXED_KHR:
|
||||
return QStringLiteral("FIFO Relaxed");
|
||||
default:
|
||||
return {};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigureGraphics::ApplyConfiguration() {
|
||||
const auto resolution_setup = static_cast<Settings::ResolutionSetup>(
|
||||
ui->resolution_combobox->currentIndex() -
|
||||
@ -232,6 +369,10 @@ void ConfigureGraphics::ApplyConfiguration() {
|
||||
Settings::values.anti_aliasing.SetValue(anti_aliasing);
|
||||
}
|
||||
Settings::values.fsr_sharpening_slider.SetValue(ui->fsr_sharpening_slider->value());
|
||||
|
||||
const auto mode = vsync_mode_combobox_enum_map[ui->vsync_mode_combobox->currentIndex()];
|
||||
const auto vsync_mode = PresentModeToSetting(mode);
|
||||
Settings::values.vsync_mode.SetValue(vsync_mode);
|
||||
} else {
|
||||
if (ui->resolution_combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) {
|
||||
Settings::values.resolution_setup.SetGlobal(true);
|
||||
@ -345,7 +486,9 @@ void ConfigureGraphics::UpdateAPILayout() {
|
||||
ui->backend_widget->setVisible(true);
|
||||
break;
|
||||
case Settings::RendererBackend::Vulkan:
|
||||
ui->device->setCurrentIndex(vulkan_device);
|
||||
if (static_cast<int>(vulkan_device) < ui->device->count()) {
|
||||
ui->device->setCurrentIndex(vulkan_device);
|
||||
}
|
||||
ui->device_widget->setVisible(true);
|
||||
ui->backend_widget->setVisible(false);
|
||||
break;
|
||||
@ -363,16 +506,27 @@ void ConfigureGraphics::RetrieveVulkanDevices() try {
|
||||
|
||||
using namespace Vulkan;
|
||||
|
||||
auto* window = this->window()->windowHandle();
|
||||
auto wsi = QtCommon::GetWindowSystemInfo(window);
|
||||
|
||||
vk::InstanceDispatch dld;
|
||||
const Common::DynamicLibrary library = OpenLibrary();
|
||||
const vk::Instance instance = CreateInstance(library, dld, VK_API_VERSION_1_1);
|
||||
const vk::Instance instance = CreateInstance(library, dld, VK_API_VERSION_1_1, wsi.type);
|
||||
const std::vector<VkPhysicalDevice> physical_devices = instance.EnumeratePhysicalDevices();
|
||||
vk::SurfaceKHR surface = //< needed to view present modes for a device
|
||||
CreateSurface(instance, wsi);
|
||||
|
||||
vulkan_devices.clear();
|
||||
vulkan_devices.reserve(physical_devices.size());
|
||||
device_present_modes.clear();
|
||||
device_present_modes.reserve(physical_devices.size());
|
||||
for (const VkPhysicalDevice device : physical_devices) {
|
||||
const std::string name = vk::PhysicalDevice(device, dld).GetProperties().deviceName;
|
||||
const auto physical_device = vk::PhysicalDevice(device, dld);
|
||||
const std::string name = physical_device.GetProperties().deviceName;
|
||||
const std::vector<VkPresentModeKHR> present_modes =
|
||||
physical_device.GetSurfacePresentModesKHR(*surface);
|
||||
vulkan_devices.push_back(QString::fromStdString(name));
|
||||
device_present_modes.push_back(present_modes);
|
||||
}
|
||||
} catch (const Vulkan::vk::Exception& exception) {
|
||||
LOG_ERROR(Frontend, "Failed to enumerate devices with error: {}", exception.what());
|
||||
@ -465,4 +619,6 @@ void ConfigureGraphics::SetupPerGameUI() {
|
||||
ui->api, static_cast<int>(Settings::values.renderer_backend.GetValue(true)));
|
||||
ConfigurationShared::InsertGlobalItem(
|
||||
ui->nvdec_emulation, static_cast<int>(Settings::values.nvdec_emulation.GetValue(true)));
|
||||
|
||||
ui->vsync_mode_layout->setVisible(false);
|
||||
}
|
||||
|
@ -5,9 +5,21 @@
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <QColor>
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
#include "common/settings.h"
|
||||
#include <qobjectdefs.h>
|
||||
#include <vulkan/vulkan_core.h>
|
||||
#include "common/common_types.h"
|
||||
|
||||
class QEvent;
|
||||
class QObject;
|
||||
|
||||
namespace Settings {
|
||||
enum class NvdecEmulation : u32;
|
||||
enum class RendererBackend : u32;
|
||||
enum class ShaderBackend : u32;
|
||||
} // namespace Settings
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
@ -35,6 +47,7 @@ private:
|
||||
void changeEvent(QEvent* event) override;
|
||||
void RetranslateUI();
|
||||
|
||||
void PopulateVSyncModeSelection();
|
||||
void UpdateBackgroundColorButton(QColor color);
|
||||
void UpdateAPILayout();
|
||||
void UpdateDeviceSelection(int device);
|
||||
@ -43,6 +56,10 @@ private:
|
||||
void RetrieveVulkanDevices();
|
||||
|
||||
void SetFSRIndicatorText(int percentage);
|
||||
/* Turns a Vulkan present mode into a textual string for a UI
|
||||
* (and eventually for a human to read) */
|
||||
const QString TranslateVSyncMode(VkPresentModeKHR mode,
|
||||
Settings::RendererBackend backend) const;
|
||||
|
||||
void SetupPerGameUI();
|
||||
|
||||
@ -58,6 +75,10 @@ private:
|
||||
ConfigurationShared::CheckState use_asynchronous_gpu_emulation;
|
||||
|
||||
std::vector<QString> vulkan_devices;
|
||||
std::vector<std::vector<VkPresentModeKHR>> device_present_modes;
|
||||
std::vector<VkPresentModeKHR>
|
||||
vsync_mode_combobox_enum_map; //< Keeps track of which present mode corresponds to which
|
||||
// selection in the combobox
|
||||
u32 vulkan_device{};
|
||||
Settings::ShaderBackend shader_backend{};
|
||||
|
||||
|
@ -188,6 +188,44 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="vsync_mode_layout" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="vsync_mode_label">
|
||||
<property name="text">
|
||||
<string>VSync Mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="vsync_mode_combobox">
|
||||
<property name="toolTip">
|
||||
<string>FIFO (VSync) does not drop frames or exhibit tearing but is limited by the screen refresh rate.
|
||||
FIFO Relaxed is similar to FIFO but allows tearing as it recovers from a slow down.
|
||||
Mailbox can have lower latency than FIFO and does not tear but may drop frames.
|
||||
Immediate (no synchronization) just presents whatever is available and can exhibit tearing.</string>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="nvdec_emulation_widget" native="true">
|
||||
<layout class="QHBoxLayout" name="nvdec_emulation_layout">
|
||||
@ -366,7 +404,7 @@
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1.5X (1080p/1620p) [EXPERIMENTAL]</string>
|
||||
<string>1.5X (1080p/1620p) [EXPERIMENTAL]</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -21,7 +21,6 @@ ConfigureGraphicsAdvanced::~ConfigureGraphicsAdvanced() = default;
|
||||
|
||||
void ConfigureGraphicsAdvanced::SetConfiguration() {
|
||||
const bool runtime_lock = !system.IsPoweredOn();
|
||||
ui->use_vsync->setEnabled(runtime_lock);
|
||||
ui->async_present->setEnabled(runtime_lock);
|
||||
ui->renderer_force_max_clock->setEnabled(runtime_lock);
|
||||
ui->async_astc->setEnabled(runtime_lock);
|
||||
@ -30,7 +29,6 @@ void ConfigureGraphicsAdvanced::SetConfiguration() {
|
||||
|
||||
ui->async_present->setChecked(Settings::values.async_presentation.GetValue());
|
||||
ui->renderer_force_max_clock->setChecked(Settings::values.renderer_force_max_clock.GetValue());
|
||||
ui->use_vsync->setChecked(Settings::values.use_vsync.GetValue());
|
||||
ui->async_astc->setChecked(Settings::values.async_astc.GetValue());
|
||||
ui->use_asynchronous_shaders->setChecked(Settings::values.use_asynchronous_shaders.GetValue());
|
||||
ui->use_fast_gpu_time->setChecked(Settings::values.use_fast_gpu_time.GetValue());
|
||||
@ -62,7 +60,6 @@ void ConfigureGraphicsAdvanced::ApplyConfiguration() {
|
||||
renderer_force_max_clock);
|
||||
ConfigurationShared::ApplyPerGameSetting(&Settings::values.max_anisotropy,
|
||||
ui->anisotropic_filtering_combobox);
|
||||
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_vsync, ui->use_vsync, use_vsync);
|
||||
ConfigurationShared::ApplyPerGameSetting(&Settings::values.async_astc, ui->async_astc,
|
||||
async_astc);
|
||||
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_asynchronous_shaders,
|
||||
@ -94,7 +91,6 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() {
|
||||
ui->async_present->setEnabled(Settings::values.async_presentation.UsingGlobal());
|
||||
ui->renderer_force_max_clock->setEnabled(
|
||||
Settings::values.renderer_force_max_clock.UsingGlobal());
|
||||
ui->use_vsync->setEnabled(Settings::values.use_vsync.UsingGlobal());
|
||||
ui->async_astc->setEnabled(Settings::values.async_astc.UsingGlobal());
|
||||
ui->use_asynchronous_shaders->setEnabled(
|
||||
Settings::values.use_asynchronous_shaders.UsingGlobal());
|
||||
@ -112,7 +108,6 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() {
|
||||
ConfigurationShared::SetColoredTristate(ui->renderer_force_max_clock,
|
||||
Settings::values.renderer_force_max_clock,
|
||||
renderer_force_max_clock);
|
||||
ConfigurationShared::SetColoredTristate(ui->use_vsync, Settings::values.use_vsync, use_vsync);
|
||||
ConfigurationShared::SetColoredTristate(ui->async_astc, Settings::values.async_astc,
|
||||
async_astc);
|
||||
ConfigurationShared::SetColoredTristate(ui->use_asynchronous_shaders,
|
||||
|
@ -86,16 +86,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="use_vsync">
|
||||
<property name="toolTip">
|
||||
<string>VSync prevents the screen from tearing, but some graphics cards have lower performance with VSync enabled. Keep it enabled if you don't notice a performance difference.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use VSync</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="async_astc">
|
||||
<property name="toolTip">
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <QInputDialog>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QMouseEvent>
|
||||
#include <QTimer>
|
||||
#include "common/assert.h"
|
||||
#include "common/param_package.h"
|
||||
|
55
src/yuzu/qt_common.cpp
Normal file
55
src/yuzu/qt_common.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QStringLiteral>
|
||||
#include <QWindow>
|
||||
#include "common/logging/log.h"
|
||||
#include "core/frontend/emu_window.h"
|
||||
#include "yuzu/qt_common.h"
|
||||
|
||||
#ifdef __linux__
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
#endif
|
||||
|
||||
namespace QtCommon {
|
||||
Core::Frontend::WindowSystemType GetWindowSystemType() {
|
||||
// Determine WSI type based on Qt platform.
|
||||
QString platform_name = QGuiApplication::platformName();
|
||||
if (platform_name == QStringLiteral("windows"))
|
||||
return Core::Frontend::WindowSystemType::Windows;
|
||||
else if (platform_name == QStringLiteral("xcb"))
|
||||
return Core::Frontend::WindowSystemType::X11;
|
||||
else if (platform_name == QStringLiteral("wayland"))
|
||||
return Core::Frontend::WindowSystemType::Wayland;
|
||||
else if (platform_name == QStringLiteral("wayland-egl"))
|
||||
return Core::Frontend::WindowSystemType::Wayland;
|
||||
else if (platform_name == QStringLiteral("cocoa"))
|
||||
return Core::Frontend::WindowSystemType::Cocoa;
|
||||
else if (platform_name == QStringLiteral("android"))
|
||||
return Core::Frontend::WindowSystemType::Android;
|
||||
|
||||
LOG_CRITICAL(Frontend, "Unknown Qt platform {}!", platform_name.toStdString());
|
||||
return Core::Frontend::WindowSystemType::Windows;
|
||||
} // namespace Core::Frontend::WindowSystemType
|
||||
|
||||
Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window) {
|
||||
Core::Frontend::EmuWindow::WindowSystemInfo wsi;
|
||||
wsi.type = GetWindowSystemType();
|
||||
|
||||
// Our Win32 Qt external doesn't have the private API.
|
||||
#if defined(WIN32) || defined(__APPLE__)
|
||||
wsi.render_surface = window ? reinterpret_cast<void*>(window->winId()) : nullptr;
|
||||
#else
|
||||
QPlatformNativeInterface* pni = QGuiApplication::platformNativeInterface();
|
||||
wsi.display_connection = pni->nativeResourceForWindow("display", window);
|
||||
if (wsi.type == Core::Frontend::WindowSystemType::Wayland)
|
||||
wsi.render_surface = window ? pni->nativeResourceForWindow("surface", window) : nullptr;
|
||||
else
|
||||
wsi.render_surface = window ? reinterpret_cast<void*>(window->winId()) : nullptr;
|
||||
#endif
|
||||
wsi.render_surface_scale = window ? static_cast<float>(window->devicePixelRatio()) : 1.0f;
|
||||
|
||||
return wsi;
|
||||
}
|
||||
} // namespace QtCommon
|
15
src/yuzu/qt_common.h
Normal file
15
src/yuzu/qt_common.h
Normal file
@ -0,0 +1,15 @@
|
||||
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWindow>
|
||||
#include "core/frontend/emu_window.h"
|
||||
|
||||
namespace QtCommon {
|
||||
|
||||
Core::Frontend::WindowSystemType GetWindowSystemType();
|
||||
|
||||
Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window);
|
||||
|
||||
} // namespace QtCommon
|
Reference in New Issue
Block a user