From 82b829625b89a706dd0d867c529f533fe928710c Mon Sep 17 00:00:00 2001
From: Fernando Sahmkow <fsahmkow27@gmail.com>
Date: Fri, 7 Jun 2019 12:56:30 -0400
Subject: video_core: Implement GPU side Syncpoints

---
 src/video_core/gpu.cpp | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

(limited to 'src/video_core/gpu.cpp')

diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp
index 52706505b0..1d12f04930 100644
--- a/src/video_core/gpu.cpp
+++ b/src/video_core/gpu.cpp
@@ -66,6 +66,30 @@ const DmaPusher& GPU::DmaPusher() const {
     return *dma_pusher;
 }
 
+void GPU::IncrementSyncPoint(const u32 syncpoint_id) {
+    syncpoints[syncpoint_id]++;
+    if (!events[syncpoint_id].empty()) {
+        u32 value = syncpoints[syncpoint_id].load();
+        auto it = events[syncpoint_id].begin();
+        while (it != events[syncpoint_id].end()) {
+            if (value >= it->value) {
+                TriggerCpuInterrupt(it->event_id);
+                it = events[syncpoint_id].erase(it);
+                continue;
+            }
+            it++;
+        }
+    }
+}
+
+u32 GPU::GetSyncpointValue(const u32 syncpoint_id) const {
+    return syncpoints[syncpoint_id].load();
+}
+
+void GPU::RegisterEvent(const u32 event_id, const u32 syncpoint_id, const u32 value) {
+    events[syncpoint_id].emplace_back(event_id, value);
+}
+
 u32 RenderTargetBytesPerPixel(RenderTargetFormat format) {
     ASSERT(format != RenderTargetFormat::NONE);
 
-- 
cgit v1.2.3-70-g09d2