Add graphics backend selection
This commit is contained in:
@@ -144,6 +144,8 @@ void Config::SetDefaults()
|
||||
SetEntryInternal(QStringLiteral("PreviewNonFloatDontAskAgain"),
|
||||
NodeValue::kBoolean, false);
|
||||
SetEntryInternal(QStringLiteral("UseGLFinish"), NodeValue::kBoolean, false);
|
||||
SetEntryInternal(QStringLiteral("GraphicsBackend"), NodeValue::kText,
|
||||
QStringLiteral("opengl"));
|
||||
SetEntryInternal(QStringLiteral("RenderProcessIsolationEnabled"),
|
||||
NodeValue::kBoolean, false);
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "preferencesbehaviortab.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "config/config.h"
|
||||
@@ -36,7 +37,8 @@ PreferencesBehaviorTab::PreferencesBehaviorTab()
|
||||
behavior_tree_ = new QTreeWidget();
|
||||
layout->addWidget(behavior_tree_);
|
||||
|
||||
behavior_tree_->setHeaderLabel(tr("Behavior"));
|
||||
behavior_tree_->setColumnCount(2);
|
||||
behavior_tree_->setHeaderLabels({ tr("Behavior"), tr("Setting") });
|
||||
|
||||
QTreeWidgetItem *general_group = AddParent(tr("General"));
|
||||
AddItem(
|
||||
@@ -97,7 +99,30 @@ PreferencesBehaviorTab::PreferencesBehaviorTab()
|
||||
"dependencies among clips when copying or splitting them."),
|
||||
node_group);
|
||||
|
||||
QTreeWidgetItem *opengl_group = AddParent(tr("OpenGL"));
|
||||
QTreeWidgetItem *rendering_group = AddParent(tr("Rendering"));
|
||||
QTreeWidgetItem *graphics_backend_item =
|
||||
new QTreeWidgetItem({ tr("Graphics Backend") });
|
||||
graphics_backend_item->setToolTip(
|
||||
0, tr("Selects the graphics API Oak should request on next launch. "
|
||||
"Vulkan is experimental and currently falls back to the OpenGL "
|
||||
"renderer for timeline/viewer rendering."));
|
||||
rendering_group->addChild(graphics_backend_item);
|
||||
graphics_backend_combobox_ = new QComboBox();
|
||||
graphics_backend_combobox_->addItem(tr("OpenGL"), QStringLiteral("opengl"));
|
||||
graphics_backend_combobox_->addItem(tr("Vulkan (experimental)"),
|
||||
QStringLiteral("vulkan"));
|
||||
const QString current_backend =
|
||||
OLIVE_CONFIG("GraphicsBackend").toString().toLower();
|
||||
const int backend_index = graphics_backend_combobox_->findData(
|
||||
current_backend.isEmpty() ? QStringLiteral("opengl")
|
||||
: current_backend);
|
||||
graphics_backend_combobox_->setCurrentIndex(backend_index >= 0
|
||||
? backend_index
|
||||
: 0);
|
||||
behavior_tree_->setItemWidget(graphics_backend_item, 1,
|
||||
graphics_backend_combobox_);
|
||||
|
||||
QTreeWidgetItem *opengl_group = AddParent(tr("OpenGL"), rendering_group);
|
||||
AddItem(tr("Use glFinish"), QStringLiteral("UseGLFinish"), opengl_group);
|
||||
}
|
||||
|
||||
@@ -110,6 +135,9 @@ void PreferencesBehaviorTab::Accept(MultiUndoCommand *command)
|
||||
OLIVE_CONFIG_STR(iterator.value()) =
|
||||
(iterator.key()->checkState(0) == Qt::Checked);
|
||||
}
|
||||
|
||||
OLIVE_CONFIG("GraphicsBackend") =
|
||||
graphics_backend_combobox_->currentData().toString();
|
||||
}
|
||||
|
||||
QTreeWidgetItem *PreferencesBehaviorTab::AddItem(const QString &text,
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#ifndef PREFERENCESBEHAVIORTAB_H
|
||||
#define PREFERENCESBEHAVIORTAB_H
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QTreeWidget>
|
||||
|
||||
#include "dialog/configbase/configdialogbase.h"
|
||||
@@ -49,6 +50,8 @@ private:
|
||||
|
||||
QMap<QTreeWidgetItem *, QString> config_map_;
|
||||
|
||||
QComboBox *graphics_backend_combobox_;
|
||||
|
||||
QTreeWidget *behavior_tree_;
|
||||
};
|
||||
|
||||
|
||||
+13
-1
@@ -41,6 +41,7 @@ extern "C" {
|
||||
#include <QIcon>
|
||||
#include <QSurfaceFormat>
|
||||
|
||||
#include "config/config.h"
|
||||
#include "core.h"
|
||||
#include "common/commandlineparser.h"
|
||||
#include "common/debug.h"
|
||||
@@ -300,7 +301,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
startup_params.set_startup_project(project_argument->GetSetting());
|
||||
|
||||
// Set OpenGL display profile
|
||||
// Set OpenGL display profile. Oak's render pipeline still uses OpenGL
|
||||
// internally even when Vulkan is requested as the Qt graphics backend.
|
||||
QSurfaceFormat format;
|
||||
|
||||
// Tries to cover all bases. If drivers don't support 3.2, they should fallback to the closest
|
||||
@@ -338,6 +340,16 @@ int main(int argc, char *argv[])
|
||||
a.reset(new QCoreApplication(argc, argv));
|
||||
}
|
||||
|
||||
olive::Config::Load();
|
||||
const QString graphics_backend =
|
||||
olive::Config::Current()[QStringLiteral("GraphicsBackend")]
|
||||
.toString()
|
||||
.toLower();
|
||||
qputenv("QSG_RHI_BACKEND",
|
||||
graphics_backend == QStringLiteral("vulkan")
|
||||
? QByteArrayLiteral("vulkan")
|
||||
: QByteArrayLiteral("opengl"));
|
||||
|
||||
if (auto *gui_app = qobject_cast<QGuiApplication *>(a.get())) {
|
||||
gui_app->setWindowIcon(QIcon(QStringLiteral(":/graphics/oak-logo.png")));
|
||||
}
|
||||
|
||||
@@ -40,11 +40,53 @@ namespace olive
|
||||
RenderManager *RenderManager::instance_ = nullptr;
|
||||
const rational RenderManager::kDryRunInterval = rational(10);
|
||||
|
||||
RenderManager::Backend RenderManager::BackendFromString(const QString &backend)
|
||||
{
|
||||
const QString lower = backend.toLower();
|
||||
if (lower == QStringLiteral("vulkan")) {
|
||||
return kVulkan;
|
||||
}
|
||||
|
||||
if (lower == QStringLiteral("multiprocess")) {
|
||||
return kMultiProcess;
|
||||
}
|
||||
|
||||
if (lower == QStringLiteral("dummy")) {
|
||||
return kDummy;
|
||||
}
|
||||
|
||||
return kOpenGL;
|
||||
}
|
||||
|
||||
QString RenderManager::BackendToString(Backend backend)
|
||||
{
|
||||
switch (backend) {
|
||||
case kOpenGL:
|
||||
return QStringLiteral("opengl");
|
||||
case kVulkan:
|
||||
return QStringLiteral("vulkan");
|
||||
case kMultiProcess:
|
||||
return QStringLiteral("multiprocess");
|
||||
case kDummy:
|
||||
return QStringLiteral("dummy");
|
||||
}
|
||||
|
||||
return QStringLiteral("opengl");
|
||||
}
|
||||
|
||||
RenderManager::RenderManager(QObject *parent)
|
||||
: backend_(kOpenGL)
|
||||
, requested_backend_(BackendFromString(
|
||||
OLIVE_CONFIG("GraphicsBackend").toString()))
|
||||
, aggressive_gc_(0)
|
||||
, worker_pool_(nullptr)
|
||||
{
|
||||
if (requested_backend_ == kVulkan) {
|
||||
qWarning()
|
||||
<< "Vulkan graphics backend was requested, but the current render "
|
||||
"pipeline still uses OpenGL. Falling back to OpenGL renderer.";
|
||||
}
|
||||
|
||||
if (backend_ == kOpenGL) {
|
||||
context_ = new OpenGLRenderer();
|
||||
decoder_cache_ = new DecoderCache();
|
||||
|
||||
@@ -78,6 +78,9 @@ public:
|
||||
/// Graphics acceleration provided by OpenGL
|
||||
kOpenGL,
|
||||
|
||||
/// Vulkan requested by the user. Falls back to OpenGL until VulkanRenderer is implemented.
|
||||
kVulkan,
|
||||
|
||||
/// Video frames are rendered by an external olive-render-worker process.
|
||||
kMultiProcess,
|
||||
|
||||
@@ -201,6 +204,14 @@ public:
|
||||
return backend_;
|
||||
}
|
||||
|
||||
Backend requested_backend() const
|
||||
{
|
||||
return requested_backend_;
|
||||
}
|
||||
|
||||
static Backend BackendFromString(const QString &backend);
|
||||
static QString BackendToString(Backend backend);
|
||||
|
||||
PreviewAutoCacher *GetCacher() const
|
||||
{
|
||||
return auto_cacher_;
|
||||
@@ -228,6 +239,7 @@ private:
|
||||
Renderer *context_;
|
||||
|
||||
Backend backend_;
|
||||
Backend requested_backend_;
|
||||
|
||||
DecoderCache *decoder_cache_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user