summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/command_classes/codecs/codec.cpp43
-rw-r--r--src/yuzu/main.cpp48
-rw-r--r--src/yuzu/uisettings.cpp4
3 files changed, 68 insertions, 27 deletions
diff --git a/src/video_core/command_classes/codecs/codec.cpp b/src/video_core/command_classes/codecs/codec.cpp
index 916277811..02d309170 100644
--- a/src/video_core/command_classes/codecs/codec.cpp
+++ b/src/video_core/command_classes/codecs/codec.cpp
@@ -2,6 +2,8 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
+#include <algorithm>
+#include <cstdio>
#include <fstream>
#include <vector>
#include "common/assert.h"
@@ -59,6 +61,34 @@ Codec::~Codec() {
av_buffer_unref(&av_gpu_decoder);
}
+#ifdef LIBVA_FOUND
+// List all the currently loaded Linux modules
+static std::vector<std::string> ListLinuxKernelModules() {
+ using FILEPtr = std::unique_ptr<FILE, decltype(&std::fclose)>;
+ auto module_listing = FILEPtr{fopen("/proc/modules", "rt"), std::fclose};
+ std::vector<std::string> modules{};
+ if (!module_listing) {
+ LOG_WARNING(Service_NVDRV, "Could not open /proc/modules to collect available modules");
+ return modules;
+ }
+ char* buffer = nullptr;
+ size_t buf_len = 0;
+ while (getline(&buffer, &buf_len, module_listing.get()) != -1) {
+ // format for the module listing file (sysfs)
+ // <name> <module_size> <depended_by_count> <depended_by_names> <status> <load_address>
+ auto line = std::string(buffer);
+ // we are only interested in module names
+ auto name_pos = line.find_first_of(" ");
+ if (name_pos == std::string::npos) {
+ continue;
+ }
+ modules.push_back(line.erase(name_pos));
+ }
+ free(buffer);
+ return modules;
+}
+#endif
+
bool Codec::CreateGpuAvDevice() {
#if defined(LIBVA_FOUND)
static constexpr std::array<const char*, 3> VAAPI_DRIVERS = {
@@ -67,8 +97,16 @@ bool Codec::CreateGpuAvDevice() {
"amdgpu",
};
AVDictionary* hwdevice_options = nullptr;
+ const auto loaded_modules = ListLinuxKernelModules();
av_dict_set(&hwdevice_options, "connection_type", "drm", 0);
for (const auto& driver : VAAPI_DRIVERS) {
+ // first check if the target driver is loaded in the kernel
+ bool found = std::any_of(loaded_modules.begin(), loaded_modules.end(),
+ [&driver](const auto& module) { return module == driver; });
+ if (!found) {
+ LOG_DEBUG(Service_NVDRV, "Kernel driver {} is not loaded, trying the next one", driver);
+ continue;
+ }
av_dict_set(&hwdevice_options, "kernel_driver", driver, 0);
const int hwdevice_error = av_hwdevice_ctx_create(&av_gpu_decoder, AV_HWDEVICE_TYPE_VAAPI,
nullptr, hwdevice_options, 0);
@@ -85,11 +123,12 @@ bool Codec::CreateGpuAvDevice() {
#endif
static constexpr auto HW_CONFIG_METHOD = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX;
static constexpr std::array GPU_DECODER_TYPES{
+#ifdef linux
+ AV_HWDEVICE_TYPE_VDPAU,
+#endif
AV_HWDEVICE_TYPE_CUDA,
#ifdef _WIN32
AV_HWDEVICE_TYPE_D3D11VA,
-#else
- AV_HWDEVICE_TYPE_VDPAU,
#endif
};
for (const auto& type : GPU_DECODER_TYPES) {
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 552db6387..9bd0db10a 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -3479,36 +3479,38 @@ void GMainWindow::filterBarSetChecked(bool state) {
}
void GMainWindow::UpdateUITheme() {
- const QString default_icons = QStringLiteral("default");
- const QString& current_theme = UISettings::values.theme;
- const bool is_default_theme = current_theme == QString::fromUtf8(UISettings::themes[0].second);
+ const QString default_theme = QStringLiteral("default");
+ QString current_theme = UISettings::values.theme;
QStringList theme_paths(default_theme_paths);
- if (is_default_theme || current_theme.isEmpty()) {
- const QString theme_uri(QStringLiteral(":default/style.qss"));
+ if (current_theme.isEmpty()) {
+ current_theme = default_theme;
+ }
+
+ if (current_theme != default_theme) {
+ QString theme_uri{QStringLiteral(":%1/style.qss").arg(current_theme)};
QFile f(theme_uri);
- if (f.open(QFile::ReadOnly | QFile::Text)) {
- QTextStream ts(&f);
- qApp->setStyleSheet(ts.readAll());
- setStyleSheet(ts.readAll());
- } else {
- qApp->setStyleSheet({});
- setStyleSheet({});
+ if (!f.open(QFile::ReadOnly | QFile::Text)) {
+ LOG_ERROR(Frontend, "Unable to open style \"{}\", fallback to the default theme",
+ UISettings::values.theme.toStdString());
+ current_theme = default_theme;
}
- QIcon::setThemeName(default_icons);
+ }
+
+ QString theme_uri{QStringLiteral(":%1/style.qss").arg(current_theme)};
+ QFile f(theme_uri);
+ if (f.open(QFile::ReadOnly | QFile::Text)) {
+ QTextStream ts(&f);
+ qApp->setStyleSheet(ts.readAll());
+ setStyleSheet(ts.readAll());
} else {
- const QString theme_uri(QLatin1Char{':'} + current_theme + QStringLiteral("/style.qss"));
- QFile f(theme_uri);
- if (f.open(QFile::ReadOnly | QFile::Text)) {
- QTextStream ts(&f);
- qApp->setStyleSheet(ts.readAll());
- setStyleSheet(ts.readAll());
- } else {
- LOG_ERROR(Frontend, "Unable to set style, stylesheet file not found");
- }
- QIcon::setThemeName(current_theme);
+ LOG_ERROR(Frontend, "Unable to set style \"{}\", stylesheet file not found",
+ UISettings::values.theme.toStdString());
+ qApp->setStyleSheet({});
+ setStyleSheet({});
}
+ QIcon::setThemeName(current_theme);
QIcon::setThemeSearchPaths(theme_paths);
}
diff --git a/src/yuzu/uisettings.cpp b/src/yuzu/uisettings.cpp
index 37499fc85..21683576c 100644
--- a/src/yuzu/uisettings.cpp
+++ b/src/yuzu/uisettings.cpp
@@ -7,8 +7,8 @@
namespace UISettings {
const Themes themes{{
- {"Light", "default"},
- {"Light Colorful", "colorful"},
+ {"Default", "default"},
+ {"Default Colorful", "colorful"},
{"Dark", "qdarkstyle"},
{"Dark Colorful", "colorful_dark"},
{"Midnight Blue", "qdarkstyle_midnight_blue"},