SHA256
Add AMD GPU Support
This commit is contained in:
3 files changed
+64
-22
No files matched your search
+50
-15
@@ -32,12 +32,13 @@ namespace ADOFAIRenderer.Core
|
|||||||
public long frameCount;
|
public long frameCount;
|
||||||
public bool skipPressToStart;
|
public bool skipPressToStart;
|
||||||
public string levelPath = "";
|
public string levelPath = "";
|
||||||
public bool isRenderCancelled;
|
public bool isRenderCancelled { get; private set; }
|
||||||
public RenderConfig Configuration = null!;
|
public RenderConfig Configuration = null!;
|
||||||
|
|
||||||
// Render Sessions State (OOP Instance Fields)
|
// Render Sessions State (OOP Instance Fields)
|
||||||
public bool isRendering;
|
public bool overrideLoading { get; private set; }
|
||||||
public bool isCapturing;
|
public bool isRendering { get; private set; }
|
||||||
|
public bool isCapturing { get; private set; }
|
||||||
public double timeBase;
|
public double timeBase;
|
||||||
public double unscaledTimeBase;
|
public double unscaledTimeBase;
|
||||||
public double dspTimeBase;
|
public double dspTimeBase;
|
||||||
@@ -90,10 +91,46 @@ namespace ADOFAIRenderer.Core
|
|||||||
CleanUpActiveRender();
|
CleanUpActiveRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets overrideLoading to true when starting to load the render scene.
|
||||||
|
/// </summary>
|
||||||
|
public void StartLoadingOverride()
|
||||||
|
{
|
||||||
|
overrideLoading = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets isRendering to true when starting the rendering setup.
|
||||||
|
/// </summary>
|
||||||
|
public void StartRendering()
|
||||||
|
{
|
||||||
|
isRendering = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets isCapturing to true and resets the cancellation flag when starting the actual frame capture.
|
||||||
|
/// </summary>
|
||||||
|
public void StartCapturing()
|
||||||
|
{
|
||||||
|
isCapturing = true;
|
||||||
|
isRenderCancelled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resets all rendering-related states.
|
||||||
|
/// </summary>
|
||||||
|
public void ResetRenderState(bool success)
|
||||||
|
{
|
||||||
|
isRendering = false;
|
||||||
|
isCapturing = false;
|
||||||
|
overrideLoading = false;
|
||||||
|
isRenderCancelled = !success;
|
||||||
|
}
|
||||||
|
|
||||||
public void CleanUpActiveRender()
|
public void CleanUpActiveRender()
|
||||||
{
|
{
|
||||||
isRendering = isCapturing = false;
|
ResetRenderState(success: false);
|
||||||
isRenderCancelled = true;
|
|
||||||
AudioSpectrumGenerator.Clear();
|
AudioSpectrumGenerator.Clear();
|
||||||
|
|
||||||
if (_activeVideoFFmpeg != null)
|
if (_activeVideoFFmpeg != null)
|
||||||
@@ -160,7 +197,7 @@ namespace ADOFAIRenderer.Core
|
|||||||
dspTimeBase = AudioSettings.dspTime;
|
dspTimeBase = AudioSettings.dspTime;
|
||||||
frameCountBase = Time.frameCount;
|
frameCountBase = Time.frameCount;
|
||||||
|
|
||||||
isRendering = true;
|
StartRendering();
|
||||||
countdown = 3;
|
countdown = 3;
|
||||||
wonFrame = -1;
|
wonFrame = -1;
|
||||||
|
|
||||||
@@ -178,7 +215,7 @@ namespace ADOFAIRenderer.Core
|
|||||||
if (!isRendering) return;
|
if (!isRendering) return;
|
||||||
if (!scrController.instance || scrController.instance.state == States.Fail || scrController.instance.state == States.Fail2)
|
if (!scrController.instance || scrController.instance.state == States.Fail || scrController.instance.state == States.Fail2)
|
||||||
{
|
{
|
||||||
isRendering = isCapturing = false;
|
ResetRenderState(success: false);
|
||||||
StopFFmpeg(false);
|
StopFFmpeg(false);
|
||||||
EndRender();
|
EndRender();
|
||||||
}
|
}
|
||||||
@@ -192,7 +229,7 @@ namespace ADOFAIRenderer.Core
|
|||||||
var extraFrames = (long)Math.Ceiling(Configuration.DelayAfterLevelEnd * Configuration.RenderFPS);
|
var extraFrames = (long)Math.Ceiling(Configuration.DelayAfterLevelEnd * Configuration.RenderFPS);
|
||||||
|
|
||||||
if (frameCount - wonFrame < extraFrames) return;
|
if (frameCount - wonFrame < extraFrames) return;
|
||||||
isRendering = isCapturing = false;
|
ResetRenderState(success: true);
|
||||||
StopFFmpeg(true);
|
StopFFmpeg(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -307,14 +344,13 @@ namespace ADOFAIRenderer.Core
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Instance != null)
|
if (Instance) Instance.levelPath = ADOBase.levelPath;
|
||||||
Instance.levelPath = ADOBase.levelPath;
|
|
||||||
|
|
||||||
scnEditor.instance.CheckUnsavedChanges(() =>
|
scnEditor.instance.CheckUnsavedChanges(() =>
|
||||||
{
|
{
|
||||||
var quitDelegate =
|
var quitDelegate =
|
||||||
(Func<bool>)Delegate.CreateDelegate(typeof(Func<bool>), scnEditor.instance, targetMethod);
|
(Func<bool>)Delegate.CreateDelegate(typeof(Func<bool>), scnEditor.instance, targetMethod);
|
||||||
|
|
||||||
|
if (Instance) Instance.StartLoadingOverride();
|
||||||
Application.wantsToQuit -= quitDelegate;
|
Application.wantsToQuit -= quitDelegate;
|
||||||
ADOBase.loader.LoadSceneWithTransition(WipeDirection.StartsFromRight, "Assets/Scenes/RenderSettingsScene.unity");
|
ADOBase.loader.LoadSceneWithTransition(WipeDirection.StartsFromRight, "Assets/Scenes/RenderSettingsScene.unity");
|
||||||
});
|
});
|
||||||
@@ -356,7 +392,7 @@ namespace ADOFAIRenderer.Core
|
|||||||
_frameReader = new FrameReader();
|
_frameReader = new FrameReader();
|
||||||
StartFFmpegThread();
|
StartFFmpegThread();
|
||||||
|
|
||||||
isCapturing = true;
|
StartCapturing();
|
||||||
scrController.instance.paused = scrController.instance.audioPaused = false;
|
scrController.instance.paused = scrController.instance.audioPaused = false;
|
||||||
scrController.instance.levelWasSkipped = true;
|
scrController.instance.levelWasSkipped = true;
|
||||||
|
|
||||||
@@ -539,8 +575,7 @@ namespace ADOFAIRenderer.Core
|
|||||||
|
|
||||||
public void CancelRender()
|
public void CancelRender()
|
||||||
{
|
{
|
||||||
isRendering = isCapturing = false;
|
ResetRenderState(success: false);
|
||||||
isRenderCancelled = true;
|
|
||||||
|
|
||||||
StopFFmpeg(false);
|
StopFFmpeg(false);
|
||||||
EndRender();
|
EndRender();
|
||||||
|
|||||||
@@ -159,10 +159,8 @@ namespace ADOFAIRenderer.Patch.Engine
|
|||||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||||
public static void Prefix(ref bool stream)
|
public static void Prefix(ref bool stream)
|
||||||
{
|
{
|
||||||
if (RenderManager.Instance && RenderManager.Instance.Configuration.ProcessAudio)
|
if (RenderManager.Instance && RenderManager.Instance.overrideLoading && RenderManager.Instance.Configuration.ProcessAudio)
|
||||||
{
|
|
||||||
stream = false;
|
stream = false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-4
@@ -15,10 +15,14 @@ namespace ADOFAIRenderer.Util
|
|||||||
public static class GPUUtil
|
public static class GPUUtil
|
||||||
{
|
{
|
||||||
private const string NvidiaPattern =
|
private const string NvidiaPattern =
|
||||||
@"^NVIDIA GeForce [RG]TX [0-9]+(?>(?> Ti)|(?> SUPER)|(?> [0-9]+GB))?(?> Laptop GPU)?/PCIe/SSE2$";
|
@"^NVIDIA GeForce [RG]TX [0-9]+(?> SUPER| Ti(?> SUPER)?)?(?> [0-9]+GB)?(?> Laptop GPU)?/PCIe/SSE2$";
|
||||||
|
|
||||||
private const string IntelPattern =
|
private const string IntelPattern =
|
||||||
@"^Intel(?>\(R\))* (?>U*HD Graphics [0-9]+$|Arc\(TM\) [A-C][0-9]+ Graphics)";
|
@"^Intel(?>\(R\))? (?>U?HD Graphics [0-9]+$|Arc\(TM\) [A-C][0-9]+ Graphics)$";
|
||||||
|
|
||||||
|
// ReSharper disable once InconsistentNaming
|
||||||
|
private const string AMDPattern =
|
||||||
|
@"^AMD Radeon RX [0-9]+(?> XT)?$";
|
||||||
|
|
||||||
private static readonly Dictionary<Codec, List<(GPUVendor, string)>> CodecMap = new()
|
private static readonly Dictionary<Codec, List<(GPUVendor, string)>> CodecMap = new()
|
||||||
{
|
{
|
||||||
@@ -28,8 +32,8 @@ namespace ADOFAIRenderer.Util
|
|||||||
[Codec.AV1] = new List<(GPUVendor, string)> { (GPUVendor.NVIDIA, "av1_nvenc"), (GPUVendor.Intel, "av1_qsv"), (GPUVendor.AMD, "av1_amf"), (GPUVendor.Unknown, "libsvtav1"), (GPUVendor.Unknown, "libaom-av1") },
|
[Codec.AV1] = new List<(GPUVendor, string)> { (GPUVendor.NVIDIA, "av1_nvenc"), (GPUVendor.Intel, "av1_qsv"), (GPUVendor.AMD, "av1_amf"), (GPUVendor.Unknown, "libsvtav1"), (GPUVendor.Unknown, "libaom-av1") },
|
||||||
[Codec.VVC] = new List<(GPUVendor, string)> { (GPUVendor.Unknown, "libvvenc") }
|
[Codec.VVC] = new List<(GPUVendor, string)> { (GPUVendor.Unknown, "libvvenc") }
|
||||||
};
|
};
|
||||||
|
|
||||||
public static GPUVendor GetActiveGPUVendor()
|
private static GPUVendor GetActiveGPUVendor()
|
||||||
{
|
{
|
||||||
var gpuName = UnityEngine.SystemInfo.graphicsDeviceName;
|
var gpuName = UnityEngine.SystemInfo.graphicsDeviceName;
|
||||||
Melon<RenderMod>.Logger.Msg($"Active GPU: {gpuName}");
|
Melon<RenderMod>.Logger.Msg($"Active GPU: {gpuName}");
|
||||||
@@ -44,6 +48,11 @@ namespace ADOFAIRenderer.Util
|
|||||||
return GPUVendor.Intel;
|
return GPUVendor.Intel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (Match unused in Regex.Matches(gpuName, AMDPattern))
|
||||||
|
{
|
||||||
|
return GPUVendor.AMD;
|
||||||
|
}
|
||||||
|
|
||||||
return GPUVendor.Unknown;
|
return GPUVendor.Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user