diff options
| author | 2019-06-18 20:53:21 -0400 | |
|---|---|---|
| committer | 2019-07-05 15:49:32 -0400 | |
| commit | d20ede40b1e9cd0539982fb1feb3b13af3501ea2 (patch) | |
| tree | a084fedd90a6a3cc3e11b099f4ddfe194d49c8ea /src | |
| parent | NVFlinger: Correct GCC compile error (diff) | |
| download | yuzu-d20ede40b1e9cd0539982fb1feb3b13af3501ea2.tar.gz yuzu-d20ede40b1e9cd0539982fb1feb3b13af3501ea2.tar.xz yuzu-d20ede40b1e9cd0539982fb1feb3b13af3501ea2.zip | |
NVServices: Styling, define constructors as explicit and corrections
Diffstat (limited to 'src')
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 | ||
| 23 | InterruptManager::~InterruptManager() = default; | ||
| 24 | |||
| 19 | void InterruptManager::GPUInterruptSyncpt(const u32 syncpoint_id, const u32 value) { | 25 | void 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 | ||
| 6 | namespace Core { | 9 | namespace Core { |
| 7 | class System; | 10 | class System; |
| 8 | } | 11 | } |
| 9 | 12 | ||
| 13 | namespace Core::Timing { | ||
| 14 | struct EventType; | ||
| 15 | } | ||
| 16 | |||
| 10 | namespace Core::Hardware { | 17 | namespace Core::Hardware { |
| 11 | 18 | ||
| 12 | class InterruptManager { | 19 | class InterruptManager { |
| 13 | public: | 20 | public: |
| 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 | ||
| 19 | private: | 26 | private: |
| 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. |
| 21 | class nvdevice { | 21 | class nvdevice { |
| 22 | public: | 22 | public: |
| 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 | ||
| 16 | namespace Service::Nvidia::Devices { | 16 | namespace Service::Nvidia::Devices { |
| 17 | 17 | ||
| 18 | nvhost_ctrl::nvhost_ctrl(Core::System& system, EventsInterface& events_interface) | 18 | nvhost_ctrl::nvhost_ctrl(Core::System& system, EventInterface& events_interface) |
| 19 | : nvdevice(system), events_interface{events_interface} {} | 19 | : nvdevice(system), events_interface{events_interface} {} |
| 20 | nvhost_ctrl::~nvhost_ctrl() = default; | 20 | nvhost_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(), ¶ms, sizeof(params)); | 74 | std::memcpy(output.data(), ¶ms, 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(), ¶ms, sizeof(params)); | 83 | std::memcpy(output.data(), ¶ms, 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(), ¶ms, sizeof(params)); | 91 | std::memcpy(output.data(), ¶ms, 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(), ¶ms, sizeof(params)); | 121 | std::memcpy(output.data(), ¶ms, sizeof(params)); |
| 126 | gpu.Guard(false); | ||
| 127 | return NvResult::Timeout; | 122 | return NvResult::Timeout; |
| 128 | } | 123 | } |
| 129 | std::memcpy(output.data(), ¶ms, sizeof(params)); | 124 | std::memcpy(output.data(), ¶ms, 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 | ||
| 15 | class nvhost_ctrl final : public nvdevice { | 15 | class nvhost_ctrl final : public nvdevice { |
| 16 | public: | 16 | public: |
| 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 | ||
| 13 | namespace Service::Nvidia::Devices { | 13 | namespace Service::Nvidia::Devices { |
| 14 | 14 | ||
| 15 | nvhost_ctrl_gpu::nvhost_ctrl_gpu(Core::System& system) : nvdevice(system){}; | 15 | nvhost_ctrl_gpu::nvhost_ctrl_gpu(Core::System& system) : nvdevice(system) {} |
| 16 | nvhost_ctrl_gpu::~nvhost_ctrl_gpu() = default; | 16 | nvhost_ctrl_gpu::~nvhost_ctrl_gpu() = default; |
| 17 | 17 | ||
| 18 | u32 nvhost_ctrl_gpu::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, | 18 | u32 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 | ||
| 14 | class nvhost_ctrl_gpu final : public nvdevice { | 14 | class nvhost_ctrl_gpu final : public nvdevice { |
| 15 | public: | 15 | public: |
| 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 | ||
| 11 | namespace Service::Nvidia::Devices { | 11 | namespace Service::Nvidia::Devices { |
| 12 | 12 | ||
| 13 | nvhost_nvdec::nvhost_nvdec(Core::System& system) : nvdevice(system){}; | 13 | nvhost_nvdec::nvhost_nvdec(Core::System& system) : nvdevice(system) {} |
| 14 | nvhost_nvdec::~nvhost_nvdec() = default; | 14 | nvhost_nvdec::~nvhost_nvdec() = default; |
| 15 | 15 | ||
| 16 | u32 nvhost_nvdec::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, | 16 | u32 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 | ||
| 14 | class nvhost_nvdec final : public nvdevice { | 14 | class nvhost_nvdec final : public nvdevice { |
| 15 | public: | 15 | public: |
| 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 | ||
| 11 | namespace Service::Nvidia::Devices { | 11 | namespace Service::Nvidia::Devices { |
| 12 | 12 | ||
| 13 | nvhost_nvjpg::nvhost_nvjpg(Core::System& system) : nvdevice(system){}; | 13 | nvhost_nvjpg::nvhost_nvjpg(Core::System& system) : nvdevice(system) {} |
| 14 | nvhost_nvjpg::~nvhost_nvjpg() = default; | 14 | nvhost_nvjpg::~nvhost_nvjpg() = default; |
| 15 | 15 | ||
| 16 | u32 nvhost_nvjpg::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, | 16 | u32 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 | ||
| 14 | class nvhost_nvjpg final : public nvdevice { | 14 | class nvhost_nvjpg final : public nvdevice { |
| 15 | public: | 15 | public: |
| 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 | ||
| 11 | namespace Service::Nvidia::Devices { | 11 | namespace Service::Nvidia::Devices { |
| 12 | 12 | ||
| 13 | nvhost_vic::nvhost_vic(Core::System& system) : nvdevice(system){}; | 13 | nvhost_vic::nvhost_vic(Core::System& system) : nvdevice(system) {} |
| 14 | nvhost_vic::~nvhost_vic() = default; | 14 | nvhost_vic::~nvhost_vic() = default; |
| 15 | 15 | ||
| 16 | u32 nvhost_vic::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output, | 16 | u32 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 | ||
| 14 | class nvhost_vic final : public nvdevice { | 14 | class nvhost_vic final : public nvdevice { |
| 15 | public: | 15 | public: |
| 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 | ||
| 21 | nvmap::nvmap(Core::System& system) : nvdevice(system){}; | 21 | nvmap::nvmap(Core::System& system) : nvdevice(system) {} |
| 22 | nvmap::~nvmap() = default; | 22 | nvmap::~nvmap() = default; |
| 23 | 23 | ||
| 24 | VAddr nvmap::GetObjectAddress(u32 handle) const { | 24 | VAddr 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 | ||
| 17 | class nvmap final : public nvdevice { | 17 | class nvmap final : public nvdevice { |
| 18 | public: | 18 | public: |
| 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 | ||
| 103 | Kernel::SharedPtr<Kernel::ReadableEvent> Module::GetEvent(const u32 event_id) { | 103 | Kernel::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 | ||
| 107 | Kernel::SharedPtr<Kernel::WritableEvent> Module::GetEventWriteable(const u32 event_id) { | 107 | Kernel::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 { | |||
| 26 | class nvdevice; | 26 | class nvdevice; |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | struct EventsInterface { | 29 | struct 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 | ||
| 109 | private: | 111 | private: |
| 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 | ||
| 81 | std::optional<std::reference_wrapper<const BufferQueue::Buffer>> BufferQueue::AcquireBuffer() { | 81 | std::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 | ||
| 215 | s64 NVFlinger::GetNextTicks() { | 213 | s64 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 | ||
| 79 | private: | 79 | private: |
| 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 | ||
| 91 | void GPU::RegisterSyncptInterrupt(const u32 syncpoint_id, const u32 value) { | 91 | void 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 | ||
| 99 | bool GPU::CancelSyncptInterrupt(const u32 syncpoint_id, const u32 value) { | 101 | bool 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 | ||
| 112 | u32 RenderTargetBytesPerPixel(RenderTargetFormat format) { | 115 | u32 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 | ||
| 255 | protected: | 251 | protected: |
| 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 | ||
| 258 | private: | 254 | private: |
| 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 | ||
| 30 | protected: | 30 | protected: |
| 31 | void TriggerCpuInterrupt(const u32 syncpoint_id, const u32 value) const override; | 31 | void TriggerCpuInterrupt(u32 syncpoint_id, u32 value) const override; |
| 32 | 32 | ||
| 33 | private: | 33 | private: |
| 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 | ||
| 29 | protected: | 29 | protected: |
| 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 |