summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hid/emulated_console.cpp4
-rw-r--r--src/core/hid/emulated_controller.cpp38
-rw-r--r--src/core/hid/emulated_devices.cpp15
-rw-r--r--src/core/hle/service/nvdrv/core/syncpoint_manager.cpp46
-rw-r--r--src/core/hle/service/nvdrv/core/syncpoint_manager.h2
-rw-r--r--src/core/hle/service/nvdrv/nvdrv.cpp44
-rw-r--r--src/core/hle/service/nvflinger/buffer_item_consumer.cpp2
-rw-r--r--src/core/hle/service/nvflinger/buffer_item_consumer.h2
-rw-r--r--src/core/hle/service/nvflinger/buffer_queue_consumer.cpp2
-rw-r--r--src/core/hle/service/nvflinger/consumer_base.cpp6
-rw-r--r--src/core/hle/service/nvflinger/consumer_base.h16
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.cpp3
-rw-r--r--src/core/hle/service/nvflinger/producer_listener.h1
13 files changed, 92 insertions, 89 deletions
diff --git a/src/core/hid/emulated_console.cpp b/src/core/hid/emulated_console.cpp
index fb7e5802a..b6c8cc58d 100644
--- a/src/core/hid/emulated_console.cpp
+++ b/src/core/hid/emulated_console.cpp
@@ -68,7 +68,7 @@ void EmulatedConsole::ReloadInput() {
// If you load any device here add the equivalent to the UnloadInput() function
SetTouchParams();
- motion_devices = Common::Input::CreateDevice<Common::Input::InputDevice>(motion_params);
+ motion_devices = Common::Input::CreateInputDevice(motion_params);
if (motion_devices) {
motion_devices->SetCallback({
.on_change =
@@ -79,7 +79,7 @@ void EmulatedConsole::ReloadInput() {
// Unique index for identifying touch device source
std::size_t index = 0;
for (auto& touch_device : touch_devices) {
- touch_device = Common::Input::CreateDevice<Common::Input::InputDevice>(touch_params[index]);
+ touch_device = Common::Input::CreateInputDevice(touch_params[index]);
if (!touch_device) {
continue;
}
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index ec1364452..c96d9eef3 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
+#include <algorithm>
+
#include "common/thread.h"
#include "core/hid/emulated_controller.h"
#include "core/hid/input_converter.h"
@@ -144,29 +146,23 @@ void EmulatedController::LoadDevices() {
LoadTASParams();
- std::transform(button_params.begin() + Settings::NativeButton::BUTTON_HID_BEGIN,
- button_params.begin() + Settings::NativeButton::BUTTON_NS_END,
- button_devices.begin(), Common::Input::CreateDevice<Common::Input::InputDevice>);
- std::transform(stick_params.begin() + Settings::NativeAnalog::STICK_HID_BEGIN,
- stick_params.begin() + Settings::NativeAnalog::STICK_HID_END,
- stick_devices.begin(), Common::Input::CreateDevice<Common::Input::InputDevice>);
- std::transform(motion_params.begin() + Settings::NativeMotion::MOTION_HID_BEGIN,
- motion_params.begin() + Settings::NativeMotion::MOTION_HID_END,
- motion_devices.begin(), Common::Input::CreateDevice<Common::Input::InputDevice>);
- std::transform(trigger_params.begin(), trigger_params.end(), trigger_devices.begin(),
- Common::Input::CreateDevice<Common::Input::InputDevice>);
- std::transform(battery_params.begin(), battery_params.end(), battery_devices.begin(),
- Common::Input::CreateDevice<Common::Input::InputDevice>);
- camera_devices = Common::Input::CreateDevice<Common::Input::InputDevice>(camera_params);
- nfc_devices = Common::Input::CreateDevice<Common::Input::InputDevice>(nfc_params);
- std::transform(output_params.begin(), output_params.end(), output_devices.begin(),
- Common::Input::CreateDevice<Common::Input::OutputDevice>);
+ std::ranges::transform(button_params, button_devices.begin(), Common::Input::CreateInputDevice);
+ std::ranges::transform(stick_params, stick_devices.begin(), Common::Input::CreateInputDevice);
+ std::ranges::transform(motion_params, motion_devices.begin(), Common::Input::CreateInputDevice);
+ std::ranges::transform(trigger_params, trigger_devices.begin(),
+ Common::Input::CreateInputDevice);
+ std::ranges::transform(battery_params, battery_devices.begin(),
+ Common::Input::CreateInputDevice);
+ camera_devices = Common::Input::CreateInputDevice(camera_params);
+ nfc_devices = Common::Input::CreateInputDevice(nfc_params);
+ std::ranges::transform(output_params, output_devices.begin(),
+ Common::Input::CreateOutputDevice);
// Initialize TAS devices
- std::transform(tas_button_params.begin(), tas_button_params.end(), tas_button_devices.begin(),
- Common::Input::CreateDevice<Common::Input::InputDevice>);
- std::transform(tas_stick_params.begin(), tas_stick_params.end(), tas_stick_devices.begin(),
- Common::Input::CreateDevice<Common::Input::InputDevice>);
+ std::ranges::transform(tas_button_params, tas_button_devices.begin(),
+ Common::Input::CreateInputDevice);
+ std::ranges::transform(tas_stick_params, tas_stick_devices.begin(),
+ Common::Input::CreateInputDevice);
}
void EmulatedController::LoadTASParams() {
diff --git a/src/core/hid/emulated_devices.cpp b/src/core/hid/emulated_devices.cpp
index 8d367b546..e421828d2 100644
--- a/src/core/hid/emulated_devices.cpp
+++ b/src/core/hid/emulated_devices.cpp
@@ -25,12 +25,12 @@ void EmulatedDevices::ReloadInput() {
Common::ParamPackage mouse_params;
mouse_params.Set("engine", "mouse");
mouse_params.Set("button", static_cast<int>(key_index));
- mouse_device = Common::Input::CreateDevice<Common::Input::InputDevice>(mouse_params);
+ mouse_device = Common::Input::CreateInputDevice(mouse_params);
key_index++;
}
- mouse_stick_device = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>(
- "engine:mouse,axis_x:0,axis_y:1");
+ mouse_stick_device =
+ Common::Input::CreateInputDeviceFromString("engine:mouse,axis_x:0,axis_y:1");
// First two axis are reserved for mouse position
key_index = 2;
@@ -38,7 +38,7 @@ void EmulatedDevices::ReloadInput() {
Common::ParamPackage mouse_params;
mouse_params.Set("engine", "mouse");
mouse_params.Set("axis", static_cast<int>(key_index));
- mouse_device = Common::Input::CreateDevice<Common::Input::InputDevice>(mouse_params);
+ mouse_device = Common::Input::CreateInputDevice(mouse_params);
key_index++;
}
@@ -50,7 +50,7 @@ void EmulatedDevices::ReloadInput() {
keyboard_params.Set("button", static_cast<int>(key_index));
keyboard_params.Set("port", 1);
keyboard_params.Set("pad", 0);
- keyboard_device = Common::Input::CreateDevice<Common::Input::InputDevice>(keyboard_params);
+ keyboard_device = Common::Input::CreateInputDevice(keyboard_params);
key_index++;
}
@@ -62,11 +62,11 @@ void EmulatedDevices::ReloadInput() {
keyboard_params.Set("button", static_cast<int>(key_index));
keyboard_params.Set("port", 1);
keyboard_params.Set("pad", 1);
- keyboard_device = Common::Input::CreateDevice<Common::Input::InputDevice>(keyboard_params);
+ keyboard_device = Common::Input::CreateInputDevice(keyboard_params);
key_index++;
}
- ring_analog_device = Common::Input::CreateDevice<Common::Input::InputDevice>(ring_params);
+ ring_analog_device = Common::Input::CreateInputDevice(ring_params);
for (std::size_t index = 0; index < mouse_button_devices.size(); ++index) {
if (!mouse_button_devices[index]) {
@@ -145,6 +145,7 @@ void EmulatedDevices::UnloadInput() {
for (auto& button : keyboard_modifier_devices) {
button.reset();
}
+ ring_analog_device.reset();
}
void EmulatedDevices::EnableConfiguration() {
diff --git a/src/core/hle/service/nvdrv/core/syncpoint_manager.cpp b/src/core/hle/service/nvdrv/core/syncpoint_manager.cpp
index eda2041a0..aba51d280 100644
--- a/src/core/hle/service/nvdrv/core/syncpoint_manager.cpp
+++ b/src/core/hle/service/nvdrv/core/syncpoint_manager.cpp
@@ -28,13 +28,15 @@ SyncpointManager::SyncpointManager(Tegra::Host1x::Host1x& host1x_) : host1x{host
SyncpointManager::~SyncpointManager() = default;
u32 SyncpointManager::ReserveSyncpoint(u32 id, bool client_managed) {
- if (syncpoints.at(id).reserved) {
+ auto& syncpoint = syncpoints.at(id);
+
+ if (syncpoint.reserved) {
ASSERT_MSG(false, "Requested syncpoint is in use");
return 0;
}
- syncpoints.at(id).reserved = true;
- syncpoints.at(id).interface_managed = client_managed;
+ syncpoint.reserved = true;
+ syncpoint.interface_managed = client_managed;
return id;
}
@@ -56,11 +58,12 @@ u32 SyncpointManager::AllocateSyncpoint(bool client_managed) {
void SyncpointManager::FreeSyncpoint(u32 id) {
std::lock_guard lock(reservation_lock);
- ASSERT(syncpoints.at(id).reserved);
- syncpoints.at(id).reserved = false;
+ auto& syncpoint = syncpoints.at(id);
+ ASSERT(syncpoint.reserved);
+ syncpoint.reserved = false;
}
-bool SyncpointManager::IsSyncpointAllocated(u32 id) {
+bool SyncpointManager::IsSyncpointAllocated(u32 id) const {
return (id <= SyncpointCount) && syncpoints[id].reserved;
}
@@ -69,7 +72,7 @@ bool SyncpointManager::HasSyncpointExpired(u32 id, u32 threshold) const {
if (!syncpoint.reserved) {
ASSERT(false);
- return 0;
+ return false;
}
// If the interface manages counters then we don't keep track of the maximum value as it handles
@@ -82,40 +85,51 @@ bool SyncpointManager::HasSyncpointExpired(u32 id, u32 threshold) const {
}
u32 SyncpointManager::IncrementSyncpointMaxExt(u32 id, u32 amount) {
- if (!syncpoints.at(id).reserved) {
+ auto& syncpoint = syncpoints.at(id);
+
+ if (!syncpoint.reserved) {
ASSERT(false);
return 0;
}
- return syncpoints.at(id).counter_max += amount;
+ return syncpoint.counter_max += amount;
}
u32 SyncpointManager::ReadSyncpointMinValue(u32 id) {
- if (!syncpoints.at(id).reserved) {
+ auto& syncpoint = syncpoints.at(id);
+
+ if (!syncpoint.reserved) {
ASSERT(false);
return 0;
}
- return syncpoints.at(id).counter_min;
+ return syncpoint.counter_min;
}
u32 SyncpointManager::UpdateMin(u32 id) {
- if (!syncpoints.at(id).reserved) {
+ auto& syncpoint = syncpoints.at(id);
+
+ if (!syncpoint.reserved) {
ASSERT(false);
return 0;
}
- syncpoints.at(id).counter_min = host1x.GetSyncpointManager().GetHostSyncpointValue(id);
- return syncpoints.at(id).counter_min;
+ syncpoint.counter_min = host1x.GetSyncpointManager().GetHostSyncpointValue(id);
+ return syncpoint.counter_min;
}
NvFence SyncpointManager::GetSyncpointFence(u32 id) {
- if (!syncpoints.at(id).reserved) {
+ auto& syncpoint = syncpoints.at(id);
+
+ if (!syncpoint.reserved) {
ASSERT(false);
return NvFence{};
}
- return {.id = static_cast<s32>(id), .value = syncpoints.at(id).counter_max};
+ return {
+ .id = static_cast<s32>(id),
+ .value = syncpoint.counter_max,
+ };
}
} // namespace Service::Nvidia::NvCore
diff --git a/src/core/hle/service/nvdrv/core/syncpoint_manager.h b/src/core/hle/service/nvdrv/core/syncpoint_manager.h
index b76ef9032..4f2cefae5 100644
--- a/src/core/hle/service/nvdrv/core/syncpoint_manager.h
+++ b/src/core/hle/service/nvdrv/core/syncpoint_manager.h
@@ -44,7 +44,7 @@ public:
/**
* @brief Checks if the given syncpoint is both allocated and below the number of HW syncpoints
*/
- bool IsSyncpointAllocated(u32 id);
+ bool IsSyncpointAllocated(u32 id) const;
/**
* @brief Finds a free syncpoint and reserves it
diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp
index 9f4c7c99a..6fc8565c0 100644
--- a/src/core/hle/service/nvdrv/nvdrv.cpp
+++ b/src/core/hle/service/nvdrv/nvdrv.cpp
@@ -55,48 +55,40 @@ void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger
Module::Module(Core::System& system)
: container{system.Host1x()}, service_context{system, "nvdrv"}, events_interface{*this} {
builders["/dev/nvhost-as-gpu"] = [this, &system](DeviceFD fd) {
- std::shared_ptr<Devices::nvdevice> device =
- std::make_shared<Devices::nvhost_as_gpu>(system, *this, container);
- return open_files.emplace(fd, device).first;
+ auto device = std::make_shared<Devices::nvhost_as_gpu>(system, *this, container);
+ return open_files.emplace(fd, std::move(device)).first;
};
builders["/dev/nvhost-gpu"] = [this, &system](DeviceFD fd) {
- std::shared_ptr<Devices::nvdevice> device =
- std::make_shared<Devices::nvhost_gpu>(system, events_interface, container);
- return open_files.emplace(fd, device).first;
+ auto device = std::make_shared<Devices::nvhost_gpu>(system, events_interface, container);
+ return open_files.emplace(fd, std::move(device)).first;
};
builders["/dev/nvhost-ctrl-gpu"] = [this, &system](DeviceFD fd) {
- std::shared_ptr<Devices::nvdevice> device =
- std::make_shared<Devices::nvhost_ctrl_gpu>(system, events_interface);
- return open_files.emplace(fd, device).first;
+ auto device = std::make_shared<Devices::nvhost_ctrl_gpu>(system, events_interface);
+ return open_files.emplace(fd, std::move(device)).first;
};
builders["/dev/nvmap"] = [this, &system](DeviceFD fd) {
- std::shared_ptr<Devices::nvdevice> device =
- std::make_shared<Devices::nvmap>(system, container);
- return open_files.emplace(fd, device).first;
+ auto device = std::make_shared<Devices::nvmap>(system, container);
+ return open_files.emplace(fd, std::move(device)).first;
};
builders["/dev/nvdisp_disp0"] = [this, &system](DeviceFD fd) {
- std::shared_ptr<Devices::nvdevice> device =
- std::make_shared<Devices::nvdisp_disp0>(system, container);
- return open_files.emplace(fd, device).first;
+ auto device = std::make_shared<Devices::nvdisp_disp0>(system, container);
+ return open_files.emplace(fd, std::move(device)).first;
};
builders["/dev/nvhost-ctrl"] = [this, &system](DeviceFD fd) {
- std::shared_ptr<Devices::nvdevice> device =
- std::make_shared<Devices::nvhost_ctrl>(system, events_interface, container);
- return open_files.emplace(fd, device).first;
+ auto device = std::make_shared<Devices::nvhost_ctrl>(system, events_interface, container);
+ return open_files.emplace(fd, std::move(device)).first;
};
builders["/dev/nvhost-nvdec"] = [this, &system](DeviceFD fd) {
- std::shared_ptr<Devices::nvdevice> device =
- std::make_shared<Devices::nvhost_nvdec>(system, container);
- return open_files.emplace(fd, device).first;
+ auto device = std::make_shared<Devices::nvhost_nvdec>(system, container);
+ return open_files.emplace(fd, std::move(device)).first;
};
builders["/dev/nvhost-nvjpg"] = [this, &system](DeviceFD fd) {
- std::shared_ptr<Devices::nvdevice> device = std::make_shared<Devices::nvhost_nvjpg>(system);
- return open_files.emplace(fd, device).first;
+ auto device = std::make_shared<Devices::nvhost_nvjpg>(system);
+ return open_files.emplace(fd, std::move(device)).first;
};
builders["/dev/nvhost-vic"] = [this, &system](DeviceFD fd) {
- std::shared_ptr<Devices::nvdevice> device =
- std::make_shared<Devices::nvhost_vic>(system, container);
- return open_files.emplace(fd, device).first;
+ auto device = std::make_shared<Devices::nvhost_vic>(system, container);
+ return open_files.emplace(fd, std::move(device)).first;
};
}
diff --git a/src/core/hle/service/nvflinger/buffer_item_consumer.cpp b/src/core/hle/service/nvflinger/buffer_item_consumer.cpp
index 6d2c92a2c..152bb5bdf 100644
--- a/src/core/hle/service/nvflinger/buffer_item_consumer.cpp
+++ b/src/core/hle/service/nvflinger/buffer_item_consumer.cpp
@@ -39,7 +39,7 @@ Status BufferItemConsumer::AcquireBuffer(BufferItem* item, std::chrono::nanoseco
return Status::NoError;
}
-Status BufferItemConsumer::ReleaseBuffer(const BufferItem& item, Fence& release_fence) {
+Status BufferItemConsumer::ReleaseBuffer(const BufferItem& item, const Fence& release_fence) {
std::scoped_lock lock{mutex};
if (const auto status = AddReleaseFenceLocked(item.buf, item.graphic_buffer, release_fence);
diff --git a/src/core/hle/service/nvflinger/buffer_item_consumer.h b/src/core/hle/service/nvflinger/buffer_item_consumer.h
index 69046233d..a5c655d9e 100644
--- a/src/core/hle/service/nvflinger/buffer_item_consumer.h
+++ b/src/core/hle/service/nvflinger/buffer_item_consumer.h
@@ -22,7 +22,7 @@ public:
explicit BufferItemConsumer(std::unique_ptr<BufferQueueConsumer> consumer);
Status AcquireBuffer(BufferItem* item, std::chrono::nanoseconds present_when,
bool wait_for_fence = true);
- Status ReleaseBuffer(const BufferItem& item, Fence& release_fence);
+ Status ReleaseBuffer(const BufferItem& item, const Fence& release_fence);
};
} // namespace Service::android
diff --git a/src/core/hle/service/nvflinger/buffer_queue_consumer.cpp b/src/core/hle/service/nvflinger/buffer_queue_consumer.cpp
index 1ce67c771..0767e548d 100644
--- a/src/core/hle/service/nvflinger/buffer_queue_consumer.cpp
+++ b/src/core/hle/service/nvflinger/buffer_queue_consumer.cpp
@@ -169,7 +169,7 @@ Status BufferQueueConsumer::Connect(std::shared_ptr<IConsumerListener> consumer_
return Status::NoInit;
}
- core->consumer_listener = consumer_listener;
+ core->consumer_listener = std::move(consumer_listener);
core->consumer_controlled_by_app = controlled_by_app;
return Status::NoError;
diff --git a/src/core/hle/service/nvflinger/consumer_base.cpp b/src/core/hle/service/nvflinger/consumer_base.cpp
index 5b9995854..982531e2d 100644
--- a/src/core/hle/service/nvflinger/consumer_base.cpp
+++ b/src/core/hle/service/nvflinger/consumer_base.cpp
@@ -83,7 +83,7 @@ Status ConsumerBase::AcquireBufferLocked(BufferItem* item, std::chrono::nanoseco
}
Status ConsumerBase::AddReleaseFenceLocked(s32 slot,
- const std::shared_ptr<GraphicBuffer> graphic_buffer,
+ const std::shared_ptr<GraphicBuffer>& graphic_buffer,
const Fence& fence) {
LOG_DEBUG(Service_NVFlinger, "slot={}", slot);
@@ -100,7 +100,7 @@ Status ConsumerBase::AddReleaseFenceLocked(s32 slot,
}
Status ConsumerBase::ReleaseBufferLocked(s32 slot,
- const std::shared_ptr<GraphicBuffer> graphic_buffer) {
+ const std::shared_ptr<GraphicBuffer>& graphic_buffer) {
// If consumer no longer tracks this graphic_buffer (we received a new
// buffer on the same slot), the buffer producer is definitely no longer
// tracking it.
@@ -121,7 +121,7 @@ Status ConsumerBase::ReleaseBufferLocked(s32 slot,
}
bool ConsumerBase::StillTracking(s32 slot,
- const std::shared_ptr<GraphicBuffer> graphic_buffer) const {
+ const std::shared_ptr<GraphicBuffer>& graphic_buffer) const {
if (slot < 0 || slot >= BufferQueueDefs::NUM_BUFFER_SLOTS) {
return false;
}
diff --git a/src/core/hle/service/nvflinger/consumer_base.h b/src/core/hle/service/nvflinger/consumer_base.h
index 90ba07f45..9a8a5f6bb 100644
--- a/src/core/hle/service/nvflinger/consumer_base.h
+++ b/src/core/hle/service/nvflinger/consumer_base.h
@@ -27,18 +27,18 @@ public:
protected:
explicit ConsumerBase(std::unique_ptr<BufferQueueConsumer> consumer_);
- virtual ~ConsumerBase();
+ ~ConsumerBase() override;
- virtual void OnFrameAvailable(const BufferItem& item) override;
- virtual void OnFrameReplaced(const BufferItem& item) override;
- virtual void OnBuffersReleased() override;
- virtual void OnSidebandStreamChanged() override;
+ void OnFrameAvailable(const BufferItem& item) override;
+ void OnFrameReplaced(const BufferItem& item) override;
+ void OnBuffersReleased() override;
+ void OnSidebandStreamChanged() override;
void FreeBufferLocked(s32 slot_index);
Status AcquireBufferLocked(BufferItem* item, std::chrono::nanoseconds present_when);
- Status ReleaseBufferLocked(s32 slot, const std::shared_ptr<GraphicBuffer> graphic_buffer);
- bool StillTracking(s32 slot, const std::shared_ptr<GraphicBuffer> graphic_buffer) const;
- Status AddReleaseFenceLocked(s32 slot, const std::shared_ptr<GraphicBuffer> graphic_buffer,
+ Status ReleaseBufferLocked(s32 slot, const std::shared_ptr<GraphicBuffer>& graphic_buffer);
+ bool StillTracking(s32 slot, const std::shared_ptr<GraphicBuffer>& graphic_buffer) const;
+ Status AddReleaseFenceLocked(s32 slot, const std::shared_ptr<GraphicBuffer>& graphic_buffer,
const Fence& fence);
struct Slot final {
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp
index c3af12c90..d1cbadde4 100644
--- a/src/core/hle/service/nvflinger/nvflinger.cpp
+++ b/src/core/hle/service/nvflinger/nvflinger.cpp
@@ -307,8 +307,7 @@ void NVFlinger::Compose() {
swap_interval = buffer.swap_interval;
- auto fence = android::Fence::NoFence();
- layer.GetConsumer().ReleaseBuffer(buffer, fence);
+ layer.GetConsumer().ReleaseBuffer(buffer, android::Fence::NoFence());
}
}
diff --git a/src/core/hle/service/nvflinger/producer_listener.h b/src/core/hle/service/nvflinger/producer_listener.h
index 1c4d5db0e..6bf8aaf1e 100644
--- a/src/core/hle/service/nvflinger/producer_listener.h
+++ b/src/core/hle/service/nvflinger/producer_listener.h
@@ -10,6 +10,7 @@ namespace Service::android {
class IProducerListener {
public:
+ virtual ~IProducerListener() = default;
virtual void OnBufferReleased() = 0;
};