Skip to content

Commit

Permalink
Fix Emu.Stop() with vulkan device enumarion hack
Browse files Browse the repository at this point in the history
  • Loading branch information
elad335 committed Jul 11, 2019
1 parent 2898309 commit b22f482
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions rpcs3/rpcs3qt/emu_settings.cpp
Expand Up @@ -163,10 +163,12 @@ emu_settings::Render_Creator::Render_Creator()
static std::mutex mtx;
static std::condition_variable cond;
static bool thread_running = true;
static volatile bool device_found = false;
static bool device_found = false;

static QStringList compatible_gpus;

extern atomic_t<u32> g_thread_count;

thread_ctrl::spawn("Vulkan device enumeration", [&]
{
thread_ctrl::set_native_priority(-1);
Expand All @@ -189,16 +191,28 @@ emu_settings::Render_Creator::Render_Creator()
}
}
}
std::scoped_lock{mtx}, thread_running = false;
cond.notify_all();

bool given_up;
std::lock_guard{mtx}, given_up = !std::exchange(thread_running, false);

if (given_up)
{
g_thread_count++;
}
else
{
cond.notify_all();
}
});

bool success = false;
{
std::unique_lock lck(mtx);
cond.wait_for(lck, std::chrono::seconds(10), [&]{ return !thread_running; });
cond.wait_for(lck, std::chrono::seconds(10), [&]{ return !std::exchange(thread_running, false); });
success = !std::exchange(thread_running, false);
}

if (thread_running)
if (!success)
{
LOG_ERROR(GENERAL, "Vulkan device enumeration timed out");
auto button = QMessageBox::critical(nullptr, tr("Vulkan check timeout"),
Expand All @@ -211,6 +225,7 @@ emu_settings::Render_Creator::Render_Creator()
std::exit(1);

supportsVulkan = false;
g_threads_count--; // Hack: assume thread terminated
}
else
{
Expand Down

0 comments on commit b22f482

Please sign in to comment.