amdgpu: non-blocking submitDone

This commit is contained in:
psucien 2024-05-17 08:22:47 +02:00
parent 9df1a8d15b
commit dbdb3dc77e
2 changed files with 13 additions and 5 deletions

View File

@ -40,7 +40,7 @@ void Liverpool::Process(std::stop_token stoken) {
} }
} }
void Liverpool::Wait() { void Liverpool::WaitGpuIdle() {
std::unique_lock lock{m_ring_access}; std::unique_lock lock{m_ring_access};
cv_complete.wait(lock, [this]() { return gfx_ring.empty(); }); cv_complete.wait(lock, [this]() { return gfx_ring.empty(); });
} }

View File

@ -619,6 +619,14 @@ public:
~Liverpool(); ~Liverpool();
void SubmitGfx(const u32* dcb, u32 dcb_size) { 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}; std::scoped_lock lock{m_ring_access};
gfx_ring.push({dcb, dcb_size}); gfx_ring.push({dcb, dcb_size});
@ -626,21 +634,21 @@ public:
cv_submit.notify_one(); cv_submit.notify_one();
} }
void SubmitDone() { void SubmitDone() {
// This is wrong as `submitDone()` should never be blocking. The behavior will be submission_lock = true;
// reworked with mutiple queues introduction
Wait();
} }
private: private:
void ProcessCmdList(const u32* cmdbuf, u32 size_in_bytes); void ProcessCmdList(const u32* cmdbuf, u32 size_in_bytes);
void Process(std::stop_token stoken); void Process(std::stop_token stoken);
void Wait(); void WaitGpuIdle();
std::jthread process_thread{}; std::jthread process_thread{};
std::queue<std::span<const u32>> gfx_ring{}; std::queue<std::span<const u32>> gfx_ring{};
std::condition_variable_any cv_submit{}; std::condition_variable_any cv_submit{};
std::condition_variable cv_complete{}; std::condition_variable cv_complete{};
std::mutex m_ring_access{}; std::mutex m_ring_access{};
bool submission_lock{};
}; };
static_assert(GFX6_3D_REG_INDEX(ps_program) == 0x2C08); static_assert(GFX6_3D_REG_INDEX(ps_program) == 0x2C08);