From cb9dd01ffd3f54f5592330e3a37e2b26975bf209 Mon Sep 17 00:00:00 2001 From: Markus Wick Date: Mon, 30 Dec 2019 13:03:20 +0100 Subject: video_core: Block in WaitFence. This function is called rarely and blocks quite often for a long time. So don't waste power and let the CPU sleep. This might also increase the performance as the other cores might be allowed to clock higher. --- src/video_core/gpu.cpp | 7 ++++--- src/video_core/gpu.h | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src/video_core') diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index 095660115..b9c5c41a2 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp @@ -66,19 +66,20 @@ const DmaPusher& GPU::DmaPusher() const { return *dma_pusher; } -void GPU::WaitFence(u32 syncpoint_id, u32 value) const { +void GPU::WaitFence(u32 syncpoint_id, u32 value) { // Synced GPU, is always in sync if (!is_async) { return; } MICROPROFILE_SCOPE(GPU_wait); - while (syncpoints[syncpoint_id].load(std::memory_order_relaxed) < value) { - } + std::unique_lock lock{sync_mutex}; + sync_cv.wait(lock, [=]() { return syncpoints[syncpoint_id].load() >= value; }); } void GPU::IncrementSyncPoint(const u32 syncpoint_id) { syncpoints[syncpoint_id]++; std::lock_guard lock{sync_mutex}; + sync_cv.notify_all(); if (!syncpt_interrupts[syncpoint_id].empty()) { u32 value = syncpoints[syncpoint_id].load(); auto it = syncpt_interrupts[syncpoint_id].begin(); diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index ecc338ae9..b648317bb 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -181,7 +182,7 @@ public: virtual void WaitIdle() const = 0; /// Allows the CPU/NvFlinger to wait on the GPU before presenting a frame. - void WaitFence(u32 syncpoint_id, u32 value) const; + void WaitFence(u32 syncpoint_id, u32 value); void IncrementSyncPoint(u32 syncpoint_id); @@ -312,6 +313,8 @@ private: std::mutex sync_mutex; + std::condition_variable sync_cv; + const bool is_async; }; -- cgit v1.2.3