summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2022-01-30 23:13:46 +0100
committerGravatar Fernando Sahmkow2022-10-06 21:00:52 +0200
commit920429fde745b3bf6d33b6ca991628f64988f754 (patch)
tree3c10b169e9e94041955500e4ed46e664255e4349
parentNVDRV: Refactor Host1x (diff)
downloadyuzu-920429fde745b3bf6d33b6ca991628f64988f754.tar.gz
yuzu-920429fde745b3bf6d33b6ca991628f64988f754.tar.xz
yuzu-920429fde745b3bf6d33b6ca991628f64988f754.zip
NVDRV: Further refactors and eliminate old code.
-rw-r--r--src/core/CMakeLists.txt2
-rw-r--r--src/core/core.cpp11
-rw-r--r--src/core/core.h10
-rw-r--r--src/core/hardware_interrupt_manager.cpp32
-rw-r--r--src/core/hardware_interrupt_manager.h32
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp26
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl.h2
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp7
-rw-r--r--src/core/hle/service/nvdrv/nvdrv.cpp21
-rw-r--r--src/core/hle/service/nvdrv/nvdrv.h7
-rw-r--r--src/core/hle/service/nvdrv/nvdrv_interface.cpp4
-rw-r--r--src/core/hle/service/nvdrv/nvdrv_interface.h2
-rw-r--r--src/video_core/command_classes/host1x.cpp29
-rw-r--r--src/video_core/gpu.cpp48
-rw-r--r--src/video_core/gpu.h9
-rw-r--r--src/video_core/host1x/syncpoint_manager.cpp4
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp4
-rw-r--r--src/video_core/renderer_vulkan/vk_rasterizer.cpp4
18 files changed, 12 insertions, 242 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 3ef19f9c2..95302c419 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -138,8 +138,6 @@ add_library(core STATIC
138 frontend/emu_window.h 138 frontend/emu_window.h
139 frontend/framebuffer_layout.cpp 139 frontend/framebuffer_layout.cpp
140 frontend/framebuffer_layout.h 140 frontend/framebuffer_layout.h
141 hardware_interrupt_manager.cpp
142 hardware_interrupt_manager.h
143 hid/emulated_console.cpp 141 hid/emulated_console.cpp
144 hid/emulated_console.h 142 hid/emulated_console.h
145 hid/emulated_controller.cpp 143 hid/emulated_controller.cpp
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 13d02e75f..1deeee154 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -27,7 +27,6 @@
27#include "core/file_sys/savedata_factory.h" 27#include "core/file_sys/savedata_factory.h"
28#include "core/file_sys/vfs_concat.h" 28#include "core/file_sys/vfs_concat.h"
29#include "core/file_sys/vfs_real.h" 29#include "core/file_sys/vfs_real.h"
30#include "core/hardware_interrupt_manager.h"
31#include "core/hid/hid_core.h" 30#include "core/hid/hid_core.h"
32#include "core/hle/kernel/k_memory_manager.h" 31#include "core/hle/kernel/k_memory_manager.h"
33#include "core/hle/kernel/k_process.h" 32#include "core/hle/kernel/k_process.h"
@@ -226,7 +225,6 @@ struct System::Impl {
226 225
227 service_manager = std::make_shared<Service::SM::ServiceManager>(kernel); 226 service_manager = std::make_shared<Service::SM::ServiceManager>(kernel);
228 services = std::make_unique<Service::Services>(service_manager, system); 227 services = std::make_unique<Service::Services>(service_manager, system);
229 interrupt_manager = std::make_unique<Hardware::InterruptManager>(system);
230 228
231 // Initialize time manager, which must happen after kernel is created 229 // Initialize time manager, which must happen after kernel is created
232 time_manager.Initialize(); 230 time_manager.Initialize();
@@ -454,7 +452,6 @@ struct System::Impl {
454 std::unique_ptr<Loader::AppLoader> app_loader; 452 std::unique_ptr<Loader::AppLoader> app_loader;
455 std::unique_ptr<Tegra::GPU> gpu_core; 453 std::unique_ptr<Tegra::GPU> gpu_core;
456 std::unique_ptr<Tegra::Host1x::Host1x> host1x_core; 454 std::unique_ptr<Tegra::Host1x::Host1x> host1x_core;
457 std::unique_ptr<Hardware::InterruptManager> interrupt_manager;
458 std::unique_ptr<Core::DeviceMemory> device_memory; 455 std::unique_ptr<Core::DeviceMemory> device_memory;
459 std::unique_ptr<AudioCore::AudioCore> audio_core; 456 std::unique_ptr<AudioCore::AudioCore> audio_core;
460 Core::Memory::Memory memory; 457 Core::Memory::Memory memory;
@@ -680,14 +677,6 @@ const Tegra::Host1x::Host1x& System::Host1x() const {
680 return *impl->host1x_core; 677 return *impl->host1x_core;
681} 678}
682 679
683Core::Hardware::InterruptManager& System::InterruptManager() {
684 return *impl->interrupt_manager;
685}
686
687const Core::Hardware::InterruptManager& System::InterruptManager() const {
688 return *impl->interrupt_manager;
689}
690
691VideoCore::RendererBase& System::Renderer() { 680VideoCore::RendererBase& System::Renderer() {
692 return impl->gpu_core->Renderer(); 681 return impl->gpu_core->Renderer();
693} 682}
diff --git a/src/core/core.h b/src/core/core.h
index e4168a921..7843cc8ad 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -91,10 +91,6 @@ namespace Core::Timing {
91class CoreTiming; 91class CoreTiming;
92} 92}
93 93
94namespace Core::Hardware {
95class InterruptManager;
96}
97
98namespace Core::HID { 94namespace Core::HID {
99class HIDCore; 95class HIDCore;
100} 96}
@@ -305,12 +301,6 @@ public:
305 /// Provides a constant reference to the core timing instance. 301 /// Provides a constant reference to the core timing instance.
306 [[nodiscard]] const Timing::CoreTiming& CoreTiming() const; 302 [[nodiscard]] const Timing::CoreTiming& CoreTiming() const;
307 303
308 /// Provides a reference to the interrupt manager instance.
309 [[nodiscard]] Core::Hardware::InterruptManager& InterruptManager();
310
311 /// Provides a constant reference to the interrupt manager instance.
312 [[nodiscard]] const Core::Hardware::InterruptManager& InterruptManager() const;
313
314 /// Provides a reference to the kernel instance. 304 /// Provides a reference to the kernel instance.
315 [[nodiscard]] Kernel::KernelCore& Kernel(); 305 [[nodiscard]] Kernel::KernelCore& Kernel();
316 306
diff --git a/src/core/hardware_interrupt_manager.cpp b/src/core/hardware_interrupt_manager.cpp
deleted file mode 100644
index d08cc3315..000000000
--- a/src/core/hardware_interrupt_manager.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/core.h"
5#include "core/core_timing.h"
6#include "core/hardware_interrupt_manager.h"
7#include "core/hle/service/nvdrv/nvdrv_interface.h"
8#include "core/hle/service/sm/sm.h"
9
10namespace Core::Hardware {
11
12InterruptManager::InterruptManager(Core::System& system_in) : system(system_in) {
13 gpu_interrupt_event = Core::Timing::CreateEvent(
14 "GPUInterrupt",
15 [this](std::uintptr_t message, u64 time,
16 std::chrono::nanoseconds) -> std::optional<std::chrono::nanoseconds> {
17 auto nvdrv = system.ServiceManager().GetService<Service::Nvidia::NVDRV>("nvdrv");
18 const u32 syncpt = static_cast<u32>(message >> 32);
19 const u32 value = static_cast<u32>(message);
20 nvdrv->SignalGPUInterruptSyncpt(syncpt, value);
21 return std::nullopt;
22 });
23}
24
25InterruptManager::~InterruptManager() = default;
26
27void InterruptManager::GPUInterruptSyncpt(const u32 syncpoint_id, const u32 value) {
28 const u64 msg = (static_cast<u64>(syncpoint_id) << 32ULL) | value;
29 system.CoreTiming().ScheduleEvent(std::chrono::nanoseconds{10}, gpu_interrupt_event, msg);
30}
31
32} // namespace Core::Hardware
diff --git a/src/core/hardware_interrupt_manager.h b/src/core/hardware_interrupt_manager.h
deleted file mode 100644
index 5665c5918..000000000
--- a/src/core/hardware_interrupt_manager.h
+++ /dev/null
@@ -1,32 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include <memory>
7
8#include "common/common_types.h"
9
10namespace Core {
11class System;
12}
13
14namespace Core::Timing {
15struct EventType;
16}
17
18namespace Core::Hardware {
19
20class InterruptManager {
21public:
22 explicit InterruptManager(Core::System& system);
23 ~InterruptManager();
24
25 void GPUInterruptSyncpt(u32 syncpoint_id, u32 value);
26
27private:
28 Core::System& system;
29 std::shared_ptr<Core::Timing::EventType> gpu_interrupt_event;
30};
31
32} // namespace Core::Hardware
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
index ffe42d423..076edb02f 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
@@ -77,12 +77,9 @@ NvResult nvhost_ctrl::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>&
77 return NvResult::NotImplemented; 77 return NvResult::NotImplemented;
78} 78}
79 79
80void nvhost_ctrl::OnOpen(DeviceFD fd) { 80void nvhost_ctrl::OnOpen(DeviceFD fd) {}
81 events_interface.RegisterForSignal(this); 81
82} 82void nvhost_ctrl::OnClose(DeviceFD fd) {}
83void nvhost_ctrl::OnClose(DeviceFD fd) {
84 events_interface.UnregisterForSignal(this);
85}
86 83
87NvResult nvhost_ctrl::NvOsGetConfigU32(const std::vector<u8>& input, std::vector<u8>& output) { 84NvResult nvhost_ctrl::NvOsGetConfigU32(const std::vector<u8>& input, std::vector<u8>& output) {
88 IocGetConfigParams params{}; 85 IocGetConfigParams params{};
@@ -395,21 +392,4 @@ u32 nvhost_ctrl::FindFreeNvEvent(u32 syncpoint_id) {
395 return 0; 392 return 0;
396} 393}
397 394
398void nvhost_ctrl::SignalNvEvent(u32 syncpoint_id, u32 value) {
399 u64 signal_mask = events_mask;
400 while (signal_mask != 0) {
401 const u64 event_id = std::countr_zero(signal_mask);
402 signal_mask &= ~(1ULL << event_id);
403 auto& event = events[event_id];
404 if (event.assigned_syncpt != syncpoint_id || event.assigned_value != value) {
405 continue;
406 }
407 if (event.status.exchange(EventState::Signalling, std::memory_order_acq_rel) ==
408 EventState::Waiting) {
409 event.kevent->GetWritableEvent().Signal();
410 }
411 event.status.store(EventState::Signalled, std::memory_order_release);
412 }
413}
414
415} // namespace Service::Nvidia::Devices 395} // namespace Service::Nvidia::Devices
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h
index 136a1e925..f511c0296 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h
@@ -56,8 +56,6 @@ public:
56 }; 56 };
57 static_assert(sizeof(SyncpointEventValue) == sizeof(u32)); 57 static_assert(sizeof(SyncpointEventValue) == sizeof(u32));
58 58
59 void SignalNvEvent(u32 syncpoint_id, u32 value);
60
61private: 59private:
62 struct InternalEvent { 60 struct InternalEvent {
63 // Mask representing registered events 61 // Mask representing registered events
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
index db3e266ad..3f981af5a 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
@@ -14,6 +14,7 @@
14#include "video_core/control/channel_state.h" 14#include "video_core/control/channel_state.h"
15#include "video_core/engines/puller.h" 15#include "video_core/engines/puller.h"
16#include "video_core/gpu.h" 16#include "video_core/gpu.h"
17#include "video_core/host1x/host1x.h"
17 18
18namespace Service::Nvidia::Devices { 19namespace Service::Nvidia::Devices {
19namespace { 20namespace {
@@ -31,7 +32,8 @@ nvhost_gpu::nvhost_gpu(Core::System& system_, EventInterface& events_interface_,
31 syncpoint_manager{core_.GetSyncpointManager()}, nvmap{core.GetNvMapFile()}, 32 syncpoint_manager{core_.GetSyncpointManager()}, nvmap{core.GetNvMapFile()},
32 channel_state{system.GPU().AllocateChannel()} { 33 channel_state{system.GPU().AllocateChannel()} {
33 channel_fence.id = syncpoint_manager.AllocateSyncpoint(); 34 channel_fence.id = syncpoint_manager.AllocateSyncpoint();
34 channel_fence.value = system_.GPU().GetSyncpointValue(channel_fence.id); 35 channel_fence.value =
36 system_.Host1x().GetSyncpointManager().GetGuestSyncpointValue(channel_fence.id);
35 sm_exception_breakpoint_int_report_event = 37 sm_exception_breakpoint_int_report_event =
36 events_interface.CreateEvent("GpuChannelSMExceptionBreakpointInt"); 38 events_interface.CreateEvent("GpuChannelSMExceptionBreakpointInt");
37 sm_exception_breakpoint_pause_report_event = 39 sm_exception_breakpoint_pause_report_event =
@@ -189,7 +191,8 @@ NvResult nvhost_gpu::AllocGPFIFOEx2(const std::vector<u8>& input, std::vector<u8
189 } 191 }
190 192
191 system.GPU().InitChannel(*channel_state); 193 system.GPU().InitChannel(*channel_state);
192 channel_fence.value = system.GPU().GetSyncpointValue(channel_fence.id); 194 channel_fence.value =
195 system.Host1x().GetSyncpointManager().GetGuestSyncpointValue(channel_fence.id);
193 196
194 params.fence_out = channel_fence; 197 params.fence_out = channel_fence;
195 198
diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp
index 8a9f3c717..1be51e401 100644
--- a/src/core/hle/service/nvdrv/nvdrv.cpp
+++ b/src/core/hle/service/nvdrv/nvdrv.cpp
@@ -33,23 +33,6 @@ EventInterface::EventInterface(Module& module_) : module{module_}, guard{}, on_s
33 33
34EventInterface::~EventInterface() = default; 34EventInterface::~EventInterface() = default;
35 35
36void EventInterface::RegisterForSignal(Devices::nvhost_ctrl* device) {
37 std::unique_lock<std::mutex> lk(guard);
38 on_signal.push_back(device);
39}
40
41void EventInterface::UnregisterForSignal(Devices::nvhost_ctrl* device) {
42 std::unique_lock<std::mutex> lk(guard);
43 on_signal.remove(device);
44}
45
46void EventInterface::Signal(u32 syncpoint_id, u32 value) {
47 std::unique_lock<std::mutex> lk(guard);
48 for (auto* device : on_signal) {
49 device->SignalNvEvent(syncpoint_id, value);
50 }
51}
52
53Kernel::KEvent* EventInterface::CreateEvent(std::string name) { 36Kernel::KEvent* EventInterface::CreateEvent(std::string name) {
54 Kernel::KEvent* new_event = module.service_context.CreateEvent(std::move(name)); 37 Kernel::KEvent* new_event = module.service_context.CreateEvent(std::move(name));
55 return new_event; 38 return new_event;
@@ -221,10 +204,6 @@ NvResult Module::Close(DeviceFD fd) {
221 return NvResult::Success; 204 return NvResult::Success;
222} 205}
223 206
224void Module::SignalSyncpt(const u32 syncpoint_id, const u32 value) {
225 events_interface.Signal(syncpoint_id, value);
226}
227
228NvResult Module::QueryEvent(DeviceFD fd, u32 event_id, Kernel::KEvent*& event) { 207NvResult Module::QueryEvent(DeviceFD fd, u32 event_id, Kernel::KEvent*& event) {
229 if (fd < 0) { 208 if (fd < 0) {
230 LOG_ERROR(Service_NVDRV, "Invalid DeviceFD={}!", fd); 209 LOG_ERROR(Service_NVDRV, "Invalid DeviceFD={}!", fd);
diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h
index 1fe98cf32..31c45236e 100644
--- a/src/core/hle/service/nvdrv/nvdrv.h
+++ b/src/core/hle/service/nvdrv/nvdrv.h
@@ -49,11 +49,6 @@ public:
49 EventInterface(Module& module_); 49 EventInterface(Module& module_);
50 ~EventInterface(); 50 ~EventInterface();
51 51
52 void RegisterForSignal(Devices::nvhost_ctrl*);
53 void UnregisterForSignal(Devices::nvhost_ctrl*);
54
55 void Signal(u32 syncpoint_id, u32 value);
56
57 Kernel::KEvent* CreateEvent(std::string name); 52 Kernel::KEvent* CreateEvent(std::string name);
58 53
59 void FreeEvent(Kernel::KEvent* event); 54 void FreeEvent(Kernel::KEvent* event);
@@ -96,8 +91,6 @@ public:
96 /// Closes a device file descriptor and returns operation success. 91 /// Closes a device file descriptor and returns operation success.
97 NvResult Close(DeviceFD fd); 92 NvResult Close(DeviceFD fd);
98 93
99 void SignalSyncpt(const u32 syncpoint_id, const u32 value);
100
101 NvResult QueryEvent(DeviceFD fd, u32 event_id, Kernel::KEvent*& event); 94 NvResult QueryEvent(DeviceFD fd, u32 event_id, Kernel::KEvent*& event);
102 95
103private: 96private:
diff --git a/src/core/hle/service/nvdrv/nvdrv_interface.cpp b/src/core/hle/service/nvdrv/nvdrv_interface.cpp
index bd41205b8..5e50a04e8 100644
--- a/src/core/hle/service/nvdrv/nvdrv_interface.cpp
+++ b/src/core/hle/service/nvdrv/nvdrv_interface.cpp
@@ -15,10 +15,6 @@
15 15
16namespace Service::Nvidia { 16namespace Service::Nvidia {
17 17
18void NVDRV::SignalGPUInterruptSyncpt(const u32 syncpoint_id, const u32 value) {
19 nvdrv->SignalSyncpt(syncpoint_id, value);
20}
21
22void NVDRV::Open(Kernel::HLERequestContext& ctx) { 18void NVDRV::Open(Kernel::HLERequestContext& ctx) {
23 LOG_DEBUG(Service_NVDRV, "called"); 19 LOG_DEBUG(Service_NVDRV, "called");
24 IPC::ResponseBuilder rb{ctx, 4}; 20 IPC::ResponseBuilder rb{ctx, 4};
diff --git a/src/core/hle/service/nvdrv/nvdrv_interface.h b/src/core/hle/service/nvdrv/nvdrv_interface.h
index cbd37b52b..cd58a4f35 100644
--- a/src/core/hle/service/nvdrv/nvdrv_interface.h
+++ b/src/core/hle/service/nvdrv/nvdrv_interface.h
@@ -18,8 +18,6 @@ public:
18 explicit NVDRV(Core::System& system_, std::shared_ptr<Module> nvdrv_, const char* name); 18 explicit NVDRV(Core::System& system_, std::shared_ptr<Module> nvdrv_, const char* name);
19 ~NVDRV() override; 19 ~NVDRV() override;
20 20
21 void SignalGPUInterruptSyncpt(u32 syncpoint_id, u32 value);
22
23private: 21private:
24 void Open(Kernel::HLERequestContext& ctx); 22 void Open(Kernel::HLERequestContext& ctx);
25 void Ioctl1(Kernel::HLERequestContext& ctx); 23 void Ioctl1(Kernel::HLERequestContext& ctx);
diff --git a/src/video_core/command_classes/host1x.cpp b/src/video_core/command_classes/host1x.cpp
deleted file mode 100644
index 11855fe10..000000000
--- a/src/video_core/command_classes/host1x.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "common/assert.h"
5#include "video_core/command_classes/host1x.h"
6#include "video_core/gpu.h"
7
8Tegra::Host1x::Host1x(GPU& gpu_) : gpu(gpu_) {}
9
10Tegra::Host1x::~Host1x() = default;
11
12void Tegra::Host1x::ProcessMethod(Method method, u32 argument) {
13 switch (method) {
14 case Method::LoadSyncptPayload32:
15 syncpoint_value = argument;
16 break;
17 case Method::WaitSyncpt:
18 case Method::WaitSyncpt32:
19 Execute(argument);
20 break;
21 default:
22 UNIMPLEMENTED_MSG("Host1x method 0x{:X}", static_cast<u32>(method));
23 break;
24 }
25}
26
27void Tegra::Host1x::Execute(u32 data) {
28 gpu.WaitFence(data, syncpoint_value);
29}
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp
index e05c9a357..a1d19b1c8 100644
--- a/src/video_core/gpu.cpp
+++ b/src/video_core/gpu.cpp
@@ -14,7 +14,6 @@
14#include "core/core.h" 14#include "core/core.h"
15#include "core/core_timing.h" 15#include "core/core_timing.h"
16#include "core/frontend/emu_window.h" 16#include "core/frontend/emu_window.h"
17#include "core/hardware_interrupt_manager.h"
18#include "core/hle/service/nvdrv/nvdata.h" 17#include "core/hle/service/nvdrv/nvdata.h"
19#include "core/perf_stats.h" 18#include "core/perf_stats.h"
20#include "video_core/cdma_pusher.h" 19#include "video_core/cdma_pusher.h"
@@ -36,8 +35,6 @@
36 35
37namespace Tegra { 36namespace Tegra {
38 37
39MICROPROFILE_DEFINE(GPU_wait, "GPU", "Wait for the GPU", MP_RGB(128, 128, 192));
40
41struct GPU::Impl { 38struct GPU::Impl {
42 explicit Impl(GPU& gpu_, Core::System& system_, bool is_async_, bool use_nvdec_) 39 explicit Impl(GPU& gpu_, Core::System& system_, bool is_async_, bool use_nvdec_)
43 : gpu{gpu_}, system{system_}, host1x{system.Host1x()}, use_nvdec{use_nvdec_}, 40 : gpu{gpu_}, system{system_}, host1x{system.Host1x()}, use_nvdec{use_nvdec_},
@@ -197,30 +194,6 @@ struct GPU::Impl {
197 return *shader_notify; 194 return *shader_notify;
198 } 195 }
199 196
200 /// Allows the CPU/NvFlinger to wait on the GPU before presenting a frame.
201 void WaitFence(u32 syncpoint_id, u32 value) {
202 if (syncpoint_id == UINT32_MAX) {
203 return;
204 }
205 MICROPROFILE_SCOPE(GPU_wait);
206 host1x.GetSyncpointManager().WaitHost(syncpoint_id, value);
207 }
208
209 void IncrementSyncPoint(u32 syncpoint_id) {
210 host1x.GetSyncpointManager().IncrementHost(syncpoint_id);
211 }
212
213 [[nodiscard]] u32 GetSyncpointValue(u32 syncpoint_id) const {
214 return host1x.GetSyncpointManager().GetHostSyncpointValue(syncpoint_id);
215 }
216
217 void RegisterSyncptInterrupt(u32 syncpoint_id, u32 value) {
218 auto& syncpoint_manager = host1x.GetSyncpointManager();
219 syncpoint_manager.RegisterHostAction(syncpoint_id, value, [this, syncpoint_id, value]() {
220 TriggerCpuInterrupt(syncpoint_id, value);
221 });
222 }
223
224 [[nodiscard]] u64 GetTicks() const { 197 [[nodiscard]] u64 GetTicks() const {
225 // This values were reversed engineered by fincs from NVN 198 // This values were reversed engineered by fincs from NVN
226 // The gpu clock is reported in units of 385/625 nanoseconds 199 // The gpu clock is reported in units of 385/625 nanoseconds
@@ -322,11 +295,6 @@ struct GPU::Impl {
322 gpu_thread.FlushAndInvalidateRegion(addr, size); 295 gpu_thread.FlushAndInvalidateRegion(addr, size);
323 } 296 }
324 297
325 void TriggerCpuInterrupt(u32 syncpoint_id, u32 value) const {
326 auto& interrupt_manager = system.InterruptManager();
327 interrupt_manager.GPUInterruptSyncpt(syncpoint_id, value);
328 }
329
330 void RequestSwapBuffers(const Tegra::FramebufferConfig* framebuffer, 298 void RequestSwapBuffers(const Tegra::FramebufferConfig* framebuffer,
331 Service::Nvidia::NvFence* fences, size_t num_fences) { 299 Service::Nvidia::NvFence* fences, size_t num_fences) {
332 size_t current_request_counter{}; 300 size_t current_request_counter{};
@@ -524,22 +492,6 @@ void GPU::RequestSwapBuffers(const Tegra::FramebufferConfig* framebuffer,
524 impl->RequestSwapBuffers(framebuffer, fences, num_fences); 492 impl->RequestSwapBuffers(framebuffer, fences, num_fences);
525} 493}
526 494
527void GPU::WaitFence(u32 syncpoint_id, u32 value) {
528 impl->WaitFence(syncpoint_id, value);
529}
530
531void GPU::IncrementSyncPoint(u32 syncpoint_id) {
532 impl->IncrementSyncPoint(syncpoint_id);
533}
534
535u32 GPU::GetSyncpointValue(u32 syncpoint_id) const {
536 return impl->GetSyncpointValue(syncpoint_id);
537}
538
539void GPU::RegisterSyncptInterrupt(u32 syncpoint_id, u32 value) {
540 impl->RegisterSyncptInterrupt(syncpoint_id, value);
541}
542
543u64 GPU::GetTicks() const { 495u64 GPU::GetTicks() const {
544 return impl->GetTicks(); 496 return impl->GetTicks();
545} 497}
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h
index f04edf5c4..655373b33 100644
--- a/src/video_core/gpu.h
+++ b/src/video_core/gpu.h
@@ -171,15 +171,6 @@ public:
171 /// Returns a const reference to the shader notifier. 171 /// Returns a const reference to the shader notifier.
172 [[nodiscard]] const VideoCore::ShaderNotify& ShaderNotify() const; 172 [[nodiscard]] const VideoCore::ShaderNotify& ShaderNotify() const;
173 173
174 /// Allows the CPU/NvFlinger to wait on the GPU before presenting a frame.
175 void WaitFence(u32 syncpoint_id, u32 value);
176
177 void IncrementSyncPoint(u32 syncpoint_id);
178
179 [[nodiscard]] u32 GetSyncpointValue(u32 syncpoint_id) const;
180
181 void RegisterSyncptInterrupt(u32 syncpoint_id, u32 value);
182
183 [[nodiscard]] u64 GetTicks() const; 174 [[nodiscard]] u64 GetTicks() const;
184 175
185 [[nodiscard]] bool IsAsync() const; 176 [[nodiscard]] bool IsAsync() const;
diff --git a/src/video_core/host1x/syncpoint_manager.cpp b/src/video_core/host1x/syncpoint_manager.cpp
index c606b8bd0..825bd551e 100644
--- a/src/video_core/host1x/syncpoint_manager.cpp
+++ b/src/video_core/host1x/syncpoint_manager.cpp
@@ -2,12 +2,15 @@
2// Licensed under GPLv3 or any later version 2// Licensed under GPLv3 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/microprofile.h"
5#include "video_core/host1x/syncpoint_manager.h" 6#include "video_core/host1x/syncpoint_manager.h"
6 7
7namespace Tegra { 8namespace Tegra {
8 9
9namespace Host1x { 10namespace Host1x {
10 11
12MICROPROFILE_DEFINE(GPU_wait, "GPU", "Wait for the GPU", MP_RGB(128, 128, 192));
13
11SyncpointManager::ActionHandle SyncpointManager::RegisterAction( 14SyncpointManager::ActionHandle SyncpointManager::RegisterAction(
12 std::atomic<u32>& syncpoint, std::list<RegisteredAction>& action_storage, u32 expected_value, 15 std::atomic<u32>& syncpoint, std::list<RegisteredAction>& action_storage, u32 expected_value,
13 std::function<void(void)>& action) { 16 std::function<void(void)>& action) {
@@ -58,6 +61,7 @@ void SyncpointManager::WaitGuest(u32 syncpoint_id, u32 expected_value) {
58} 61}
59 62
60void SyncpointManager::WaitHost(u32 syncpoint_id, u32 expected_value) { 63void SyncpointManager::WaitHost(u32 syncpoint_id, u32 expected_value) {
64 MICROPROFILE_SCOPE(GPU_wait);
61 Wait(syncpoints_host[syncpoint_id], wait_host_cv, expected_value); 65 Wait(syncpoints_host[syncpoint_id], wait_host_cv, expected_value);
62} 66}
63 67
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index f745fbf56..b572950a6 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -396,10 +396,6 @@ void RasterizerOpenGL::SignalSemaphore(GPUVAddr addr, u32 value) {
396} 396}
397 397
398void RasterizerOpenGL::SignalSyncPoint(u32 value) { 398void RasterizerOpenGL::SignalSyncPoint(u32 value) {
399 if (!gpu.IsAsync()) {
400 gpu.IncrementSyncPoint(value);
401 return;
402 }
403 fence_manager.SignalSyncPoint(value); 399 fence_manager.SignalSyncPoint(value);
404} 400}
405 401
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
index 50fdf5e18..a95f68231 100644
--- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp
+++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
@@ -458,10 +458,6 @@ void RasterizerVulkan::SignalSemaphore(GPUVAddr addr, u32 value) {
458} 458}
459 459
460void RasterizerVulkan::SignalSyncPoint(u32 value) { 460void RasterizerVulkan::SignalSyncPoint(u32 value) {
461 if (!gpu.IsAsync()) {
462 gpu.IncrementSyncPoint(value);
463 return;
464 }
465 fence_manager.SignalSyncPoint(value); 461 fence_manager.SignalSyncPoint(value);
466} 462}
467 463