mirror of
https://github.com/par274/sharpemu.git
synced 2026-08-03 16:39:51 +08:00
Fix Vulkan presenter synchronization and frame handling issues (#747)
* [VideoOut/Vulkan] Fix boot deadlock, writeback stall, and presentation bugs - Presenter thread now starts on the compute dispatch path too, fixing a boot deadlock when a title's first GPU work is compute (Ghost of Yotei G-Buffer clear). - Guest render-target format swaps between sibling pixel formats now reinterpret in place instead of recreating blank, preserving GPU-written content. - Vectorized the guest-buffer writeback scan (equal-byte skip + coarse per-page pre-check), fixing multi-second stalls on fragmented buffers that starved JobWorker completion signals. - _presentedSequence now advances on every Render() early-return path, fixing an unthrottled busy loop on stale/dropped presentations. * Remove unnecessary Silk.NET.Windowing dependency
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
// Copyright (C) 2026 SharpEmu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
|
||||
namespace SharpEmu.Libs.VideoOut;
|
||||
|
||||
public static class FlipProgressTracker
|
||||
{
|
||||
private static long _lastFlipTimestamp;
|
||||
private static long _lastFlipVersion;
|
||||
private static int _hasFlipped;
|
||||
|
||||
public static void RecordFlip(long version)
|
||||
{
|
||||
Volatile.Write(ref _lastFlipVersion, version);
|
||||
Volatile.Write(ref _lastFlipTimestamp, Stopwatch.GetTimestamp());
|
||||
Volatile.Write(ref _hasFlipped, 1);
|
||||
}
|
||||
|
||||
public static bool HasFlipped => Volatile.Read(ref _hasFlipped) != 0;
|
||||
|
||||
public static long LastFlipVersion => Volatile.Read(ref _lastFlipVersion);
|
||||
|
||||
public static double? SecondsSinceLastFlip()
|
||||
{
|
||||
if (Volatile.Read(ref _hasFlipped) == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var elapsedTicks = Stopwatch.GetTimestamp() - Volatile.Read(ref _lastFlipTimestamp);
|
||||
return elapsedTicks / (double)Stopwatch.Frequency;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user