SHA256
Add MacOS H/W Acceleration Support
This commit is contained in:
2 files changed
+15
-6
No files matched your search
@@ -21,6 +21,7 @@ namespace ADOFAIRenderer.Patch.Engine
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
|
// ReSharper disable once InconsistentNaming
|
||||||
public static void Postfix(AudioSource __result, string snd, double time, AudioMixerGroup group, float volume, int priority)
|
public static void Postfix(AudioSource __result, string snd, double time, AudioMixerGroup group, float volume, int priority)
|
||||||
{
|
{
|
||||||
if (RenderManager.IsCapturingActive && RenderManager.Instance.Configuration.AudioConfig.RenderAudio && __result != null)
|
if (RenderManager.IsCapturingActive && RenderManager.Instance.Configuration.AudioConfig.RenderAudio && __result != null)
|
||||||
@@ -84,6 +85,7 @@ namespace ADOFAIRenderer.Patch.Engine
|
|||||||
public static class AudioSourceSetScheduledEndTimePatch
|
public static class AudioSourceSetScheduledEndTimePatch
|
||||||
{
|
{
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
|
// ReSharper disable once InconsistentNaming
|
||||||
public static void Postfix(AudioSource __instance, double time)
|
public static void Postfix(AudioSource __instance, double time)
|
||||||
{
|
{
|
||||||
if (RenderManager.IsCapturingActive && RenderManager.Instance.Configuration.AudioConfig.RenderAudio)
|
if (RenderManager.IsCapturingActive && RenderManager.Instance.Configuration.AudioConfig.RenderAudio)
|
||||||
@@ -101,6 +103,7 @@ namespace ADOFAIRenderer.Patch.Engine
|
|||||||
public static class AudioSourceStopPatch
|
public static class AudioSourceStopPatch
|
||||||
{
|
{
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
|
// ReSharper disable once InconsistentNaming
|
||||||
public static void Postfix(AudioSource __instance)
|
public static void Postfix(AudioSource __instance)
|
||||||
{
|
{
|
||||||
if (RenderManager.IsCapturingActive && RenderManager.Instance.Configuration.AudioConfig.RenderAudio)
|
if (RenderManager.IsCapturingActive && RenderManager.Instance.Configuration.AudioConfig.RenderAudio)
|
||||||
|
|||||||
+12
-6
@@ -4,13 +4,14 @@ using System.Linq;
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using ADOFAIRenderer.Util.FFmpeg;
|
using ADOFAIRenderer.Util.FFmpeg;
|
||||||
using MelonLoader;
|
using MelonLoader;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace ADOFAIRenderer.Util
|
namespace ADOFAIRenderer.Util
|
||||||
{
|
{
|
||||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||||
public enum GPUVendor
|
public enum GPUVendor
|
||||||
{
|
{
|
||||||
Unknown, NVIDIA, AMD, Intel
|
Unknown, NVIDIA, AMD, Intel, Apple
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class GPUUtil
|
public static class GPUUtil
|
||||||
@@ -27,8 +28,8 @@ namespace ADOFAIRenderer.Util
|
|||||||
|
|
||||||
private static readonly Dictionary<Codec, List<(GPUVendor, string)>> CodecMap = new()
|
private static readonly Dictionary<Codec, List<(GPUVendor, string)>> CodecMap = new()
|
||||||
{
|
{
|
||||||
[Codec.H264] = new List<(GPUVendor, string)> { (GPUVendor.NVIDIA, "h264_nvenc"), (GPUVendor.Intel, "h264_qsv"), (GPUVendor.AMD, "h264_amf"), (GPUVendor.Unknown, "libx264") },
|
[Codec.H264] = new List<(GPUVendor, string)> { (GPUVendor.NVIDIA, "h264_nvenc"), (GPUVendor.Intel, "h264_qsv"), (GPUVendor.AMD, "h264_amf"), (GPUVendor.Apple, "h264_videotoolbox"), (GPUVendor.Unknown, "libx264") },
|
||||||
[Codec.H265] = new List<(GPUVendor, string)> { (GPUVendor.NVIDIA, "hevc_nvenc"), (GPUVendor.Intel, "hevc_qsv"), (GPUVendor.AMD, "hevc_amf"), (GPUVendor.Unknown, "libx265") },
|
[Codec.H265] = new List<(GPUVendor, string)> { (GPUVendor.NVIDIA, "hevc_nvenc"), (GPUVendor.Intel, "hevc_qsv"), (GPUVendor.AMD, "hevc_amf"), (GPUVendor.Apple, "hevc_videotoolbox"), (GPUVendor.Unknown, "libx265") },
|
||||||
[Codec.VP9] = new List<(GPUVendor, string)> { (GPUVendor.NVIDIA, "vp9_nvenc"), (GPUVendor.Intel, "vp9_qsv"), (GPUVendor.Unknown, "libvpx-vp9") },
|
[Codec.VP9] = new List<(GPUVendor, string)> { (GPUVendor.NVIDIA, "vp9_nvenc"), (GPUVendor.Intel, "vp9_qsv"), (GPUVendor.Unknown, "libvpx-vp9") },
|
||||||
[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") }
|
||||||
@@ -41,7 +42,7 @@ namespace ADOFAIRenderer.Util
|
|||||||
{
|
{
|
||||||
if (_hasCachedVendor) return _cachedVendor;
|
if (_hasCachedVendor) return _cachedVendor;
|
||||||
|
|
||||||
var gpuName = UnityEngine.SystemInfo.graphicsDeviceName;
|
var gpuName = SystemInfo.graphicsDeviceName;
|
||||||
Melon<RenderMod>.Logger.Msg($"Active GPU: {gpuName}");
|
Melon<RenderMod>.Logger.Msg($"Active GPU: {gpuName}");
|
||||||
|
|
||||||
_cachedVendor = GPUVendor.Unknown;
|
_cachedVendor = GPUVendor.Unknown;
|
||||||
@@ -68,6 +69,11 @@ namespace ADOFAIRenderer.Util
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_cachedVendor == GPUVendor.Unknown && Application.platform == RuntimePlatform.OSXPlayer)
|
||||||
|
{
|
||||||
|
_cachedVendor = GPUVendor.Apple;
|
||||||
|
}
|
||||||
|
|
||||||
_hasCachedVendor = true;
|
_hasCachedVendor = true;
|
||||||
return _cachedVendor;
|
return _cachedVendor;
|
||||||
@@ -86,13 +92,13 @@ namespace ADOFAIRenderer.Util
|
|||||||
if (GetActiveGPUVendor() != GPUVendor.NVIDIA) return null;
|
if (GetActiveGPUVendor() != GPUVendor.NVIDIA) return null;
|
||||||
|
|
||||||
// 1. Try parsing from UnityEngine.SystemInfo.graphicsDeviceVersion
|
// 1. Try parsing from UnityEngine.SystemInfo.graphicsDeviceVersion
|
||||||
var deviceVersion = UnityEngine.SystemInfo.graphicsDeviceVersion;
|
var deviceVersion = SystemInfo.graphicsDeviceVersion;
|
||||||
if (!string.IsNullOrEmpty(deviceVersion))
|
if (!string.IsNullOrEmpty(deviceVersion))
|
||||||
{
|
{
|
||||||
var match = Regex.Match(deviceVersion, @"\b(\d+)\.(\d+)\.(\d+)\.(\d+)\b");
|
var match = Regex.Match(deviceVersion, @"\b(\d+)\.(\d+)\.(\d+)\.(\d+)\b");
|
||||||
if (match.Success)
|
if (match.Success)
|
||||||
{
|
{
|
||||||
if (int.TryParse(match.Groups[3].Value, out int sub) && int.TryParse(match.Groups[4].Value, out int build))
|
if (int.TryParse(match.Groups[3].Value, out var sub) && int.TryParse(match.Groups[4].Value, out int build))
|
||||||
{
|
{
|
||||||
var nvidiaVerInt = sub % 10 * 10000 + build;
|
var nvidiaVerInt = sub % 10 * 10000 + build;
|
||||||
_cachedNvidiaVersion = nvidiaVerInt / 100.0;
|
_cachedNvidiaVersion = nvidiaVerInt / 100.0;
|
||||||
|
|||||||
Reference in new issue
Block a user