mirror of
https://github.com/par274/sharpemu.git
synced 2026-08-03 08:29:53 +08:00
f3d9439952
* [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
37 lines
1.0 KiB
C#
37 lines
1.0 KiB
C#
// 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;
|
|
}
|
|
}
|