mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-30 02:44:17 +01:00
Avoid waiting on mutex in PresentationEngine::Present
We want to block on the host thread during presentation while the host surface isn't present to implicitly pause the game, this can end up being fairly costly as it involves locking the `PresentationEngine` mutex which can lead to a lot of contention with the presentation thread. This fixes the issue by polling if there is a surface and only if there isn't then doing the wait as it isn't mandatory to wait always, we'll eventually run into the guest thread stalling.
This commit is contained in:
parent
30475ffc43
commit
d7399e33c1
@ -374,8 +374,11 @@ namespace skyline::gpu {
|
||||
}
|
||||
|
||||
u64 PresentationEngine::Present(const std::shared_ptr<Texture> &texture, i64 timestamp, i64 swapInterval, AndroidRect crop, NativeWindowScalingMode scalingMode, NativeWindowTransform transform, skyline::service::hosbinder::AndroidFence fence, const std::function<void()>& presentCallback) {
|
||||
if (!vkSurface.has_value()) {
|
||||
// We want this function to generally (not necessarily always) block when a surface is not present to implicitly pause the game
|
||||
std::unique_lock lock(mutex);
|
||||
surfaceCondition.wait(lock, [this]() { return vkSurface.has_value(); });
|
||||
}
|
||||
|
||||
presentQueue.Push(PresentableFrame{
|
||||
texture,
|
||||
|
Loading…
Reference in New Issue
Block a user