Browse Source
real vulkan device info (#1)
real vulkan device info (#1)
Reviewed-on: https://git.eden-emu.dev/crueter/eden/pulls/1
No known key found for this signature in database
GPG Key ID: 425ACD2D4830EBC6
27 changed files with 948 additions and 109 deletions
-
13CMakeModules/EdenModule.cmake
-
3src/CMakeLists.txt
-
1src/Eden/Config/GlobalConfigureDialog.qml
-
4src/Eden/Config/fields/BaseField.qml
-
4src/Eden/Config/fields/ConfigComboBox.qml
-
20src/Eden/Config/pages/SettingsList.qml
-
19src/Eden/Config/pages/cpu/CpuGeneralPage.qml
-
42src/Eden/Config/pages/graphics/RendererPage.qml
-
1src/Eden/Interface/CMakeLists.txt
-
150src/Eden/Interface/GraphicsDeviceInterface.cpp
-
74src/Eden/Interface/GraphicsDeviceInterface.h
-
2src/Eden/Interface/SettingsInterface.h
-
3src/Eden/Main/CMakeLists.txt
-
2src/qt_common/CMakeLists.txt
-
4src/qt_common/qt_common.cpp
-
4src/qt_common/util/vk_device_info.cpp
-
71src/qt_common/util/vk_device_info.h
-
6src/yuzu/CMakeLists.txt
-
2src/yuzu/configuration/configure_dialog.cpp
-
2src/yuzu/configuration/configure_dialog.h
-
36src/yuzu/configuration/configure_graphics.cpp
-
2src/yuzu/configuration/configure_graphics.h
-
2src/yuzu/configuration/configure_per_game.cpp
-
2src/yuzu/configuration/configure_per_game.h
-
548src/yuzu/main.cpp
-
4src/yuzu/main_window.cpp
-
36src/yuzu/vk_device_info.h
@ -0,0 +1,150 @@ |
|||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
|||
// SPDX-License-Identifier: GPL-3.0-or-later
|
|||
|
|||
#include "GraphicsDeviceInterface.h"
|
|||
#include <QWindow>
|
|||
#include "common/settings.h"
|
|||
#include "common/settings_enums.h"
|
|||
#include "qt_common/qt_common.h"
|
|||
|
|||
static const QString TranslateVSyncMode(VkPresentModeKHR mode, |
|||
Settings::RendererBackend backend) { |
|||
switch (mode) { |
|||
case VK_PRESENT_MODE_IMMEDIATE_KHR: |
|||
return backend == Settings::RendererBackend::OpenGL |
|||
? QtCommon::tr("Off") |
|||
: QStringLiteral("Immediate (%1)").arg(QtCommon::tr("VSync Off")); |
|||
case VK_PRESENT_MODE_MAILBOX_KHR: |
|||
return QStringLiteral("Mailbox (%1)").arg(QtCommon::tr("Recommended")); |
|||
case VK_PRESENT_MODE_FIFO_KHR: |
|||
return backend == Settings::RendererBackend::OpenGL |
|||
? QtCommon::tr("On") |
|||
: QStringLiteral("FIFO (%1)").arg(QtCommon::tr("VSync On")); |
|||
case VK_PRESENT_MODE_FIFO_RELAXED_KHR: |
|||
return QStringLiteral("FIFO Relaxed"); |
|||
default: |
|||
return {}; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
GraphicsDeviceInterface::GraphicsDeviceInterface(QQuickItem *parent) |
|||
: QQuickItem(parent) |
|||
{} |
|||
|
|||
QStringList GraphicsDeviceInterface::devices() |
|||
{ |
|||
return vulkan_devices; |
|||
} |
|||
|
|||
void GraphicsDeviceInterface::populateDevices() |
|||
{ |
|||
vulkan_devices.clear(); |
|||
vulkan_devices.reserve(records.size()); |
|||
device_present_modes.clear(); |
|||
device_present_modes.reserve(records.size()); |
|||
for (const auto &record : records) { |
|||
vulkan_devices.push_back(QString::fromStdString(record.name)); |
|||
device_present_modes.push_back(record.vsync_support); |
|||
|
|||
// if (record.has_broken_compute) {
|
|||
// expose_compute_option();
|
|||
// }
|
|||
} |
|||
|
|||
emit devicesChanged(); |
|||
} |
|||
|
|||
void GraphicsDeviceInterface::populateVsync() |
|||
{ |
|||
if (m_api == Settings::RendererBackend::Null) { |
|||
return; |
|||
} |
|||
|
|||
const auto &present_modes = //< relevant vector of present modes for the selected device or API
|
|||
m_isVulkan && m_device > -1 ? device_present_modes[m_device] : default_present_modes; |
|||
|
|||
m_vsyncModes.clear(); |
|||
m_vsyncModes.reserve(present_modes.size()); |
|||
|
|||
for (const auto present_mode : present_modes) { |
|||
const auto mode_name = TranslateVSyncMode(present_mode, m_api); |
|||
if (mode_name.isEmpty()) { |
|||
continue; |
|||
} |
|||
|
|||
m_vsyncModes.append(mode_name); |
|||
} |
|||
|
|||
emit vsyncModesChanged(m_vsyncModes); |
|||
} |
|||
|
|||
Settings::RendererBackend GraphicsDeviceInterface::api() const |
|||
{ |
|||
return m_api; |
|||
} |
|||
|
|||
void GraphicsDeviceInterface::setApi(const Settings::RendererBackend &newApi) |
|||
{ |
|||
if (m_api == newApi) |
|||
return; |
|||
|
|||
m_api = newApi; |
|||
emit apiChanged(m_api); |
|||
|
|||
m_isOpenGL = newApi == Settings::RendererBackend::OpenGL; |
|||
m_isVulkan = newApi == Settings::RendererBackend::Vulkan; |
|||
|
|||
emit isOpenGLChanged(m_isOpenGL); |
|||
emit isVulkanChanged(m_isVulkan); |
|||
} |
|||
|
|||
void GraphicsDeviceInterface::componentComplete() |
|||
{ |
|||
VkDeviceInfo::PopulateRecords(records, (QWindow *) window()); |
|||
populateDevices(); |
|||
populateVsync(); |
|||
} |
|||
|
|||
bool GraphicsDeviceInterface::isOpenGL() const |
|||
{ |
|||
return m_isOpenGL; |
|||
} |
|||
|
|||
bool GraphicsDeviceInterface::isVulkan() const |
|||
{ |
|||
return m_isVulkan; |
|||
} |
|||
|
|||
int GraphicsDeviceInterface::device() const |
|||
{ |
|||
return m_device; |
|||
} |
|||
|
|||
void GraphicsDeviceInterface::setDevice(int newDevice) |
|||
{ |
|||
if (m_device == newDevice) |
|||
return; |
|||
m_device = newDevice; |
|||
emit deviceChanged(m_device); |
|||
|
|||
populateVsync(); |
|||
} |
|||
|
|||
QStringList GraphicsDeviceInterface::vsyncModes() const |
|||
{ |
|||
return m_vsyncModes; |
|||
} |
|||
|
|||
int GraphicsDeviceInterface::vsyncMode() const |
|||
{ |
|||
return m_vsyncMode; |
|||
} |
|||
|
|||
void GraphicsDeviceInterface::setVsyncMode(int newVsyncMode) |
|||
{ |
|||
if (m_vsyncMode == newVsyncMode) |
|||
return; |
|||
m_vsyncMode = newVsyncMode; |
|||
emit vsyncModeChanged(m_vsyncMode); |
|||
} |
|||
@ -0,0 +1,74 @@ |
|||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project |
|||
// SPDX-License-Identifier: GPL-3.0-or-later |
|||
#pragma once |
|||
|
|||
#include <QQuickItem> |
|||
|
|||
#include "qt_common/util/vk_device_info.h" |
|||
|
|||
class GraphicsDeviceInterface : public QQuickItem |
|||
{ |
|||
Q_OBJECT |
|||
QML_ELEMENT |
|||
|
|||
Q_PROPERTY(QStringList devices READ devices NOTIFY devicesChanged) |
|||
Q_PROPERTY(QStringList vsyncModes READ vsyncModes NOTIFY vsyncModesChanged) |
|||
|
|||
Q_PROPERTY(Settings::RendererBackend api READ api WRITE setApi NOTIFY apiChanged) |
|||
Q_PROPERTY(int device READ device WRITE setDevice NOTIFY deviceChanged) |
|||
Q_PROPERTY(int vsyncMode READ vsyncMode WRITE setVsyncMode NOTIFY vsyncModeChanged) |
|||
|
|||
Q_PROPERTY(bool isOpenGL READ isOpenGL NOTIFY isOpenGLChanged) |
|||
Q_PROPERTY(bool isVulkan READ isVulkan NOTIFY isVulkanChanged) |
|||
public: |
|||
explicit GraphicsDeviceInterface(QQuickItem *parent = nullptr); |
|||
|
|||
QStringList devices(); |
|||
|
|||
Settings::RendererBackend api() const; |
|||
void setApi(const Settings::RendererBackend &newApi); |
|||
|
|||
bool isOpenGL() const; |
|||
bool isVulkan() const; |
|||
|
|||
int device() const; |
|||
void setDevice(int newDevice); |
|||
|
|||
QStringList vsyncModes() const; |
|||
|
|||
int vsyncMode() const; |
|||
void setVsyncMode(int newVsyncMode); |
|||
|
|||
protected: |
|||
void componentComplete(); |
|||
signals: |
|||
void apiChanged(Settings::RendererBackend api); |
|||
void devicesChanged(); |
|||
|
|||
void isOpenGLChanged(bool isOpenGL); |
|||
void isVulkanChanged(bool isVulkan); |
|||
|
|||
void deviceChanged(int device); |
|||
|
|||
void vsyncModesChanged(QStringList vsyncModes); |
|||
|
|||
void vsyncModeChanged(int vsyncMode); |
|||
|
|||
private: |
|||
std::vector<VkDeviceInfo::Record> records{}; |
|||
|
|||
QStringList vulkan_devices; |
|||
QStringList m_vsyncModes; |
|||
|
|||
std::vector<std::vector<VkPresentModeKHR>> device_present_modes; |
|||
|
|||
void populateDevices(); |
|||
void populateVsync(); |
|||
|
|||
Settings::RendererBackend m_api; |
|||
bool m_isOpenGL; |
|||
bool m_isVulkan; |
|||
|
|||
int m_device; |
|||
int m_vsyncMode; |
|||
}; |
|||
@ -0,0 +1,71 @@ |
|||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project |
|||
// SPDX-License-Identifier: GPL-3.0-or-later |
|||
|
|||
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project |
|||
// SPDX-License-Identifier: GPL-2.0-or-later |
|||
|
|||
#pragma once |
|||
|
|||
#include "common/settings_enums.h" |
|||
#include "vulkan/vulkan_core.h" |
|||
#include <string> |
|||
#include <string_view> |
|||
#include <vector> |
|||
|
|||
class QWindow; |
|||
|
|||
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 inline 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 inline 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; |
|||
} |
|||
} |
|||
|
|||
namespace VkDeviceInfo { |
|||
|
|||
// Short class to record Vulkan driver information for configuration purposes |
|||
class Record |
|||
{ |
|||
public: |
|||
explicit Record(std::string_view name, |
|||
const std::vector<VkPresentModeKHR>& vsync_modes, |
|||
bool has_broken_compute); |
|||
~Record(); |
|||
|
|||
const std::string name; |
|||
const std::vector<VkPresentModeKHR> vsync_support; |
|||
const bool has_broken_compute; |
|||
}; |
|||
|
|||
void PopulateRecords(std::vector<Record>& records, QWindow* window); |
|||
|
|||
} // namespace VkDeviceInfo |
|||
@ -1,36 +0,0 @@ |
|||
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project |
|||
// SPDX-License-Identifier: GPL-2.0-or-later |
|||
|
|||
#pragma once |
|||
|
|||
#include <algorithm> |
|||
#include <iterator> |
|||
#include <memory> |
|||
#include <string> |
|||
#include <string_view> |
|||
#include <vector> |
|||
#include "common/common_types.h" |
|||
#include "vulkan/vulkan_core.h" |
|||
|
|||
class QWindow; |
|||
|
|||
namespace Settings { |
|||
enum class VSyncMode : u32; |
|||
} |
|||
// #include "common/settings.h" |
|||
|
|||
namespace VkDeviceInfo { |
|||
// Short class to record Vulkan driver information for configuration purposes |
|||
class Record { |
|||
public: |
|||
explicit Record(std::string_view name, const std::vector<VkPresentModeKHR>& vsync_modes, |
|||
bool has_broken_compute); |
|||
~Record(); |
|||
|
|||
const std::string name; |
|||
const std::vector<VkPresentModeKHR> vsync_support; |
|||
const bool has_broken_compute; |
|||
}; |
|||
|
|||
void PopulateRecords(std::vector<Record>& records, QWindow* window); |
|||
} // namespace VkDeviceInfo |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue