summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hardware_interrupt_manager.cpp8
-rw-r--r--src/core/hardware_interrupt_manager.h15
-rw-r--r--src/core/hle/service/nvdrv/devices/nvdevice.h2
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp10
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl.h4
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp2
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h2
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp2
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_nvdec.h2
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp2
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h2
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_vic.cpp2
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_vic.h2
-rw-r--r--src/core/hle/service/nvdrv/devices/nvmap.cpp2
-rw-r--r--src/core/hle/service/nvdrv/devices/nvmap.h2
-rw-r--r--src/core/hle/service/nvdrv/nvdrv.cpp4
-rw-r--r--src/core/hle/service/nvdrv/nvdrv.h16
-rw-r--r--src/core/hle/service/nvflinger/buffer_queue.cpp2
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.cpp7
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.h2
-rw-r--r--src/video_core/gpu.cpp25
-rw-r--r--src/video_core/gpu.h18
-rw-r--r--src/video_core/gpu_asynch.h2
-rw-r--r--src/video_core/gpu_synch.h3
24 files changed, 73 insertions, 65 deletions
diff --git a/src/core/hardware_interrupt_manager.cpp b/src/core/hardware_interrupt_manager.cpp
index c3fffa894..c2115db2d 100644
--- a/src/core/hardware_interrupt_manager.cpp
+++ b/src/core/hardware_interrupt_manager.cpp
@@ -1,5 +1,9 @@
1// Copyright 2019 Yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
1 4
2#include "core/core.h" 5#include "core/core.h"
6#include "core/core_timing.h"
3#include "core/hardware_interrupt_manager.h" 7#include "core/hardware_interrupt_manager.h"
4#include "core/hle/service/nvdrv/interface.h" 8#include "core/hle/service/nvdrv/interface.h"
5#include "core/hle/service/sm/sm.h" 9#include "core/hle/service/sm/sm.h"
@@ -11,11 +15,13 @@ InterruptManager::InterruptManager(Core::System& system_in) : system(system_in)
11 system.CoreTiming().RegisterEvent("GPUInterrupt", [this](u64 message, s64) { 15 system.CoreTiming().RegisterEvent("GPUInterrupt", [this](u64 message, s64) {
12 auto nvdrv = system.ServiceManager().GetService<Service::Nvidia::NVDRV>("nvdrv"); 16 auto nvdrv = system.ServiceManager().GetService<Service::Nvidia::NVDRV>("nvdrv");
13 const u32 syncpt = static_cast<u32>(message >> 32); 17 const u32 syncpt = static_cast<u32>(message >> 32);
14 const u32 value = static_cast<u32>(message & 0x00000000FFFFFFFFULL); 18 const u32 value = static_cast<u32>(message);
15 nvdrv->SignalGPUInterruptSyncpt(syncpt, value); 19 nvdrv->SignalGPUInterruptSyncpt(syncpt, value);
16 }); 20 });
17} 21}
18 22
23InterruptManager::~InterruptManager() = default;
24
19void InterruptManager::GPUInterruptSyncpt(const u32 syncpoint_id, const u32 value) { 25void InterruptManager::GPUInterruptSyncpt(const u32 syncpoint_id, const u32 value) {
20 const u64 msg = (static_cast<u64>(syncpoint_id) << 32ULL) | value; 26 const u64 msg = (static_cast<u64>(syncpoint_id) << 32ULL) | value;
21 system.CoreTiming().ScheduleEvent(10, gpu_interrupt_event, msg); 27 system.CoreTiming().ScheduleEvent(10, gpu_interrupt_event, msg);
diff --git a/src/core/hardware_interrupt_manager.h b/src/core/hardware_interrupt_manager.h
index 590392f75..494db883a 100644
--- a/src/core/hardware_interrupt_manager.h
+++ b/src/core/hardware_interrupt_manager.h
@@ -1,20 +1,27 @@
1// Copyright 2019 Yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
1#pragma once 5#pragma once
2 6
3#include "common/common_types.h" 7#include "common/common_types.h"
4#include "core/core_timing.h"
5 8
6namespace Core { 9namespace Core {
7class System; 10class System;
8} 11}
9 12
13namespace Core::Timing {
14struct EventType;
15}
16
10namespace Core::Hardware { 17namespace Core::Hardware {
11 18
12class InterruptManager { 19class InterruptManager {
13public: 20public:
14 InterruptManager(Core::System& system); 21 explicit InterruptManager(Core::System& system);
15 ~InterruptManager() = default; 22 ~InterruptManager();
16 23
17 void GPUInterruptSyncpt(const u32 syncpoint_id, const u32 value); 24 void GPUInterruptSyncpt(u32 syncpoint_id, u32 value);
18 25
19private: 26private:
20 Core::System& system; 27 Core::System& system;
diff --git a/src/core/hle/service/nvdrv/devices/nvdevice.h b/src/core/hle/service/nvdrv/devices/nvdevice.h
index fae69eb19..5b8248433 100644
--- a/src/core/hle/service/nvdrv/devices/nvdevice.h
+++ b/src/core/hle/service/nvdrv/devices/nvdevice.h
@@ -20,7 +20,7 @@ namespace Service::Nvidia::Devices {
20/// implement the ioctl interface. 20/// implement the ioctl interface.
21class nvdevice { 21class nvdevice {
22public: 22public:
23 nvdevice(Core::System& system) : system{system} {}; 23 explicit nvdevice(Core::System& system) : system{system} {};
24 virtual ~nvdevice() = default; 24 virtual ~nvdevice() = default;
25 union Ioctl { 25 union Ioctl {
26 u32_le raw; 26 u32_le raw;
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
index a5a4f8c7b..749aa71d4 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
@@ -15,7 +15,7 @@
15 15
16namespace Service::Nvidia::Devices { 16namespace Service::Nvidia::Devices {
17 17
18nvhost_ctrl::nvhost_ctrl(Core::System& system, EventsInterface& events_interface) 18nvhost_ctrl::nvhost_ctrl(Core::System& system, EventInterface& events_interface)
19 : nvdevice(system), events_interface{events_interface} {} 19 : nvdevice(system), events_interface{events_interface} {}
20nvhost_ctrl::~nvhost_ctrl() = default; 20nvhost_ctrl::~nvhost_ctrl() = default;
21 21
@@ -67,12 +67,11 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>&
67 if (!gpu.IsAsync()) { 67 if (!gpu.IsAsync()) {
68 return NvResult::Success; 68 return NvResult::Success;
69 } 69 }
70 gpu.Guard(true); 70 auto lock = gpu.LockSync();
71 u32 current_syncpoint_value = gpu.GetSyncpointValue(params.syncpt_id); 71 u32 current_syncpoint_value = gpu.GetSyncpointValue(params.syncpt_id);
72 if (current_syncpoint_value >= params.threshold) { 72 if (current_syncpoint_value >= params.threshold) {
73 params.value = current_syncpoint_value; 73 params.value = current_syncpoint_value;
74 std::memcpy(output.data(), &params, sizeof(params)); 74 std::memcpy(output.data(), &params, sizeof(params));
75 gpu.Guard(false);
76 return NvResult::Success; 75 return NvResult::Success;
77 } 76 }
78 77
@@ -82,7 +81,6 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>&
82 81
83 if (params.timeout == 0) { 82 if (params.timeout == 0) {
84 std::memcpy(output.data(), &params, sizeof(params)); 83 std::memcpy(output.data(), &params, sizeof(params));
85 gpu.Guard(false);
86 return NvResult::Timeout; 84 return NvResult::Timeout;
87 } 85 }
88 86
@@ -91,7 +89,6 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>&
91 event_id = params.value & 0x00FF; 89 event_id = params.value & 0x00FF;
92 if (event_id >= 64) { 90 if (event_id >= 64) {
93 std::memcpy(output.data(), &params, sizeof(params)); 91 std::memcpy(output.data(), &params, sizeof(params));
94 gpu.Guard(false);
95 return NvResult::BadParameter; 92 return NvResult::BadParameter;
96 } 93 }
97 } else { 94 } else {
@@ -119,15 +116,12 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>&
119 ctrl.must_delay = true; 116 ctrl.must_delay = true;
120 ctrl.timeout = params.timeout; 117 ctrl.timeout = params.timeout;
121 ctrl.event_id = event_id; 118 ctrl.event_id = event_id;
122 gpu.Guard(false);
123 return NvResult::Timeout; 119 return NvResult::Timeout;
124 } 120 }
125 std::memcpy(output.data(), &params, sizeof(params)); 121 std::memcpy(output.data(), &params, sizeof(params));
126 gpu.Guard(false);
127 return NvResult::Timeout; 122 return NvResult::Timeout;
128 } 123 }
129 std::memcpy(output.data(), &params, sizeof(params)); 124 std::memcpy(output.data(), &params, sizeof(params));
130 gpu.Guard(false);
131 return NvResult::BadParameter; 125 return NvResult::BadParameter;
132} 126}
133 127
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h
index 7cb41aa54..14e6e7e57 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h
@@ -14,7 +14,7 @@ namespace Service::Nvidia::Devices {
14 14
15class nvhost_ctrl final : public nvdevice { 15class nvhost_ctrl final : public nvdevice {
16public: 16public:
17 nvhost_ctrl(Core::System& system, EventsInterface& events_interface); 17 explicit nvhost_ctrl(Core::System& system, EventInterface& events_interface);
18 ~nvhost_ctrl() override; 18 ~nvhost_ctrl() override;
19 19
20 u32 ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 20 u32 ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output,
@@ -143,7 +143,7 @@ private:
143 143
144 u32 IocCtrlEventSignal(const std::vector<u8>& input, std::vector<u8>& output); 144 u32 IocCtrlEventSignal(const std::vector<u8>& input, std::vector<u8>& output);
145 145
146 EventsInterface& events_interface; 146 EventInterface& events_interface;
147}; 147};
148 148
149} // namespace Service::Nvidia::Devices 149} // namespace Service::Nvidia::Devices
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp
index e3d2b4470..988effd90 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp
@@ -12,7 +12,7 @@
12 12
13namespace Service::Nvidia::Devices { 13namespace Service::Nvidia::Devices {
14 14
15nvhost_ctrl_gpu::nvhost_ctrl_gpu(Core::System& system) : nvdevice(system){}; 15nvhost_ctrl_gpu::nvhost_ctrl_gpu(Core::System& system) : nvdevice(system) {}
16nvhost_ctrl_gpu::~nvhost_ctrl_gpu() = default; 16nvhost_ctrl_gpu::~nvhost_ctrl_gpu() = default;
17 17
18u32 nvhost_ctrl_gpu::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 18u32 nvhost_ctrl_gpu::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output,
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h
index de36cb014..2b035ae3f 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h
@@ -13,7 +13,7 @@ namespace Service::Nvidia::Devices {
13 13
14class nvhost_ctrl_gpu final : public nvdevice { 14class nvhost_ctrl_gpu final : public nvdevice {
15public: 15public:
16 nvhost_ctrl_gpu(Core::System& system); 16 explicit nvhost_ctrl_gpu(Core::System& system);
17 ~nvhost_ctrl_gpu() override; 17 ~nvhost_ctrl_gpu() override;
18 18
19 u32 ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 19 u32 ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output,
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp
index f464328f3..f572ad30f 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp
@@ -10,7 +10,7 @@
10 10
11namespace Service::Nvidia::Devices { 11namespace Service::Nvidia::Devices {
12 12
13nvhost_nvdec::nvhost_nvdec(Core::System& system) : nvdevice(system){}; 13nvhost_nvdec::nvhost_nvdec(Core::System& system) : nvdevice(system) {}
14nvhost_nvdec::~nvhost_nvdec() = default; 14nvhost_nvdec::~nvhost_nvdec() = default;
15 15
16u32 nvhost_nvdec::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 16u32 nvhost_nvdec::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output,
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.h b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.h
index c2b7a22f6..2710f0511 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.h
@@ -13,7 +13,7 @@ namespace Service::Nvidia::Devices {
13 13
14class nvhost_nvdec final : public nvdevice { 14class nvhost_nvdec final : public nvdevice {
15public: 15public:
16 nvhost_nvdec(Core::System& system); 16 explicit nvhost_nvdec(Core::System& system);
17 ~nvhost_nvdec() override; 17 ~nvhost_nvdec() override;
18 18
19 u32 ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 19 u32 ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output,
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp
index d4d67fc72..38282956f 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp
@@ -10,7 +10,7 @@
10 10
11namespace Service::Nvidia::Devices { 11namespace Service::Nvidia::Devices {
12 12
13nvhost_nvjpg::nvhost_nvjpg(Core::System& system) : nvdevice(system){}; 13nvhost_nvjpg::nvhost_nvjpg(Core::System& system) : nvdevice(system) {}
14nvhost_nvjpg::~nvhost_nvjpg() = default; 14nvhost_nvjpg::~nvhost_nvjpg() = default;
15 15
16u32 nvhost_nvjpg::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 16u32 nvhost_nvjpg::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output,
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h
index 4bf280d67..379766693 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h
@@ -13,7 +13,7 @@ namespace Service::Nvidia::Devices {
13 13
14class nvhost_nvjpg final : public nvdevice { 14class nvhost_nvjpg final : public nvdevice {
15public: 15public:
16 nvhost_nvjpg(Core::System& system); 16 explicit nvhost_nvjpg(Core::System& system);
17 ~nvhost_nvjpg() override; 17 ~nvhost_nvjpg() override;
18 18
19 u32 ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 19 u32 ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output,
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp b/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp
index 24e38d31a..70e8091db 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp
@@ -10,7 +10,7 @@
10 10
11namespace Service::Nvidia::Devices { 11namespace Service::Nvidia::Devices {
12 12
13nvhost_vic::nvhost_vic(Core::System& system) : nvdevice(system){}; 13nvhost_vic::nvhost_vic(Core::System& system) : nvdevice(system) {}
14nvhost_vic::~nvhost_vic() = default; 14nvhost_vic::~nvhost_vic() = default;
15 15
16u32 nvhost_vic::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 16u32 nvhost_vic::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output,
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_vic.h b/src/core/hle/service/nvdrv/devices/nvhost_vic.h
index 3d0934a78..7d111977e 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_vic.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_vic.h
@@ -13,7 +13,7 @@ namespace Service::Nvidia::Devices {
13 13
14class nvhost_vic final : public nvdevice { 14class nvhost_vic final : public nvdevice {
15public: 15public:
16 nvhost_vic(Core::System& system); 16 explicit nvhost_vic(Core::System& system);
17 ~nvhost_vic() override; 17 ~nvhost_vic() override;
18 18
19 u32 ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, 19 u32 ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output,
diff --git a/src/core/hle/service/nvdrv/devices/nvmap.cpp b/src/core/hle/service/nvdrv/devices/nvmap.cpp
index 349454685..223b496b7 100644
--- a/src/core/hle/service/nvdrv/devices/nvmap.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvmap.cpp
@@ -18,7 +18,7 @@ enum {
18}; 18};
19} 19}
20 20
21nvmap::nvmap(Core::System& system) : nvdevice(system){}; 21nvmap::nvmap(Core::System& system) : nvdevice(system) {}
22nvmap::~nvmap() = default; 22nvmap::~nvmap() = default;
23 23
24VAddr nvmap::GetObjectAddress(u32 handle) const { 24VAddr nvmap::GetObjectAddress(u32 handle) const {
diff --git a/src/core/hle/service/nvdrv/devices/nvmap.h b/src/core/hle/service/nvdrv/devices/nvmap.h
index b79ed736c..bf4a101c2 100644
--- a/src/core/hle/service/nvdrv/devices/nvmap.h
+++ b/src/core/hle/service/nvdrv/devices/nvmap.h
@@ -16,7 +16,7 @@ namespace Service::Nvidia::Devices {
16 16
17class nvmap final : public nvdevice { 17class nvmap final : public nvdevice {
18public: 18public:
19 nvmap(Core::System& system); 19 explicit nvmap(Core::System& system);
20 ~nvmap() override; 20 ~nvmap() override;
21 21
22 /// Returns the allocated address of an nvmap object given its handle. 22 /// Returns the allocated address of an nvmap object given its handle.
diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp
index 8958e21e3..2011a226a 100644
--- a/src/core/hle/service/nvdrv/nvdrv.cpp
+++ b/src/core/hle/service/nvdrv/nvdrv.cpp
@@ -100,11 +100,11 @@ void Module::SignalSyncpt(const u32 syncpoint_id, const u32 value) {
100 } 100 }
101} 101}
102 102
103Kernel::SharedPtr<Kernel::ReadableEvent> Module::GetEvent(const u32 event_id) { 103Kernel::SharedPtr<Kernel::ReadableEvent> Module::GetEvent(const u32 event_id) const {
104 return events_interface.events[event_id].readable; 104 return events_interface.events[event_id].readable;
105} 105}
106 106
107Kernel::SharedPtr<Kernel::WritableEvent> Module::GetEventWriteable(const u32 event_id) { 107Kernel::SharedPtr<Kernel::WritableEvent> Module::GetEventWriteable(const u32 event_id) const {
108 return events_interface.events[event_id].writable; 108 return events_interface.events[event_id].writable;
109} 109}
110 110
diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h
index b7f692962..8f7c59a21 100644
--- a/src/core/hle/service/nvdrv/nvdrv.h
+++ b/src/core/hle/service/nvdrv/nvdrv.h
@@ -26,14 +26,15 @@ namespace Devices {
26class nvdevice; 26class nvdevice;
27} 27}
28 28
29struct EventsInterface { 29struct EventInterface {
30 u64 events_mask{}; 30 u64 events_mask{};
31 std::array<Kernel::EventPair, MaxNvEvents> events; 31 std::array<Kernel::EventPair, MaxNvEvents> events;
32 std::array<EventState, MaxNvEvents> status{}; 32 std::array<EventState, MaxNvEvents> status{};
33 std::array<bool, MaxNvEvents> registered{}; 33 std::array<bool, MaxNvEvents> registered{};
34 std::array<u32, MaxNvEvents> assigned_syncpt{}; 34 std::array<u32, MaxNvEvents> assigned_syncpt{};
35 std::array<u32, MaxNvEvents> assigned_value{}; 35 std::array<u32, MaxNvEvents> assigned_value{};
36 u32 GetFreeEvent() { 36 static constexpr u32 null_event = 0xFFFFFFFF;
37 u32 GetFreeEvent() const {
37 u64 mask = events_mask; 38 u64 mask = events_mask;
38 for (u32 i = 0; i < MaxNvEvents; i++) { 39 for (u32 i = 0; i < MaxNvEvents; i++) {
39 const bool is_free = (mask & 0x1) == 0; 40 const bool is_free = (mask & 0x1) == 0;
@@ -44,12 +45,13 @@ struct EventsInterface {
44 } 45 }
45 mask = mask >> 1; 46 mask = mask >> 1;
46 } 47 }
47 return 0xFFFFFFFF; 48 return null_event;
48 } 49 }
49 void SetEventStatus(const u32 event_id, EventState new_status) { 50 void SetEventStatus(const u32 event_id, EventState new_status) {
50 EventState old_status = status[event_id]; 51 EventState old_status = status[event_id];
51 if (old_status == new_status) 52 if (old_status == new_status) {
52 return; 53 return;
54 }
53 status[event_id] = new_status; 55 status[event_id] = new_status;
54 if (new_status == EventState::Registered) { 56 if (new_status == EventState::Registered) {
55 registered[event_id] = true; 57 registered[event_id] = true;
@@ -102,9 +104,9 @@ public:
102 104
103 void SignalSyncpt(const u32 syncpoint_id, const u32 value); 105 void SignalSyncpt(const u32 syncpoint_id, const u32 value);
104 106
105 Kernel::SharedPtr<Kernel::ReadableEvent> GetEvent(const u32 event_id); 107 Kernel::SharedPtr<Kernel::ReadableEvent> GetEvent(u32 event_id) const;
106 108
107 Kernel::SharedPtr<Kernel::WritableEvent> GetEventWriteable(const u32 event_id); 109 Kernel::SharedPtr<Kernel::WritableEvent> GetEventWriteable(u32 event_id) const;
108 110
109private: 111private:
110 /// Id to use for the next open file descriptor. 112 /// Id to use for the next open file descriptor.
@@ -116,7 +118,7 @@ private:
116 /// Mapping of device node names to their implementation. 118 /// Mapping of device node names to their implementation.
117 std::unordered_map<std::string, std::shared_ptr<Devices::nvdevice>> devices; 119 std::unordered_map<std::string, std::shared_ptr<Devices::nvdevice>> devices;
118 120
119 EventsInterface events_interface; 121 EventInterface events_interface;
120}; 122};
121 123
122/// Registers all NVDRV services with the specified service manager. 124/// Registers all NVDRV services with the specified service manager.
diff --git a/src/core/hle/service/nvflinger/buffer_queue.cpp b/src/core/hle/service/nvflinger/buffer_queue.cpp
index d8aa3f1c0..ddc224f2c 100644
--- a/src/core/hle/service/nvflinger/buffer_queue.cpp
+++ b/src/core/hle/service/nvflinger/buffer_queue.cpp
@@ -79,7 +79,7 @@ void BufferQueue::QueueBuffer(u32 slot, BufferTransformFlags transform,
79} 79}
80 80
81std::optional<std::reference_wrapper<const BufferQueue::Buffer>> BufferQueue::AcquireBuffer() { 81std::optional<std::reference_wrapper<const BufferQueue::Buffer>> BufferQueue::AcquireBuffer() {
82 std::vector<Buffer>::iterator itr = queue.end(); 82 auto itr = queue.end();
83 while (itr == queue.end() && !queue_sequence.empty()) { 83 while (itr == queue.end() && !queue_sequence.empty()) {
84 u32 slot = queue_sequence.front(); 84 u32 slot = queue_sequence.front();
85 itr = std::find_if(queue.begin(), queue.end(), [&slot](const Buffer& buffer) { 85 itr = std::find_if(queue.begin(), queue.end(), [&slot](const Buffer& buffer) {
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp
index 70441f6a2..f9db79370 100644
--- a/src/core/hle/service/nvflinger/nvflinger.cpp
+++ b/src/core/hle/service/nvflinger/nvflinger.cpp
@@ -37,8 +37,6 @@ NVFlinger::NVFlinger(Core::Timing::CoreTiming& core_timing) : core_timing{core_t
37 displays.emplace_back(4, "Null"); 37 displays.emplace_back(4, "Null");
38 38
39 // Schedule the screen composition events 39 // Schedule the screen composition events
40 // const auto ticks = Settings::values.force_30fps_mode ? frame_ticks_30fps : frame_ticks;
41
42 composition_event = core_timing.RegisterEvent("ScreenComposition", [this](u64 userdata, 40 composition_event = core_timing.RegisterEvent("ScreenComposition", [this](u64 userdata,
43 s64 cycles_late) { 41 s64 cycles_late) {
44 Compose(); 42 Compose();
@@ -212,8 +210,9 @@ void NVFlinger::Compose() {
212 } 210 }
213} 211}
214 212
215s64 NVFlinger::GetNextTicks() { 213s64 NVFlinger::GetNextTicks() const {
216 return (Core::Timing::BASE_CLOCK_RATE * (1LL << swap_interval)) / 120; 214 constexpr s64 max_hertz = 120LL;
215 return (Core::Timing::BASE_CLOCK_RATE * (1LL << swap_interval)) / max_hertz;
217} 216}
218 217
219} // namespace Service::NVFlinger 218} // namespace Service::NVFlinger
diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h
index 86b94302c..988be8726 100644
--- a/src/core/hle/service/nvflinger/nvflinger.h
+++ b/src/core/hle/service/nvflinger/nvflinger.h
@@ -74,7 +74,7 @@ public:
74 /// finished. 74 /// finished.
75 void Compose(); 75 void Compose();
76 76
77 s64 GetNextTicks(); 77 s64 GetNextTicks() const;
78 78
79private: 79private:
80 /// Finds the display identified by the specified ID. 80 /// Finds the display identified by the specified ID.
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 {
89} 89}
90 90
91void GPU::RegisterSyncptInterrupt(const u32 syncpoint_id, const u32 value) { 91void GPU::RegisterSyncptInterrupt(const u32 syncpoint_id, const u32 value) {
92 for (u32 in_value : syncpt_interrupts[syncpoint_id]) { 92 auto& interrupt = syncpt_interrupts[syncpoint_id];
93 if (in_value == value) 93 bool contains = std::any_of(interrupt.begin(), interrupt.end(),
94 return; 94 [value](u32 in_value) { return in_value == value; });
95 if (contains) {
96 return;
95 } 97 }
96 syncpt_interrupts[syncpoint_id].emplace_back(value); 98 syncpt_interrupts[syncpoint_id].emplace_back(value);
97} 99}
98 100
99bool GPU::CancelSyncptInterrupt(const u32 syncpoint_id, const u32 value) { 101bool GPU::CancelSyncptInterrupt(const u32 syncpoint_id, const u32 value) {
100 std::lock_guard lock{sync_mutex}; 102 std::lock_guard lock{sync_mutex};
101 auto it = syncpt_interrupts[syncpoint_id].begin(); 103 auto& interrupt = syncpt_interrupts[syncpoint_id];
102 while (it != syncpt_interrupts[syncpoint_id].end()) { 104 const auto iter =
103 if (value == *it) { 105 std::find_if(interrupt.begin(), interrupt.end(),
104 it = syncpt_interrupts[syncpoint_id].erase(it); 106 [value](u32 interrupt_value) { return value == interrupt_value; });
105 return true; 107
106 } 108 if (iter == interrupt.end()) {
107 it++; 109 return false;
108 } 110 }
109 return false; 111 interrupt.erase(iter);
112 return true;
110} 113}
111 114
112u32 RenderTargetBytesPerPixel(RenderTargetFormat format) { 115u32 RenderTargetBytesPerPixel(RenderTargetFormat format) {
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h
index 94afc91f8..334dec48c 100644
--- a/src/video_core/gpu.h
+++ b/src/video_core/gpu.h
@@ -168,20 +168,16 @@ public:
168 /// Returns a reference to the GPU DMA pusher. 168 /// Returns a reference to the GPU DMA pusher.
169 Tegra::DmaPusher& DmaPusher(); 169 Tegra::DmaPusher& DmaPusher();
170 170
171 void IncrementSyncPoint(const u32 syncpoint_id); 171 void IncrementSyncPoint(u32 syncpoint_id);
172 172
173 u32 GetSyncpointValue(const u32 syncpoint_id) const; 173 u32 GetSyncpointValue(u32 syncpoint_id) const;
174 174
175 void RegisterSyncptInterrupt(const u32 syncpoint_id, const u32 value); 175 void RegisterSyncptInterrupt(u32 syncpoint_id, u32 value);
176 176
177 bool CancelSyncptInterrupt(const u32 syncpoint_id, const u32 value); 177 bool CancelSyncptInterrupt(u32 syncpoint_id, u32 value);
178 178
179 void Guard(bool guard_set) { 179 std::unique_lock<std::mutex> LockSync() {
180 if (guard_set) { 180 return std::unique_lock{sync_mutex};
181 sync_mutex.lock();
182 } else {
183 sync_mutex.unlock();
184 }
185 } 181 }
186 182
187 bool IsAsync() const { 183 bool IsAsync() const {
@@ -253,7 +249,7 @@ public:
253 virtual void FlushAndInvalidateRegion(CacheAddr addr, u64 size) = 0; 249 virtual void FlushAndInvalidateRegion(CacheAddr addr, u64 size) = 0;
254 250
255protected: 251protected:
256 virtual void TriggerCpuInterrupt(const u32 syncpoint_id, const u32 value) const = 0; 252 virtual void TriggerCpuInterrupt(u32 syncpoint_id, u32 value) const = 0;
257 253
258private: 254private:
259 void ProcessBindMethod(const MethodCall& method_call); 255 void ProcessBindMethod(const MethodCall& method_call);
diff --git a/src/video_core/gpu_asynch.h b/src/video_core/gpu_asynch.h
index 5f1b2fb7d..36377d677 100644
--- a/src/video_core/gpu_asynch.h
+++ b/src/video_core/gpu_asynch.h
@@ -28,7 +28,7 @@ public:
28 void FlushAndInvalidateRegion(CacheAddr addr, u64 size) override; 28 void FlushAndInvalidateRegion(CacheAddr addr, u64 size) override;
29 29
30protected: 30protected:
31 void TriggerCpuInterrupt(const u32 syncpoint_id, const u32 value) const override; 31 void TriggerCpuInterrupt(u32 syncpoint_id, u32 value) const override;
32 32
33private: 33private:
34 GPUThread::ThreadManager gpu_thread; 34 GPUThread::ThreadManager gpu_thread;
diff --git a/src/video_core/gpu_synch.h b/src/video_core/gpu_synch.h
index 58d258503..07bcc47f1 100644
--- a/src/video_core/gpu_synch.h
+++ b/src/video_core/gpu_synch.h
@@ -27,7 +27,8 @@ public:
27 void FlushAndInvalidateRegion(CacheAddr addr, u64 size) override; 27 void FlushAndInvalidateRegion(CacheAddr addr, u64 size) override;
28 28
29protected: 29protected:
30 void TriggerCpuInterrupt(const u32 syncpoint_id, const u32 value) const override {} 30 void TriggerCpuInterrupt([[maybe_unused]] u32 syncpoint_id,
31 [[maybe_unused]] u32 value) const override {}
31}; 32};
32 33
33} // namespace VideoCommon 34} // namespace VideoCommon