Emu: use vulkan as default renderer

This commit is contained in:
Megamouse 2020-09-29 18:26:54 +02:00
parent 046923d9f7
commit 5226076676
5 changed files with 37 additions and 6 deletions

View File

@ -203,6 +203,11 @@ namespace cfg
return m_value;
}
void set(T value)
{
m_value = value;
}
void from_default() override
{
m_value = def;

View File

@ -126,6 +126,14 @@ void Emulator::Init()
// Reset defaults, cache them
g_cfg.from_default();
// Not all renderers are known at compile time, so set a provided default if possible
if (m_default_renderer == video_renderer::vulkan && !m_default_graphics_adapter.empty())
{
g_cfg.video.renderer.set(m_default_renderer);
g_cfg.video.vk.adapter.from_string(m_default_graphics_adapter);
}
g_cfg_defaults = g_cfg.to_string();
// Reload override configuration set via command line

View File

@ -9,6 +9,7 @@ u64 get_system_time();
u64 get_guest_system_time();
enum class localized_string_id;
enum class video_renderer;
enum class system_state
{
@ -64,6 +65,9 @@ class Emulator final
atomic_t<u64> m_pause_start_time{0}; // set when paused
atomic_t<u64> m_pause_amend_time{0}; // increased when resumed
video_renderer m_default_renderer;
std::string m_default_graphics_adapter;
std::string m_config_override_path;
std::string m_path;
std::string m_path_old;
@ -218,6 +222,8 @@ public:
bool HasGui() const { return m_has_gui; }
void SetHasGui(bool has_gui) { m_has_gui = has_gui; }
void SetDefaultRenderer(video_renderer renderer) { m_default_renderer = renderer; }
void SetDefaultGraphicsAdapter(std::string adapter) { m_default_graphics_adapter = std::move(adapter); }
void SetConfigOverride(std::string path) { m_config_override_path = std::move(path); }
std::string GetFormattedTitle(double fps) const;

View File

@ -21,7 +21,7 @@ inline std::string sstr(const QVariant& _in) { return sstr(_in.toString()); }
// Emit sorted YAML
namespace
{
static NEVER_INLINE void emitData(YAML::Emitter& out, const YAML::Node& node)
static NEVER_INLINE void emit_data(YAML::Emitter& out, const YAML::Node& node)
{
// TODO
out << node;
@ -63,6 +63,19 @@ emu_settings::emu_settings()
: QObject()
, m_render_creator(new render_creator(this))
{
if (!m_render_creator)
{
fmt::throw_exception("emu_settings::emu_settings() render_creator is null");
}
// Make Vulkan default setting if it is supported
if (m_render_creator->Vulkan.supported && !m_render_creator->Vulkan.adapters.empty())
{
const std::string adapter = sstr(m_render_creator->Vulkan.adapters.at(0));
cfg_log.notice("Setting the default renderer to Vulkan. Default GPU: '%s')", adapter);
Emu.SetDefaultRenderer(video_renderer::vulkan);
Emu.SetDefaultGraphicsAdapter(adapter);
}
}
emu_settings::~emu_settings()
@ -149,7 +162,7 @@ void emu_settings::LoadSettings(const std::string& title_id)
void emu_settings::SaveSettings()
{
YAML::Emitter out;
emitData(out, m_currentSettings);
emit_data(out, m_currentSettings);
std::string config_name;

View File

@ -289,8 +289,7 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
if (!r_creator)
{
cfg_log.error("settings_dialog::settings_dialog render_creator is null");
return;
fmt::throw_exception("settings_dialog::settings_dialog() render_creator is null");
}
r_creator->update_names(
@ -538,15 +537,15 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
ui->antiAliasing->setCurrentText(renderer.has_msaa ? qstr(m_emu_settings->GetSetting(emu_settings_type::MSAA)) : tr("Disabled", "MSAA"));
ui->antiAliasing->blockSignals(false);
ui->graphicsAdapterBox->clear();
// Fill combobox with placeholder if no adapters needed
if (!renderer.has_adapters)
{
ui->graphicsAdapterBox->clear();
ui->graphicsAdapterBox->addItem(tr("Not needed for %1 renderer", "Graphics adapter").arg(text));
return;
}
// Fill combobox
ui->graphicsAdapterBox->clear();
for (const auto& adapter : renderer.adapters)
{
ui->graphicsAdapterBox->addItem(adapter);