Implement Filter-Before-Capture Structure

This commit is contained in:
copecone committed 2026-05-28 11:33:47 +09:00
1 parent 379c0360d7
commit ec06f99603
4 files changed
+70 -38

No files matched your search

+20 -13
View File
@@ -98,24 +98,27 @@ namespace ADOFAIRenderer
// 60회 초과 시 최후의 블랙 프레임 삽입하여 전체 파이프라인 마비 방지
Melon<RenderMod>.Logger.Error($"[Render Skipped] Frame {RenderManager.FrameCount} rendering failed after 60 retries. Supplying black frame.");
var currentFrame = FrameCountForVideo++;
var targetFps = RenderManager.Configuration.TargetFPS;
var videoFps = RenderManager.Configuration.VideoFPS;
var quotient = targetFps / videoFps;
var num = Math.Abs(quotient - Math.Round(quotient)) < 1e-9 ? (long)Math.Round(quotient) : 1L;
var effectiveVideoFps = Math.Min(videoFps, targetFps);
var videoFrameIndex = (long)(currentFrame * effectiveVideoFps / targetFps);
if (FrameCountForVideo % num == 0)
if (videoFrameIndex > LastVideoFrameIndex)
{
LastVideoFrameIndex = videoFrameIndex;
LastRequestedVideoFrameIndex = videoFrameIndex;
var byteSize = RenderManager.Configuration.RenderWidth * RenderManager.Configuration.RenderHeight * 4;
var blackFrame = System.Buffers.ArrayPool<byte>.Shared.Rent(byteSize);
Array.Clear(blackFrame, 0, byteSize);
lock (RenderManager.ImageQueue)
{
RenderManager.ImageQueue[FrameCountForVideo] = blackFrame;
RenderManager.ImageQueue[videoFrameIndex] = blackFrame;
}
}
FrameCountForVideo++;
RenderCheck = false; // 진행 허용
}
@@ -130,6 +133,9 @@ namespace ADOFAIRenderer
}
public static long FrameCountForVideo;
public static long LastVideoFrameIndex = -1;
public static long LastRequestedVideoFrameIndex = -1;
public static bool IsRenderCancelled = false;
public static int ReadbackFailureCount;
public static int ThrottleCount;
public static bool IsThrottling;
@@ -167,15 +173,16 @@ namespace ADOFAIRenderer
var targetFps = RenderManager.Configuration.TargetFPS;
var videoFps = RenderManager.Configuration.VideoFPS;
var quotient = targetFps / videoFps;
var num = Math.Abs(quotient - Math.Round(quotient)) < 1e-9 ? (int)Math.Round(quotient) : 1;
if (currentFrame % num != 0)
{
return;
}
var effectiveVideoFps = Math.Min(videoFps, targetFps);
FrameReader?.RequestFrameCapture(texture, currentFrame);
var videoFrameIndex = (long)(currentFrame * effectiveVideoFps / targetFps);
if (videoFrameIndex > LastVideoFrameIndex)
{
LastVideoFrameIndex = videoFrameIndex;
LastRequestedVideoFrameIndex = videoFrameIndex;
FrameReader?.RequestFrameCapture(texture, videoFrameIndex);
}
/*
AsyncGPUReadback.Request(texture, 0, delegate(AsyncGPUReadbackRequest req)