diff --git a/src/video_core/amdgpu/liverpool.cpp b/src/video_core/amdgpu/liverpool.cpp index 03e93eb9..5bbe6ee2 100644 --- a/src/video_core/amdgpu/liverpool.cpp +++ b/src/video_core/amdgpu/liverpool.cpp @@ -40,7 +40,7 @@ void Liverpool::Process(std::stop_token stoken) { } } -void Liverpool::Wait() { +void Liverpool::WaitGpuIdle() { std::unique_lock lock{m_ring_access}; cv_complete.wait(lock, [this]() { return gfx_ring.empty(); }); } diff --git a/src/video_core/amdgpu/liverpool.h b/src/video_core/amdgpu/liverpool.h index c040a2ff..2f0d2500 100644 --- a/src/video_core/amdgpu/liverpool.h +++ b/src/video_core/amdgpu/liverpool.h @@ -619,6 +619,14 @@ public: ~Liverpool(); void SubmitGfx(const u32* dcb, u32 dcb_size) { + if (submission_lock) { + WaitGpuIdle(); + + // Suspend logic goes here + + submission_lock = false; + } + { std::scoped_lock lock{m_ring_access}; gfx_ring.push({dcb, dcb_size}); @@ -626,21 +634,21 @@ public: cv_submit.notify_one(); } void SubmitDone() { - // This is wrong as `submitDone()` should never be blocking. The behavior will be - // reworked with mutiple queues introduction - Wait(); + submission_lock = true; } private: void ProcessCmdList(const u32* cmdbuf, u32 size_in_bytes); void Process(std::stop_token stoken); - void Wait(); + void WaitGpuIdle(); std::jthread process_thread{}; std::queue> gfx_ring{}; std::condition_variable_any cv_submit{}; std::condition_variable cv_complete{}; std::mutex m_ring_access{}; + + bool submission_lock{}; }; static_assert(GFX6_3D_REG_INDEX(ps_program) == 0x2C08);