SHA256
Add License Exception
This commit is contained in:
16 files changed
+1038
-994
No files matched your search
@@ -1,30 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using FFmpeg.AutoGen;
|
||||
|
||||
namespace ADOFAIRenderer.Util.FFmpeg
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum Codec
|
||||
{
|
||||
H264, H265, VP9, AV1, VVC
|
||||
}
|
||||
|
||||
internal static class CodecUtil
|
||||
{
|
||||
public static readonly Dictionary<Codec, AVCodecID> AudioCodecMatch = new()
|
||||
{
|
||||
[Codec.H264] = AVCodecID.AV_CODEC_ID_AAC,
|
||||
[Codec.H265] = AVCodecID.AV_CODEC_ID_AAC,
|
||||
[Codec.VP9] = AVCodecID.AV_CODEC_ID_OPUS,
|
||||
[Codec.AV1] = AVCodecID.AV_CODEC_ID_OPUS,
|
||||
[Codec.VVC] = AVCodecID.AV_CODEC_ID_OPUS
|
||||
};
|
||||
|
||||
public static readonly Dictionary<AVCodecID, List<int>> AvailableSampleRate = new()
|
||||
{
|
||||
[AVCodecID.AV_CODEC_ID_AAC] = new List<int> { 44100, 48000, 96000 },
|
||||
[AVCodecID.AV_CODEC_ID_OPUS] = new List<int> { 48000 }
|
||||
};
|
||||
}
|
||||
}
|
||||
+729
-730
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using ADOFAIRenderer.Data;
|
||||
using FFmpeg.AutoGen;
|
||||
using MelonLoader;
|
||||
using Unity.Collections;
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace ADOFAIRenderer.Util.FFmpeg
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum RateControlMode
|
||||
{
|
||||
CBR,
|
||||
VBR,
|
||||
CQP
|
||||
}
|
||||
}
|
||||
+106
-106
@@ -2,112 +2,112 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using ADOFAIRenderer.Data;
|
||||
|
||||
namespace ADOFAIRenderer.Util.FFmpeg
|
||||
namespace ADOFAIRenderer.Util.FFmpeg;
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
internal enum EncoderKind
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum EncoderKind
|
||||
{
|
||||
Software,
|
||||
NVENC,
|
||||
AMF,
|
||||
QSV,
|
||||
VideoToolbox
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
internal sealed class VideoEncoder : IEquatable<VideoEncoder>
|
||||
{
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
|
||||
// ── H.264 ──
|
||||
public static readonly VideoEncoder H264_NVENC = new("h264_nvenc", Codec.H264, GPUVendor.NVIDIA, EncoderKind.NVENC);
|
||||
public static readonly VideoEncoder H264_QSV = new("h264_qsv", Codec.H264, GPUVendor.Intel, EncoderKind.QSV);
|
||||
public static readonly VideoEncoder H264_AMF = new("h264_amf", Codec.H264, GPUVendor.AMD, EncoderKind.AMF);
|
||||
public static readonly VideoEncoder H264_VideoToolbox = new("h264_videotoolbox", Codec.H264, GPUVendor.Apple, EncoderKind.VideoToolbox);
|
||||
public static readonly VideoEncoder Libx264 = new("libx264", Codec.H264, GPUVendor.Unknown, EncoderKind.Software);
|
||||
|
||||
// ── H.265 (HEVC) ──
|
||||
public static readonly VideoEncoder HEVC_NVENC = new("hevc_nvenc", Codec.H265, GPUVendor.NVIDIA, EncoderKind.NVENC);
|
||||
public static readonly VideoEncoder HEVC_QSV = new("hevc_qsv", Codec.H265, GPUVendor.Intel, EncoderKind.QSV);
|
||||
public static readonly VideoEncoder HEVC_AMF = new("hevc_amf", Codec.H265, GPUVendor.AMD, EncoderKind.AMF);
|
||||
public static readonly VideoEncoder HEVC_VideoToolbox = new("hevc_videotoolbox", Codec.H265, GPUVendor.Apple, EncoderKind.VideoToolbox);
|
||||
public static readonly VideoEncoder Libx265 = new("libx265", Codec.H265, GPUVendor.Unknown, EncoderKind.Software);
|
||||
|
||||
// ── VP9 ──
|
||||
public static readonly VideoEncoder VP9_NVENC = new("vp9_nvenc", Codec.VP9, GPUVendor.NVIDIA, EncoderKind.NVENC);
|
||||
public static readonly VideoEncoder VP9_QSV = new("vp9_qsv", Codec.VP9, GPUVendor.Intel, EncoderKind.QSV);
|
||||
public static readonly VideoEncoder LibvpxVP9 = new("libvpx-vp9", Codec.VP9, GPUVendor.Unknown, EncoderKind.Software);
|
||||
|
||||
// ── AV1 ──
|
||||
public static readonly VideoEncoder AV1_NVENC = new("av1_nvenc", Codec.AV1, GPUVendor.NVIDIA, EncoderKind.NVENC);
|
||||
public static readonly VideoEncoder AV1_QSV = new("av1_qsv", Codec.AV1, GPUVendor.Intel, EncoderKind.QSV);
|
||||
public static readonly VideoEncoder AV1_AMF = new("av1_amf", Codec.AV1, GPUVendor.AMD, EncoderKind.AMF);
|
||||
public static readonly VideoEncoder LibSvtAv1 = new("libsvtav1", Codec.AV1, GPUVendor.Unknown, EncoderKind.Software);
|
||||
public static readonly VideoEncoder LibAomAv1 = new("libaom-av1", Codec.AV1, GPUVendor.Unknown, EncoderKind.Software);
|
||||
|
||||
// ── VVC ──
|
||||
public static readonly VideoEncoder LibVvenc = new("libvvenc", Codec.VVC, GPUVendor.Unknown, EncoderKind.Software);
|
||||
|
||||
// ReSharper restore MemberCanBePrivate.Global
|
||||
|
||||
public static readonly IReadOnlyList<VideoEncoder> All = new[]
|
||||
{
|
||||
H264_NVENC, H264_QSV, H264_AMF, H264_VideoToolbox, Libx264,
|
||||
HEVC_NVENC, HEVC_QSV, HEVC_AMF, HEVC_VideoToolbox, Libx265,
|
||||
VP9_NVENC, VP9_QSV, LibvpxVP9,
|
||||
AV1_NVENC, AV1_QSV, AV1_AMF, LibSvtAv1, LibAomAv1,
|
||||
LibVvenc
|
||||
};
|
||||
|
||||
private static readonly Dictionary<string, VideoEncoder> ByName =
|
||||
All.ToDictionary(e => e.Name, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public string Name { get; }
|
||||
public Codec Codec { get; }
|
||||
public GPUVendor Vendor { get; }
|
||||
public EncoderKind Kind { get; }
|
||||
public bool IsHardware => Kind != EncoderKind.Software;
|
||||
|
||||
private VideoEncoder(string name, Codec codec, GPUVendor vendor, EncoderKind kind)
|
||||
{
|
||||
Name = name;
|
||||
Codec = codec;
|
||||
Vendor = vendor;
|
||||
Kind = kind;
|
||||
}
|
||||
|
||||
public static VideoEncoder? FromName(string name)
|
||||
{
|
||||
return string.IsNullOrEmpty(name) ? null : ByName.GetValueOrDefault(name);
|
||||
}
|
||||
|
||||
public bool Equals(VideoEncoder other)
|
||||
{
|
||||
if (ReferenceEquals(null, other)) return false;
|
||||
return ReferenceEquals(this, other) || string.Equals(Name, other.Name, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return ReferenceEquals(this, obj) || obj is VideoEncoder other && Equals(other);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return StringComparer.OrdinalIgnoreCase.GetHashCode(Name);
|
||||
}
|
||||
|
||||
public static bool operator ==(VideoEncoder left, VideoEncoder right)
|
||||
{
|
||||
return Equals(left, right);
|
||||
}
|
||||
|
||||
public static bool operator !=(VideoEncoder left, VideoEncoder right)
|
||||
{
|
||||
return !Equals(left, right);
|
||||
}
|
||||
|
||||
public override string ToString() => Name;
|
||||
}
|
||||
Software,
|
||||
NVENC,
|
||||
AMF,
|
||||
QSV,
|
||||
VideoToolbox
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
internal sealed class VideoEncoder : IEquatable<VideoEncoder>
|
||||
{
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
|
||||
// ── H.264 ──
|
||||
public static readonly VideoEncoder H264_NVENC = new("h264_nvenc", Codec.H264, GPUVendor.NVIDIA, EncoderKind.NVENC);
|
||||
public static readonly VideoEncoder H264_QSV = new("h264_qsv", Codec.H264, GPUVendor.Intel, EncoderKind.QSV);
|
||||
public static readonly VideoEncoder H264_AMF = new("h264_amf", Codec.H264, GPUVendor.AMD, EncoderKind.AMF);
|
||||
public static readonly VideoEncoder H264_VideoToolbox = new("h264_videotoolbox", Codec.H264, GPUVendor.Apple, EncoderKind.VideoToolbox);
|
||||
public static readonly VideoEncoder Libx264 = new("libx264", Codec.H264, GPUVendor.Unknown, EncoderKind.Software);
|
||||
|
||||
// ── H.265 (HEVC) ──
|
||||
public static readonly VideoEncoder HEVC_NVENC = new("hevc_nvenc", Codec.H265, GPUVendor.NVIDIA, EncoderKind.NVENC);
|
||||
public static readonly VideoEncoder HEVC_QSV = new("hevc_qsv", Codec.H265, GPUVendor.Intel, EncoderKind.QSV);
|
||||
public static readonly VideoEncoder HEVC_AMF = new("hevc_amf", Codec.H265, GPUVendor.AMD, EncoderKind.AMF);
|
||||
public static readonly VideoEncoder HEVC_VideoToolbox = new("hevc_videotoolbox", Codec.H265, GPUVendor.Apple, EncoderKind.VideoToolbox);
|
||||
public static readonly VideoEncoder Libx265 = new("libx265", Codec.H265, GPUVendor.Unknown, EncoderKind.Software);
|
||||
|
||||
// ── VP9 ──
|
||||
public static readonly VideoEncoder VP9_NVENC = new("vp9_nvenc", Codec.VP9, GPUVendor.NVIDIA, EncoderKind.NVENC);
|
||||
public static readonly VideoEncoder VP9_QSV = new("vp9_qsv", Codec.VP9, GPUVendor.Intel, EncoderKind.QSV);
|
||||
public static readonly VideoEncoder LibvpxVP9 = new("libvpx-vp9", Codec.VP9, GPUVendor.Unknown, EncoderKind.Software);
|
||||
|
||||
// ── AV1 ──
|
||||
public static readonly VideoEncoder AV1_NVENC = new("av1_nvenc", Codec.AV1, GPUVendor.NVIDIA, EncoderKind.NVENC);
|
||||
public static readonly VideoEncoder AV1_QSV = new("av1_qsv", Codec.AV1, GPUVendor.Intel, EncoderKind.QSV);
|
||||
public static readonly VideoEncoder AV1_AMF = new("av1_amf", Codec.AV1, GPUVendor.AMD, EncoderKind.AMF);
|
||||
public static readonly VideoEncoder LibSvtAv1 = new("libsvtav1", Codec.AV1, GPUVendor.Unknown, EncoderKind.Software);
|
||||
public static readonly VideoEncoder LibAomAv1 = new("libaom-av1", Codec.AV1, GPUVendor.Unknown, EncoderKind.Software);
|
||||
|
||||
// ── VVC ──
|
||||
public static readonly VideoEncoder LibVvenc = new("libvvenc", Codec.VVC, GPUVendor.Unknown, EncoderKind.Software);
|
||||
|
||||
// ReSharper restore MemberCanBePrivate.Global
|
||||
|
||||
public static readonly IReadOnlyList<VideoEncoder> All = new[]
|
||||
{
|
||||
H264_NVENC, H264_QSV, H264_AMF, H264_VideoToolbox, Libx264,
|
||||
HEVC_NVENC, HEVC_QSV, HEVC_AMF, HEVC_VideoToolbox, Libx265,
|
||||
VP9_NVENC, VP9_QSV, LibvpxVP9,
|
||||
AV1_NVENC, AV1_QSV, AV1_AMF, LibSvtAv1, LibAomAv1,
|
||||
LibVvenc
|
||||
};
|
||||
|
||||
private static readonly Dictionary<string, VideoEncoder> ByName =
|
||||
All.ToDictionary(e => e.Name, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public string Name { get; }
|
||||
public Codec Codec { get; }
|
||||
public GPUVendor Vendor { get; }
|
||||
public EncoderKind Kind { get; }
|
||||
public bool IsHardware => Kind != EncoderKind.Software;
|
||||
|
||||
private VideoEncoder(string name, Codec codec, GPUVendor vendor, EncoderKind kind)
|
||||
{
|
||||
Name = name;
|
||||
Codec = codec;
|
||||
Vendor = vendor;
|
||||
Kind = kind;
|
||||
}
|
||||
|
||||
public static VideoEncoder? FromName(string name)
|
||||
{
|
||||
return string.IsNullOrEmpty(name) ? null : ByName.GetValueOrDefault(name);
|
||||
}
|
||||
|
||||
public bool Equals(VideoEncoder other)
|
||||
{
|
||||
if (ReferenceEquals(null, other)) return false;
|
||||
return ReferenceEquals(this, other) || string.Equals(Name, other.Name, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return ReferenceEquals(this, obj) || obj is VideoEncoder other && Equals(other);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return StringComparer.OrdinalIgnoreCase.GetHashCode(Name);
|
||||
}
|
||||
|
||||
public static bool operator ==(VideoEncoder left, VideoEncoder right)
|
||||
{
|
||||
return Equals(left, right);
|
||||
}
|
||||
|
||||
public static bool operator !=(VideoEncoder left, VideoEncoder right)
|
||||
{
|
||||
return !Equals(left, right);
|
||||
}
|
||||
|
||||
public override string ToString() => Name;
|
||||
}
|
||||
+113
-113
@@ -2,152 +2,152 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using ADOFAIRenderer.Data;
|
||||
using ADOFAIRenderer.Util.FFmpeg;
|
||||
using MelonLoader;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ADOFAIRenderer.Util
|
||||
namespace ADOFAIRenderer.Util;
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
internal enum GPUVendor
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
internal enum GPUVendor
|
||||
{
|
||||
Unknown, NVIDIA, AMD, Intel, Apple
|
||||
}
|
||||
Unknown, NVIDIA, AMD, Intel, Apple
|
||||
}
|
||||
|
||||
internal static class GPUUtil
|
||||
internal static class GPUUtil
|
||||
{
|
||||
private const string NvidiaPattern =
|
||||
@"^NVIDIA GeForce [RG]TX [0-9]+(?> SUPER| Ti(?> SUPER)?)?(?> [0-9]+GB)?(?> Laptop GPU)?(?>/PCIe/SSE2)?$";
|
||||
|
||||
private const string IntelPattern =
|
||||
@"^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 GPUVendor _cachedVendor = GPUVendor.Unknown;
|
||||
private static bool _hasCachedVendor;
|
||||
|
||||
private static GPUVendor GetActiveGPUVendor()
|
||||
{
|
||||
private const string NvidiaPattern =
|
||||
@"^NVIDIA GeForce [RG]TX [0-9]+(?> SUPER| Ti(?> SUPER)?)?(?> [0-9]+GB)?(?> Laptop GPU)?(?>/PCIe/SSE2)?$";
|
||||
if (_hasCachedVendor) return _cachedVendor;
|
||||
|
||||
private const string IntelPattern =
|
||||
@"^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 GPUVendor _cachedVendor = GPUVendor.Unknown;
|
||||
private static bool _hasCachedVendor;
|
||||
|
||||
private static GPUVendor GetActiveGPUVendor()
|
||||
{
|
||||
if (_hasCachedVendor) return _cachedVendor;
|
||||
|
||||
var gpuName = SystemInfo.graphicsDeviceName;
|
||||
Melon<RenderMod>.Logger.Msg($"Active GPU: {gpuName}");
|
||||
var gpuName = SystemInfo.graphicsDeviceName;
|
||||
Melon<RenderMod>.Logger.Msg($"Active GPU: {gpuName}");
|
||||
|
||||
_cachedVendor = GPUVendor.Unknown;
|
||||
foreach (Match unused in Regex.Matches(gpuName, NvidiaPattern))
|
||||
_cachedVendor = GPUVendor.Unknown;
|
||||
foreach (Match unused in Regex.Matches(gpuName, NvidiaPattern))
|
||||
{
|
||||
_cachedVendor = GPUVendor.NVIDIA;
|
||||
break;
|
||||
}
|
||||
|
||||
if (_cachedVendor == GPUVendor.Unknown)
|
||||
{
|
||||
foreach (Match unused in Regex.Matches(gpuName, IntelPattern))
|
||||
{
|
||||
_cachedVendor = GPUVendor.NVIDIA;
|
||||
_cachedVendor = GPUVendor.Intel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_cachedVendor == GPUVendor.Unknown)
|
||||
if (_cachedVendor == GPUVendor.Unknown)
|
||||
{
|
||||
foreach (Match unused in Regex.Matches(gpuName, AMDPattern))
|
||||
{
|
||||
foreach (Match unused in Regex.Matches(gpuName, IntelPattern))
|
||||
{
|
||||
_cachedVendor = GPUVendor.Intel;
|
||||
break;
|
||||
}
|
||||
_cachedVendor = GPUVendor.AMD;
|
||||
break;
|
||||
}
|
||||
|
||||
if (_cachedVendor == GPUVendor.Unknown)
|
||||
{
|
||||
foreach (Match unused in Regex.Matches(gpuName, AMDPattern))
|
||||
{
|
||||
_cachedVendor = GPUVendor.AMD;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_cachedVendor == GPUVendor.Unknown && Application.platform == RuntimePlatform.OSXPlayer)
|
||||
{
|
||||
_cachedVendor = GPUVendor.Apple;
|
||||
}
|
||||
|
||||
_hasCachedVendor = true;
|
||||
return _cachedVendor;
|
||||
}
|
||||
|
||||
private static double? _cachedNvidiaVersion;
|
||||
private static bool _hasCachedNvidiaVersion;
|
||||
|
||||
public static double? GetNvidiaDriverVersion()
|
||||
if (_cachedVendor == GPUVendor.Unknown && Application.platform == RuntimePlatform.OSXPlayer)
|
||||
{
|
||||
if (_hasCachedNvidiaVersion) return _cachedNvidiaVersion;
|
||||
_cachedVendor = GPUVendor.Apple;
|
||||
}
|
||||
|
||||
_hasCachedVendor = true;
|
||||
return _cachedVendor;
|
||||
}
|
||||
|
||||
_hasCachedNvidiaVersion = true;
|
||||
_cachedNvidiaVersion = null;
|
||||
private static double? _cachedNvidiaVersion;
|
||||
private static bool _hasCachedNvidiaVersion;
|
||||
|
||||
if (GetActiveGPUVendor() != GPUVendor.NVIDIA) return null;
|
||||
public static double? GetNvidiaDriverVersion()
|
||||
{
|
||||
if (_hasCachedNvidiaVersion) return _cachedNvidiaVersion;
|
||||
|
||||
// 1. Try parsing from UnityEngine.SystemInfo.graphicsDeviceVersion
|
||||
var deviceVersion = SystemInfo.graphicsDeviceVersion;
|
||||
if (!string.IsNullOrEmpty(deviceVersion))
|
||||
_hasCachedNvidiaVersion = true;
|
||||
_cachedNvidiaVersion = null;
|
||||
|
||||
if (GetActiveGPUVendor() != GPUVendor.NVIDIA) return null;
|
||||
|
||||
// 1. Try parsing from 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)
|
||||
{
|
||||
var match = Regex.Match(deviceVersion, @"\b(\d+)\.(\d+)\.(\d+)\.(\d+)\b");
|
||||
if (match.Success)
|
||||
if (int.TryParse(match.Groups[3].Value, out var 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;
|
||||
Melon<RenderMod>.Logger.Msg($"Parsed NVIDIA Driver Version from SystemInfo: {_cachedNvidiaVersion:F2}");
|
||||
return _cachedNvidiaVersion;
|
||||
}
|
||||
var nvidiaVerInt = sub % 10 * 10000 + build;
|
||||
_cachedNvidiaVersion = nvidiaVerInt / 100.0;
|
||||
Melon<RenderMod>.Logger.Msg($"Parsed NVIDIA Driver Version from SystemInfo: {_cachedNvidiaVersion:F2}");
|
||||
return _cachedNvidiaVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Fallback to Windows Registry (only on Windows NT platforms via RegistryUtil)
|
||||
if (System.Environment.OSVersion.Platform != System.PlatformID.Win32NT) return null;
|
||||
const string classKey = @"SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}";
|
||||
var subkeys = RegistryUtil.GetHKLMSubKeyNames(classKey);
|
||||
if (subkeys == null) return null;
|
||||
// 2. Fallback to Windows Registry (only on Windows NT platforms via RegistryUtil)
|
||||
if (System.Environment.OSVersion.Platform != System.PlatformID.Win32NT) return null;
|
||||
const string classKey = @"SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}";
|
||||
var subkeys = RegistryUtil.GetHKLMSubKeyNames(classKey);
|
||||
if (subkeys == null) return null;
|
||||
|
||||
foreach (var subkey in subkeys)
|
||||
{
|
||||
var subkeyPath = classKey + "\\" + subkey;
|
||||
var provider = RegistryUtil.GetHKLMValue(subkeyPath, "ProviderName");
|
||||
if (provider == null || !provider.Contains("NVIDIA")) continue;
|
||||
foreach (var subkey in subkeys)
|
||||
{
|
||||
var subkeyPath = classKey + "\\" + subkey;
|
||||
var provider = RegistryUtil.GetHKLMValue(subkeyPath, "ProviderName");
|
||||
if (provider == null || !provider.Contains("NVIDIA")) continue;
|
||||
|
||||
var driverVersionStr = RegistryUtil.GetHKLMValue(subkeyPath, "DriverVersion");
|
||||
if (string.IsNullOrEmpty(driverVersionStr)) continue;
|
||||
var driverVersionStr = RegistryUtil.GetHKLMValue(subkeyPath, "DriverVersion");
|
||||
if (string.IsNullOrEmpty(driverVersionStr)) continue;
|
||||
|
||||
var regMatch = Regex.Match(driverVersionStr, @"\b(\d+)\.(\d+)\.(\d+)\.(\d+)\b");
|
||||
if (!regMatch.Success) continue;
|
||||
if (!int.TryParse(regMatch.Groups[3].Value, out var sub) ||
|
||||
!int.TryParse(regMatch.Groups[4].Value, out var build)) continue;
|
||||
var regMatch = Regex.Match(driverVersionStr, @"\b(\d+)\.(\d+)\.(\d+)\.(\d+)\b");
|
||||
if (!regMatch.Success) continue;
|
||||
if (!int.TryParse(regMatch.Groups[3].Value, out var sub) ||
|
||||
!int.TryParse(regMatch.Groups[4].Value, out var build)) continue;
|
||||
|
||||
var nvidiaVerInt = sub % 10 * 10000 + build;
|
||||
_cachedNvidiaVersion = nvidiaVerInt / 100f;
|
||||
Melon<RenderMod>.Logger.Msg($"Parsed NVIDIA Driver Version from Registry (RegistryUtil): {_cachedNvidiaVersion:F2}");
|
||||
return _cachedNvidiaVersion;
|
||||
}
|
||||
|
||||
return null;
|
||||
var nvidiaVerInt = sub % 10 * 10000 + build;
|
||||
_cachedNvidiaVersion = nvidiaVerInt / 100f;
|
||||
Melon<RenderMod>.Logger.Msg($"Parsed NVIDIA Driver Version from Registry (RegistryUtil): {_cachedNvidiaVersion:F2}");
|
||||
return _cachedNvidiaVersion;
|
||||
}
|
||||
|
||||
public static List<VideoEncoder> GetPrioritizedEncoders(Codec codec, bool forceSoftware = false)
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<VideoEncoder> GetPrioritizedEncoders(Codec codec, bool forceSoftware = false)
|
||||
{
|
||||
var encoders = VideoEncoder.All.Where(e => e.Codec == codec).ToList();
|
||||
if (forceSoftware)
|
||||
{
|
||||
var encoders = VideoEncoder.All.Where(e => e.Codec == codec).ToList();
|
||||
if (forceSoftware)
|
||||
{
|
||||
return encoders.Where(e => !e.IsHardware).ToList();
|
||||
}
|
||||
|
||||
var vendor = GetActiveGPUVendor();
|
||||
var prioritized = new List<VideoEncoder>();
|
||||
var others = new List<VideoEncoder>();
|
||||
|
||||
foreach (var item in encoders)
|
||||
{
|
||||
if (item.Vendor == vendor) prioritized.Add(item);
|
||||
else others.Add(item);
|
||||
}
|
||||
|
||||
prioritized.AddRange(others);
|
||||
return prioritized;
|
||||
return encoders.Where(e => !e.IsHardware).ToList();
|
||||
}
|
||||
|
||||
var vendor = GetActiveGPUVendor();
|
||||
var prioritized = new List<VideoEncoder>();
|
||||
var others = new List<VideoEncoder>();
|
||||
|
||||
foreach (var item in encoders)
|
||||
{
|
||||
if (item.Vendor == vendor) prioritized.Add(item);
|
||||
else others.Add(item);
|
||||
}
|
||||
|
||||
prioritized.AddRange(others);
|
||||
return prioritized;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user