Open benkyoujouzu opened 7 months ago
Are you able to reproduce this is in pure winit
? Or in other front-ends that use winit, like eframe
or I believe fyrox
?
Are you able to reproduce this is in pure
winit
? Or in other front-ends that use winit, likeeframe
or I believefyrox
?
I've tested the egui_demo_app and a demo in the fyrox tutorial, and both experience significant frame rate drops when using a high polling rate mouse. Therefore, it's likely that the problem lies within winit.
I found a winit issue that may be related to this problem: rust-windowing/winit#1418
Awesome, that's very useful information. Thank you for investigating!
I found the problem and made a pull request to winit https://github.com/rust-windowing/winit/pull/3609.
Edit: This breaks some handling of winit. Additional fixes needed.
I found the problem and made a pull request to winit rust-windowing/winit#3609.
Edit: This breaks some handling of winit. Additional fixes needed.
On my opened issue on winit I noted that I tested your pull but with no success, it made no difference between before / after the pull was added, if you have or want more information let me know.
Wanted to share this here because this is recent and seems highly relevant to this issue!
Note that I tried making a window with winit and with winapi directly, both had performance issues, so I suspect it's windows especially after my profiling results, so the only fix would be to find a workaround
Bevy Version
0.13.1
System Information
SystemInfo { os: "Windows 11 Home", kernel: "22631", cpu: "AMD Ryzen 9 7940HS w/ Radeon 780M Graphics", core_count: "8", memory: "15.2 GiB" }
AdapterInfo { name: "NVIDIA GeForce RTX 4060 Laptop GPU", vendor: 4318, device: 10464, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "536.45", backend: Vulkan }
What Went Wrong
I have a mouse that allows me to adjust its polling rate. There are no issues when the mouse's polling rate is below 2000Hz. However, when I set the polling rate to 4000Hz, even in the simplest scenes, rapidly moving the mouse causes a significant drop in frame rate, with the maximum frame time increasing from around 10ms to about 80ms. Minimal example
1000Hz:
4000Hz:
What You Did
Since I haven't encountered similar issues in Godot and some games, it likely isn't a problem with the performance of my computer.
I tried using
PresentMode::Fifo
,PresentMode::Mailbox
, andPresentMode::Immediate
, but the frame drops did not improve.I attempted the method from SDL#8756 using GetRawInputBuffer to acquire raw mouse input in a dedicated thread (my code), yet there was still no improvement.
Tracing data shows a lot of
CursorMoved
events between two frames when using a 4000Hz polling rate. I tried commenting out the code handlingCursorMoved
in bevy_winit and settingevent_loop.listen_device_events(DeviceEvents::Never)
, but these did not solve the problem.1000Hz:
4000Hz:
I suspect that some logic within bevy_winit or winit might be causing the stutter with high polling rate mice, but I haven't identified the cause. Do you have any idea?