Apply Optimized GPU Readback

This commit is contained in:
copecone committed 2026-05-27 13:14:31 +09:00
1 parent 3797cb7077
commit 9454226306
8 files changed
+208 -18

No files matched your search

+10 -7
View File
@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.IO;
using System.Threading;
using ADOFAIRenderer.Util;
using ADOFAIRenderer.Util.FFmpeg;
using MelonLoader;
using MelonLoader.Utils;
using UnityEngine;
@@ -13,7 +14,7 @@ namespace ADOFAIRenderer.Component
public class RenderManager : MonoBehaviour
{
public static int Countdown;
public static int FrameCount;
public static long FrameCount;
public static bool SkipPressToStart;
public static string LevelPath = "";
public static RenderManager Instance = null!;
@@ -52,12 +53,12 @@ namespace ADOFAIRenderer.Component
}
}
public static SortedList<int, byte[]> ImageQueue = new SortedList<int, byte[]>();
public static SortedList<long, byte[]> ImageQueue = new SortedList<long, byte[]>();
public static Thread? RenderThread;
public static int PassCount;
public static long PassCount;
public static bool EndRequested;
public static bool EndSuccessful;
public static int WonFrame = -1;
public static long WonFrame = -1;
private static bool _renderSetup;
@@ -125,7 +126,7 @@ namespace ADOFAIRenderer.Component
WonFrame = FrameCount;
}
var extraFrames = (int)Math.Ceiling(Configuration.EndWaitTime * Configuration.TargetFPS);
var extraFrames = (long)Math.Ceiling(Configuration.EndWaitTime * Configuration.TargetFPS);
if (FrameCount - WonFrame < extraFrames) return;
RenderMod.IsRendering = RenderMod.IsCapturing = false;
@@ -164,6 +165,8 @@ namespace ADOFAIRenderer.Component
FrameCount = 0;
RenderMod.FrameReader?.Dispose();
RenderMod.FrameReader = new FrameReader();
StartFFmpegThread();
RenderMod.IsCapturing = true;
@@ -258,7 +261,7 @@ namespace ADOFAIRenderer.Component
videoFFmpeg.Start(_currentOutPath, bitrate);
var num = isMultiple ? (int)Math.Round(quotient) : 1;
var num = isMultiple ? (long)Math.Round(quotient) : 1L;
while (true)
{
@@ -267,7 +270,7 @@ namespace ADOFAIRenderer.Component
{
if (ImageQueue.Count > 0)
{
int firstKey = ImageQueue.Keys[0];
var firstKey = ImageQueue.Keys[0];
if (firstKey == PassCount)
{
buffer = ImageQueue[firstKey];