aboutsummaryrefslogtreecommitdiff
path: root/src/hid_core
diff options
context:
space:
mode:
authorlizzie <lizzie@eden-emu.dev>2026-05-29 03:28:47 +0200
committercrueter <crueter@eden-emu.dev>2026-05-29 03:28:47 +0200
commitdef03f6589007026572816baed73f762818f05bb (patch)
tree100949ba575fe2eb66492d10a7c7cc0b825bf3f6 /src/hid_core
parent5ea24621cf8e75fe20ff35c4e41a05baf9497be8 (diff)
[video_core] fix redundant resize-copy overload and just use default-init resize, to reduce stutter on Mario BP (#3874)
before vs. after Mario Brothership kept remaking vectors of sizes 256 AND 4095 (TIC) and 1215 AND 524287 (TSC) every single frame, which resulted in a noticeable overhead the main cause was because of using `resize(n, c)` instead of `resize(n)` (also to aggressively resize for more room beforehand), the copy overload of resize does a copy of... well.. the value over the entire vector, additionally __append() keeps getting called because the capacity goes bonkers and all over the place ![image](/attachments/e3ba07fb-1c85-4d56-9b81-bb16a8150c15) ![image](/attachments/5c4eba26-015a-4c95-9b24-b41695a62e51) Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3874 Reviewed-by: crueter <crueter@eden-emu.dev> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Diffstat (limited to 'src/hid_core')
-rw-r--r--src/hid_core/resources/touch_screen/touch_screen_resource.cpp24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/hid_core/resources/touch_screen/touch_screen_resource.cpp b/src/hid_core/resources/touch_screen/touch_screen_resource.cpp
index 5d77fe5719..018a43b6c0 100644
--- a/src/hid_core/resources/touch_screen/touch_screen_resource.cpp
+++ b/src/hid_core/resources/touch_screen/touch_screen_resource.cpp
@@ -486,27 +486,17 @@ void TouchResource::ReadTouchInput() {
SanitizeInput(current_touch_state);
std::scoped_lock lock{*input_mutex};
- if (current_touch_state.entry_count == previous_touch_state.entry_count) {
- if (current_touch_state.entry_count < 1) {
- return;
- }
+ if (current_touch_state.entry_count == previous_touch_state.entry_count && current_touch_state.entry_count >= 1) {
bool has_moved = false;
- for (std::size_t i = 0; i < static_cast<std::size_t>(current_touch_state.entry_count);
- i++) {
- s32 delta_x = std::abs(static_cast<s32>(current_touch_state.states[i].position.x) -
- static_cast<s32>(previous_touch_state.states[i].position.x));
- s32 delta_y = std::abs(static_cast<s32>(current_touch_state.states[i].position.y) -
- static_cast<s32>(previous_touch_state.states[i].position.y));
- if (delta_x > 1 || delta_y > 1) {
- has_moved = true;
- }
+ for (std::size_t i = 0; !has_moved && i < std::size_t(current_touch_state.entry_count); i++) {
+ s32 delta_x = std::abs(s32(current_touch_state.states[i].position.x) - s32(previous_touch_state.states[i].position.x));
+ s32 delta_y = std::abs(s32(current_touch_state.states[i].position.y) - s32(previous_touch_state.states[i].position.y));
+ has_moved |= (delta_x > 1 || delta_y > 1);
}
- if (!has_moved) {
- return;
+ if (has_moved) {
+ input_event->Signal();
}
}
-
- input_event->Signal();
}
void TouchResource::OnTouchUpdate(s64 timestamp) {