From 82b829625b89a706dd0d867c529f533fe928710c Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow 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 52706505b..1d12f0493 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 From 8942047d419f6d2d0c56adad689fbf3bcd4d2961 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Fri, 7 Jun 2019 20:41:06 -0400 Subject: Gpu: Implement Hardware Interrupt Manager and manage GPU interrupts --- src/video_core/gpu.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/video_core/gpu.cpp') diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index 1d12f0493..06eb570ab 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp @@ -29,7 +29,8 @@ u32 FramebufferConfig::BytesPerPixel(PixelFormat format) { UNREACHABLE(); } -GPU::GPU(Core::System& system, VideoCore::RendererBase& renderer) : renderer{renderer} { +GPU::GPU(Core::System& system, VideoCore::RendererBase& renderer) + : system{system}, renderer{renderer} { auto& rasterizer{renderer.Rasterizer()}; memory_manager = std::make_unique(rasterizer); dma_pusher = std::make_unique(*this); @@ -87,6 +88,10 @@ u32 GPU::GetSyncpointValue(const u32 syncpoint_id) const { } void GPU::RegisterEvent(const u32 event_id, const u32 syncpoint_id, const u32 value) { + for (auto& ev : events[syncpoint_id]) { + if (ev.event_id == event_id && ev.value == value) + return; + } events[syncpoint_id].emplace_back(event_id, value); } -- cgit v1.2.3 From a45643cb3b07e76e73814baf1d472d636dd2cd91 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Fri, 7 Jun 2019 21:13:20 -0400 Subject: nv_services: Stub CtrlEventSignal --- src/video_core/gpu.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/video_core/gpu.cpp') diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index 06eb570ab..1fa6770ca 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp @@ -95,6 +95,17 @@ void GPU::RegisterEvent(const u32 event_id, const u32 syncpoint_id, const u32 va events[syncpoint_id].emplace_back(event_id, value); } +void GPU::CancelEvent(const u32 event_id, const u32 syncpoint_id, const u32 value) { + auto it = events[syncpoint_id].begin(); + while (it != events[syncpoint_id].end()) { + if (value == it->value) { + it = events[syncpoint_id].erase(it); + return; + } + it++; + } +} + u32 RenderTargetBytesPerPixel(RenderTargetFormat format) { ASSERT(format != RenderTargetFormat::NONE); -- cgit v1.2.3 From eef55f493b636bfc57389e9c541ddf2c39f6f826 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Fri, 7 Jun 2019 22:13:40 -0400 Subject: Gpu: Mark areas as protected. --- src/video_core/gpu.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/video_core/gpu.cpp') diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index 1fa6770ca..ee976f81f 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp @@ -69,6 +69,7 @@ const DmaPusher& GPU::DmaPusher() const { void GPU::IncrementSyncPoint(const u32 syncpoint_id) { syncpoints[syncpoint_id]++; + sync_guard.lock(); if (!events[syncpoint_id].empty()) { u32 value = syncpoints[syncpoint_id].load(); auto it = events[syncpoint_id].begin(); @@ -81,6 +82,7 @@ void GPU::IncrementSyncPoint(const u32 syncpoint_id) { it++; } } + sync_guard.unlock(); } u32 GPU::GetSyncpointValue(const u32 syncpoint_id) const { -- cgit v1.2.3 From c13433aee4032ce654de1db31a93e4aed578596f Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Sat, 8 Jun 2019 16:45:25 -0400 Subject: Gpu: use an std mutex instead of a spin_lock to guard syncpoints --- src/video_core/gpu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/video_core/gpu.cpp') diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index ee976f81f..c71f0f9bf 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp @@ -69,7 +69,7 @@ const DmaPusher& GPU::DmaPusher() const { void GPU::IncrementSyncPoint(const u32 syncpoint_id) { syncpoints[syncpoint_id]++; - sync_guard.lock(); + sync_mutex.lock(); if (!events[syncpoint_id].empty()) { u32 value = syncpoints[syncpoint_id].load(); auto it = events[syncpoint_id].begin(); @@ -82,7 +82,7 @@ void GPU::IncrementSyncPoint(const u32 syncpoint_id) { it++; } } - sync_guard.unlock(); + sync_mutex.unlock(); } u32 GPU::GetSyncpointValue(const u32 syncpoint_id) const { -- cgit v1.2.3 From 0706d633bf7764455082cfdfdc35c14507cb6897 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Mon, 10 Jun 2019 08:19:27 -0400 Subject: nv_host_ctrl: Make Sync GPU variant always return synced result. --- src/video_core/gpu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/video_core/gpu.cpp') diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index c71f0f9bf..086db0e69 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp @@ -29,8 +29,8 @@ u32 FramebufferConfig::BytesPerPixel(PixelFormat format) { UNREACHABLE(); } -GPU::GPU(Core::System& system, VideoCore::RendererBase& renderer) - : system{system}, renderer{renderer} { +GPU::GPU(Core::System& system, VideoCore::RendererBase& renderer, bool is_async) + : system{system}, renderer{renderer}, is_async{is_async} { auto& rasterizer{renderer.Rasterizer()}; memory_manager = std::make_unique(rasterizer); dma_pusher = std::make_unique(*this); -- cgit v1.2.3 From 7d1b974bcaf72c32910dcf4ff2d435f91cf40609 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Wed, 12 Jun 2019 07:52:49 -0400 Subject: GPU: Correct Interrupts to interrupt on syncpt/value instead of event, mirroring hardware --- src/video_core/gpu.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/video_core/gpu.cpp') diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index 086db0e69..efea23bf2 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp @@ -70,13 +70,13 @@ const DmaPusher& GPU::DmaPusher() const { void GPU::IncrementSyncPoint(const u32 syncpoint_id) { syncpoints[syncpoint_id]++; sync_mutex.lock(); - if (!events[syncpoint_id].empty()) { + if (!syncpt_interrupts[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); + auto it = syncpt_interrupts[syncpoint_id].begin(); + while (it != syncpt_interrupts[syncpoint_id].end()) { + if (value >= *it) { + TriggerCpuInterrupt(syncpoint_id, *it); + it = syncpt_interrupts[syncpoint_id].erase(it); continue; } it++; @@ -89,19 +89,19 @@ 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) { - for (auto& ev : events[syncpoint_id]) { - if (ev.event_id == event_id && ev.value == value) +void GPU::RegisterSyncptInterrupt(const u32 syncpoint_id, const u32 value) { + for (u32 in_value : syncpt_interrupts[syncpoint_id]) { + if (in_value == value) return; } - events[syncpoint_id].emplace_back(event_id, value); + syncpt_interrupts[syncpoint_id].emplace_back(value); } -void GPU::CancelEvent(const u32 event_id, const u32 syncpoint_id, const u32 value) { - auto it = events[syncpoint_id].begin(); - while (it != events[syncpoint_id].end()) { - if (value == it->value) { - it = events[syncpoint_id].erase(it); +void GPU::CancelSyncptInterrupt(const u32 syncpoint_id, const u32 value) { + auto it = syncpt_interrupts[syncpoint_id].begin(); + while (it != syncpt_interrupts[syncpoint_id].end()) { + if (value == *it) { + it = syncpt_interrupts[syncpoint_id].erase(it); return; } it++; -- cgit v1.2.3 From 0335a25d1fcca5328ef79b3c62edb679df63ffba Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Mon, 17 Jun 2019 15:27:42 -0400 Subject: NVServices: Make NVEvents Automatic according to documentation. --- src/video_core/gpu.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/video_core/gpu.cpp') diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index efea23bf2..cdb2f804e 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp @@ -97,15 +97,18 @@ void GPU::RegisterSyncptInterrupt(const u32 syncpoint_id, const u32 value) { syncpt_interrupts[syncpoint_id].emplace_back(value); } -void GPU::CancelSyncptInterrupt(const u32 syncpoint_id, const u32 value) { +bool GPU::CancelSyncptInterrupt(const u32 syncpoint_id, const u32 value) { + sync_mutex.lock(); auto it = syncpt_interrupts[syncpoint_id].begin(); while (it != syncpt_interrupts[syncpoint_id].end()) { if (value == *it) { it = syncpt_interrupts[syncpoint_id].erase(it); - return; + return true; } it++; } + return false; + sync_mutex.unlock(); } u32 RenderTargetBytesPerPixel(RenderTargetFormat format) { -- cgit v1.2.3 From b391e5f6386eecf6170b544245e3e4e31427913c Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Tue, 18 Jun 2019 16:58:29 -0400 Subject: NVFlinger: Correct GCC compile error --- src/video_core/gpu.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/video_core/gpu.cpp') diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index cdb2f804e..278528618 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp @@ -69,7 +69,7 @@ const DmaPusher& GPU::DmaPusher() const { void GPU::IncrementSyncPoint(const u32 syncpoint_id) { syncpoints[syncpoint_id]++; - sync_mutex.lock(); + std::lock_guard lock{sync_mutex}; if (!syncpt_interrupts[syncpoint_id].empty()) { u32 value = syncpoints[syncpoint_id].load(); auto it = syncpt_interrupts[syncpoint_id].begin(); @@ -82,7 +82,6 @@ void GPU::IncrementSyncPoint(const u32 syncpoint_id) { it++; } } - sync_mutex.unlock(); } u32 GPU::GetSyncpointValue(const u32 syncpoint_id) const { @@ -98,7 +97,7 @@ void GPU::RegisterSyncptInterrupt(const u32 syncpoint_id, const u32 value) { } bool GPU::CancelSyncptInterrupt(const u32 syncpoint_id, const u32 value) { - sync_mutex.lock(); + std::lock_guard lock{sync_mutex}; auto it = syncpt_interrupts[syncpoint_id].begin(); while (it != syncpt_interrupts[syncpoint_id].end()) { if (value == *it) { @@ -108,7 +107,6 @@ bool GPU::CancelSyncptInterrupt(const u32 syncpoint_id, const u32 value) { it++; } return false; - sync_mutex.unlock(); } u32 RenderTargetBytesPerPixel(RenderTargetFormat format) { -- cgit v1.2.3 From d20ede40b1e9cd0539982fb1feb3b13af3501ea2 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Tue, 18 Jun 2019 20:53:21 -0400 Subject: NVServices: Styling, define constructors as explicit and corrections --- src/video_core/gpu.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src/video_core/gpu.cpp') diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index 278528618..da8c715b6 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp @@ -89,24 +89,27 @@ u32 GPU::GetSyncpointValue(const u32 syncpoint_id) const { } void GPU::RegisterSyncptInterrupt(const u32 syncpoint_id, const u32 value) { - for (u32 in_value : syncpt_interrupts[syncpoint_id]) { - if (in_value == value) - return; + auto& interrupt = syncpt_interrupts[syncpoint_id]; + bool contains = std::any_of(interrupt.begin(), interrupt.end(), + [value](u32 in_value) { return in_value == value; }); + if (contains) { + return; } syncpt_interrupts[syncpoint_id].emplace_back(value); } bool GPU::CancelSyncptInterrupt(const u32 syncpoint_id, const u32 value) { std::lock_guard lock{sync_mutex}; - auto it = syncpt_interrupts[syncpoint_id].begin(); - while (it != syncpt_interrupts[syncpoint_id].end()) { - if (value == *it) { - it = syncpt_interrupts[syncpoint_id].erase(it); - return true; - } - it++; + auto& interrupt = syncpt_interrupts[syncpoint_id]; + const auto iter = + std::find_if(interrupt.begin(), interrupt.end(), + [value](u32 interrupt_value) { return value == interrupt_value; }); + + if (iter == interrupt.end()) { + return false; } - return false; + interrupt.erase(iter); + return true; } u32 RenderTargetBytesPerPixel(RenderTargetFormat format) { -- cgit v1.2.3