New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RSX: wait when emulation is paused (reduces CPU usage) #10837
Conversation
I'm sure there's a better way. |
Should be at |
Relates to #9641, specifically pausing this way will make that ticket unactionable. Maybe add fixes link for that to this PR then. |
Maybe we can simply add a 16ms wait to the main loop instead. Maybe it's time to implement that pause screen 🤣 |
You can do it the same as shader loading dialog, just create a custom interface with low opacity that is updated every 16ms and calls flip in the update method, then trigger update from inside the paused loop. Just remember to destroy it once the pause ends. |
We can still pause rsx regardless of the issue ticket and the pause dialog though, until someone implements either. I just don't see a reason to destroy the planet any more than we have to for no reason. |
That was my original argument in that other ticket, you either waste resources drawing a pause screen or you leave it empty. Since the choice is to conserve resources and you are the reporter of the other ticket, I really see no point in handling it. Or do you still want a pause screen? Remember it will literally undo some of the power savings here. |
There are a couple of things to consider here: |
Accessing last frame would be nice for savestates "start paused" loading mode as well, currently it just waits till one more frame is rendered then pause. |
The problem is how the OS handles painting the window - if you resize/minimize/move etc it is up to the application to handle the event, otherwise the window is just going to have garbage in it. Of course for this to happen would mean RSX thread has to be awake to repaint everything and this causes another hilarious problem - you cannot tell that the window size changed without polling unless you set up your own notification hooks. |
I'm not saying its not doable or anything, just that it will eat up some system resources for visual consistency. I can set up the basic framework for it if it is decided to go that route, but RIP power savings is going to be the problem. |
But if it's event based then you can just wake up the thread for a blip and do the necessary work in one iteration can't you? |
It is not event based, I explained that above. It is event-based from the OS level (win32, X11) but not on our side (Qt, Vulkan) |
Can't we catch the event with Qt? |
I remember this does not work. Previously there was some Msq injection I had added to gsframe that allowed me to snoop on the win32 activity before the driver could start acting on it, but it ended up being really dangerous and it was removed. it has to do with timing, if you catch a QT event, wake up and do something, you must be sure the driver does not trash your decision immediately after. Things my have improved since then, though I haven't really checked. |
Since there is still a lot of discussion, let's keep the other ticket open then. I'll have to check later the best place to add the sleep. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ramblings:
- rsx::thread now derives from cpu_thread which has some simpler ways of checking if paused without being stopped. You can just check if
state & (cpu_flag::dbg_global_pause + cpu_flag::exit) == cpu_flag::dbg_global_pause
to check if only pause is enabled. However, this isn't even necessary due to point 2... - As elad mentioned, we already have some logic to optionally pause things in cpu_wait() wich is called every iteration whenever test_stopped() is called. You should add your sleep in there based on the state value. You should even just sleep once (16ms) and let the system continue which allows RSX to keep operating in a low power mode and is able to react to other requests such as screen refreshes and such.
Updated PR with the suggested solution (hopefully correct). |
This decreases my cpu usage by to <1% during Emu.Pause()
This decreases my cpu usage in GMPADTEST from ~9% to <1% during Emu.Pause() (together with the other pad_thread PR)