Fix Emu.Stop() with vulkan device enumeration hack

This commit is contained in:
Eladash 2019-07-11 16:22:51 +03:00 committed by Ivan
parent f3551cedb7
commit efbae02a22

View File

@ -166,11 +166,11 @@ emu_settings::Render_Creator::Render_Creator()
static std::mutex mtx; static std::mutex mtx;
static std::condition_variable cond; static std::condition_variable cond;
static bool thread_running = true; static bool thread_running = true;
static volatile bool device_found = false; static bool device_found = false;
static QStringList compatible_gpus; static QStringList compatible_gpus;
thread_ctrl::spawn("Vulkan device enumeration", [&] std::thread enum_thread = std::thread([&]
{ {
thread_ctrl::set_native_priority(-1); thread_ctrl::set_native_priority(-1);
@ -192,6 +192,7 @@ emu_settings::Render_Creator::Render_Creator()
} }
} }
} }
std::scoped_lock{mtx}, thread_running = false; std::scoped_lock{mtx}, thread_running = false;
cond.notify_all(); cond.notify_all();
}); });
@ -210,6 +211,7 @@ emu_settings::Render_Creator::Render_Creator()
"Selecting ignore starts the emulator without Vulkan support."), "Selecting ignore starts the emulator without Vulkan support."),
QMessageBox::Ignore | QMessageBox::Abort, QMessageBox::Abort); QMessageBox::Ignore | QMessageBox::Abort, QMessageBox::Abort);
enum_thread.detach();
if (button != QMessageBox::Ignore) if (button != QMessageBox::Ignore)
std::exit(1); std::exit(1);
@ -219,6 +221,7 @@ emu_settings::Render_Creator::Render_Creator()
{ {
supportsVulkan = device_found; supportsVulkan = device_found;
vulkanAdapters = std::move(compatible_gpus); vulkanAdapters = std::move(compatible_gpus);
enum_thread.join();
} }
#endif #endif