18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-03 06:35:21 +01:00

perf(application): the hidden window of the test mode polled a few times a second

The main loop called glfwPollEvents() every frame. With no messages waiting, PeekMessage called over and
over yields the thread (ZwYieldExecution in the profile), so in a short frame it was a large part of it: 8.7%
of the main thread on linia_107_objazdy, 0.3% on Tomaszewo. The test mode's window is hidden and takes
no input, so there its messages are looked at every 50 ms. Outside the test mode they are polled every
frame, as before.
This commit is contained in:
jerrrrycho
2026-12-02 07:04:33 +01:00
parent 2fdf9d27b2
commit cdaa40ac3b
+9 -1
View File
@@ -685,6 +685,10 @@ int eu07_application::run()
{
auto frame{0};
frame_pacer framepacer;
// the window of the test mode is hidden and takes no input: its messages are looked at a few times a second. looked for
// every frame, PeekMessage gives up the rest of the time slice of the thread when there are none, which in a short frame
// came to a tenth of it
auto nextpoll{std::chrono::steady_clock::now()};
Timer::subsystem.mainloop_period.start();
// main application loop
while (!glfwWindowShouldClose(m_windows.front()) && !m_modestack.empty())
@@ -695,7 +699,11 @@ int eu07_application::run()
Timer::subsystem.mainloop_total.start();
GfxRenderer->Frame_Start();
Timer::subsystem.loop_input.start();
glfwPollEvents();
if (false == Global.test.enabled || std::chrono::steady_clock::now() >= nextpoll)
{
glfwPollEvents();
nextpoll = std::chrono::steady_clock::now() + std::chrono::milliseconds{50};
}
if (m_headtrack)
m_headtrack->update();