summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.cpp2
-rw-r--r--src/video_core/gpu.cpp7
-rw-r--r--src/video_core/gpu.h5
3 files changed, 9 insertions, 5 deletions
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp
index 52623cf89..9810d2c64 100644
--- a/src/core/hle/service/nvflinger/nvflinger.cpp
+++ b/src/core/hle/service/nvflinger/nvflinger.cpp
@@ -192,7 +192,7 @@ void NVFlinger::Compose() {
192 192
193 const auto& igbp_buffer = buffer->get().igbp_buffer; 193 const auto& igbp_buffer = buffer->get().igbp_buffer;
194 194
195 const auto& gpu = system.GPU(); 195 auto& gpu = system.GPU();
196 const auto& multi_fence = buffer->get().multi_fence; 196 const auto& multi_fence = buffer->get().multi_fence;
197 for (u32 fence_id = 0; fence_id < multi_fence.num_fences; fence_id++) { 197 for (u32 fence_id = 0; fence_id < multi_fence.num_fences; fence_id++) {
198 const auto& fence = multi_fence.fences[fence_id]; 198 const auto& fence = multi_fence.fences[fence_id];
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 {
66 return *dma_pusher; 66 return *dma_pusher;
67} 67}
68 68
69void GPU::WaitFence(u32 syncpoint_id, u32 value) const { 69void GPU::WaitFence(u32 syncpoint_id, u32 value) {
70 // Synced GPU, is always in sync 70 // Synced GPU, is always in sync
71 if (!is_async) { 71 if (!is_async) {
72 return; 72 return;
73 } 73 }
74 MICROPROFILE_SCOPE(GPU_wait); 74 MICROPROFILE_SCOPE(GPU_wait);
75 while (syncpoints[syncpoint_id].load(std::memory_order_relaxed) < value) { 75 std::unique_lock lock{sync_mutex};
76 } 76 sync_cv.wait(lock, [=]() { return syncpoints[syncpoint_id].load() >= value; });
77} 77}
78 78
79void GPU::IncrementSyncPoint(const u32 syncpoint_id) { 79void GPU::IncrementSyncPoint(const u32 syncpoint_id) {
80 syncpoints[syncpoint_id]++; 80 syncpoints[syncpoint_id]++;
81 std::lock_guard lock{sync_mutex}; 81 std::lock_guard lock{sync_mutex};
82 sync_cv.notify_all();
82 if (!syncpt_interrupts[syncpoint_id].empty()) { 83 if (!syncpt_interrupts[syncpoint_id].empty()) {
83 u32 value = syncpoints[syncpoint_id].load(); 84 u32 value = syncpoints[syncpoint_id].load();
84 auto it = syncpt_interrupts[syncpoint_id].begin(); 85 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 @@
6 6
7#include <array> 7#include <array>
8#include <atomic> 8#include <atomic>
9#include <condition_variable>
9#include <list> 10#include <list>
10#include <memory> 11#include <memory>
11#include <mutex> 12#include <mutex>
@@ -181,7 +182,7 @@ public:
181 virtual void WaitIdle() const = 0; 182 virtual void WaitIdle() const = 0;
182 183
183 /// Allows the CPU/NvFlinger to wait on the GPU before presenting a frame. 184 /// Allows the CPU/NvFlinger to wait on the GPU before presenting a frame.
184 void WaitFence(u32 syncpoint_id, u32 value) const; 185 void WaitFence(u32 syncpoint_id, u32 value);
185 186
186 void IncrementSyncPoint(u32 syncpoint_id); 187 void IncrementSyncPoint(u32 syncpoint_id);
187 188
@@ -312,6 +313,8 @@ private:
312 313
313 std::mutex sync_mutex; 314 std::mutex sync_mutex;
314 315
316 std::condition_variable sync_cv;
317
315 const bool is_async; 318 const bool is_async;
316}; 319};
317 320