Add MacOS H/W Acceleration Support

This commit is contained in:
copecone committed 2026-08-07 22:11:58 +09:00
1 parent ced281f039
commit 2fe09c71ae
2 files changed
+15 -6

No files matched your search

+3
View File
@@ -21,6 +21,7 @@ namespace ADOFAIRenderer.Patch.Engine
}
[HarmonyPostfix]
// ReSharper disable once InconsistentNaming
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)
@@ -84,6 +85,7 @@ namespace ADOFAIRenderer.Patch.Engine
public static class AudioSourceSetScheduledEndTimePatch
{
[HarmonyPostfix]
// ReSharper disable once InconsistentNaming
public static void Postfix(AudioSource __instance, double time)
{
if (RenderManager.IsCapturingActive && RenderManager.Instance.Configuration.AudioConfig.RenderAudio)
@@ -101,6 +103,7 @@ namespace ADOFAIRenderer.Patch.Engine
public static class AudioSourceStopPatch
{
[HarmonyPostfix]
// ReSharper disable once InconsistentNaming
public static void Postfix(AudioSource __instance)
{
if (RenderManager.IsCapturingActive && RenderManager.Instance.Configuration.AudioConfig.RenderAudio)
+12 -6
View File
@@ -4,13 +4,14 @@ using System.Linq;
using System.Text.RegularExpressions;
using ADOFAIRenderer.Util.FFmpeg;
using MelonLoader;
using UnityEngine;
namespace ADOFAIRenderer.Util
{
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum GPUVendor
{
Unknown, NVIDIA, AMD, Intel
Unknown, NVIDIA, AMD, Intel, Apple
}
public static class GPUUtil
@@ -27,8 +28,8 @@ namespace ADOFAIRenderer.Util
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.H265] = new List<(GPUVendor, string)> { (GPUVendor.NVIDIA, "hevc_nvenc"), (GPUVendor.Intel, "hevc_qsv"), (GPUVendor.AMD, "hevc_amf"), (GPUVendor.Unknown, "libx265") },
[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.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.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") }
@@ -41,7 +42,7 @@ namespace ADOFAIRenderer.Util
{
if (_hasCachedVendor) return _cachedVendor;
var gpuName = UnityEngine.SystemInfo.graphicsDeviceName;
var gpuName = SystemInfo.graphicsDeviceName;
Melon<RenderMod>.Logger.Msg($"Active GPU: {gpuName}");
_cachedVendor = GPUVendor.Unknown;
@@ -68,6 +69,11 @@ namespace ADOFAIRenderer.Util
break;
}
}
if (_cachedVendor == GPUVendor.Unknown && Application.platform == RuntimePlatform.OSXPlayer)
{
_cachedVendor = GPUVendor.Apple;
}
_hasCachedVendor = true;
return _cachedVendor;
@@ -86,13 +92,13 @@ namespace ADOFAIRenderer.Util
if (GetActiveGPUVendor() != GPUVendor.NVIDIA) return null;
// 1. Try parsing from UnityEngine.SystemInfo.graphicsDeviceVersion
var deviceVersion = UnityEngine.SystemInfo.graphicsDeviceVersion;
var deviceVersion = SystemInfo.graphicsDeviceVersion;
if (!string.IsNullOrEmpty(deviceVersion))
{
var match = Regex.Match(deviceVersion, @"\b(\d+)\.(\d+)\.(\d+)\.(\d+)\b");
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;
_cachedNvidiaVersion = nvidiaVerInt / 100.0;