Skip to content

Commit 75d8a49

Browse files
committed
Only run thread when rasterizer is bound
1 parent d556f2e commit 75d8a49

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/video_core/amdgpu/liverpool.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,14 @@ static std::span<const u32> NextPacket(std::span<const u32> span, size_t offset)
6868
Liverpool::Liverpool() {
6969
num_counter_pairs = Libraries::Kernel::sceKernelIsNeoMode() ? 16 : 8;
7070
process_thread = std::jthread{std::bind_front(&Liverpool::Process, this)};
71-
watchdog_thread = std::jthread(std::bind_front(&Liverpool::Watchdog, this));
7271
}
7372

7473
Liverpool::~Liverpool() {
75-
watchdog_thread.request_stop();
74+
if (!rasterizer) {
75+
watchdog_thread.request_stop();
76+
watchdog_thread.join();
77+
}
7678
process_thread.request_stop();
77-
watchdog_thread.join();
7879
process_thread.join();
7980
}
8081

@@ -162,14 +163,14 @@ void Liverpool::Process(std::stop_token stoken) {
162163
void Liverpool::Watchdog(std::stop_token stoken) {
163164
Common::SetCurrentThreadName("shadPS4:GpuWatchdog");
164165

165-
while (!stoken.stop_requested()) {
166+
while (!stoken.stop_requested() || !rasterizer) {
166167
{
167168
std::unique_lock lk(submit_mutex);
168169
Common::CondvarWait(submit_cv, lk, stoken,
169170
[this] { return !submit_done && !pop_pending; });
170171
}
171172

172-
if (stoken.stop_requested()) {
173+
if (stoken.stop_requested() || !rasterizer) {
173174
return;
174175
}
175176

src/video_core/amdgpu/liverpool.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <condition_variable>
77
#include <coroutine>
88
#include <exception>
9+
#include <functional>
910
#include <mutex>
1011
#include <semaphore>
1112
#include <span>
@@ -92,7 +93,11 @@ struct Liverpool {
9293
}
9394

9495
void BindRasterizer(Vulkan::Rasterizer* rasterizer_) {
96+
const bool start_watchdog = !rasterizer;
9597
rasterizer = rasterizer_;
98+
if (start_watchdog) {
99+
watchdog_thread = std::jthread(std::bind_front(&Liverpool::Watchdog, this));
100+
}
96101
}
97102

98103
template <bool wait_done = false>

0 commit comments

Comments
 (0)